Work on enabling custom inventory names
This commit is contained in:
parent
a1733467d3
commit
ec7c35e604
13 changed files with 90 additions and 71 deletions
|
@ -1,9 +1,5 @@
|
|||
package com.pahimar.ee3.block;
|
||||
|
||||
import com.pahimar.ee3.lib.Reference;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
|
@ -13,6 +9,12 @@ import net.minecraft.util.MathHelper;
|
|||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
|
||||
import com.pahimar.ee3.lib.Reference;
|
||||
import com.pahimar.ee3.tileentity.TileEE;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
/**
|
||||
* BlockEE
|
||||
*
|
||||
|
@ -57,5 +59,9 @@ public abstract class BlockEE extends BlockContainer {
|
|||
}
|
||||
|
||||
world.setBlockMetadataWithNotify(x, y, z, direction, 3);
|
||||
|
||||
if (itemStack.hasDisplayName()) {
|
||||
((TileEE) world.getBlockTileEntity(x, y, z)).setCustomName(itemStack.getDisplayName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,7 +12,6 @@ import com.pahimar.ee3.inventory.ContainerAlchemicalBag;
|
|||
import com.pahimar.ee3.lib.Sprites;
|
||||
import com.pahimar.ee3.lib.Strings;
|
||||
|
||||
import cpw.mods.fml.common.registry.LanguageRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
|
@ -28,8 +27,8 @@ public class GuiAlchemicalBag extends GuiContainer {
|
|||
|
||||
protected void drawGuiContainerForegroundLayer(int x, int y) {
|
||||
|
||||
this.fontRenderer.drawString(LanguageRegistry.instance().getStringLocalization(Strings.GUI_ALCHEMICAL_BAG_NAME), 8, 6, 4210752);
|
||||
this.fontRenderer.drawString(StatCollector.translateToLocal("container.inventory"), 44, this.ySize - 96 + 2, 4210752);
|
||||
this.fontRenderer.drawString(StatCollector.translateToLocal(Strings.CONTAINER_ALCHEMICAL_BAG_NAME), 8, 6, 4210752);
|
||||
this.fontRenderer.drawString(StatCollector.translateToLocal(Strings.CONTAINER_INVENTORY), 44, this.ySize - 96 + 2, 4210752);
|
||||
}
|
||||
|
||||
protected void drawGuiContainerBackgroundLayer(float opacity, int x, int y) {
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.pahimar.ee3.client.gui.inventory;
|
|||
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.util.StatCollector;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
@ -9,18 +10,16 @@ import org.lwjgl.opengl.GL11;
|
|||
import com.pahimar.ee3.inventory.ContainerAlchemicalChest;
|
||||
import com.pahimar.ee3.lib.Sprites;
|
||||
import com.pahimar.ee3.lib.Strings;
|
||||
import com.pahimar.ee3.tileentity.TileAlchemicalChest;
|
||||
|
||||
import cpw.mods.fml.common.registry.LanguageRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class GuiAlchemicalChest extends GuiContainer {
|
||||
|
||||
private TileAlchemicalChest tileAlchemicalChest;
|
||||
private IInventory tileAlchemicalChest;
|
||||
|
||||
public GuiAlchemicalChest(InventoryPlayer inventoryPlayer, TileAlchemicalChest tileAlchemicalChest) {
|
||||
public GuiAlchemicalChest(InventoryPlayer inventoryPlayer, IInventory tileAlchemicalChest) {
|
||||
|
||||
super(new ContainerAlchemicalChest(inventoryPlayer, tileAlchemicalChest));
|
||||
this.tileAlchemicalChest = tileAlchemicalChest;
|
||||
|
@ -30,8 +29,8 @@ public class GuiAlchemicalChest extends GuiContainer {
|
|||
|
||||
protected void drawGuiContainerForegroundLayer(int x, int y) {
|
||||
|
||||
this.fontRenderer.drawString(LanguageRegistry.instance().getStringLocalization(Strings.GUI_ALCHEMICAL_CHEST_NAME), 8, 6, 4210752);
|
||||
this.fontRenderer.drawString(StatCollector.translateToLocal("container.inventory"), 44, this.ySize - 96 + 2, 4210752);
|
||||
this.fontRenderer.drawString(this.tileAlchemicalChest.func_94042_c() ? this.tileAlchemicalChest.getInvName() : StatCollector.translateToLocal(this.tileAlchemicalChest.getInvName()), 8, 6, 4210752);
|
||||
this.fontRenderer.drawString(StatCollector.translateToLocal(Strings.CONTAINER_INVENTORY), 44, this.ySize - 96 + 2, 4210752);
|
||||
}
|
||||
|
||||
protected void drawGuiContainerBackgroundLayer(float opacity, int x, int y) {
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
package com.pahimar.ee3.client.gui.inventory;
|
||||
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.util.StatCollector;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.pahimar.ee3.inventory.ContainerAludel;
|
||||
|
@ -7,12 +11,8 @@ import com.pahimar.ee3.lib.Sprites;
|
|||
import com.pahimar.ee3.lib.Strings;
|
||||
import com.pahimar.ee3.tileentity.TileAludel;
|
||||
|
||||
import cpw.mods.fml.common.registry.LanguageRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.util.StatCollector;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class GuiAludel extends GuiContainer {
|
||||
|
@ -30,8 +30,8 @@ public class GuiAludel extends GuiContainer {
|
|||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int x, int y) {
|
||||
|
||||
this.fontRenderer.drawString(LanguageRegistry.instance().getStringLocalization(Strings.GUI_ALUDEL_NAME), 73, 6, 4210752);
|
||||
this.fontRenderer.drawString(StatCollector.translateToLocal("container.inventory"), 8, this.ySize - 93, 4210752);
|
||||
this.fontRenderer.drawString(StatCollector.translateToLocal(Strings.CONTAINER_ALUDEL_NAME), 73, 6, 4210752);
|
||||
this.fontRenderer.drawString(StatCollector.translateToLocal(Strings.CONTAINER_INVENTORY), 8, this.ySize - 93, 4210752);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -11,7 +11,6 @@ import com.pahimar.ee3.lib.Sprites;
|
|||
import com.pahimar.ee3.lib.Strings;
|
||||
import com.pahimar.ee3.tileentity.TileCalcinator;
|
||||
|
||||
import cpw.mods.fml.common.registry.LanguageRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
|
@ -38,8 +37,8 @@ public class GuiCalcinator extends GuiContainer {
|
|||
|
||||
protected void drawGuiContainerForegroundLayer(int x, int y) {
|
||||
|
||||
this.fontRenderer.drawString(LanguageRegistry.instance().getStringLocalization(Strings.GUI_CALCINATOR_NAME), 60, 6, 4210752);
|
||||
this.fontRenderer.drawString(StatCollector.translateToLocal("container.inventory"), 8, this.ySize - 96 + 2, 4210752);
|
||||
this.fontRenderer.drawString(StatCollector.translateToLocal(Strings.CONTAINER_CALCINATOR_NAME), 60, 6, 4210752);
|
||||
this.fontRenderer.drawString(StatCollector.translateToLocal(Strings.CONTAINER_INVENTORY), 8, this.ySize - 96 + 2, 4210752);
|
||||
}
|
||||
|
||||
protected void drawGuiContainerBackgroundLayer(float opacity, int x, int y) {
|
||||
|
|
|
@ -39,7 +39,6 @@ public class WorldTransmutationHandler {
|
|||
int upperBoundY = -1 * lowerBoundY;
|
||||
int lowerBoundZ = -1 * rangeZ / 2;
|
||||
int upperBoundZ = -1 * lowerBoundZ;
|
||||
boolean hasSoundPlayed = false;
|
||||
boolean anySuccess = false;
|
||||
|
||||
double xShift = 0;
|
||||
|
|
|
@ -3,14 +3,13 @@ package com.pahimar.ee3.inventory;
|
|||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import com.pahimar.ee3.tileentity.TileAlchemicalChest;
|
||||
|
||||
public class ContainerAlchemicalChest extends Container {
|
||||
|
||||
private TileAlchemicalChest tileAlchemicalChest;
|
||||
private IInventory tileAlchemicalChest;
|
||||
|
||||
private final int CHEST_INVENTORY_ROWS = 4;
|
||||
private final int CHEST_INVENTORY_COLUMNS = 13;
|
||||
|
@ -18,7 +17,7 @@ public class ContainerAlchemicalChest extends Container {
|
|||
private final int PLAYER_INVENTORY_ROWS = 3;
|
||||
private final int PLAYER_INVENTORY_COLUMNS = 9;
|
||||
|
||||
public ContainerAlchemicalChest(InventoryPlayer inventoryPlayer, TileAlchemicalChest tileAlchemicalChest) {
|
||||
public ContainerAlchemicalChest(InventoryPlayer inventoryPlayer, IInventory tileAlchemicalChest) {
|
||||
|
||||
this.tileAlchemicalChest = tileAlchemicalChest;
|
||||
|
||||
|
|
|
@ -10,14 +10,14 @@ import net.minecraft.world.WorldSavedData;
|
|||
|
||||
import com.pahimar.ee3.lib.Strings;
|
||||
|
||||
public class AlchemicalBagSavedData extends WorldSavedData implements IInventory {
|
||||
public class WorldSavedDataEE extends WorldSavedData implements IInventory {
|
||||
|
||||
public UUID uuid;
|
||||
public ItemStack[] inventory;
|
||||
|
||||
private final int INVENTORY_SIZE = 13 * 4;
|
||||
|
||||
public AlchemicalBagSavedData(String filePath) {
|
||||
public WorldSavedDataEE(String filePath) {
|
||||
|
||||
super(filePath);
|
||||
inventory = new ItemStack[INVENTORY_SIZE];
|
|
@ -15,12 +15,6 @@ public class Strings {
|
|||
public static final String FINAL_ERROR_MESSAGE = "version.final_error";
|
||||
public static final String MC_VERSION_NOT_FOUND = "version.mc_version_not_found";
|
||||
|
||||
/* Gui related constants */
|
||||
public static final String GUI_CALCINATOR_NAME = "gui.calcinator.name";
|
||||
public static final String GUI_ALUDEL_NAME = "gui.aludel.name";
|
||||
public static final String GUI_ALCHEMICAL_CHEST_NAME = "gui.alchemicalChest.name";
|
||||
public static final String GUI_ALCHEMICAL_BAG_NAME = "gui.alchemicalBag.name";
|
||||
|
||||
/* NBT related constants */
|
||||
public static final String NBT_ITEM_CHARGE_LEVEL_KEY = "itemChargeLevel";
|
||||
public static final String NBT_ITEM_MODE_KEY = "itemMode";
|
||||
|
@ -29,6 +23,7 @@ public class Strings {
|
|||
public static final String NBT_ITEM_ALCHEMICAL_BAG_GUI_OPEN = "itemAlchemicalBagGuiOpen";
|
||||
public static final String NBT_TE_OWNER_KEY = "teOwner";
|
||||
public static final String NBT_TE_STATE_KEY = "teState";
|
||||
public static final String NBT_TE_CUSTOM_NAME = "CustomName";
|
||||
public static final String NBT_TE_DIRECTION_KEY = "teDirection";
|
||||
|
||||
/* Block name constants */
|
||||
|
@ -57,4 +52,11 @@ public class Strings {
|
|||
public static final String TRANSMUTATION_COST_BLOCK = "block" + TRANSMUTATION_COST;
|
||||
public static final String TRANSMUTATION_COST_MOB = "mob" + TRANSMUTATION_COST;
|
||||
|
||||
/* Container related constants */
|
||||
public static final String CONTAINER_CALCINATOR_NAME = "container." + CALCINATOR_NAME;
|
||||
public static final String CONTAINER_ALUDEL_NAME = "container." + ALUDEL_NAME;
|
||||
public static final String CONTAINER_ALCHEMICAL_CHEST_NAME = "container." + ALCHEMICAL_CHEST_NAME;
|
||||
public static final String CONTAINER_ALCHEMICAL_BAG_NAME = "container." + ALCHEMICAL_BAG_NAME;
|
||||
public static final String CONTAINER_INVENTORY = "container.inventory";
|
||||
|
||||
}
|
|
@ -23,30 +23,23 @@ import cpw.mods.fml.common.network.Player;
|
|||
public class PacketTileUpdate extends PacketEE {
|
||||
|
||||
public int x, y, z;
|
||||
public byte direction;
|
||||
public short state;
|
||||
public String player;
|
||||
public String customName;
|
||||
|
||||
public PacketTileUpdate() {
|
||||
|
||||
super(PacketTypeHandler.TILE, true);
|
||||
}
|
||||
|
||||
public void setCoords(int x, int y, int z) {
|
||||
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
public void writeData(DataOutputStream data) throws IOException {
|
||||
|
||||
data.writeInt(x);
|
||||
data.writeInt(y);
|
||||
data.writeInt(z);
|
||||
data.writeByte(direction);
|
||||
data.writeShort(state);
|
||||
data.writeUTF(player);
|
||||
data.writeUTF(customName);
|
||||
}
|
||||
|
||||
public void readData(DataInputStream data) throws IOException {
|
||||
|
@ -54,9 +47,9 @@ public class PacketTileUpdate extends PacketEE {
|
|||
this.x = data.readInt();
|
||||
this.y = data.readInt();
|
||||
this.z = data.readInt();
|
||||
this.direction = data.readByte();
|
||||
this.state = data.readShort();
|
||||
this.player = data.readUTF();
|
||||
this.customName = data.readUTF();
|
||||
}
|
||||
|
||||
public void execute(INetworkManager manager, Player player) {
|
||||
|
|
|
@ -96,7 +96,7 @@ public class TileAlchemicalChest extends TileEE implements IInventory {
|
|||
@Override
|
||||
public String getInvName() {
|
||||
|
||||
return "container." + Strings.ALCHEMICAL_CHEST_NAME;
|
||||
return this.hasCustomName() ? this.getCustomName() : Strings.CONTAINER_ALCHEMICAL_CHEST_NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -216,13 +216,14 @@ public class TileAlchemicalChest extends TileEE implements IInventory {
|
|||
}
|
||||
}
|
||||
nbtTagCompound.setTag("Items", tagList);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
// public boolean hasCustomName()
|
||||
public boolean func_94042_c() {
|
||||
|
||||
return false;
|
||||
return this.hasCustomName();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -17,19 +17,9 @@ import com.pahimar.ee3.lib.Strings;
|
|||
*/
|
||||
public class TileEE extends TileEntity {
|
||||
|
||||
private byte direction;
|
||||
private short state;
|
||||
private String owner;
|
||||
|
||||
public byte getDirection() {
|
||||
|
||||
return direction;
|
||||
}
|
||||
|
||||
public void setDirection(byte direction) {
|
||||
|
||||
this.direction = direction;
|
||||
}
|
||||
private String customName;
|
||||
|
||||
public short getState() {
|
||||
|
||||
|
@ -46,11 +36,31 @@ public class TileEE extends TileEntity {
|
|||
return owner;
|
||||
}
|
||||
|
||||
public boolean hasOwner() {
|
||||
|
||||
return ((owner != null) && (owner.length() > 0));
|
||||
}
|
||||
|
||||
public void setOwner(String owner) {
|
||||
|
||||
this.owner = owner;
|
||||
}
|
||||
|
||||
public boolean hasCustomName() {
|
||||
|
||||
return ((this.customName != null) && (this.customName.length() > 0));
|
||||
}
|
||||
|
||||
public String getCustomName() {
|
||||
|
||||
return customName;
|
||||
}
|
||||
|
||||
public void setCustomName(String customName) {
|
||||
|
||||
this.customName = customName;
|
||||
}
|
||||
|
||||
public boolean isUseableByPlayer(EntityPlayer player) {
|
||||
|
||||
return owner.equals(player.username);
|
||||
|
@ -60,19 +70,31 @@ public class TileEE extends TileEntity {
|
|||
|
||||
super.readFromNBT(nbtTagCompound);
|
||||
|
||||
direction = nbtTagCompound.getByte(Strings.NBT_TE_DIRECTION_KEY);
|
||||
state = nbtTagCompound.getShort(Strings.NBT_TE_STATE_KEY);
|
||||
owner = nbtTagCompound.getString(Strings.NBT_TE_OWNER_KEY);
|
||||
if (nbtTagCompound.hasKey(Strings.NBT_TE_STATE_KEY)) {
|
||||
this.state = nbtTagCompound.getShort(Strings.NBT_TE_STATE_KEY);
|
||||
}
|
||||
|
||||
if (nbtTagCompound.hasKey(Strings.NBT_TE_OWNER_KEY)) {
|
||||
this.owner = nbtTagCompound.getString(Strings.NBT_TE_OWNER_KEY);
|
||||
}
|
||||
|
||||
if (nbtTagCompound.hasKey(Strings.NBT_TE_CUSTOM_NAME)) {
|
||||
this.customName = nbtTagCompound.getString(Strings.NBT_TE_CUSTOM_NAME);
|
||||
}
|
||||
}
|
||||
|
||||
public void writeToNBT(NBTTagCompound nbtTagCompound) {
|
||||
|
||||
super.writeToNBT(nbtTagCompound);
|
||||
|
||||
nbtTagCompound.setByte(Strings.NBT_TE_DIRECTION_KEY, direction);
|
||||
nbtTagCompound.setShort(Strings.NBT_TE_STATE_KEY, state);
|
||||
if (owner != null && owner != "") {
|
||||
nbtTagCompound.setString(Strings.NBT_TE_OWNER_KEY, owner);
|
||||
nbtTagCompound.setShort(Strings.NBT_TE_STATE_KEY, this.state);
|
||||
|
||||
if (hasOwner()) {
|
||||
nbtTagCompound.setString(Strings.NBT_TE_OWNER_KEY, this.owner);
|
||||
}
|
||||
|
||||
if (this.hasCustomName()) {
|
||||
nbtTagCompound.setString(Strings.NBT_TE_CUSTOM_NAME, this.customName);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -22,10 +22,10 @@
|
|||
<entry key="tile.calcinator.name">Calcinator</entry>
|
||||
<entry key="tile.aludel.name">Aludel</entry>
|
||||
<entry key="tile.alchemicalChest.name">Alchemical Chest</entry>
|
||||
<entry key="gui.calcinator.name">Calcinator</entry>
|
||||
<entry key="gui.aludel.name">Aludel</entry>
|
||||
<entry key="gui.alchemicalChest.name">Alchemical Chest</entry>
|
||||
<entry key="gui.alchemicalBag.name">Alchemical Bag</entry>
|
||||
<entry key="container.calcinator">Calcinator</entry>
|
||||
<entry key="container.aludel">Aludel</entry>
|
||||
<entry key="container.alchemicalChest">Alchemical Chest</entry>
|
||||
<entry key="container.alchemicalBag">Alchemical Bag</entry>
|
||||
<entry key="itemGroup.EE3">Equivalent Exchange 3</entry>
|
||||
<entry key="version.init_log_message">Initializing remote version check against remote version authority, located at</entry>
|
||||
<entry key="version.uninitialized">Remote version check failed to initialize properly</entry>
|
||||
|
|
Loading…
Reference in a new issue