diff --git a/IronChests2/common/cpw/mods/ironchest/BlockIronChest.java b/IronChests2/common/cpw/mods/ironchest/BlockIronChest.java index 4a8225c..9008cf6 100644 --- a/IronChests2/common/cpw/mods/ironchest/BlockIronChest.java +++ b/IronChests2/common/cpw/mods/ironchest/BlockIronChest.java @@ -83,30 +83,6 @@ public class BlockIronChest extends BlockContainer { return IronChestType.makeEntity(metadata); } -// public Icon getBlockTexture(IBlockAccess worldAccess, int i, int j, int k, int l) -// { -// int meta = worldAccess.getBlockMetadata(i, j, k); -// IronChestType type = IronChestType.values()[meta]; -// TileEntity te = worldAccess.getBlockTileEntity(i, j, k); -// TileEntityIronChest icte = null; -// if (te != null && te instanceof TileEntityIronChest) -// { -// icte = (TileEntityIronChest) te; -// } -// if (l == 0 || l == 1) -// { // Top and Bottom -// return type.getTextureRow() * 16 + 1; -// } -// else if (icte != null && l == icte.getFacing()) -// { // Front -// return type.getTextureRow() * 16 + 2; -// } -// else -// { // Back and Sides -// return type.getTextureRow() * 16; -// } -// } - @SideOnly(Side.CLIENT) @Override public Icon getIcon(int i, int j) diff --git a/IronChests2/common/cpw/mods/ironchest/ContainerIronChestBase.java b/IronChests2/common/cpw/mods/ironchest/ContainerIronChestBase.java index 44f96f6..3228424 100644 --- a/IronChests2/common/cpw/mods/ironchest/ContainerIronChestBase.java +++ b/IronChests2/common/cpw/mods/ironchest/ContainerIronChestBase.java @@ -53,6 +53,10 @@ public class ContainerIronChestBase extends Container { return null; } } + else if (!type.acceptsStack(itemstack1)) + { + return null; + } else if (!mergeItemStack(itemstack1, 0, type.size, false)) { return null; @@ -78,13 +82,16 @@ public class ContainerIronChestBase extends Container { protected void layoutContainer(IInventory playerInventory, IInventory chestInventory, IronChestType type, int xSize, int ySize) { - for (int chestRow = 0; chestRow < type.getRowCount(); chestRow++) - { - for (int chestCol = 0; chestCol < type.getRowLength(); chestCol++) + if (type == IronChestType.DIRTCHEST9000) { + addSlotToContainer(type.makeSlot(chestInventory, 0, 12 + 4 * 18, 8 + 2 * 18)); + } else { + for (int chestRow = 0; chestRow < type.getRowCount(); chestRow++) { - addSlotToContainer(new Slot(chestInventory, chestCol + chestRow * type.getRowLength(), 12 + chestCol * 18, 8 + chestRow * 18)); + for (int chestCol = 0; chestCol < type.getRowLength(); chestCol++) + { + addSlotToContainer(type.makeSlot(chestInventory, chestCol + chestRow * type.getRowLength(), 12 + chestCol * 18, 8 + chestRow * 18)); + } } - } int leftCol = (xSize - 162) / 2 + 1; diff --git a/IronChests2/common/cpw/mods/ironchest/IronChestType.java b/IronChests2/common/cpw/mods/ironchest/IronChestType.java index ceac5e4..7ae6bf8 100644 --- a/IronChests2/common/cpw/mods/ironchest/IronChestType.java +++ b/IronChests2/common/cpw/mods/ironchest/IronChestType.java @@ -16,6 +16,8 @@ import java.util.List; import net.minecraft.block.Block; import net.minecraft.client.renderer.texture.IconRegister; +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.Slot; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.Icon; @@ -32,6 +34,7 @@ public enum IronChestType { SILVER(72, 9, false, "Silver Chest", "silverchest.png", 4, Arrays.asList("ingotSilver"), TileEntitySilverChest.class, "mmmm3mmmm", "mGmG0GmGm"), CRYSTAL(108, 12, true, "Crystal Chest", "crystalchest.png", 5, Arrays.asList("blockGlass"), TileEntityCrystalChest.class, "GGGGPGGGG"), OBSIDIAN(108, 12, false, "Obsidian Chest", "obsidianchest.png", 6, Arrays.asList("obsidian"), TileEntityObsidianChest.class, "mmmm2mmmm"), + DIRTCHEST9000(1, 1, false, "Dirt Chest 9000", "dirtchest.png",7,Arrays.asList("dirt"), TileEntityDirtChest.class,Item.itemsList[Block.dirt.blockID],"mmmmCmmmm"), WOOD(0, 0, false, "", "", -1, Arrays.asList("plankWood"), null); int size; private int rowLength; @@ -42,9 +45,15 @@ public enum IronChestType { public Class clazz; private String[] recipes; private ArrayList matList; + private Item itemFilter; IronChestType(int size, int rowLength, boolean tieredChest, String friendlyName, String modelTexture, int textureRow, List mats, Class clazz, String... recipes) + { + this(size, rowLength, tieredChest, friendlyName, modelTexture, textureRow, mats, clazz, (Item)null, recipes); + } + IronChestType(int size, int rowLength, boolean tieredChest, String friendlyName, String modelTexture, int textureRow, List mats, + Class clazz, Item itemFilter, String... recipes) { this.size = size; this.rowLength = rowLength; @@ -53,6 +62,7 @@ public enum IronChestType { this.modelTexture = modelTexture; this.textureRow = textureRow; this.clazz = clazz; + this.itemFilter = itemFilter; this.recipes = recipes; this.matList = new ArrayList(); matList.addAll(mats); @@ -153,6 +163,10 @@ public enum IronChestType { { return Block.obsidian; } + else if (mat == "dirt") + { + return Block.dirt; + } return mat; } @@ -230,4 +244,14 @@ public enum IronChestType { private static String[] sideNames = { "top", "front", "side" }; private static int[] sideMapping = { 0, 0, 2, 1, 2, 2, 2 }; + + public Slot makeSlot(IInventory chestInventory, int index, int x, int y) + { + return new ValidatingSlot(chestInventory, index, x, y, this); + } + + public boolean acceptsStack(ItemStack itemstack) + { + return itemFilter == null || itemstack == null || itemstack.getItem() == itemFilter; + } } diff --git a/IronChests2/common/cpw/mods/ironchest/TileEntityDirtChest.java b/IronChests2/common/cpw/mods/ironchest/TileEntityDirtChest.java new file mode 100644 index 0000000..5e985b3 --- /dev/null +++ b/IronChests2/common/cpw/mods/ironchest/TileEntityDirtChest.java @@ -0,0 +1,29 @@ +package cpw.mods.ironchest; + +import cpw.mods.fml.common.registry.LanguageRegistry; +import net.minecraft.block.Block; +import net.minecraft.client.resources.I18n; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.nbt.NBTTagString; +import net.minecraft.util.StatCollector; + +public class TileEntityDirtChest extends TileEntityIronChest { + private static ItemStack dirtChest9000GuideBook = new ItemStack(Item.writtenBook); + static { + dirtChest9000GuideBook.setTagInfo("author", new NBTTagString("author", "cpw")); + dirtChest9000GuideBook.setTagInfo("title", new NBTTagString("title", StatCollector.translateToLocal("book.ironchest:dirtchest9000.title"))); + NBTTagList pages = new NBTTagList(); + pages.appendTag(new NBTTagString("1", StatCollector.translateToLocal("book.ironchest:dirtchest9000.page1"))); + pages.appendTag(new NBTTagString("2", StatCollector.translateToLocal("book.ironchest:dirtchest9000.page2"))); + pages.appendTag(new NBTTagString("3", StatCollector.translateToLocal("book.ironchest:dirtchest9000.page3"))); + pages.appendTag(new NBTTagString("4", StatCollector.translateToLocal("book.ironchest:dirtchest9000.page4"))); + pages.appendTag(new NBTTagString("5", StatCollector.translateToLocal("book.ironchest:dirtchest9000.page5"))); + dirtChest9000GuideBook.setTagInfo("pages", pages); + } + public TileEntityDirtChest() { + super(IronChestType.DIRTCHEST9000); + setInventorySlotContents(0, dirtChest9000GuideBook.copy()); + } +} diff --git a/IronChests2/common/cpw/mods/ironchest/TileEntityIronChest.java b/IronChests2/common/cpw/mods/ironchest/TileEntityIronChest.java index 2421bf0..a844486 100644 --- a/IronChests2/common/cpw/mods/ironchest/TileEntityIronChest.java +++ b/IronChests2/common/cpw/mods/ironchest/TileEntityIronChest.java @@ -500,7 +500,7 @@ public class TileEntityIronChest extends TileEntity implements IInventory { @Override public boolean isItemValidForSlot(int i, ItemStack itemstack) { - return true; + return type.acceptsStack(itemstack); } @Override diff --git a/IronChests2/common/cpw/mods/ironchest/ValidatingSlot.java b/IronChests2/common/cpw/mods/ironchest/ValidatingSlot.java new file mode 100644 index 0000000..f0348c9 --- /dev/null +++ b/IronChests2/common/cpw/mods/ironchest/ValidatingSlot.java @@ -0,0 +1,21 @@ +package cpw.mods.ironchest; + +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; + +public class ValidatingSlot extends Slot { + private IronChestType type; + + public ValidatingSlot(IInventory par1iInventory, int par2, int par3, int par4, IronChestType type) + { + super(par1iInventory, par2, par3, par4); + this.type = type; + } + + @Override + public boolean isItemValid(ItemStack par1ItemStack) + { + return type.acceptsStack(par1ItemStack); + } +} diff --git a/IronChests2/common/cpw/mods/ironchest/client/GUIChest.java b/IronChests2/common/cpw/mods/ironchest/client/GUIChest.java index 316a146..d40a7af 100644 --- a/IronChests2/common/cpw/mods/ironchest/client/GUIChest.java +++ b/IronChests2/common/cpw/mods/ironchest/client/GUIChest.java @@ -27,7 +27,8 @@ public class GUIChest extends GuiContainer { COPPER(new ResourceLocation("ironchest", "textures/gui/coppercontainer.png")), SILVER(new ResourceLocation("ironchest", "textures/gui/silvercontainer.png")), GOLD(new ResourceLocation("ironchest", "textures/gui/goldcontainer.png")), - DIAMOND(new ResourceLocation("ironchest", "textures/gui/diamondcontainer.png")); + DIAMOND(new ResourceLocation("ironchest", "textures/gui/diamondcontainer.png")), + DIRT(new ResourceLocation("ironchest", "textures/gui/dirtcontainer.png")); public final ResourceLocation location; private ResourceList(ResourceLocation loc) { this.location = loc; @@ -40,7 +41,8 @@ public class GUIChest extends GuiContainer { COPPER(184, 184, ResourceList.COPPER, IronChestType.COPPER), SILVER(184, 238, ResourceList.SILVER, IronChestType.SILVER), CRYSTAL(238, 256, ResourceList.DIAMOND, IronChestType.CRYSTAL), - OBSIDIAN(238, 256, ResourceList.DIAMOND, IronChestType.OBSIDIAN); + OBSIDIAN(238, 256, ResourceList.DIAMOND, IronChestType.OBSIDIAN), + DIRTCHEST9000(184, 184, ResourceList.DIRT, IronChestType.DIRTCHEST9000); private int xSize; private int ySize; diff --git a/IronChests2/resources/assets/ironchest/lang/en_US.lang b/IronChests2/resources/assets/ironchest/lang/en_US.lang index 897a39e..c848ed8 100644 --- a/IronChests2/resources/assets/ironchest/lang/en_US.lang +++ b/IronChests2/resources/assets/ironchest/lang/en_US.lang @@ -5,6 +5,7 @@ tile.ironchest:COPPER.name=Copper Chest tile.ironchest:SILVER.name=Silver Chest tile.ironchest:CRYSTAL.name=Crystal Chest tile.ironchest:OBSIDIAN.name=Obsidian Chest +tile.ironchest:DIRTCHEST9000.name=DirtChest 9000! item.ironchest:IRONGOLD.name=Iron to Gold Chest Upgrade item.ironchest:GOLDDIAMOND.name=Gold to Diamond Chest Upgrade @@ -15,3 +16,10 @@ item.ironchest:DIAMONDCRYSTAL.name=Diamond to Crystal Chest Upgrade item.ironchest:WOODIRON.name=Wood to Iron Chest Upgrade item.ironchest:WOODCOPPER.name=Wood to Copper Chest Upgrade item.ironchest:DIAMONDOBSIDIAN.name=Diamond to Obsidian Chest Upgrade + +book.ironchest:dirtchest9000.title=How to use your DirtChest 9000! +book.ironchest:dirtchest9000.page1=Welcome to your new DirtChest 9000! We hope you will enjoy many happy years of storing your stack of dirt in our storage utility. +book.ironchest:dirtchest9000.page2=Usage: simply insert the stack of dirt of your choice into the highly receptive slot and enjoy the great convenience of having that dirt available to you, any time you pass by this chest! +book.ironchest:dirtchest9000.page3=We hope you have enjoyed reviewing this instruction manual, and hope you will consider using our products in future! Kind regards, The DirtChest 9000 manual writers incorporated. +book.ironchest:dirtchest9000.page4=Warranty: This product has no warranty of any kind. Your dirt may not be stored, it may slowly leech into the environment, or alternatively, it may not do anything at all. +book.ironchest:dirtchest9000.page5=DirtChest 9000 is kind to the environment. Please dispose of this guide book responsibly, and do not whatever you do just chuck it into some lava. We would be very sad. diff --git a/IronChests2/resources/assets/ironchest/textures/gui/dirtcontainer.png b/IronChests2/resources/assets/ironchest/textures/gui/dirtcontainer.png new file mode 100644 index 0000000..44667e1 Binary files /dev/null and b/IronChests2/resources/assets/ironchest/textures/gui/dirtcontainer.png differ diff --git a/IronChests2/resources/assets/ironchest/textures/model/dirtchest.png b/IronChests2/resources/assets/ironchest/textures/model/dirtchest.png new file mode 100644 index 0000000..168e179 Binary files /dev/null and b/IronChests2/resources/assets/ironchest/textures/model/dirtchest.png differ