Added future multi-lang support

This commit is contained in:
Henry Mao 2012-12-14 22:21:52 +08:00
parent efc755d77a
commit d311e58311
5 changed files with 102 additions and 8 deletions

View file

@ -0,0 +1,10 @@
# Assembly Line Language Properties
# @author Calclavia
# Blocks
tile.crate.name=Crate
tile.conveyorBelt.name=Conveyor Belt
tile.architectTable.name=Architect's Table
# Items
# item.battery.name=Battery

View file

@ -49,11 +49,16 @@ public class AssemblyLine
public static final String CHANNEL = "AssemblyLine";
public static final String TEXTURE_PATH = "/assemblyline/textures/";
public static final String RESOURCE_PATH = "/assemblyline/";
public static final String TEXTURE_PATH = RESOURCE_PATH + "textures/";
public static final String LANGUAGE_PATH = RESOURCE_PATH + "language/";
private static final String[] LANGUAGES_SUPPORTED = new String[] { "en_US" };
public static final Configuration CONFIGURATION = new Configuration(new File(Loader.instance().getConfigDir(), "UniversalElectricity/AssemblyLine.cfg"));
public static final int BLOCK_ID_PREFIX = 3030;
public static Block blockConveyorBelt;
public static Block blockInteraction;
public static Block blockArchitectTable;
@ -85,19 +90,49 @@ public class AssemblyLine
{
proxy.init();
// TODO Load language files and use those for block naming
int languages = 0;
/**
* Load all languages.
*/
for (String language : LANGUAGES_SUPPORTED)
{
LanguageRegistry.instance().loadLocalization(LANGUAGE_PATH + language + ".properties", language, false);
if (LanguageRegistry.instance().getStringLocalization("children", language) != "")
{
try
{
String[] children = LanguageRegistry.instance().getStringLocalization("children", language).split(",");
for (String child : children)
{
if (child != "" || child != null)
{
LanguageRegistry.instance().loadLocalization(LANGUAGE_PATH + language + ".properties", child, false);
languages++;
}
}
languages++;
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
System.out.println(NAME + ": Loaded " + languages + " languages.");
// Add Names
LanguageRegistry.addName(blockConveyorBelt, "Conveyor Belt");
LanguageRegistry.addName(blockArchitectTable, "Architect's Table");
for (MachineType type : MachineType.values())
{
LanguageRegistry.addName(new ItemStack(blockInteraction, 1, type.metadata), type.name);
}
// Conveyor Belt
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockConveyorBelt, 2), new Object[] { "III", "WMW", 'I', "ingotSteel", 'W', Block.wood, 'M', "motor" }));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockConveyorBelt, 4), new Object[] { "III", "WMW", 'I', "ingotSteel", 'W', Block.wood, 'M', "motor" }));
// Rejector
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockInteraction, 1, MachineType.SORTER.metadata), new Object[] { "WPW", "@R@", '@', "plateSteel", 'R', Item.redstone, 'P', Block.pistonBase, 'C', "basicCircuit", 'W', "copperWire" }));

View file

@ -12,7 +12,7 @@ public class BlockArchitectTable extends Block
{
super(par1, Material.wood);
this.blockIndexInTexture = 59;
this.setBlockName("ArchitectTable");
this.setBlockName("architectTable");
this.setCreativeTab(UETab.INSTANCE);
}

View file

@ -0,0 +1,49 @@
package assemblyline.common.block;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.World;
import universalelectricity.prefab.UETab;
/**
* A block that allows the placement of mass amount of a specific item within it.
* It will be allowed to go on Conveyor Belts
* @author Calclavia
*
*/
public class BlockCrate extends Block
{
public BlockCrate(int par1)
{
super(par1, Material.iron);
this.blockIndexInTexture = 59;
this.setBlockName("create");
this.setCreativeTab(UETab.INSTANCE);
}
/**
* Returns the block texture based on the side being looked at. Args: side
*/
public int getBlockTextureFromSide(int par1)
{
return par1 == 1 ? this.blockIndexInTexture - 16 : (par1 == 0 ? Block.planks.getBlockTextureFromSide(0) : (par1 != 2 && par1 != 4 ? this.blockIndexInTexture : this.blockIndexInTexture + 1));
}
/**
* Called upon block activation (right click on the block.)
*/
public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9)
{
if (par1World.isRemote)
{
return true;
}
else
{
par5EntityPlayer.displayGUIWorkbench(par2, par3, par4);
return true;
}
}
}

View file

@ -20,7 +20,7 @@ public class BlockConveyorBelt extends BlockMachine
{
public BlockConveyorBelt(int id)
{
super("Conveyor Belt", id, UniversalElectricity.machine);
super("conveyorBelt", id, UniversalElectricity.machine);
this.setBlockBounds(0, 0, 0, 1, 0.3f, 1);
this.setCreativeTab(UETab.INSTANCE);
}