Browse Source

refactor language system

tags/0.4.0
asiekierka 3 years ago
parent
commit
5c04640aa2

+ 3
- 0
.gitmodules View File

@@ -0,0 +1,3 @@
1
+[submodule "lang"]
2
+	path = lang
3
+	url = https://github.com/CharsetMC/Charset-i18n

+ 1
- 0
build.gradle View File

@@ -62,6 +62,7 @@ sourceSets {
62 62
 	main {
63 63
 		resources {
64 64
 			srcDirs += 'docs'
65
+			srcDirs += 'lang'
65 66
 		}
66 67
 	}
67 68
 }

+ 1
- 0
lang

@@ -0,0 +1 @@
1
+Subproject commit 549f17b3a076bc562750f912548608007a086986

+ 1
- 1
src/main/java/pl/asie/charset/gates/PartGate.java View File

@@ -293,7 +293,7 @@ public abstract class PartGate extends Multipart implements IRenderComparable<Pa
293 293
 	}
294 294
 
295 295
 	public List<ItemStack> getDrops(EntityPlayer player) {
296
-		return Arrays.asList(ItemGate.getStack(this, EnchantmentHelper.getEnchantmentLevel(Enchantments.SILK_TOUCH, player.getHeldItemMainhand()) > 0));
296
+		return Arrays.asList(ItemGate.getStack(this, player != null ? (EnchantmentHelper.getEnchantmentLevel(Enchantments.SILK_TOUCH, player.getHeldItemMainhand()) > 0) : false));
297 297
 	}
298 298
 
299 299
 	// Refer to Multipart.class when updating

+ 13
- 13
src/main/java/pl/asie/charset/lib/utils/ColorUtils.java View File

@@ -13,20 +13,20 @@ public final class ColorUtils {
13 13
 			0x664C33, 0x667F33, 0x993333, 0x191919
14 14
 	};
15 15
 
