Simplify some of the backpack code and "fix" the localization code so that it isn't prefixing "Woven" in a non-localization friendly way. This is only hack fix though, all the bags will lose the "Woven" prefix entirely until Forestry is converted to the vanilla localization api.

This commit is contained in:
CovertJaguar committed 2014-08-12 05:13:09 -07:00
1 parent 54146d29b9
commit af081c614f
5 files changed
+27 -20

No files matched your search

@@ -48,6 +48,11 @@ public class BackpackDefinition implements IBackpackDefinition {
return StringUtil.localize("storage.backpack." + name);
}
@Override
public String getName(ItemStack backpack) {
return getName();
}
@Override
public int getPrimaryColour() {
return primaryColor;
@@ -23,7 +23,7 @@ public class BackpackHelper implements IBackpackInterface {
@Override
public Item addBackpack(IBackpackDefinition definition, EnumBackpackType type) {
BackpackManager.definitions.put(definition.getKey(), definition);
return new ItemBackpack(definition, type.ordinal() + 1);
return new ItemBackpack(definition, type);
}
}
@@ -43,16 +43,17 @@ import forestry.core.render.TextureManager;
import forestry.core.utils.ItemInventory;
import forestry.core.utils.StringUtil;
import forestry.storage.BackpackMode;
import java.util.EnumSet;
public class ItemBackpack extends ItemInventoried {
IBackpackDefinition info;
byte type;
EnumBackpackType type;
public ItemBackpack(IBackpackDefinition info, int type) {
public ItemBackpack(IBackpackDefinition info, EnumBackpackType type) {
super();
this.info = info;
this.type = (byte) type;
this.type = type;
setMaxStackSize(1);
}
@@ -250,10 +251,11 @@ public class ItemBackpack extends ItemInventoried {
@Override
public String getItemStackDisplayName(ItemStack itemstack) {
if (type > 1)
return StringUtil.localize("storage.backpack.t2adj") + " " + info.getName();
else
try {
return info.getName(itemstack);
} catch (Error er) {
return info.getName();
}
}
/* ICONS */
@@ -263,13 +265,14 @@ public class ItemBackpack extends ItemInventoried {
@SideOnly(Side.CLIENT)
@Override
public void registerIcons(IIconRegister register) {
icons = new IIcon[EnumBackpackType.values().length][6];
icons = new IIcon[2][6];
for (int i = 0; i < EnumBackpackType.values().length; i++) {
for (EnumBackpackType t : EnumSet.of(EnumBackpackType.T1, EnumBackpackType.T2)) {
int i = t.ordinal() - 1;
icons[i][0] = TextureManager.getInstance().registerTex(
register, "backpacks/" + EnumBackpackType.values()[i].toString().toLowerCase(Locale.ENGLISH) + ".cloth");
register, "backpacks/" + t.toString().toLowerCase(Locale.ENGLISH) + ".cloth");
icons[i][1] = TextureManager.getInstance().registerTex(
register, "backpacks/" + EnumBackpackType.values()[i].toString().toLowerCase(Locale.ENGLISH) + ".outline");
register, "backpacks/" + t.toString().toLowerCase(Locale.ENGLISH) + ".outline");
icons[i][2] = TextureManager.getInstance().registerTex(register, "backpacks/neutral");
icons[i][3] = TextureManager.getInstance().registerTex(register, "backpacks/locked");
icons[i][4] = TextureManager.getInstance().registerTex(register, "backpacks/receive");
@@ -303,9 +306,7 @@ public class ItemBackpack extends ItemInventoried {
@Override
public IIcon getIconFromDamageForRenderPass(int i, int j) {
int iconType = type;
if (type > 0)
iconType--;
int iconType = type.ordinal() - 1;
if (j == 0)
return icons[iconType][0];
@@ -322,13 +323,13 @@ public class ItemBackpack extends ItemInventoried {
return icons[iconType][2];
}
public static int getSlotsForType(int type) {
public static int getSlotsForType(EnumBackpackType type) {
switch (type) {
case 0:
case APIARIST:
return Defaults.SLOTS_BACKPACK_APIARIST;
case 2:
case T2:
return Defaults.SLOTS_BACKPACK_T2;
case 1:
case T1:
default:
return Defaults.SLOTS_BACKPACK_DEFAULT;
}
@@ -14,6 +14,7 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import forestry.api.core.ForestryAPI;
import forestry.api.storage.EnumBackpackType;
import forestry.plugins.PluginApiculture;
import forestry.plugins.PluginLepidopterology;
import forestry.storage.BackpackDefinition;
@@ -46,7 +47,7 @@ public class ItemNaturalistBackpack extends ItemBackpack {
private final int guiId;
public ItemNaturalistBackpack(int guiId, BackpackDefinition definition) {
super(definition, 0);
super(definition, EnumBackpackType.APIARIST);
this.guiId = guiId;
}