diff --git a/ee3_common/com/pahimar/ee3/block/BlockAlchemicalChest.java b/ee3_common/com/pahimar/ee3/block/BlockAlchemicalChest.java index 23e49906..10bffc74 100644 --- a/ee3_common/com/pahimar/ee3/block/BlockAlchemicalChest.java +++ b/ee3_common/com/pahimar/ee3/block/BlockAlchemicalChest.java @@ -10,6 +10,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; +import net.minecraftforge.common.ForgeDirection; import com.pahimar.ee3.EquivalentExchange3; import com.pahimar.ee3.lib.GuiIds; @@ -71,16 +72,23 @@ public class BlockAlchemicalChest extends BlockEE { public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9) { - if (!world.isRemote) { - TileAlchemicalChest tileAlchemicalChest = (TileAlchemicalChest) world.getBlockTileEntity(x, y, z); - - if (tileAlchemicalChest != null) { - player.openGui(EquivalentExchange3.instance, GuiIds.ALCHEMICAL_CHEST, world, x, y, z); - } + if (player.isSneaking()) { + return true; + } + else if (world.isBlockSolidOnSide(x, y + 1, z, ForgeDirection.DOWN)) { + return true; + } + else { + if (!world.isRemote) { + TileAlchemicalChest tileAlchemicalChest = (TileAlchemicalChest) world.getBlockTileEntity(x, y, z); + + if (tileAlchemicalChest != null) { + player.openGui(EquivalentExchange3.instance, GuiIds.ALCHEMICAL_CHEST, world, x, y, z); + } + } + + return true; } - - return true; - } private void dropInventory(World world, int x, int y, int z) { diff --git a/ee3_common/com/pahimar/ee3/block/BlockAludel.java b/ee3_common/com/pahimar/ee3/block/BlockAludel.java index 15621911..e143cf64 100644 --- a/ee3_common/com/pahimar/ee3/block/BlockAludel.java +++ b/ee3_common/com/pahimar/ee3/block/BlockAludel.java @@ -2,13 +2,6 @@ package com.pahimar.ee3.block; import java.util.Random; -import com.pahimar.ee3.EquivalentExchange3; -import com.pahimar.ee3.lib.GuiIds; -import com.pahimar.ee3.lib.RenderIds; -import com.pahimar.ee3.lib.Strings; -import com.pahimar.ee3.tileentity.TileAludel; -import com.pahimar.ee3.tileentity.TileCalcinator; - import net.minecraft.block.material.Material; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; @@ -18,28 +11,34 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; +import com.pahimar.ee3.EquivalentExchange3; +import com.pahimar.ee3.lib.GuiIds; +import com.pahimar.ee3.lib.RenderIds; +import com.pahimar.ee3.lib.Strings; +import com.pahimar.ee3.tileentity.TileAludel; public class BlockAludel extends BlockEE { /** - * Is the random generator used by aludel to drop the inventory contents in random directions. + * Is the random generator used by aludel to drop the inventory contents in + * random directions. */ private Random rand = new Random(); - + public BlockAludel(int id) { - + super(id, Material.rock); this.setBlockName(Strings.ALUDEL_NAME); this.setCreativeTab(EquivalentExchange3.tabsEE3); this.setHardness(5F); } - + @Override public TileEntity createNewTileEntity(World world) { return new TileAludel(); } - + @Override public boolean renderAsNormalBlock() { @@ -66,48 +65,53 @@ public class BlockAludel extends BlockEE { @Override public void breakBlock(World world, int x, int y, int z, int id, int meta) { - + dropInventory(world, x, y, z); super.breakBlock(world, x, y, z, id, meta); } - + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9) { - if (!world.isRemote) { - TileAludel tileAludel = (TileAludel) world.getBlockTileEntity(x, y, z); - - if (tileAludel != null) { - player.openGui(EquivalentExchange3.instance, GuiIds.ALUDEL, world, x, y, z); - } + if (player.isSneaking()) { + return false; } - - return true; - - } + else { + if (!world.isRemote) { + TileAludel tileAludel = (TileAludel) world.getBlockTileEntity(x, y, z); + if (tileAludel != null) { + player.openGui(EquivalentExchange3.instance, GuiIds.ALUDEL, world, x, y, z); + } + } + + return true; + } + } + private void dropInventory(World world, int x, int y, int z) { + TileEntity tileEntity = world.getBlockTileEntity(x, y, z); - + if (!(tileEntity instanceof IInventory)) { - + return; } - + IInventory inventory = (IInventory) tileEntity; for (int i = 0; i < inventory.getSizeInventory(); i++) { - + ItemStack itemStack = inventory.getStackInSlot(i); - + if ((itemStack != null) && (itemStack.stackSize > 0)) { float dX = this.rand.nextFloat() * 0.8F + 0.1F; float dY = this.rand.nextFloat() * 0.8F + 0.1F; float dZ = this.rand.nextFloat() * 0.8F + 0.1F; - + EntityItem entityItem = new EntityItem(world, x + dX, y + dY, z + dZ, new ItemStack(itemStack.itemID, itemStack.stackSize, itemStack.getItemDamage())); - + if (itemStack.hasTagCompound()) { - entityItem.getEntityItem().setTagCompound((NBTTagCompound)itemStack.getTagCompound().copy()); + entityItem.getEntityItem().setTagCompound((NBTTagCompound) itemStack.getTagCompound().copy()); } float factor = 0.05F; diff --git a/ee3_common/com/pahimar/ee3/block/BlockCalcinator.java b/ee3_common/com/pahimar/ee3/block/BlockCalcinator.java index d1e9139d..3619d38e 100644 --- a/ee3_common/com/pahimar/ee3/block/BlockCalcinator.java +++ b/ee3_common/com/pahimar/ee3/block/BlockCalcinator.java @@ -81,16 +81,20 @@ public class BlockCalcinator extends BlockEE { public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9) { - if (!world.isRemote) { - TileCalcinator tileCalcinator = (TileCalcinator) world.getBlockTileEntity(x, y, z); - - if (tileCalcinator != null) { - player.openGui(EquivalentExchange3.instance, GuiIds.CALCINATOR, world, x, y, z); - } + if (player.isSneaking()) { + return false; + } + else { + if (!world.isRemote) { + TileCalcinator tileCalcinator = (TileCalcinator) world.getBlockTileEntity(x, y, z); + + if (tileCalcinator != null) { + player.openGui(EquivalentExchange3.instance, GuiIds.CALCINATOR, world, x, y, z); + } + } + + return true; } - - return true; - } private void dropInventory(World world, int x, int y, int z) { diff --git a/ee3_common/com/pahimar/ee3/client/gui/inventory/GuiAlchemicalBag.java b/ee3_common/com/pahimar/ee3/client/gui/inventory/GuiAlchemicalBag.java index 9013848c..c3958aa2 100644 --- a/ee3_common/com/pahimar/ee3/client/gui/inventory/GuiAlchemicalBag.java +++ b/ee3_common/com/pahimar/ee3/client/gui/inventory/GuiAlchemicalBag.java @@ -2,10 +2,12 @@ package com.pahimar.ee3.client.gui.inventory; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; import net.minecraft.util.StatCollector; import org.lwjgl.opengl.GL11; +import com.pahimar.ee3.core.helper.NBTHelper; import com.pahimar.ee3.inventory.ContainerAlchemicalBag; import com.pahimar.ee3.lib.Sprites; import com.pahimar.ee3.lib.Strings; @@ -40,4 +42,18 @@ public class GuiAlchemicalBag extends GuiContainer { this.drawTexturedModalRect(xStart, yStart, 0, 0, this.xSize, this.ySize); } + public void onGuiClosed() { + + super.onGuiClosed(); + + if (this.mc.thePlayer != null) { + for (ItemStack itemStack : this.mc.thePlayer.inventory.mainInventory) { + if (itemStack != null) { + if (NBTHelper.hasTag(itemStack, Strings.NBT_ITEM_ALCHEMY_BAG_GUI_OPEN)) { + NBTHelper.removeTag(itemStack, Strings.NBT_ITEM_ALCHEMY_BAG_GUI_OPEN); + } + } + } + } + } } diff --git a/ee3_common/com/pahimar/ee3/client/gui/inventory/GuiAludel.java b/ee3_common/com/pahimar/ee3/client/gui/inventory/GuiAludel.java new file mode 100644 index 00000000..d1ee136a --- /dev/null +++ b/ee3_common/com/pahimar/ee3/client/gui/inventory/GuiAludel.java @@ -0,0 +1,49 @@ +package com.pahimar.ee3.client.gui.inventory; + +import org.lwjgl.opengl.GL11; + +import com.pahimar.ee3.inventory.ContainerAludel; +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.inventory.Container; +import net.minecraft.util.StatCollector; + +@SideOnly(Side.CLIENT) +public class GuiAludel extends GuiContainer { + + private TileAludel tileAludel; + + public GuiAludel(InventoryPlayer inventoryPlayer, TileAludel tileAludel) { + + super(new ContainerAludel(inventoryPlayer, tileAludel)); + this.tileAludel = tileAludel; + this.xSize = 176; + this.ySize = 187; + } + + @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); + } + + @Override + protected void drawGuiContainerBackgroundLayer(float var1, int var2, int var3) { + + int backgroundTexture = this.mc.renderEngine.getTexture(Sprites.GUI_ALUDEL); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.mc.renderEngine.bindTexture(backgroundTexture); + int xStart = (this.width - this.xSize) / 2; + int yStart = (this.height - this.ySize) / 2; + this.drawTexturedModalRect(xStart, yStart, 0, 0, this.xSize, this.ySize); + } + +} diff --git a/ee3_common/com/pahimar/ee3/core/handlers/ItemEventHandler.java b/ee3_common/com/pahimar/ee3/core/handlers/ItemEventHandler.java index c20d2a46..b6fe5c14 100644 --- a/ee3_common/com/pahimar/ee3/core/handlers/ItemEventHandler.java +++ b/ee3_common/com/pahimar/ee3/core/handlers/ItemEventHandler.java @@ -30,6 +30,9 @@ public class ItemEventHandler { else if (NBTHelper.hasTag(event.item.getEntityItem(), Strings.NBT_ITEM_TRANSMUTATION_GUI_OPEN)) { NBTHelper.removeTag(event.item.getEntityItem(), Strings.NBT_ITEM_TRANSMUTATION_GUI_OPEN); } + else if (NBTHelper.hasTag(event.item.getEntityItem(), Strings.NBT_ITEM_ALCHEMY_BAG_GUI_OPEN)) { + NBTHelper.removeTag(event.item.getEntityItem(), Strings.NBT_ITEM_ALCHEMY_BAG_GUI_OPEN); + } } @ForgeSubscribe @@ -41,6 +44,9 @@ public class ItemEventHandler { else if (NBTHelper.hasTag(event.entityItem.getEntityItem(), Strings.NBT_ITEM_TRANSMUTATION_GUI_OPEN)) { NBTHelper.removeTag(event.entityItem.getEntityItem(), Strings.NBT_ITEM_TRANSMUTATION_GUI_OPEN); } + else if (NBTHelper.hasTag(event.entityItem.getEntityItem(), Strings.NBT_ITEM_ALCHEMY_BAG_GUI_OPEN)) { + NBTHelper.removeTag(event.entityItem.getEntityItem(), Strings.NBT_ITEM_ALCHEMY_BAG_GUI_OPEN); + } } @ForgeSubscribe @@ -53,6 +59,9 @@ public class ItemEventHandler { else if (NBTHelper.hasTag(entityItem.getEntityItem(), Strings.NBT_ITEM_TRANSMUTATION_GUI_OPEN)) { NBTHelper.removeTag(entityItem.getEntityItem(), Strings.NBT_ITEM_TRANSMUTATION_GUI_OPEN); } + else if (NBTHelper.hasTag(entityItem.getEntityItem(), Strings.NBT_ITEM_ALCHEMY_BAG_GUI_OPEN)) { + NBTHelper.removeTag(entityItem.getEntityItem(), Strings.NBT_ITEM_ALCHEMY_BAG_GUI_OPEN); + } } } } diff --git a/ee3_common/com/pahimar/ee3/core/proxy/CommonProxy.java b/ee3_common/com/pahimar/ee3/core/proxy/CommonProxy.java index d963fa62..b4f8a17c 100644 --- a/ee3_common/com/pahimar/ee3/core/proxy/CommonProxy.java +++ b/ee3_common/com/pahimar/ee3/core/proxy/CommonProxy.java @@ -7,11 +7,13 @@ import net.minecraft.world.World; import com.pahimar.ee3.client.gui.inventory.GuiAlchemicalBag; import com.pahimar.ee3.client.gui.inventory.GuiAlchemicalChest; +import com.pahimar.ee3.client.gui.inventory.GuiAludel; import com.pahimar.ee3.client.gui.inventory.GuiCalcinator; import com.pahimar.ee3.client.gui.inventory.GuiPortableCrafting; import com.pahimar.ee3.client.gui.inventory.GuiPortableTransmutation; import com.pahimar.ee3.inventory.ContainerAlchemicalBag; import com.pahimar.ee3.inventory.ContainerAlchemicalChest; +import com.pahimar.ee3.inventory.ContainerAludel; import com.pahimar.ee3.inventory.ContainerCalcinator; import com.pahimar.ee3.inventory.ContainerPortableCrafting; import com.pahimar.ee3.inventory.ContainerPortableTransmutation; @@ -105,6 +107,10 @@ public class CommonProxy implements IGuiHandler { // TODO Alchemical Bag inventory work is incomplete return new ContainerAlchemicalBag(player.inventory); } + else if (ID == GuiIds.ALUDEL) { + TileAludel tileAludel = (TileAludel) world.getBlockTileEntity(x, y, z); + return new ContainerAludel(player.inventory, tileAludel); + } return null; } @@ -130,6 +136,10 @@ public class CommonProxy implements IGuiHandler { // TODO Alchemical Bag inventory work is incomplete return new GuiAlchemicalBag(player.inventory); } + else if (ID == GuiIds.ALUDEL) { + TileAludel tileAludel = (TileAludel) world.getBlockTileEntity(x, y, z); + return new GuiAludel(player.inventory, tileAludel); + } return null; } diff --git a/ee3_common/com/pahimar/ee3/inventory/AlchemicalBagSavedData.java b/ee3_common/com/pahimar/ee3/inventory/AlchemicalBagSavedData.java new file mode 100644 index 00000000..88f3c9fa --- /dev/null +++ b/ee3_common/com/pahimar/ee3/inventory/AlchemicalBagSavedData.java @@ -0,0 +1,109 @@ +package com.pahimar.ee3.inventory; + +import java.util.UUID; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.WorldSavedData; + +import com.pahimar.ee3.lib.Strings; + +public class AlchemicalBagSavedData extends WorldSavedData implements IInventory { + + public UUID uuid; + public ItemStack[] inventory; + + private final int INVENTORY_SIZE = 13 * 4; + + public AlchemicalBagSavedData(String filePath) { + + super(filePath); + inventory = new ItemStack[INVENTORY_SIZE]; + } + + @Override + public void readFromNBT(NBTTagCompound var1) { + + // TODO Auto-generated method stub + + } + + @Override + public void writeToNBT(NBTTagCompound var1) { + + // TODO Auto-generated method stub + + } + + @Override + public int getSizeInventory() { + + return this.inventory.length; + } + + @Override + public ItemStack getStackInSlot(int slot) { + + return this.inventory[slot]; + } + + @Override + public ItemStack decrStackSize(int var1, int var2) { + + // TODO Auto-generated method stub + return null; + } + + @Override + public ItemStack getStackInSlotOnClosing(int var1) { + + // TODO Auto-generated method stub + return null; + } + + @Override + public void setInventorySlotContents(int var1, ItemStack var2) { + + // TODO Auto-generated method stub + + } + + @Override + public String getInvName() { + + return "worldsaveddata" + "." + Strings.ALCHEMY_BAG_NAME; + } + + @Override + public int getInventoryStackLimit() { + + return 64; + } + + @Override + public void onInventoryChanged() { + + // TODO Auto-generated method stub + + } + + @Override + public boolean isUseableByPlayer(EntityPlayer var1) { + + // TODO Auto-generated method stub + return false; + } + + @Override + public void openChest() { + + } + + @Override + public void closeChest() { + + } + +} diff --git a/ee3_common/com/pahimar/ee3/inventory/ContainerAlchemicalBag.java b/ee3_common/com/pahimar/ee3/inventory/ContainerAlchemicalBag.java index d3cbfc6f..4da05feb 100644 --- a/ee3_common/com/pahimar/ee3/inventory/ContainerAlchemicalBag.java +++ b/ee3_common/com/pahimar/ee3/inventory/ContainerAlchemicalBag.java @@ -1,15 +1,18 @@ package com.pahimar.ee3.inventory; +import com.pahimar.ee3.core.helper.NBTHelper; +import com.pahimar.ee3.lib.Strings; + import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Container; import net.minecraft.inventory.Slot; - +import net.minecraft.item.ItemStack; public class ContainerAlchemicalBag extends Container { public ContainerAlchemicalBag(InventoryPlayer inventoryPlayer) { - + // Add the player's inventory slots to the container for (int inventoryRowIndex = 0; inventoryRowIndex < 3; ++inventoryRowIndex) { for (int inventoryColumnIndex = 0; inventoryColumnIndex < 9; ++inventoryColumnIndex) { @@ -22,11 +25,27 @@ public class ContainerAlchemicalBag extends Container { this.addSlotToContainer(new Slot(inventoryPlayer, actionBarSlotIndex, 44 + actionBarSlotIndex * 18, 162)); } } - + @Override public boolean canInteractWith(EntityPlayer var1) { return true; } + + @Override + public void onCraftGuiClosed(EntityPlayer player) { + super.onCraftGuiClosed(player); + + if (!player.worldObj.isRemote) { + InventoryPlayer invPlayer = player.inventory; + for (ItemStack itemStack : invPlayer.mainInventory) { + if (itemStack != null) { + if (NBTHelper.hasTag(itemStack, Strings.NBT_ITEM_ALCHEMY_BAG_GUI_OPEN)) { + NBTHelper.removeTag(itemStack, Strings.NBT_ITEM_ALCHEMY_BAG_GUI_OPEN); + } + } + } + } + } } diff --git a/ee3_common/com/pahimar/ee3/inventory/ContainerAlchemicalChest.java b/ee3_common/com/pahimar/ee3/inventory/ContainerAlchemicalChest.java index 71f49b30..f78fd3b9 100644 --- a/ee3_common/com/pahimar/ee3/inventory/ContainerAlchemicalChest.java +++ b/ee3_common/com/pahimar/ee3/inventory/ContainerAlchemicalChest.java @@ -12,11 +12,11 @@ public class ContainerAlchemicalChest extends Container { private TileAlchemicalChest tileAlchemicalChest; - private int numChestRows = 4; - private int numChestColumns = 13; + private final int CHEST_INVENTORY_ROWS = 4; + private final int CHEST_INVENTORY_COLUMNS = 13; - private int numPlayerRows = 3; - private int numPlayerColumns = 9; + private final int PLAYER_INVENTORY_ROWS = 3; + private final int PLAYER_INVENTORY_COLUMNS = 9; public ContainerAlchemicalChest(InventoryPlayer inventoryPlayer, TileAlchemicalChest tileAlchemicalChest) { @@ -25,21 +25,21 @@ public class ContainerAlchemicalChest extends Container { tileAlchemicalChest.openChest(); // Add the Alchemical Chest slots to the container - for (int chestRowIndex = 0; chestRowIndex < numChestRows; ++chestRowIndex) { - for (int chestColumnIndex = 0; chestColumnIndex < numChestColumns; ++chestColumnIndex) { + for (int chestRowIndex = 0; chestRowIndex < CHEST_INVENTORY_ROWS; ++chestRowIndex) { + for (int chestColumnIndex = 0; chestColumnIndex < CHEST_INVENTORY_COLUMNS; ++chestColumnIndex) { this.addSlotToContainer(new Slot(tileAlchemicalChest, chestColumnIndex + chestRowIndex * 13, 8 + chestColumnIndex * 18, 18 + chestRowIndex * 18)); } } // Add the player's inventory slots to the container - for (int inventoryRowIndex = 0; inventoryRowIndex < numPlayerRows; ++inventoryRowIndex) { - for (int inventoryColumnIndex = 0; inventoryColumnIndex < numPlayerColumns; ++inventoryColumnIndex) { + for (int inventoryRowIndex = 0; inventoryRowIndex < PLAYER_INVENTORY_ROWS; ++inventoryRowIndex) { + for (int inventoryColumnIndex = 0; inventoryColumnIndex < PLAYER_INVENTORY_COLUMNS; ++inventoryColumnIndex) { this.addSlotToContainer(new Slot(inventoryPlayer, inventoryColumnIndex + inventoryRowIndex * 9 + 9, 44 + inventoryColumnIndex * 18, 104 + inventoryRowIndex * 18)); } } // Add the player's action bar slots to the container - for (int actionBarSlotIndex = 0; actionBarSlotIndex < numPlayerColumns; ++actionBarSlotIndex) { + for (int actionBarSlotIndex = 0; actionBarSlotIndex < PLAYER_INVENTORY_COLUMNS; ++actionBarSlotIndex) { this.addSlotToContainer(new Slot(inventoryPlayer, actionBarSlotIndex, 44 + actionBarSlotIndex * 18, 162)); } } @@ -68,12 +68,12 @@ public class ContainerAlchemicalChest extends Container { ItemStack itemStack = slot.getStack(); newItemStack = itemStack.copy(); - if (slotIndex < (numChestRows * numChestColumns)) { - if (!this.mergeItemStack(itemStack, (numChestRows * numChestColumns), this.inventorySlots.size(), true)) { + if (slotIndex < (CHEST_INVENTORY_ROWS * CHEST_INVENTORY_COLUMNS)) { + if (!this.mergeItemStack(itemStack, (CHEST_INVENTORY_ROWS * CHEST_INVENTORY_COLUMNS), this.inventorySlots.size(), true)) { return null; } } - else if (!this.mergeItemStack(itemStack, 0, (numChestRows * numChestColumns), false)) { + else if (!this.mergeItemStack(itemStack, 0, (CHEST_INVENTORY_ROWS * CHEST_INVENTORY_COLUMNS), false)) { return null; } diff --git a/ee3_common/com/pahimar/ee3/inventory/ContainerAludel.java b/ee3_common/com/pahimar/ee3/inventory/ContainerAludel.java new file mode 100644 index 00000000..6623a45a --- /dev/null +++ b/ee3_common/com/pahimar/ee3/inventory/ContainerAludel.java @@ -0,0 +1,50 @@ +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.Slot; +import net.minecraft.item.ItemStack; + +import com.pahimar.ee3.tileentity.TileAludel; + +public class ContainerAludel extends Container { + + private TileAludel tileAludel; + + private final int PLAYER_INVENTORY_ROWS = 3; + private final int PLAYER_INVENTORY_COLUMNS = 9; + + public ContainerAludel(InventoryPlayer inventoryPlayer, TileAludel tileAludel) { + + this.tileAludel = tileAludel; + + this.addSlotToContainer(new Slot(tileAludel, TileAludel.INPUT_INVENTORY_INDEX, 44, 18)); + this.addSlotToContainer(new Slot(tileAludel, TileAludel.DUST_INVENTORY_INDEX, 44, 39)); + this.addSlotToContainer(new Slot(tileAludel, TileAludel.FUEL_INVENTORY_INDEX, 44, 74)); + this.addSlotToContainer(new Slot(tileAludel, TileAludel.OUTPUT_INVENTORY_INDEX, 120, 39)); + + // Add the player's inventory slots to the container + for (int inventoryRowIndex = 0; inventoryRowIndex < PLAYER_INVENTORY_ROWS; ++inventoryRowIndex) { + for (int inventoryColumnIndex = 0; inventoryColumnIndex < PLAYER_INVENTORY_COLUMNS; ++inventoryColumnIndex) { + this.addSlotToContainer(new Slot(inventoryPlayer, inventoryColumnIndex + inventoryRowIndex * 9 + 9, 8 + inventoryColumnIndex * 18, 106 + inventoryRowIndex * 18)); + } + } + + // Add the player's action bar slots to the container + for (int actionBarSlotIndex = 0; actionBarSlotIndex < PLAYER_INVENTORY_COLUMNS; ++actionBarSlotIndex) { + this.addSlotToContainer(new Slot(inventoryPlayer, actionBarSlotIndex, 8 + actionBarSlotIndex * 18, 164)); + } + } + + @Override + public boolean canInteractWith(EntityPlayer var1) { + + return true; + } + + public ItemStack transferStackInSlot(EntityPlayer entityPlayer, int slotIndex) { + + return null; + } +} diff --git a/ee3_common/com/pahimar/ee3/item/ItemAlchemyBag.java b/ee3_common/com/pahimar/ee3/item/ItemAlchemyBag.java index a02ff931..db452c85 100644 --- a/ee3_common/com/pahimar/ee3/item/ItemAlchemyBag.java +++ b/ee3_common/com/pahimar/ee3/item/ItemAlchemyBag.java @@ -3,11 +3,15 @@ package com.pahimar.ee3.item; import java.util.List; import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.util.MathHelper; +import net.minecraft.world.World; import com.pahimar.ee3.EquivalentExchange3; +import com.pahimar.ee3.core.helper.NBTHelper; import com.pahimar.ee3.lib.Colours; +import com.pahimar.ee3.lib.GuiIds; import com.pahimar.ee3.lib.Strings; import cpw.mods.fml.client.FMLClientHandler; @@ -16,16 +20,30 @@ import cpw.mods.fml.relauncher.SideOnly; public class ItemAlchemyBag extends ItemEE { - public static final String[] alchemyBagNames = new String[] { "white", "orange", "magenta", "light_blue", "yellow", "lime", "pink", "gray", "light_gray", "cyan", "purple", "blue", "brown", "green", "red", "black" }; - public ItemAlchemyBag(int id) { super(id); - this.setHasSubtypes(true); this.setIconCoord(7, 0); this.setItemName(Strings.ALCHEMY_BAG_NAME); this.setCreativeTab(EquivalentExchange3.tabsEE3); } + + @Override + public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer entityPlayer) { + + if (!world.isRemote) { + NBTHelper.setBoolean(itemStack, Strings.NBT_ITEM_ALCHEMY_BAG_GUI_OPEN, true); + entityPlayer.openGui(EquivalentExchange3.instance, GuiIds.ALCHEMICAL_BAG, entityPlayer.worldObj, (int) entityPlayer.posX, (int) entityPlayer.posY, (int) entityPlayer.posZ); + } + + return itemStack; + } + + @Override + public boolean getShareTag() { + + return true; + } @SideOnly(Side.CLIENT) public boolean requiresMultipleRenderPasses() { @@ -33,34 +51,27 @@ public class ItemAlchemyBag extends ItemEE { return true; } - @SideOnly(Side.CLIENT) - public int getIconFromDamageForRenderPass(int meta, int renderPass) { - - if (renderPass == 0) { - return this.getIconFromDamage(meta); + @Override + public int getIconIndex(ItemStack itemStack, int renderPass) { + + if (NBTHelper.hasTag(itemStack, Strings.NBT_ITEM_ALCHEMY_BAG_GUI_OPEN)) { + if (renderPass == 0) { + return this.iconIndex + 2; + } + else { + return this.iconIndex + 1 + 2; + } } else { - return this.getIconFromDamage(meta) + 1; + if (renderPass == 0) { + return this.iconIndex; + } + else { + return this.iconIndex + 1; + } } } - @SideOnly(Side.CLIENT) - public int getIconFromDamage(int meta) { - - if (FMLClientHandler.instance().getClient().currentScreen != null) { - return (this.iconIndex + 2); - } - - return this.iconIndex; - } - - @SideOnly(Side.CLIENT) - public String getItemNameIS(ItemStack stack) { - - int meta = MathHelper.clamp_int(stack.getItemDamage(), 0, 15); - return super.getItemName() + "." + alchemyBagNames[meta]; - } - @SideOnly(Side.CLIENT) public int getColorFromItemStack(ItemStack itemStack, int renderPass) { @@ -120,13 +131,4 @@ public class ItemAlchemyBag extends ItemEE { } return returnValue; } - - @SideOnly(Side.CLIENT) - public void getSubItems(int id, CreativeTabs creativeTab, List list) { - - for (int meta = 0; meta < 16; ++meta) { - list.add(new ItemStack(id, 1, meta)); - } - } - } diff --git a/ee3_common/com/pahimar/ee3/lib/Strings.java b/ee3_common/com/pahimar/ee3/lib/Strings.java index 9fe66859..c6c76136 100644 --- a/ee3_common/com/pahimar/ee3/lib/Strings.java +++ b/ee3_common/com/pahimar/ee3/lib/Strings.java @@ -25,6 +25,7 @@ public class Strings { public static final String NBT_ITEM_MODE_KEY = "itemMode"; public static final String NBT_ITEM_CRAFTING_GUI_OPEN = "itemCraftingGuiOpen"; public static final String NBT_ITEM_TRANSMUTATION_GUI_OPEN = "itemTransmutationGuiOpen"; + public static final String NBT_ITEM_ALCHEMY_BAG_GUI_OPEN = "itemAlchemyBagGuiOpen"; public static final String NBT_TE_OWNER_KEY = "teOwner"; public static final String NBT_TE_STATE_KEY = "teState"; public static final String NBT_TE_DIRECTION_KEY = "teDirection"; diff --git a/ee3_common/com/pahimar/ee3/tileentity/TileAlchemicalChest.java b/ee3_common/com/pahimar/ee3/tileentity/TileAlchemicalChest.java index 4c77caff..07cbdeb5 100644 --- a/ee3_common/com/pahimar/ee3/tileentity/TileAlchemicalChest.java +++ b/ee3_common/com/pahimar/ee3/tileentity/TileAlchemicalChest.java @@ -23,6 +23,8 @@ public class TileAlchemicalChest extends TileEE implements IInventory { /** Server sync counter (once per 20 ticks) */ private int ticksSinceSync; + + private final int INVENTORY_SIZE = 13 * 4; /** * The ItemStacks that hold the items currently being used in the Alchemical @@ -32,7 +34,7 @@ public class TileAlchemicalChest extends TileEE implements IInventory { public TileAlchemicalChest() { - inventory = new ItemStack[13 * 4]; + inventory = new ItemStack[INVENTORY_SIZE]; } @Override @@ -69,20 +71,26 @@ public class TileAlchemicalChest extends TileEE implements IInventory { @Override public ItemStack getStackInSlotOnClosing(int slot) { - ItemStack itemStack = getStackInSlot(slot); - if (itemStack != null) { - setInventorySlotContents(slot, null); + if (this.inventory[slot] != null) { + ItemStack itemStack = this.inventory[slot]; + this.inventory[slot] = null; + return itemStack; + } + else { + return null; } - return itemStack; } @Override public void setInventorySlotContents(int slot, ItemStack itemStack) { - inventory[slot] = itemStack; - if (itemStack != null && itemStack.stackSize > getInventoryStackLimit()) { - itemStack.stackSize = getInventoryStackLimit(); + this.inventory[slot] = itemStack; + + if (itemStack != null && itemStack.stackSize > this.getInventoryStackLimit()) { + itemStack.stackSize = this.getInventoryStackLimit(); } + + this.onInventoryChanged(); } @Override diff --git a/ee3_common/com/pahimar/ee3/tileentity/TileAludel.java b/ee3_common/com/pahimar/ee3/tileentity/TileAludel.java index e92e95e4..26c1d648 100644 --- a/ee3_common/com/pahimar/ee3/tileentity/TileAludel.java +++ b/ee3_common/com/pahimar/ee3/tileentity/TileAludel.java @@ -1,12 +1,11 @@ package com.pahimar.ee3.tileentity; -import com.pahimar.ee3.lib.Strings; - import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; +import com.pahimar.ee3.lib.Strings; public class TileAludel extends TileEE implements IInventory { @@ -15,11 +14,18 @@ public class TileAludel extends TileEE implements IInventory { */ private ItemStack[] inventory; - public TileAludel() { - - inventory = new ItemStack[4]; - } + private final int INVENTORY_SIZE = 4; + public static final int INPUT_INVENTORY_INDEX = 0; + public static final int DUST_INVENTORY_INDEX = 1; + public static final int FUEL_INVENTORY_INDEX = 2; + public static final int OUTPUT_INVENTORY_INDEX = 3; + + public TileAludel() { + + inventory = new ItemStack[INVENTORY_SIZE]; + } + @Override public int getSizeInventory() { @@ -47,7 +53,7 @@ public class TileAludel extends TileEE implements IInventory { } } } - + return itemStack; } @@ -84,14 +90,14 @@ public class TileAludel extends TileEE implements IInventory { @Override public void openChest() { - + } @Override public void closeChest() { - + } - + public void readFromNBT(NBTTagCompound nbtTagCompound) { super.readFromNBT(nbtTagCompound); diff --git a/resources/com/pahimar/ee3/art/gui/aludel.png b/resources/com/pahimar/ee3/art/gui/aludel.png new file mode 100644 index 00000000..076e4348 Binary files /dev/null and b/resources/com/pahimar/ee3/art/gui/aludel.png differ diff --git a/resources/com/pahimar/ee3/art/gui/calcinator.png b/resources/com/pahimar/ee3/art/gui/calcinator.png index 444c09c1..f09b465b 100644 Binary files a/resources/com/pahimar/ee3/art/gui/calcinator.png and b/resources/com/pahimar/ee3/art/gui/calcinator.png differ diff --git a/resources/com/pahimar/ee3/art/xcf/gui/aludel.xcf b/resources/com/pahimar/ee3/art/xcf/gui/aludel.xcf new file mode 100644 index 00000000..44218080 Binary files /dev/null and b/resources/com/pahimar/ee3/art/xcf/gui/aludel.xcf differ diff --git a/resources/com/pahimar/ee3/art/xcf/gui/calcinator.xcf b/resources/com/pahimar/ee3/art/xcf/gui/calcinator.xcf index 0f85eec6..072de07c 100644 Binary files a/resources/com/pahimar/ee3/art/xcf/gui/calcinator.xcf and b/resources/com/pahimar/ee3/art/xcf/gui/calcinator.xcf differ diff --git a/resources/com/pahimar/ee3/lang/en_US.xml b/resources/com/pahimar/ee3/lang/en_US.xml index b5289690..49894715 100644 --- a/resources/com/pahimar/ee3/lang/en_US.xml +++ b/resources/com/pahimar/ee3/lang/en_US.xml @@ -16,22 +16,7 @@ Azure Dust Amaranthine Dust Iridescent Dust - White Alchemical Bag - Orange Alchemical Bag - Magenta Alchemical Bag - Light Blue Alchemical Bag - Yellow Alchemical Bag - Lime Alchemical Bag - Pink Alchemical Bag - Gray Alchemical Bag - Light Gray Alchemical Bag - Cyan Alchemical Bag - Purple Alchemical Bag - Blue Alchemical Bag - Brown Alchemical Bag - Green Alchemical Bag - Red Alchemical Bag - Black Alchemical Bag + Alchemical Bag Red Water (Still) Red Water (Flowing) Calcinator @@ -40,6 +25,7 @@ Calcinator Aludel Alchemical Chest + Alchemical Bag Equivalent Exchange 3 Initializing remote version check against remote version authority, located at Remote version check failed to initialize properly