Skip to content

Commit

Permalink
Support for custom localizations, closes #2626
Browse files Browse the repository at this point in the history
  • Loading branch information
aidancbrady committed Jul 21, 2015
1 parent 9a9f77a commit 7323a13
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 47 deletions.
21 changes: 14 additions & 7 deletions src/main/java/mekanism/common/item/ItemBalloon.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package mekanism.common.item;

import java.util.List;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import mekanism.api.Coord4D;
import mekanism.api.EnumColor;
import mekanism.api.Pos3D;
Expand All @@ -17,10 +17,11 @@
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

import java.util.List;

public class ItemBalloon extends ItemMekanism
{
Expand Down Expand Up @@ -74,14 +75,20 @@ public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer
@Override
public String getItemStackDisplayName(ItemStack stack)
{
String color = getColor(stack).getDyedName();
EnumColor color = getColor(stack);
String dyeName = color.getDyedName();

if(StatCollector.canTranslate(getUnlocalizedName(stack) + "." + color.dyeName))
{
return LangUtils.localize(getUnlocalizedName(stack) + "." + color.dyeName);
}

if(getColor(stack) == EnumColor.BLACK)
{
color = EnumColor.DARK_GREY + getColor(stack).getDyeName();
dyeName = EnumColor.DARK_GREY + color.getDyeName();
}

return color + " " + LangUtils.localize("tooltip.balloon");
return dyeName + " " + LangUtils.localize("tooltip.balloon");
}

@Override
Expand Down
47 changes: 20 additions & 27 deletions src/main/java/mekanism/common/item/ItemBlockMachine.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
package mekanism.common.item;

import cofh.api.energy.IEnergyContainerItem;
import cpw.mods.fml.common.Optional.Interface;
import cpw.mods.fml.common.Optional.InterfaceList;
import cpw.mods.fml.common.Optional.Method;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import ic2.api.item.ElectricItem;
import ic2.api.item.IElectricItem;
import ic2.api.item.IElectricItemManager;
import ic2.api.item.ISpecialElectricItem;

import java.util.List;
import java.util.Map;

import mekanism.api.Coord4D;
import mekanism.api.EnumColor;
import mekanism.api.MekanismConfig.general;
Expand All @@ -18,25 +20,14 @@
import mekanism.common.Mekanism;
import mekanism.common.Tier.BaseTier;
import mekanism.common.Upgrade;
import mekanism.common.base.IElectricChest;
import mekanism.common.base.IFactory;
import mekanism.common.base.IRedstoneControl;
import mekanism.common.base.*;
import mekanism.common.base.IRedstoneControl.RedstoneControl;
import mekanism.common.base.ISideConfiguration;
import mekanism.common.base.ISustainedData;
import mekanism.common.base.ISustainedInventory;
import mekanism.common.base.ISustainedTank;
import mekanism.common.base.IUpgradeTile;
import mekanism.common.block.BlockMachine.MachineType;
import mekanism.common.integration.IC2ItemManager;
import mekanism.common.inventory.InventoryElectricChest;
import mekanism.common.network.PacketElectricChest.ElectricChestMessage;
import mekanism.common.network.PacketElectricChest.ElectricChestPacketType;
import mekanism.common.tile.TileEntityBasicBlock;
import mekanism.common.tile.TileEntityElectricBlock;
import mekanism.common.tile.TileEntityElectricChest;
import mekanism.common.tile.TileEntityFactory;
import mekanism.common.tile.TileEntityPortableTank;
import mekanism.common.tile.*;
import mekanism.common.util.LangUtils;
import mekanism.common.util.MekanismUtils;
import net.minecraft.block.Block;
Expand All @@ -53,19 +44,17 @@
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
import net.minecraftforge.common.util.Constants.NBT;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.IFluidContainerItem;
import cofh.api.energy.IEnergyContainerItem;
import cpw.mods.fml.common.Optional.Interface;
import cpw.mods.fml.common.Optional.InterfaceList;
import cpw.mods.fml.common.Optional.Method;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

import java.util.List;
import java.util.Map;

/**
* Item class for handling multiple machine block IDs.
Expand Down Expand Up @@ -149,10 +138,14 @@ public String getItemStackDisplayName(ItemStack itemstack)

if(type == MachineType.BASIC_FACTORY || type == MachineType.ADVANCED_FACTORY || type == MachineType.ELITE_FACTORY)
{
String tier = type == MachineType.BASIC_FACTORY ? BaseTier.BASIC.getLocalizedName() : (type == MachineType.ADVANCED_FACTORY ?
BaseTier.ADVANCED.getLocalizedName() : BaseTier.ELITE.getLocalizedName());

return tier + " " + RecipeType.values()[getRecipeType(itemstack)].getLocalizedName() + " " + super.getItemStackDisplayName(itemstack);
BaseTier tier = type == MachineType.BASIC_FACTORY ? BaseTier.BASIC : (type == MachineType.ADVANCED_FACTORY ? BaseTier.ADVANCED : BaseTier.ELITE);

if(StatCollector.canTranslate("tile." + tier.getName() + RecipeType.values()[getRecipeType(itemstack)].getUnlocalizedName() + "Factory"))
{
return LangUtils.localize("tile." + tier.getName() + RecipeType.values()[getRecipeType(itemstack)].getUnlocalizedName() + "Factory");
}

return tier.getLocalizedName() + " " + RecipeType.values()[getRecipeType(itemstack)].getLocalizedName() + " " + super.getItemStackDisplayName(itemstack);
}

return super.getItemStackDisplayName(itemstack);
Expand Down
13 changes: 10 additions & 3 deletions src/main/java/mekanism/common/item/ItemBlockPlastic.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package mekanism.common.item;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import mekanism.api.EnumColor;

import mekanism.common.util.LangUtils;
import net.minecraft.block.Block;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.util.StatCollector;

public class ItemBlockPlastic extends ItemBlock
{
Expand Down Expand Up @@ -37,6 +38,12 @@ public String getItemStackDisplayName(ItemStack stack)
{
EnumColor colour = EnumColor.DYES[stack.getItemDamage()&15];
String colourName;

if(StatCollector.canTranslate(getUnlocalizedName(stack) + "." + colour.dyeName))
{
return LangUtils.localize(getUnlocalizedName(stack) + "." + colour.dyeName);
}

if(colour == EnumColor.BLACK)
{
colourName = EnumColor.DARK_GREY + colour.getDyeName();
Expand Down
27 changes: 17 additions & 10 deletions src/main/java/mekanism/common/multipart/ItemGlowPanel.java
Original file line number Diff line number Diff line change
@@ -1,24 +1,26 @@
package mekanism.common.multipart;

import java.util.List;

import codechicken.lib.vec.BlockCoord;
import codechicken.lib.vec.Vector3;
import codechicken.microblock.HollowMicroblock;
import codechicken.multipart.JItemMultiPart;
import codechicken.multipart.TMultiPart;
import codechicken.multipart.TileMultipart;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import mekanism.api.EnumColor;
import mekanism.common.Mekanism;
import mekanism.common.util.LangUtils;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import codechicken.lib.vec.BlockCoord;
import codechicken.lib.vec.Vector3;
import codechicken.microblock.HollowMicroblock;
import codechicken.multipart.JItemMultiPart;
import codechicken.multipart.TMultiPart;
import codechicken.multipart.TileMultipart;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

import java.util.List;

public class ItemGlowPanel extends JItemMultiPart
{
Expand Down Expand Up @@ -104,6 +106,11 @@ public String getItemStackDisplayName(ItemStack stack)
{
EnumColor colour = EnumColor.DYES[stack.getItemDamage()];
String colourName;

if(StatCollector.canTranslate(getUnlocalizedName(stack) + "." + colour.dyeName))
{
return LangUtils.localize(getUnlocalizedName(stack) + "." + colour.dyeName);
}

if(colour == EnumColor.BLACK)
{
Expand Down

0 comments on commit 7323a13

Please sign in to comment.