From 7959ee8afb3118117ed106e4ed5c787c20e97d24 Mon Sep 17 00:00:00 2001 From: Astoria Date: Fri, 17 Mar 2023 15:45:49 -0500 Subject: [PATCH] Main chests, lots of duplicated code. Fix later! --- .../afloydironchest/IronChestMain.java | 6 ++ .../afloydironchest/blocks/DiamondChest.java | 66 ++++++++++++ .../afloydironchest/blocks/GoldChest.java | 66 ++++++++++++ .../afloydironchest/blocks/IronChest.java | 30 ++++++ .../afloydironchest/blocks/SteelChest.java | 66 ++++++++++++ .../mixin/MixinTileEntity.java | 6 ++ .../tileEntities/TileEntityDiamondChest.java | 100 ++++++++++++++++++ .../tileEntities/TileEntityGoldChest.java | 100 ++++++++++++++++++ .../tileEntities/TileEntitySteelChest.java | 100 ++++++++++++++++++ .../resources/lang/afloydironchest/en_US.lang | 8 +- 10 files changed, 547 insertions(+), 1 deletion(-) create mode 100644 src/main/java/net/brokenmoon/afloydironchest/blocks/DiamondChest.java create mode 100644 src/main/java/net/brokenmoon/afloydironchest/blocks/GoldChest.java create mode 100644 src/main/java/net/brokenmoon/afloydironchest/blocks/SteelChest.java create mode 100644 src/main/java/net/brokenmoon/afloydironchest/tileEntities/TileEntityDiamondChest.java create mode 100644 src/main/java/net/brokenmoon/afloydironchest/tileEntities/TileEntityGoldChest.java create mode 100644 src/main/java/net/brokenmoon/afloydironchest/tileEntities/TileEntitySteelChest.java diff --git a/src/main/java/net/brokenmoon/afloydironchest/IronChestMain.java b/src/main/java/net/brokenmoon/afloydironchest/IronChestMain.java index 4248cc5..9f6c339 100644 --- a/src/main/java/net/brokenmoon/afloydironchest/IronChestMain.java +++ b/src/main/java/net/brokenmoon/afloydironchest/IronChestMain.java @@ -1,6 +1,9 @@ package net.brokenmoon.afloydironchest; +import net.brokenmoon.afloydironchest.blocks.DiamondChest; import net.brokenmoon.afloydironchest.blocks.IronChest; +import net.brokenmoon.afloydironchest.blocks.GoldChest; +import net.brokenmoon.afloydironchest.blocks.SteelChest; import net.fabricmc.api.ModInitializer; import net.minecraft.src.Block; import net.minecraft.src.Material; @@ -14,6 +17,9 @@ public class IronChestMain implements ModInitializer { public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID); public static Block IronChest = BlockHelper.createBlock(MOD_ID, new IronChest(900, Material.iron), "ironchest", "ironchest.png", Block.soundMetalFootstep, 5, 6, 0); + public static Block GoldChest = BlockHelper.createBlock(MOD_ID, new GoldChest(901, Material.iron), "goldchest", "ironchest.png", Block.soundMetalFootstep, 5, 6, 0); + public static Block DiamondChest = BlockHelper.createBlock(MOD_ID, new DiamondChest(902, Material.iron), "diamondchest", "ironchest.png", Block.soundMetalFootstep, 5, 6, 0); + public static Block SteelChest = BlockHelper.createBlock(MOD_ID, new SteelChest(903, Material.iron), "steelchest", "ironchest.png", Block.soundMetalFootstep, 5, 6, 0); @Override public void onInitialize() { diff --git a/src/main/java/net/brokenmoon/afloydironchest/blocks/DiamondChest.java b/src/main/java/net/brokenmoon/afloydironchest/blocks/DiamondChest.java new file mode 100644 index 0000000..af8bcd0 --- /dev/null +++ b/src/main/java/net/brokenmoon/afloydironchest/blocks/DiamondChest.java @@ -0,0 +1,66 @@ +package net.brokenmoon.afloydironchest.blocks; + +import net.brokenmoon.afloydironchest.MixinInterfaces.IEntityPlayerMP; +import net.brokenmoon.afloydironchest.MixinInterfaces.IEntityPlayerSP; +import net.brokenmoon.afloydironchest.tileEntities.TileEntityDiamondChest; +import net.minecraft.src.*; + +import java.util.Random; + +public class DiamondChest extends BlockContainer{ + + Random random = new Random(); + public DiamondChest(int id, Material blockMaterial){ + super(id, blockMaterial); + } + + @Override + public void onBlockRemoval(World world, int i, int j, int k) { + TileEntityDiamondChest te = (TileEntityDiamondChest)world.getBlockTileEntity(i, j, k); + for (int l = 0; l < te.getSizeInventory(); ++l) { + ItemStack itemstack = te.getStackInSlot(l); + if (itemstack == null) continue; + float f = this.random.nextFloat() * 0.8f + 0.1f; + float f1 = this.random.nextFloat() * 0.8f + 0.1f; + float f2 = this.random.nextFloat() * 0.8f + 0.1f; + while (itemstack.stackSize > 0) { + int i1 = this.random.nextInt(21) + 10; + if (i1 > itemstack.stackSize) { + i1 = itemstack.stackSize; + } + itemstack.stackSize -= i1; + EntityItem entityitem = new EntityItem(world, (float)i + f, (float)j + f1, (float)k + f2, new ItemStack(itemstack.itemID, i1, itemstack.getMetadata())); + float f3 = 0.05f; + entityitem.motionX = (float)this.random.nextGaussian() * f3; + entityitem.motionY = (float)this.random.nextGaussian() * f3 + 0.2f; + entityitem.motionZ = (float)this.random.nextGaussian() * f3; + world.entityJoinedWorld(entityitem); + } + } + super.onBlockRemoval(world, i, j, k); + } + + @Override + public boolean blockActivated(World world, int x, int y, int z, EntityPlayer entityplayer) { + IInventory chest = (TileEntityDiamondChest)world.getBlockTileEntity(x, y, z); + if (!world.isMultiplayerAndNotHost) { + this.displayGui(entityplayer, chest); + } + return true; + } + + @Override + protected TileEntity getBlockEntity() { + return new TileEntityDiamondChest(); + } + + public static void displayGui(EntityPlayer player, IInventory inventory){ + if(player instanceof EntityPlayerMP) { + //Multiplayer + ((IEntityPlayerMP)player).displayGUIIronChest(inventory); + return; + } + //Singleplayer + ((IEntityPlayerSP)player).displayGUIIronChest(inventory); + } +} diff --git a/src/main/java/net/brokenmoon/afloydironchest/blocks/GoldChest.java b/src/main/java/net/brokenmoon/afloydironchest/blocks/GoldChest.java new file mode 100644 index 0000000..c4ea0fd --- /dev/null +++ b/src/main/java/net/brokenmoon/afloydironchest/blocks/GoldChest.java @@ -0,0 +1,66 @@ +package net.brokenmoon.afloydironchest.blocks; + +import net.brokenmoon.afloydironchest.MixinInterfaces.IEntityPlayerMP; +import net.brokenmoon.afloydironchest.MixinInterfaces.IEntityPlayerSP; +import net.brokenmoon.afloydironchest.tileEntities.TileEntityGoldChest; +import net.minecraft.src.*; + +import java.util.Random; + +public class GoldChest extends BlockContainer{ + + Random random = new Random(); + public GoldChest(int id, Material blockMaterial){ + super(id, blockMaterial); + } + + @Override + public void onBlockRemoval(World world, int i, int j, int k) { + TileEntityGoldChest te = (TileEntityGoldChest)world.getBlockTileEntity(i, j, k); + for (int l = 0; l < te.getSizeInventory(); ++l) { + ItemStack itemstack = te.getStackInSlot(l); + if (itemstack == null) continue; + float f = this.random.nextFloat() * 0.8f + 0.1f; + float f1 = this.random.nextFloat() * 0.8f + 0.1f; + float f2 = this.random.nextFloat() * 0.8f + 0.1f; + while (itemstack.stackSize > 0) { + int i1 = this.random.nextInt(21) + 10; + if (i1 > itemstack.stackSize) { + i1 = itemstack.stackSize; + } + itemstack.stackSize -= i1; + EntityItem entityitem = new EntityItem(world, (float)i + f, (float)j + f1, (float)k + f2, new ItemStack(itemstack.itemID, i1, itemstack.getMetadata())); + float f3 = 0.05f; + entityitem.motionX = (float)this.random.nextGaussian() * f3; + entityitem.motionY = (float)this.random.nextGaussian() * f3 + 0.2f; + entityitem.motionZ = (float)this.random.nextGaussian() * f3; + world.entityJoinedWorld(entityitem); + } + } + super.onBlockRemoval(world, i, j, k); + } + + @Override + public boolean blockActivated(World world, int x, int y, int z, EntityPlayer entityplayer) { + IInventory chest = (TileEntityGoldChest)world.getBlockTileEntity(x, y, z); + if (!world.isMultiplayerAndNotHost) { + this.displayGui(entityplayer, chest); + } + return true; + } + + @Override + protected TileEntity getBlockEntity() { + return new TileEntityGoldChest(); + } + + public static void displayGui(EntityPlayer player, IInventory inventory){ + if(player instanceof EntityPlayerMP) { + //Multiplayer + ((IEntityPlayerMP)player).displayGUIIronChest(inventory); + return; + } + //Singleplayer + ((IEntityPlayerSP)player).displayGUIIronChest(inventory); + } +} diff --git a/src/main/java/net/brokenmoon/afloydironchest/blocks/IronChest.java b/src/main/java/net/brokenmoon/afloydironchest/blocks/IronChest.java index 334e830..fda66ff 100644 --- a/src/main/java/net/brokenmoon/afloydironchest/blocks/IronChest.java +++ b/src/main/java/net/brokenmoon/afloydironchest/blocks/IronChest.java @@ -5,11 +5,41 @@ import net.brokenmoon.afloydironchest.MixinInterfaces.IEntityPlayerSP; import net.brokenmoon.afloydironchest.tileEntities.TileEntityIronChest; import net.minecraft.src.*; +import java.util.Random; + public class IronChest extends BlockContainer { + + Random random = new Random(); public IronChest(int id, Material blockMaterial){ super(id, blockMaterial); } + @Override + public void onBlockRemoval(World world, int i, int j, int k) { + TileEntityIronChest te = (TileEntityIronChest)world.getBlockTileEntity(i, j, k); + for (int l = 0; l < te.getSizeInventory(); ++l) { + ItemStack itemstack = te.getStackInSlot(l); + if (itemstack == null) continue; + float f = this.random.nextFloat() * 0.8f + 0.1f; + float f1 = this.random.nextFloat() * 0.8f + 0.1f; + float f2 = this.random.nextFloat() * 0.8f + 0.1f; + while (itemstack.stackSize > 0) { + int i1 = this.random.nextInt(21) + 10; + if (i1 > itemstack.stackSize) { + i1 = itemstack.stackSize; + } + itemstack.stackSize -= i1; + EntityItem entityitem = new EntityItem(world, (float)i + f, (float)j + f1, (float)k + f2, new ItemStack(itemstack.itemID, i1, itemstack.getMetadata())); + float f3 = 0.05f; + entityitem.motionX = (float)this.random.nextGaussian() * f3; + entityitem.motionY = (float)this.random.nextGaussian() * f3 + 0.2f; + entityitem.motionZ = (float)this.random.nextGaussian() * f3; + world.entityJoinedWorld(entityitem); + } + } + super.onBlockRemoval(world, i, j, k); + } + @Override public boolean blockActivated(World world, int x, int y, int z, EntityPlayer entityplayer) { IInventory chest = (TileEntityIronChest)world.getBlockTileEntity(x, y, z); diff --git a/src/main/java/net/brokenmoon/afloydironchest/blocks/SteelChest.java b/src/main/java/net/brokenmoon/afloydironchest/blocks/SteelChest.java new file mode 100644 index 0000000..22651fa --- /dev/null +++ b/src/main/java/net/brokenmoon/afloydironchest/blocks/SteelChest.java @@ -0,0 +1,66 @@ +package net.brokenmoon.afloydironchest.blocks; + +import net.brokenmoon.afloydironchest.MixinInterfaces.IEntityPlayerMP; +import net.brokenmoon.afloydironchest.MixinInterfaces.IEntityPlayerSP; +import net.brokenmoon.afloydironchest.tileEntities.TileEntitySteelChest; +import net.minecraft.src.*; + +import java.util.Random; + +public class SteelChest extends BlockContainer{ + + Random random = new Random(); + public SteelChest(int id, Material blockMaterial){ + super(id, blockMaterial); + } + + @Override + public void onBlockRemoval(World world, int i, int j, int k) { + TileEntitySteelChest te = (TileEntitySteelChest)world.getBlockTileEntity(i, j, k); + for (int l = 0; l < te.getSizeInventory(); ++l) { + ItemStack itemstack = te.getStackInSlot(l); + if (itemstack == null) continue; + float f = this.random.nextFloat() * 0.8f + 0.1f; + float f1 = this.random.nextFloat() * 0.8f + 0.1f; + float f2 = this.random.nextFloat() * 0.8f + 0.1f; + while (itemstack.stackSize > 0) { + int i1 = this.random.nextInt(21) + 10; + if (i1 > itemstack.stackSize) { + i1 = itemstack.stackSize; + } + itemstack.stackSize -= i1; + EntityItem entityitem = new EntityItem(world, (float)i + f, (float)j + f1, (float)k + f2, new ItemStack(itemstack.itemID, i1, itemstack.getMetadata())); + float f3 = 0.05f; + entityitem.motionX = (float)this.random.nextGaussian() * f3; + entityitem.motionY = (float)this.random.nextGaussian() * f3 + 0.2f; + entityitem.motionZ = (float)this.random.nextGaussian() * f3; + world.entityJoinedWorld(entityitem); + } + } + super.onBlockRemoval(world, i, j, k); + } + + @Override + public boolean blockActivated(World world, int x, int y, int z, EntityPlayer entityplayer) { + IInventory chest = (TileEntitySteelChest)world.getBlockTileEntity(x, y, z); + if (!world.isMultiplayerAndNotHost) { + this.displayGui(entityplayer, chest); + } + return true; + } + + @Override + protected TileEntity getBlockEntity() { + return new TileEntitySteelChest(); + } + + public static void displayGui(EntityPlayer player, IInventory inventory){ + if(player instanceof EntityPlayerMP) { + //Multiplayer + ((IEntityPlayerMP)player).displayGUIIronChest(inventory); + return; + } + //Singleplayer + ((IEntityPlayerSP)player).displayGUIIronChest(inventory); + } +} diff --git a/src/main/java/net/brokenmoon/afloydironchest/mixin/MixinTileEntity.java b/src/main/java/net/brokenmoon/afloydironchest/mixin/MixinTileEntity.java index 500399d..f0f4862 100644 --- a/src/main/java/net/brokenmoon/afloydironchest/mixin/MixinTileEntity.java +++ b/src/main/java/net/brokenmoon/afloydironchest/mixin/MixinTileEntity.java @@ -1,6 +1,9 @@ package net.brokenmoon.afloydironchest.mixin; +import net.brokenmoon.afloydironchest.tileEntities.TileEntityDiamondChest; +import net.brokenmoon.afloydironchest.tileEntities.TileEntityGoldChest; import net.brokenmoon.afloydironchest.tileEntities.TileEntityIronChest; +import net.brokenmoon.afloydironchest.tileEntities.TileEntitySteelChest; import net.minecraft.src.TileEntity; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -11,6 +14,9 @@ public class MixinTileEntity { static { addMapping(TileEntityIronChest.class, "Iron Chest"); + addMapping(TileEntityGoldChest.class, "Gold Chest"); + addMapping(TileEntityDiamondChest.class, "Diamond Chest"); + addMapping(TileEntitySteelChest.class, "Steel Chest"); } } diff --git a/src/main/java/net/brokenmoon/afloydironchest/tileEntities/TileEntityDiamondChest.java b/src/main/java/net/brokenmoon/afloydironchest/tileEntities/TileEntityDiamondChest.java new file mode 100644 index 0000000..44d8b50 --- /dev/null +++ b/src/main/java/net/brokenmoon/afloydironchest/tileEntities/TileEntityDiamondChest.java @@ -0,0 +1,100 @@ +package net.brokenmoon.afloydironchest.tileEntities; + +import net.minecraft.src.*; + +public class TileEntityDiamondChest extends TileEntity implements IInventory { + private ItemStack[] contents = new ItemStack[108]; + + @Override + public int getSizeInventory() { + return 108; + } + + @Override + public ItemStack getStackInSlot(int i) { + return this.contents[i]; + } + + @Override + public ItemStack decrStackSize(int i, int j) { + if (this.contents[i] != null) { + ItemStack itemstack1; + if (this.contents[i].stackSize <= j) { + itemstack1 = this.contents[i]; + this.contents[i] = null; + this.onInventoryChanged(); + return itemstack1; + } else { + itemstack1 = this.contents[i].splitStack(j); + if (this.contents[i].stackSize == 0) { + this.contents[i] = null; + } + + this.onInventoryChanged(); + return itemstack1; + } + } else { + return null; + } + } + + @Override + public void setInventorySlotContents(int i, ItemStack itemStack) { + this.contents[i] = itemStack; + if (itemStack != null && itemStack.stackSize > this.getInventoryStackLimit()) { + itemStack.stackSize = this.getInventoryStackLimit(); + } + + this.onInventoryChanged(); + } + + @Override + public String getInvName() { + return "Diamond Chest"; + } + + public void readFromNBT(NBTTagCompound nbttagcompound) { + super.readFromNBT(nbttagcompound); + NBTTagList nbttaglist = nbttagcompound.getTagList("Items"); + this.contents = new ItemStack[this.getSizeInventory()]; + + for(int i = 0; i < nbttaglist.tagCount(); ++i) { + NBTTagCompound nbttagcompound1 = (NBTTagCompound)nbttaglist.tagAt(i); + int j = nbttagcompound1.getByte("Slot") & 255; + if (j >= 0 && j < this.contents.length) { + this.contents[j] = new ItemStack(nbttagcompound1); + } + } + + } + + public void writeToNBT(NBTTagCompound nbttagcompound) { + super.writeToNBT(nbttagcompound); + NBTTagList nbttaglist = new NBTTagList(); + + for(int i = 0; i < this.contents.length; ++i) { + if (this.contents[i] != null) { + NBTTagCompound nbttagcompound1 = new NBTTagCompound(); + nbttagcompound1.setByte("Slot", (byte)i); + this.contents[i].writeToNBT(nbttagcompound1); + nbttaglist.setTag(nbttagcompound1); + } + } + + nbttagcompound.setTag("Items", nbttaglist); + } + + @Override + public int getInventoryStackLimit() { + return 64; + } + + @Override + public boolean canInteractWith(EntityPlayer entityPlayer) { + if (this.worldObj.getBlockTileEntity(this.xCoord, this.yCoord, this.zCoord) != this) { + return false; + } else { + return entityPlayer.getDistanceSq((double)this.xCoord + 0.5, (double)this.yCoord + 0.5, (double)this.zCoord + 0.5) <= 64.0; + } + } +} diff --git a/src/main/java/net/brokenmoon/afloydironchest/tileEntities/TileEntityGoldChest.java b/src/main/java/net/brokenmoon/afloydironchest/tileEntities/TileEntityGoldChest.java new file mode 100644 index 0000000..3c6d662 --- /dev/null +++ b/src/main/java/net/brokenmoon/afloydironchest/tileEntities/TileEntityGoldChest.java @@ -0,0 +1,100 @@ +package net.brokenmoon.afloydironchest.tileEntities; + +import net.minecraft.src.*; + +public class TileEntityGoldChest extends TileEntity implements IInventory { + private ItemStack[] contents = new ItemStack[81]; + + @Override + public int getSizeInventory() { + return 81; + } + + @Override + public ItemStack getStackInSlot(int i) { + return this.contents[i]; + } + + @Override + public ItemStack decrStackSize(int i, int j) { + if (this.contents[i] != null) { + ItemStack itemstack1; + if (this.contents[i].stackSize <= j) { + itemstack1 = this.contents[i]; + this.contents[i] = null; + this.onInventoryChanged(); + return itemstack1; + } else { + itemstack1 = this.contents[i].splitStack(j); + if (this.contents[i].stackSize == 0) { + this.contents[i] = null; + } + + this.onInventoryChanged(); + return itemstack1; + } + } else { + return null; + } + } + + @Override + public void setInventorySlotContents(int i, ItemStack itemStack) { + this.contents[i] = itemStack; + if (itemStack != null && itemStack.stackSize > this.getInventoryStackLimit()) { + itemStack.stackSize = this.getInventoryStackLimit(); + } + + this.onInventoryChanged(); + } + + @Override + public String getInvName() { + return "Gold Chest"; + } + + public void readFromNBT(NBTTagCompound nbttagcompound) { + super.readFromNBT(nbttagcompound); + NBTTagList nbttaglist = nbttagcompound.getTagList("Items"); + this.contents = new ItemStack[this.getSizeInventory()]; + + for(int i = 0; i < nbttaglist.tagCount(); ++i) { + NBTTagCompound nbttagcompound1 = (NBTTagCompound)nbttaglist.tagAt(i); + int j = nbttagcompound1.getByte("Slot") & 255; + if (j >= 0 && j < this.contents.length) { + this.contents[j] = new ItemStack(nbttagcompound1); + } + } + + } + + public void writeToNBT(NBTTagCompound nbttagcompound) { + super.writeToNBT(nbttagcompound); + NBTTagList nbttaglist = new NBTTagList(); + + for(int i = 0; i < this.contents.length; ++i) { + if (this.contents[i] != null) { + NBTTagCompound nbttagcompound1 = new NBTTagCompound(); + nbttagcompound1.setByte("Slot", (byte)i); + this.contents[i].writeToNBT(nbttagcompound1); + nbttaglist.setTag(nbttagcompound1); + } + } + + nbttagcompound.setTag("Items", nbttaglist); + } + + @Override + public int getInventoryStackLimit() { + return 64; + } + + @Override + public boolean canInteractWith(EntityPlayer entityPlayer) { + if (this.worldObj.getBlockTileEntity(this.xCoord, this.yCoord, this.zCoord) != this) { + return false; + } else { + return entityPlayer.getDistanceSq((double)this.xCoord + 0.5, (double)this.yCoord + 0.5, (double)this.zCoord + 0.5) <= 64.0; + } + } +} diff --git a/src/main/java/net/brokenmoon/afloydironchest/tileEntities/TileEntitySteelChest.java b/src/main/java/net/brokenmoon/afloydironchest/tileEntities/TileEntitySteelChest.java new file mode 100644 index 0000000..8a3f030 --- /dev/null +++ b/src/main/java/net/brokenmoon/afloydironchest/tileEntities/TileEntitySteelChest.java @@ -0,0 +1,100 @@ +package net.brokenmoon.afloydironchest.tileEntities; + +import net.minecraft.src.*; + +public class TileEntitySteelChest extends TileEntity implements IInventory { + private ItemStack[] contents = new ItemStack[108]; + + @Override + public int getSizeInventory() { + return 108; + } + + @Override + public ItemStack getStackInSlot(int i) { + return this.contents[i]; + } + + @Override + public ItemStack decrStackSize(int i, int j) { + if (this.contents[i] != null) { + ItemStack itemstack1; + if (this.contents[i].stackSize <= j) { + itemstack1 = this.contents[i]; + this.contents[i] = null; + this.onInventoryChanged(); + return itemstack1; + } else { + itemstack1 = this.contents[i].splitStack(j); + if (this.contents[i].stackSize == 0) { + this.contents[i] = null; + } + + this.onInventoryChanged(); + return itemstack1; + } + } else { + return null; + } + } + + @Override + public void setInventorySlotContents(int i, ItemStack itemStack) { + this.contents[i] = itemStack; + if (itemStack != null && itemStack.stackSize > this.getInventoryStackLimit()) { + itemStack.stackSize = this.getInventoryStackLimit(); + } + + this.onInventoryChanged(); + } + + @Override + public String getInvName() { + return "Steel Chest"; + } + + public void readFromNBT(NBTTagCompound nbttagcompound) { + super.readFromNBT(nbttagcompound); + NBTTagList nbttaglist = nbttagcompound.getTagList("Items"); + this.contents = new ItemStack[this.getSizeInventory()]; + + for(int i = 0; i < nbttaglist.tagCount(); ++i) { + NBTTagCompound nbttagcompound1 = (NBTTagCompound)nbttaglist.tagAt(i); + int j = nbttagcompound1.getByte("Slot") & 255; + if (j >= 0 && j < this.contents.length) { + this.contents[j] = new ItemStack(nbttagcompound1); + } + } + + } + + public void writeToNBT(NBTTagCompound nbttagcompound) { + super.writeToNBT(nbttagcompound); + NBTTagList nbttaglist = new NBTTagList(); + + for(int i = 0; i < this.contents.length; ++i) { + if (this.contents[i] != null) { + NBTTagCompound nbttagcompound1 = new NBTTagCompound(); + nbttagcompound1.setByte("Slot", (byte)i); + this.contents[i].writeToNBT(nbttagcompound1); + nbttaglist.setTag(nbttagcompound1); + } + } + + nbttagcompound.setTag("Items", nbttaglist); + } + + @Override + public int getInventoryStackLimit() { + return 64; + } + + @Override + public boolean canInteractWith(EntityPlayer entityPlayer) { + if (this.worldObj.getBlockTileEntity(this.xCoord, this.yCoord, this.zCoord) != this) { + return false; + } else { + return entityPlayer.getDistanceSq((double)this.xCoord + 0.5, (double)this.yCoord + 0.5, (double)this.zCoord + 0.5) <= 64.0; + } + } +} diff --git a/src/main/resources/lang/afloydironchest/en_US.lang b/src/main/resources/lang/afloydironchest/en_US.lang index 5625cc9..62fb4e9 100644 --- a/src/main/resources/lang/afloydironchest/en_US.lang +++ b/src/main/resources/lang/afloydironchest/en_US.lang @@ -1,2 +1,8 @@ tile.ironchest.ironchest.name=Iron Chest -tile.ironchest.ironchest.desc=A larger chest \ No newline at end of file +tile.ironchest.ironchest.desc=A large chest. +tile.ironchest.goldchest.name=Gold Chest +tile.ironchest.goldchest.desc=An extra-large chest. +tile.ironchest.diamondchest.name=Diamond Chest +tile.ironchest.diamondchest.desc=An extremely large chest. +tile.ironchest.steelchest.name=Steel Chest +tile.ironchest.steelchest.desc=An extremely large chest. \ No newline at end of file