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 @@
[submodule "lang"]
path = lang
url = https://github.com/CharsetMC/Charset-i18n

+ 1
- 0
build.gradle View File

@@ -62,6 +62,7 @@ sourceSets {
main {
resources {
srcDirs += 'docs'
srcDirs += 'lang'
}
}
}

+ 1
- 0
lang

@@ -0,0 +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
}

public List<ItemStack> getDrops(EntityPlayer player) {
return Arrays.asList(ItemGate.getStack(this, EnchantmentHelper.getEnchantmentLevel(Enchantments.SILK_TOUCH, player.getHeldItemMainhand()) > 0));
return Arrays.asList(ItemGate.getStack(this, player != null ? (EnchantmentHelper.getEnchantmentLevel(Enchantments.SILK_TOUCH, player.getHeldItemMainhand()) > 0) : false));
}

// 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 {
0x664C33, 0x667F33, 0x993333, 0x191919
};

private static final String[] WOOL_TO_NAME = new String[]{
"white", "orange", "magenta", "light.blue",
"yellow", "lime", "pink", "gray",
"light.gray", "cyan", "purple", "blue",
"brown", "green", "red", "black"
};

private static final String[] OREDICT_DYE_SUFFIXES = new String[]{
private static final String[] UPPERCASE_DYE_SUFFIXES = new String[]{
"White", "Orange", "Magenta", "LightBlue",
"Yellow", "Lime", "Pink", "Gray",
"LightGray", "Cyan", "Purple", "Blue",
"Brown", "Green", "Red", "Black"
};

private static final String[] LOWERCASE_DYE_SUFFIXES = new String[]{
"white", "orange", "magenta", "lightBlue",
"yellow", "lime", "pink", "gray",
"lightGray", "cyan", "purple", "blue",
"brown", "green", "red", "black"
};

private static final int[] OREDICT_DYE_IDS = new int[16];

private static final char[] WOOL_TO_CHAT = new char[]{
@@ -40,7 +40,7 @@ public final class ColorUtils {

public static void initialize() {
for (int i = 0; i < 16; i++) {
OREDICT_DYE_IDS[i] = OreDictionary.getOreID("dye" + OREDICT_DYE_SUFFIXES[i]);
OREDICT_DYE_IDS[i] = OreDictionary.getOreID("dye" + UPPERCASE_DYE_SUFFIXES[i]);
}
}

@@ -73,12 +73,12 @@ public final class ColorUtils {
return WOOL_TO_RGB[wool & 15];
}

public static String getNameSuffix(int wool) {
return WOOL_TO_NAME[wool & 15];
public static String getOreDictEntry(String prefix, int wool) {
return prefix + UPPERCASE_DYE_SUFFIXES[wool & 15];
}

public static String getOreDictEntry(String prefix, int wool) {
return prefix + OREDICT_DYE_SUFFIXES[wool & 15];
public static String getLangEntry(String prefix, int wool) {
return prefix + LOWERCASE_DYE_SUFFIXES[wool & 15];
}

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;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;

import net.minecraft.util.text.translation.I18n;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

import pl.asie.charset.lib.ModCharsetLib;
import pl.asie.charset.lib.utils.ColorUtils;

/**
* Created by asie on 1/15/16.
@@ -42,9 +44,17 @@ public class ItemShard extends Item {
setHasSubtypes(true);
}

@Override
public String getItemStackDisplayName(ItemStack stack) {
if (stack.getItemDamage() > 0 && stack.getItemDamage() <= 16) {
return I18n.translateToLocalFormatted("item.charset.shard.colored.name", I18n.translateToLocal(ColorUtils.getLangEntry("charset.color.", stack.getItemDamage() - 1)));
} else {
return I18n.translateToLocal("item.charset.shard.name");
}
}
@Override
public String getUnlocalizedName(ItemStack stack) {
return "item.charset.shard." + stack.getItemDamage();
return "item.charset.shard.name";
}

@Override

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

@@ -20,6 +20,7 @@ import mcmultipart.item.ItemMultiPart;
import mcmultipart.multipart.IMultipart;
import pl.asie.charset.api.wires.WireFace;
import pl.asie.charset.lib.ModCharsetLib;
import pl.asie.charset.lib.utils.ColorUtils;
import pl.asie.charset.wires.logic.PartWireBase;
import pl.asie.charset.wires.logic.PartWireProvider;

@@ -64,7 +65,7 @@ public class ItemWire extends ItemMultiPart {
name = I18n.translateToLocal("tile.charset.wire.name");
break;
case INSULATED:
name = String.format(I18n.translateToLocal("tile.charset.wire.insulated.suffix"), I18n.translateToLocal("charset.color." + EnumDyeColor.byMetadata(kind.color()).getUnlocalizedName()));
name = String.format(I18n.translateToLocal("tile.charset.wire.insulated.name"), I18n.translateToLocal(ColorUtils.getLangEntry("charset.color.", kind.color())));
break;
case BUNDLED:
name = I18n.translateToLocal("tile.charset.wire.bundled.name");
@@ -72,7 +73,7 @@ public class ItemWire extends ItemMultiPart {
}

if (isFreestanding(stack)) {
name = String.format(I18n.translateToLocal("tile.charset.wire.freestanding.prefix"), name);
name = String.format(I18n.translateToLocal("tile.charset.wire.freestanding.name"), name);
}

return name;

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

@@ -23,8 +23,6 @@ public class ModCharsetWrench {

@EventHandler
public void preInit(FMLPreInitializationEvent event) {
MultipartRegistry.registerPartFactory(new PartWireProvider(), "charsetwires:wire");

wrench = new ItemWrench();
GameRegistry.register(wrench.setRegistryName("wrench"));
ModCharsetLib.proxy.registerItemModel(wrench, 0, "charsetwrench:wrench");

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

@@ -1,24 +0,0 @@
item.charset.tape.name=Tape
item.charset.tapedrive.name=Tape Drive
item.charset.tapereel.name=Tape Reel
item.charset.tapeitem.name=Magnetic Tape

item.charset.tape.iron.name=Iron Tape
item.charset.tape.gold.name=Gold Tape
item.charset.tape.diamond.name=Diamond Tape
item.charset.tape.emerald.name=Emerald Tape
item.charset.tape.quartz.name=Quartz Tape
item.charset.tape.dark_iron.name=Dark Iron Tape
item.charset.tape.ruby.name=Ruby Tape
item.charset.tape.sapphire.name=Sapphire Tape

item.charset.tape.gold.tip=Shiny
item.charset.tape.diamond.tip=Audiophile
item.charset.tape.dark_iron.tip=Dank
item.charset.tape.quartz.tip=Precise
item.charset.tape.emerald.tip=Best of Trade

tile.charset.ironNoteBlock.name=Iron Note Block

tooltip.charset.tape.none=No Tape
tooltip.charset.tape.unnamed=Unnamed Tape

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

@@ -1 +0,0 @@
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 @@
part.charset.gate.nand=NAND Gate
part.charset.gate.nand.i=AND Gate
part.charset.gate.nor=NOR Gate
part.charset.gate.nor.i=OR Gate
part.charset.gate.xor=XOR Gate
part.charset.gate.xor.i=XNOR Gate
part.charset.gate.buffer=Inverted Buffer Gate
part.charset.gate.buffer.i=Buffer Gate
part.charset.gate.pulse_former=Pulse Former
part.charset.gate.multiplexer=Multiplexer
part.charset.gate.rs_latch=RS Latch

item.charset.screwdriver.name=Screwdriver

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

@@ -1 +1,86 @@
itemGroup.charset=The Charset Project
# CharsetAudio
item.charset.tape.name=Tape
item.charset.tapedrive.name=Tape Drive
item.charset.tapereel.name=Tape Reel
item.charset.tapeitem.name=Magnetic Tape

item.charset.tape.iron.name=Iron Tape
item.charset.tape.gold.name=Gold Tape
item.charset.tape.diamond.name=Diamond Tape
item.charset.tape.emerald.name=Emerald Tape
item.charset.tape.quartz.name=Quartz Tape
item.charset.tape.dark_iron.name=Dark Iron Tape
item.charset.tape.ruby.name=Ruby Tape
item.charset.tape.sapphire.name=Sapphire Tape

item.charset.tape.gold.tip=Shiny
item.charset.tape.diamond.tip=Audiophile
item.charset.tape.dark_iron.tip=Dank
item.charset.tape.quartz.tip=Precise
item.charset.tape.emerald.tip=Best of Trade

tile.charset.ironNoteBlock.name=Iron Note Block

tooltip.charset.tape.none=No Tape
tooltip.charset.tape.unnamed=Unnamed Tape

# CharsetDrama
item.charset.dramaInABottle.name=Drama in a Bottle

# CharsetGates
part.charset.gate.nand=NAND Gate
part.charset.gate.nand.i=AND Gate
part.charset.gate.nor=NOR Gate
part.charset.gate.nor.i=OR Gate
part.charset.gate.xor=XOR Gate
part.charset.gate.xor.i=XNOR Gate
part.charset.gate.buffer=Inverted Buffer Gate
part.charset.gate.buffer.i=Buffer Gate
part.charset.gate.pulse_former=Pulse Former
part.charset.gate.multiplexer=Multiplexer
part.charset.gate.rs_latch=RS Latch

# CharsetLib
charset.color.black=Black
charset.color.red=Red
charset.color.green=Green
charset.color.brown=Brown
charset.color.blue=Blue
charset.color.purple=Purple
charset.color.cyan=Cyan
charset.color.silver=Light Gray
charset.color.gray=Gray
charset.color.pink=Pink
charset.color.lime=Lime
charset.color.yellow=Yellow
charset.color.lightBlue=Light Blue
charset.color.magenta=Magenta
charset.color.orange=Orange
charset.color.white=White

itemGroup.charset=The Charset Project

# CharsetPipes
item.charset.pipe.name=Pipe
tile.charset.shifter.name=Shifter

# CharsetStorage
key.charset.backpackOpen=Open Backpack
item.charset.key.name=Key
item.charset.lock.name=Lock
item.charset.masterKey.name=Master Key
tile.charset.backpack.name=Backpack

# CharsetTweaks
item.charset.graphite.name=Graphite
item.charset.shard.colored.name=%s Glass Shard
item.charset.shard.name=Glass Shard

# CharsetWires
tile.charset.wire.name=Redstone Cable
tile.charset.wire.insulated.name=%s Insulated Cable
tile.charset.wire.bundled.name=Bundled Cable
tile.charset.wire.freestanding.name=Freestanding %s

# CharsetWrench
item.charset.wrench.name=Wrench

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

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

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

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

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

@@ -1,19 +0,0 @@
item.charset.graphite.name=Graphite

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

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

@@ -1,20 +0,0 @@
tile.charset.wire.name=Redstone Cable
tile.charset.wire.insulated.suffix=%s Insulated Cable
tile.charset.wire.bundled.name=Bundled Cable
tile.charset.wire.freestanding.prefix=Freestanding %s
charset.color.black=Black
charset.color.red=Red
charset.color.green=Green
charset.color.brown=Brown
charset.color.blue=Blue
charset.color.purple=Purple
charset.color.cyan=Cyan
charset.color.silver=Light Gray
charset.color.gray=Gray
charset.color.pink=Pink
charset.color.lime=Lime
charset.color.yellow=Yellow
charset.color.lightBlue=Light Blue
charset.color.magenta=Magenta
charset.color.orange=Orange
charset.color.white=White

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

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

Loading…
Cancel
Save