16
-	private static final String[] WOOL_TO_NAME = new String[]{
17
-			"white", "orange", "magenta", "light.blue",
18
-			"yellow", "lime", "pink", "gray",
19
-			"light.gray", "cyan", "purple", "blue",
20
-			"brown", "green", "red", "black"
21
-	};
22
-
23
-	private static final String[] OREDICT_DYE_SUFFIXES = new String[]{
16
+	private static final String[] UPPERCASE_DYE_SUFFIXES = new String[]{
24 17
 			"White", "Orange", "Magenta", "LightBlue",
25 18
 			"Yellow", "Lime", "Pink", "Gray",
26 19
 			"LightGray", "Cyan", "Purple", "Blue",
27 20
 			"Brown", "Green", "Red", "Black"
28 21
 	};
29 22
 
23
+	private static final String[] LOWERCASE_DYE_SUFFIXES = new String[]{
24
+			"white", "orange", "magenta", "lightBlue",
25
+			"yellow", "lime", "pink", "gray",
26
+			"lightGray", "cyan", "purple", "blue",
27
+			"brown", "green", "red", "black"
28
+	};
29
+
30 30
 	private static final int[] OREDICT_DYE_IDS = new int[16];
31 31
 
32 32
 	private static final char[] WOOL_TO_CHAT = new char[]{
@@ -40,7 +40,7 @@ public final class ColorUtils {
40 40
 
41 41
 	public static void initialize() {
42 42
 		for (int i = 0; i < 16; i++) {
43
-			OREDICT_DYE_IDS[i] = OreDictionary.getOreID("dye" + OREDICT_DYE_SUFFIXES[i]);
43
+			OREDICT_DYE_IDS[i] = OreDictionary.getOreID("dye" + UPPERCASE_DYE_SUFFIXES[i]);
44 44
 		}
45 45
 	}
46 46
 
@@ -73,12 +73,12 @@ public final class ColorUtils {
73 73
 		return WOOL_TO_RGB[wool & 15];
74 74
 	}
75 75
 
76
-	public static String getNameSuffix(int wool) {
77
-		return WOOL_TO_NAME[wool & 15];
76
+	public static String getOreDictEntry(String prefix, int wool) {
77
+		return prefix + UPPERCASE_DYE_SUFFIXES[wool & 15];
78 78
 	}
79 79
 
80
-	public static String getOreDictEntry(String prefix, int wool) {
81
-		return prefix + OREDICT_DYE_SUFFIXES[wool & 15];
80
+	public static String getLangEntry(String prefix, int wool) {
81
+		return prefix + LOWERCASE_DYE_SUFFIXES[wool & 15];
82 82
 	}
83 83
 
84 84
 	public static String getFormatting(int wool) {

+ 11
- 1
src/main/java/pl/asie/charset/tweaks/shard/ItemShard.java View File

@@ -9,10 +9,12 @@ import net.minecraft.item.EnumDyeColor;
9 9
 import net.minecraft.item.Item;
10 10
 import net.minecraft.item.ItemStack;
11 11
 
12
+import net.minecraft.util.text.translation.I18n;
12 13
 import net.minecraftforge.fml.relauncher.Side;
13 14
 import net.minecraftforge.fml.relauncher.SideOnly;
14 15
 
15 16
 import pl.asie.charset.lib.ModCharsetLib;
17
+import pl.asie.charset.lib.utils.ColorUtils;
16 18
 
17 19
 /**
18 20
  * Created by asie on 1/15/16.
@@ -42,9 +44,17 @@ public class ItemShard extends Item {
42 44
 		setHasSubtypes(true);
43 45
 	}
44 46
 
47
+	@Override
48
+	public String getItemStackDisplayName(ItemStack stack) {
49
+		if (stack.getItemDamage() > 0 && stack.getItemDamage() <= 16) {
50
+			return I18n.translateToLocalFormatted("item.charset.shard.colored.name", I18n.translateToLocal(ColorUtils.getLangEntry("charset.color.", stack.getItemDamage() - 1)));
51
+		} else {
52
+			return I18n.translateToLocal("item.charset.shard.name");
53
+		}
54
+	}
45 55
 	@Override
46 56
 	public String getUnlocalizedName(ItemStack stack) {
47
-		return "item.charset.shard." + stack.getItemDamage();
57
+		return "item.charset.shard.name";
48 58
 	}
49 59
 
50 60
 	@Override

+ 3
- 2
src/main/java/pl/asie/charset/wires/ItemWire.java View File

@@ -20,6 +20,7 @@ import mcmultipart.item.ItemMultiPart;
20 20
 import mcmultipart.multipart.IMultipart;
21 21
 import pl.asie.charset.api.wires.WireFace;
22 22
 import pl.asie.charset.lib.ModCharsetLib;
23
+import pl.asie.charset.lib.utils.ColorUtils;
23 24
 import pl.asie.charset.wires.logic.PartWireBase;
24 25
 import pl.asie.charset.wires.logic.PartWireProvider;
25 26
 
@@ -64,7 +65,7 @@ public class ItemWire extends ItemMultiPart {
64 65
 				name = I18n.translateToLocal("tile.charset.wire.name");
65 66
 				break;
66 67
 			case INSULATED:
67
-				name = String.format(I18n.translateToLocal("tile.charset.wire.insulated.suffix"), I18n.translateToLocal("charset.color." + EnumDyeColor.byMetadata(kind.color()).getUnlocalizedName()));
68
+				name = String.format(I18n.translateToLocal("tile.charset.wire.insulated.name"), I18n.translateToLocal(ColorUtils.getLangEntry("charset.color.", kind.color())));
68 69
 				break;
69 70
 			case BUNDLED:
70 71
 				name = I18n.translateToLocal("tile.charset.wire.bundled.name");
@@ -72,7 +73,7 @@ public class ItemWire extends ItemMultiPart {
72 73
 		}
73 74
 
74 75
 		if (isFreestanding(stack)) {
75
-			name = String.format(I18n.translateToLocal("tile.charset.wire.freestanding.prefix"), name);
76
+			name = String.format(I18n.translateToLocal("tile.charset.wire.freestanding.name"), name);
76 77
 		}
77 78
 
78 79
 		return name;

+ 0
- 2
src/main/java/pl/asie/charset/wrench/ModCharsetWrench.java View File

@@ -23,8 +23,6 @@ public class ModCharsetWrench {
23 23
 
24 24
 	@EventHandler
25 25
 	public void preInit(FMLPreInitializationEvent event) {
26
-		MultipartRegistry.registerPartFactory(new PartWireProvider(), "charsetwires:wire");
27
-
28 26
 		wrench = new ItemWrench();
29 27
 		GameRegistry.register(wrench.setRegistryName("wrench"));
30 28
 		ModCharsetLib.proxy.registerItemModel(wrench, 0, "charsetwrench:wrench");

+ 0
- 24
src/main/resources/assets/charsetaudio/lang/en_US.lang View File

@@ -1,24 +0,0 @@
1
-item.charset.tape.name=Tape
2
-item.charset.tapedrive.name=Tape Drive
3
-item.charset.tapereel.name=Tape Reel
4
-item.charset.tapeitem.name=Magnetic Tape
5
-
6
-item.charset.tape.iron.name=Iron Tape
7
-item.charset.tape.gold.name=Gold Tape
8
-item.charset.tape.diamond.name=Diamond Tape
9
-item.charset.tape.emerald.name=Emerald Tape
10
-item.charset.tape.quartz.name=Quartz Tape
11
-item.charset.tape.dark_iron.name=Dark Iron Tape
12
-item.charset.tape.ruby.name=Ruby Tape
13
-item.charset.tape.sapphire.name=Sapphire Tape
14
-
15
-item.charset.tape.gold.tip=Shiny
16
-item.charset.tape.diamond.tip=Audiophile
17
-item.charset.tape.dark_iron.tip=Dank
18
-item.charset.tape.quartz.tip=Precise
19
-item.charset.tape.emerald.tip=Best of Trade
20
-
21
-tile.charset.ironNoteBlock.name=Iron Note Block
22
-
23
-tooltip.charset.tape.none=No Tape
24
-tooltip.charset.tape.unnamed=Unnamed Tape

+ 0
- 1
src/main/resources/assets/charsetdrama/lang/en_US.lang View File

@@ -1 +0,0 @@
1
-item.charset.dramaInABottle.name=Drama in a Bottle

+ 0
- 13
src/main/resources/assets/charsetgates/lang/en_US.lang View File

@@ -1,13 +0,0 @@
1
-part.charset.gate.nand=NAND Gate
2
-part.charset.gate.nand.i=AND Gate
3
-part.charset.gate.nor=NOR Gate
4
-part.charset.gate.nor.i=OR Gate
5
-part.charset.gate.xor=XOR Gate
6
-part.charset.gate.xor.i=XNOR Gate
7
-part.charset.gate.buffer=Inverted Buffer Gate
8
-part.charset.gate.buffer.i=Buffer Gate
9
-part.charset.gate.pulse_former=Pulse Former
10
-part.charset.gate.multiplexer=Multiplexer
11
-part.charset.gate.rs_latch=RS Latch
12
-
13
-item.charset.screwdriver.name=Screwdriver

+ 86
- 1
src/main/resources/assets/charsetlib/lang/en_US.lang View File

@@ -1 +1,86 @@
1
-itemGroup.charset=The Charset Project
1
+# CharsetAudio
2
+item.charset.tape.name=Tape
3
+item.charset.tapedrive.name=Tape Drive
4
+item.charset.tapereel.name=Tape Reel
5
+item.charset.tapeitem.name=Magnetic Tape
6
+
7
+item.charset.tape.iron.name=Iron Tape
8
+item.charset.tape.gold.name=Gold Tape
9
+item.charset.tape.diamond.name=Diamond Tape
10
+item.charset.tape.emerald.name=Emerald Tape
11
+item.charset.tape.quartz.name=Quartz Tape
12
+item.charset.tape.dark_iron.name=Dark Iron Tape
13
+item.charset.tape.ruby.name=Ruby Tape
14
+item.charset.tape.sapphire.name=Sapphire Tape
15
+
16
+item.charset.tape.gold.tip=Shiny
17
+item.charset.tape.diamond.tip=Audiophile
18
+item.charset.tape.dark_iron.tip=Dank
19
+item.charset.tape.quartz.tip=Precise
20
+item.charset.tape.emerald.tip=Best of Trade
21
+
22
+tile.charset.ironNoteBlock.name=Iron Note Block
23
+
24
+tooltip.charset.tape.none=No Tape
25
+tooltip.charset.tape.unnamed=Unnamed Tape
26
+
27
+# CharsetDrama
28
+item.charset.dramaInABottle.name=Drama in a Bottle
29
+
30
+# CharsetGates
31
+part.charset.gate.nand=NAND Gate
32
+part.charset.gate.nand.i=AND Gate
33
+part.charset.gate.nor=NOR Gate
34
+part.charset.gate.nor.i=OR Gate
35
+part.charset.gate.xor=XOR Gate
36
+part.charset.gate.xor.i=XNOR Gate
37
+part.charset.gate.buffer=Inverted Buffer Gate
38
+part.charset.gate.buffer.i=Buffer Gate
39
+part.charset.gate.pulse_former=Pulse Former
40
+part.charset.gate.multiplexer=Multiplexer
41
+part.charset.gate.rs_latch=RS Latch
42
+
43
+# CharsetLib
44
+charset.color.black=Black
45
+charset.color.red=Red
46
+charset.color.green=Green
47
+charset.color.brown=Brown
48
+charset.color.blue=Blue
49
+charset.color.purple=Purple
50
+charset.color.cyan=Cyan
51
+charset.color.silver=Light Gray
52
+charset.color.gray=Gray
53
+charset.color.pink=Pink
54
+charset.color.lime=Lime
55
+charset.color.yellow=Yellow
56
+charset.color.lightBlue=Light Blue
57
+charset.color.magenta=Magenta
58
+charset.color.orange=Orange
59
+charset.color.white=White
60
+
61
+itemGroup.charset=The Charset Project
62
+
63
+# CharsetPipes
64
+item.charset.pipe.name=Pipe
65
+tile.charset.shifter.name=Shifter
66
+
67
+# CharsetStorage
68
+key.charset.backpackOpen=Open Backpack
69
+item.charset.key.name=Key
70
+item.charset.lock.name=Lock
71
+item.charset.masterKey.name=Master Key
72
+tile.charset.backpack.name=Backpack
73
+
74
+# CharsetTweaks
75
+item.charset.graphite.name=Graphite
76
+item.charset.shard.colored.name=%s Glass Shard
77
+item.charset.shard.name=Glass Shard
78
+
79
+# CharsetWires
80
+tile.charset.wire.name=Redstone Cable
81
+tile.charset.wire.insulated.name=%s Insulated Cable
82
+tile.charset.wire.bundled.name=Bundled Cable
83
+tile.charset.wire.freestanding.name=Freestanding %s
84
+
85
+# CharsetWrench
86
+item.charset.wrench.name=Wrench

+ 0
- 2
src/main/resources/assets/charsetpipes/lang/en_US.lang View File

@@ -1,2 +0,0 @@
1
-item.charset.pipe.name=Pipe
2
-tile.charset.shifter.name=Shifter

+ 0
- 5
src/main/resources/assets/charsetstorage/lang/en_US.lang View File

@@ -1,5 +0,0 @@
1
-key.charset.backpackOpen=Open Backpack
2
-item.charset.key.name=Key
3
-item.charset.lock.name=Lock
4
-item.charset.masterKey.name=Master Key
5
-tile.charset.backpack.name=Backpack

+ 0
- 19
src/main/resources/assets/charsettweaks/lang/en_US.lang View File

@@ -1,19 +0,0 @@
1
-item.charset.graphite.name=Graphite
2
-
3
-item.charset.shard.16.name=Black Glass Shard
4
-item.charset.shard.15.name=Red Glass Shard
5
-item.charset.shard.14.name=Green Glass Shard
6
-item.charset.shard.13.name=Brown Glass Shard
7
-item.charset.shard.12.name=Blue Glass Shard
8
-item.charset.shard.11.name=Purple Glass Shard
9
-item.charset.shard.10.name=Cyan Glass Shard
10
-item.charset.shard.9.name=Light Gray Glass Shard
11
-item.charset.shard.8.name=Gray Glass Shard
12
-item.charset.shard.7.name=Pink Glass Shard
13
-item.charset.shard.6.name=Lime Glass Shard
14
-item.charset.shard.5.name=Yellow Glass Shard
15
-item.charset.shard.4.name=Light Blue Glass Shard
16
-item.charset.shard.3.name=Magenta Glass Shard
17
-item.charset.shard.2.name=Orange Glass Shard
18
-item.charset.shard.1.name=White Glass Shard
19
-item.charset.shard.0.name=Glass Shard

+ 0
- 20
src/main/resources/assets/charsetwires/lang/en_US.lang View File

@@ -1,20 +0,0 @@
1
-tile.charset.wire.name=Redstone Cable
2
-tile.charset.wire.insulated.suffix=%s Insulated Cable
3
-tile.charset.wire.bundled.name=Bundled Cable
4
-tile.charset.wire.freestanding.prefix=Freestanding %s
5
-charset.color.black=Black
6
-charset.color.red=Red
7
-charset.color.green=Green
8
-charset.color.brown=Brown
9
-charset.color.blue=Blue
10
-charset.color.purple=Purple
11
-charset.color.cyan=Cyan
12
-charset.color.silver=Light Gray
13
-charset.color.gray=Gray
14
-charset.color.pink=Pink
15
-charset.color.lime=Lime
16
-charset.color.yellow=Yellow
17
-charset.color.lightBlue=Light Blue
18
-charset.color.magenta=Magenta
19
-charset.color.orange=Orange
20
-charset.color.white=White

+ 0
- 1
src/main/resources/assets/charsetwrench/lang/en_US.lang View File

@@ -1 +0,0 @@
1
-item.charset.wrench.name=Wrench

Loading…
Cancel
Save