From 6dc10af8577022a201a61a6dc3d73c62b016a3b2 Mon Sep 17 00:00:00 2001 From: Justin Aquadro Date: Mon, 7 Sep 2015 00:03:25 -0400 Subject: [PATCH] Drawer tape (relocate drawers with contents) --- build.gradle | 2 +- .../textures/blocks/TextureBuilder.exe | Bin 17920 -> 0 bytes .../assets/storagedrawers/lang/en_US.lang | 41 ++-- .../assets/storagedrawers/lang/es_AR.lang | 28 +-- .../assets/storagedrawers/lang/fr_FR.lang | 36 ++-- .../assets/storagedrawers/lang/he_IL.lang | 28 +-- .../assets/storagedrawers/lang/ko_KR.lang | 28 +-- .../assets/storagedrawers/lang/pl_PL.lang | 28 +-- .../assets/storagedrawers/lang/ru_RU.lang | 32 +-- .../assets/storagedrawers/lang/zh_CN.lang | 36 ++-- .../storagedrawers/textures/blocks/tape.png | Bin 0 -> 465 bytes .../textures/items/tape_roll.png | Bin 0 -> 507 bytes .../api/storage/attribute/ISealable.java | 16 ++ .../storagedrawers/block/BlockDrawers.java | 67 +++++- .../block/tile/BaseTileEntity.java | 73 +++++++ .../block/tile/TileEntityDrawers.java | 202 ++++++++++-------- .../block/tile/TileEntityDrawersComp.java | 46 ++-- .../client/renderer/DrawersItemRenderer.java | 151 +++++++++++++ .../client/renderer/DrawersRenderer.java | 21 ++ .../renderer/TileEntityDrawersRenderer.java | 5 +- .../storagedrawers/config/ConfigManager.java | 2 + .../storagedrawers/core/ClientProxy.java | 11 + .../storagedrawers/core/CommonProxy.java | 3 + .../storagedrawers/core/ModBlocks.java | 7 + .../storagedrawers/core/ModItems.java | 20 +- .../storagedrawers/core/ModRecipes.java | 5 + .../storagedrawers/core/api/PackFactory.java | 6 +- .../integration/RefinedRelocation.java | 7 + .../storagedrawers/item/ItemCompDrawers.java | 15 +- .../storagedrawers/item/ItemDrawers.java | 19 +- .../storagedrawers/item/ItemTape.java | 53 +++++ 31 files changed, 725 insertions(+), 263 deletions(-) delete mode 100644 packs/Forestry/resources/assets/storagedrawersforestry/textures/blocks/TextureBuilder.exe create mode 100644 resources/assets/storagedrawers/textures/blocks/tape.png create mode 100644 resources/assets/storagedrawers/textures/items/tape_roll.png create mode 100644 src/com/jaquadro/minecraft/storagedrawers/api/storage/attribute/ISealable.java create mode 100644 src/com/jaquadro/minecraft/storagedrawers/block/tile/BaseTileEntity.java create mode 100644 src/com/jaquadro/minecraft/storagedrawers/client/renderer/DrawersItemRenderer.java create mode 100644 src/com/jaquadro/minecraft/storagedrawers/item/ItemTape.java diff --git a/build.gradle b/build.gradle index 2510442bc..1fc518553 100644 --- a/build.gradle +++ b/build.gradle @@ -17,7 +17,7 @@ buildscript { apply plugin: 'forge' -version = "1.7.10-1.5.15" +version = "1.7.10-1.6.0" group= "com.jaquadro.minecraft.storagedrawers" // http://maven.apache.org/guides/mini/guide-naming-conventions.html archivesBaseName = "StorageDrawers" diff --git a/packs/Forestry/resources/assets/storagedrawersforestry/textures/blocks/TextureBuilder.exe b/packs/Forestry/resources/assets/storagedrawersforestry/textures/blocks/TextureBuilder.exe deleted file mode 100644 index ebb696c90039107cfe07bcc586159212a06543ab..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 17920 zcmeHO3vgU#bw2m*YG0OQB-?uUk-e6ac>T~?lI16MBFmC(1wVvVwsB%`R=Zcy#=Cph z_wG8Djfq6+rb&R}hSH=^9)S$Wv_KfbkQ8W~(zHMuhJZUQuS_yiI>3ZUnTFvpH1s>? z-n%cYgfVo6w!Zc~_dk#S|IdH^^Pm6R|E><)`floo_zHQoF7bs-5CDs zMtUOn+{!1F{m-o&olIF;&NL>>ct%Uavsojrjp>?M$ZDyqHgG7WWsIaAZDeLHT}PQydB^+t(&4EXvGZqWHs>Glgm zuap0!r-Rxe^dHBF-oWMCiE?!gvHUSjR1f^gHxVr_r~kULR#aUi1Hku{)rscyGkM?x z+X29nu{wGKlS_kEQPVOLz(lv(QQ(2zguCqOgF&LEo;D!Jy3#amZfgK{+0{qXUxrFi zW4q#F-BhZhOE(k!tc~CkDm9_EVf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=l`sv<7|%!D5MM~9jHn&`(76-okYcAM5Vwnj z7@~bz=d{F$$%Yx|?zTUZV0`Fqv8c49d1lFwLQA6u2SKc$S>`pfNvDIuH!T2QMKhL zGD_@GgJ%-Dym4Uf#NHvYRQ#J!w(oM#F5`p4WqgAki4DZQo{jzNU;g6$y&t}#<&o8| zs?Xt*9O>JSAH}?c;)!3QDf|m zX>;?R8lsxpY|HWCNbLjDk!Y=N^G`+D5l2i+Cul!sIbbi6#y zYH7L1bdme7m&Q=$zqwwBx~}|yWE=@;Cs)zWe7Owk(Z%~wv7IAmhcnR>Mq%s8nPOM* z=6?BG8;_K8C=<^(##YRuFk(Bis+~JA57`#3efYko(0*VO(gNp;IUG^3B_@#NB4?8v zvXZ9JW2E6<4|M7#{>(Kj`W$lVu@zY#*Dj1nes{%s^@&~W950D%jx*ZQ=y*ow9v_dZ zSL|6?zuKzRHr*<9cERqP`DQS~X;?yocU8_tb-hbUu)hR}|>eB{4g+LTXn6XMr%|csyc<31ww_UNOAKT@ynX(ANgiHa$s0E$rTymby3yfX98;si%zT-jO1R_pQJG|M~g3MJ&^1$t7${#8#U-2)X;`{jY!YB~OG^!OVk4r9ISmm*NRM z#S~*>Blaid6ZZG`mOe=Q^!vL$n`UGpTiCY$Jb!D2C6@U{9_d)q&U#lgfb~Jc(}z=1 ze*A52e)#9+VV>*j?jE?n!{oDLQTFpbS)TZP_UQ>pzYirOWpx=x&AiC!P}jrb&uabq z#6xACU%%LRk`A5XxfImJGv`jd;i4ImvBnznriz#xsJpi(llySzV|9rMhgs6C8e7e_ ztx%fbm+-O2c;W+Z^&dHEYI7HO2+W>YpqA=1YvW2_Sjp+Gv)*gX2n<99Pgg&ebxsLQ E06Orj;Q#;t literal 0 HcmV?d00001 diff --git a/resources/assets/storagedrawers/textures/items/tape_roll.png b/resources/assets/storagedrawers/textures/items/tape_roll.png new file mode 100644 index 0000000000000000000000000000000000000000..41809a1a31e65734438c036406a5bda6a1971a37 GIT binary patch literal 507 zcmVWdKxYbs#e!Q)O@Iz67Zw&~=*VhC^B0~SXI@IbtC=MLC*kh4KHudH%ms9Euj@exoD$Pf@8B%YL*i4sn5 z15{KX&II`xLLv~{R~2o?AbiUn9`g90qM|0*;VB*B_N;^+V+ x8W%6`M@a{;Fk$6@*o getDrops (World world, int x, int y, int z, int metadata, int fortune) { + ItemStack dropStack = new ItemStack(Item.getItemFromBlock(this), 1, metadata); + + ArrayList drops = new ArrayList(); + drops.add(dropStack); + + TileEntityDrawers tile = getTileEntity(world, x, y, z); + if (tile == null || !tile.isSealed()) + return drops; + + NBTTagCompound tiledata = new NBTTagCompound(); + tile.writeToNBT(tiledata); + + NBTTagCompound data = new NBTTagCompound(); + data.setTag("tile", tiledata); + + dropStack.setTagCompound(data); + + return drops; + } + @Override public TileEntityDrawers createNewTileEntity (World world, int meta) { return new TileEntityDrawersStandard(); @@ -618,6 +672,9 @@ public IIcon getVoidIcon () { return iconVoid; } + @SideOnly(Side.CLIENT) + public IIcon getTapeIcon () { return iconTaped; } + @Override @SideOnly(Side.CLIENT) public void registerBlockIcons (IIconRegister register) { @@ -641,6 +698,8 @@ public void registerBlockIcons (IIconRegister register) { iconTrim[i] = register.registerIcon(StorageDrawers.MOD_ID + ":drawers_" + subtex[i] + "_trim"); } + iconTaped = register.registerIcon(StorageDrawers.MOD_ID + ":tape"); + String[] overlays = new String[] { null, null, "iron", "gold", "obsidian", "diamond", "emerald" }; iconOverlay = new IIcon[overlays.length]; diff --git a/src/com/jaquadro/minecraft/storagedrawers/block/tile/BaseTileEntity.java b/src/com/jaquadro/minecraft/storagedrawers/block/tile/BaseTileEntity.java new file mode 100644 index 000000000..36554f9dd --- /dev/null +++ b/src/com/jaquadro/minecraft/storagedrawers/block/tile/BaseTileEntity.java @@ -0,0 +1,73 @@ +package com.jaquadro.minecraft.storagedrawers.block.tile; + +import com.jaquadro.minecraft.storagedrawers.StorageDrawers; +import cpw.mods.fml.common.FMLLog; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import org.apache.logging.log4j.Level; + +import java.util.Iterator; + +public class BaseTileEntity extends TileEntity +{ + private NBTTagCompound failureSnapshot; + + @Override + public void readFromNBT (NBTTagCompound tag) { + super.readFromNBT(tag); + + failureSnapshot = null; + + try { + readFromFixedNBT(tag); + readFromPortableNBT(tag); + } + catch (Throwable t) { + trapLoadFailure(t, tag); + } + } + + @Override + public void writeToNBT (NBTTagCompound tag) { + super.writeToNBT(tag); + + if (failureSnapshot != null) { + restoreLoadFailure(tag); + return; + } + + try { + writeToFixedNBT(tag); + writeToPortableNBT(tag); + } + catch (Throwable t) { + FMLLog.log(StorageDrawers.MOD_ID, Level.ERROR, t, "Tile Save Failure."); + } + } + + public void readFromPortableNBT (NBTTagCompound tag) { } + + public void writeToPortableNBT (NBTTagCompound tag) { } + + protected void readFromFixedNBT (NBTTagCompound tag) { } + + protected void writeToFixedNBT (NBTTagCompound tag) { } + + protected void trapLoadFailure (Throwable t, NBTTagCompound tag) { + failureSnapshot = (NBTTagCompound)tag.copy(); + FMLLog.log(StorageDrawers.MOD_ID, Level.ERROR, t, "Tile Load Failure."); + } + + protected void restoreLoadFailure (NBTTagCompound tag) { + Iterator iter = failureSnapshot.func_150296_c().iterator(); + while (iter.hasNext()) { + String key = iter.next(); + if (!tag.hasKey(key)) + tag.setTag(key, failureSnapshot.getTag(key).copy()); + } + } + + protected boolean loadDidFail () { + return failureSnapshot != null; + } +} diff --git a/src/com/jaquadro/minecraft/storagedrawers/block/tile/TileEntityDrawers.java b/src/com/jaquadro/minecraft/storagedrawers/block/tile/TileEntityDrawers.java index c889daa49..aac557278 100644 --- a/src/com/jaquadro/minecraft/storagedrawers/block/tile/TileEntityDrawers.java +++ b/src/com/jaquadro/minecraft/storagedrawers/block/tile/TileEntityDrawers.java @@ -5,6 +5,7 @@ import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawer; import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawerGroupInteractive; import com.jaquadro.minecraft.storagedrawers.api.storage.attribute.ILockable; +import com.jaquadro.minecraft.storagedrawers.api.storage.attribute.ISealable; import com.jaquadro.minecraft.storagedrawers.api.storage.attribute.LockAttribute; import com.jaquadro.minecraft.storagedrawers.config.ConfigManager; import com.jaquadro.minecraft.storagedrawers.core.ModItems; @@ -34,7 +35,7 @@ import java.util.Iterator; import java.util.UUID; -public abstract class TileEntityDrawers extends TileEntity implements IDrawerGroupInteractive, ISidedInventory, IUpgradeProvider, ILockable +public abstract class TileEntityDrawers extends BaseTileEntity implements IDrawerGroupInteractive, ISidedInventory, IUpgradeProvider, ILockable, ISealable { private IDrawer[] drawers; private IDrawerInventory inventory; @@ -44,6 +45,7 @@ public abstract class TileEntityDrawers extends TileEntity implements IDrawerGro private int direction; private int drawerCapacity = 1; private boolean shrouded = false; + private boolean taped = false; private EnumSet lockAttributes = null; @@ -238,6 +240,29 @@ public void setIsShrouded (boolean shrouded) { } } + public boolean isSealed () { + if (!StorageDrawers.config.cache.enableTape) + return false; + + return taped; + } + + public boolean setIsSealed (boolean state) { + if (!StorageDrawers.config.cache.enableTape) + return false; + + if (this.taped != state) { + this.taped = state; + + if (worldObj != null && !worldObj.isRemote) { + markDirty(); + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + } + } + + return true; + } + public boolean isVoid () { if (!StorageDrawers.config.cache.enableVoidUpgrades) return false; @@ -347,24 +372,6 @@ public int interactPutItemsIntoSlot (int slot, EntityPlayer player) { return count; } - protected void trapLoadFailure (Throwable t, NBTTagCompound tag) { - failureSnapshot = (NBTTagCompound)tag.copy(); - FMLLog.log(StorageDrawers.MOD_ID, Level.ERROR, t, "Tile Load Failure."); - } - - protected void restoreLoadFailure (NBTTagCompound tag) { - Iterator iter = failureSnapshot.func_150296_c().iterator(); - while (iter.hasNext()) { - String key = iter.next(); - if (!tag.hasKey(key)) - tag.setTag(key, failureSnapshot.getTag(key).copy()); - } - } - - protected boolean loadDidFail () { - return failureSnapshot != null; - } - private void readLegacyUpgradeNBT (NBTTagCompound tag) { if (tag.hasKey("Lev") && tag.getByte("Lev") > 1) addUpgrade(new ItemStack(ModItems.upgrade, 1, tag.getByte("Lev"))); @@ -375,105 +382,107 @@ private void readLegacyUpgradeNBT (NBTTagCompound tag) { } @Override - public void readFromNBT (NBTTagCompound tag) { - super.readFromNBT(tag); + protected void readFromFixedNBT (NBTTagCompound tag) { + super.readFromFixedNBT(tag); - failureSnapshot = null; + setDirection(tag.getByte("Dir")); - try { - upgrades = new ItemStack[upgrades.length]; + taped = false; + if (tag.hasKey("Tape")) + taped = tag.getBoolean("Tape"); - setDirection(tag.getByte("Dir")); - drawerCapacity = tag.getInteger("Cap"); + customName = null; + if (tag.hasKey("CustomName", Constants.NBT.TAG_STRING)) + customName = tag.getString("CustomName"); + } - if (!tag.hasKey("Upgrades")) { - readLegacyUpgradeNBT(tag); - } - else { - NBTTagList upgradeList = tag.getTagList("Upgrades", Constants.NBT.TAG_COMPOUND); - for (int i = 0; i < upgradeList.tagCount(); i++) { - NBTTagCompound upgradeTag = upgradeList.getCompoundTagAt(i); + @Override + protected void writeToFixedNBT (NBTTagCompound tag) { + super.writeToFixedNBT(tag); - int slot = upgradeTag.getByte("Slot"); - setUpgrade(slot, ItemStack.loadItemStackFromNBT(upgradeTag)); - } - } + tag.setByte("Dir", (byte) direction); - lockAttributes = null; - if (tag.hasKey("Lock")) - lockAttributes = LockAttribute.getEnumSet(tag.getByte("Lock")); + if (taped) + tag.setBoolean("Tape", taped); - shrouded = false; - if (tag.hasKey("Shr")) - shrouded = tag.getBoolean("Shr"); + if (hasCustomInventoryName()) + tag.setString("CustomName", customName); + } - NBTTagList slots = tag.getTagList("Slots", Constants.NBT.TAG_COMPOUND); - int drawerCount = slots.tagCount(); - drawers = new IDrawer[slots.tagCount()]; + @Override + public void readFromPortableNBT (NBTTagCompound tag) { + super.readFromPortableNBT(tag); - for (int i = 0, n = drawers.length; i < n; i++) { - NBTTagCompound slot = slots.getCompoundTagAt(i); - drawers[i] = createDrawer(i); - drawers[i].readFromNBT(slot); - } + upgrades = new ItemStack[upgrades.length]; - inventory = new StorageInventory(this, getSideManager(), this); + drawerCapacity = tag.getInteger("Cap"); - if (tag.hasKey("CustomName", Constants.NBT.TAG_STRING)) - customName = tag.getString("CustomName"); + if (!tag.hasKey("Upgrades")) { + readLegacyUpgradeNBT(tag); } - catch (Throwable t) { - trapLoadFailure(t, tag); + else { + NBTTagList upgradeList = tag.getTagList("Upgrades", Constants.NBT.TAG_COMPOUND); + for (int i = 0; i < upgradeList.tagCount(); i++) { + NBTTagCompound upgradeTag = upgradeList.getCompoundTagAt(i); + + int slot = upgradeTag.getByte("Slot"); + setUpgrade(slot, ItemStack.loadItemStackFromNBT(upgradeTag)); + } } - } - @Override - public void writeToNBT (NBTTagCompound tag) { - super.writeToNBT(tag); + lockAttributes = null; + if (tag.hasKey("Lock")) + lockAttributes = LockAttribute.getEnumSet(tag.getByte("Lock")); - if (failureSnapshot != null) { - restoreLoadFailure(tag); - return; - } + shrouded = false; + if (tag.hasKey("Shr")) + shrouded = tag.getBoolean("Shr"); - try { - tag.setByte("Dir", (byte) direction); - tag.setInteger("Cap", drawerCapacity); + NBTTagList slots = tag.getTagList("Slots", Constants.NBT.TAG_COMPOUND); + drawers = new IDrawer[slots.tagCount()]; - NBTTagList upgradeList = new NBTTagList(); - for (int i = 0; i < upgrades.length; i++) { - if (upgrades[i] != null) { - NBTTagCompound upgradeTag = upgrades[i].writeToNBT(new NBTTagCompound()); - upgradeTag.setByte("Slot", (byte)i); + for (int i = 0, n = drawers.length; i < n; i++) { + NBTTagCompound slot = slots.getCompoundTagAt(i); + drawers[i] = createDrawer(i); + drawers[i].readFromNBT(slot); + } - upgradeList.appendTag(upgradeTag); - } - } + inventory = new StorageInventory(this, getSideManager(), this); + } - if (upgradeList.tagCount() > 0) - tag.setTag("Upgrades", upgradeList); + @Override + public void writeToPortableNBT (NBTTagCompound tag) { + super.writeToPortableNBT(tag); - if (lockAttributes != null) - tag.setByte("Lock", (byte)LockAttribute.getBitfield(lockAttributes)); + tag.setInteger("Cap", drawerCapacity); - if (shrouded) - tag.setBoolean("Shr", shrouded); + NBTTagList upgradeList = new NBTTagList(); + for (int i = 0; i < upgrades.length; i++) { + if (upgrades[i] != null) { + NBTTagCompound upgradeTag = upgrades[i].writeToNBT(new NBTTagCompound()); + upgradeTag.setByte("Slot", (byte)i); - NBTTagList slots = new NBTTagList(); - for (IDrawer drawer : drawers) { - NBTTagCompound slot = new NBTTagCompound(); - drawer.writeToNBT(slot); - slots.appendTag(slot); + upgradeList.appendTag(upgradeTag); } + } - tag.setTag("Slots", slots); + if (upgradeList.tagCount() > 0) + tag.setTag("Upgrades", upgradeList); - if (hasCustomInventoryName()) - tag.setString("CustomName", customName); - } - catch (Throwable t) { - FMLLog.log(StorageDrawers.MOD_ID, Level.ERROR, t, "Tile Save Failure."); + if (lockAttributes != null) + tag.setByte("Lock", (byte) LockAttribute.getBitfield(lockAttributes)); + + if (shrouded) + tag.setBoolean("Shr", shrouded); + + NBTTagList slots = new NBTTagList(); + for (IDrawer drawer : drawers) { + NBTTagCompound slot = new NBTTagCompound(); + drawer.writeToNBT(slot); + slots.appendTag(slot); } + + tag.setTag("Slots", slots); } @Override @@ -547,6 +556,9 @@ public IDrawerInventory getDrawerInventory () { @Override public boolean isDrawerEnabled (int slot) { + if (isSealed()) + return false; + return getDrawer(slot) != null; } @@ -557,6 +569,9 @@ public int[] getAccessibleSlotsFromSide (int side) { @Override public boolean canInsertItem (int slot, ItemStack stack, int side) { + if (isSealed()) + return false; + if (isLocked(LockAttribute.LOCK_EMPTY) && inventory instanceof StorageInventory) { IDrawer drawer = getDrawer(inventory.getDrawerSlot(slot)); if (drawer != null && drawer.isEmpty()) @@ -568,6 +583,9 @@ public boolean canInsertItem (int slot, ItemStack stack, int side) { @Override public boolean canExtractItem (int slot, ItemStack stack, int side) { + if (isSealed()) + return false; + return inventory.canExtractItem(slot, stack, side); } diff --git a/src/com/jaquadro/minecraft/storagedrawers/block/tile/TileEntityDrawersComp.java b/src/com/jaquadro/minecraft/storagedrawers/block/tile/TileEntityDrawersComp.java index 8b4c12b22..d57eaf586 100644 --- a/src/com/jaquadro/minecraft/storagedrawers/block/tile/TileEntityDrawersComp.java +++ b/src/com/jaquadro/minecraft/storagedrawers/block/tile/TileEntityDrawersComp.java @@ -99,7 +99,7 @@ public int putItemsIntoSlot (int slot, ItemStack stack, int count) { } @Override - public void readFromNBT (NBTTagCompound tag) { + public void readFromPortableNBT (NBTTagCompound tag) { pooledCount = 0; for (int i = 0; i < getDrawerCount(); i++) { @@ -107,40 +107,32 @@ public void readFromNBT (NBTTagCompound tag) { convRate[i] = 0; } - super.readFromNBT(tag); + super.readFromPortableNBT(tag); - try { - pooledCount = tag.getInteger("Count"); + pooledCount = tag.getInteger("Count"); - if (tag.hasKey("Conv0")) - convRate[0] = tag.getByte("Conv0"); - if (tag.hasKey("Conv1")) - convRate[1] = tag.getByte("Conv1"); - if (tag.hasKey("Conv2")) - convRate[2] = tag.getByte("Conv2"); + if (tag.hasKey("Conv0")) + convRate[0] = tag.getByte("Conv0"); + if (tag.hasKey("Conv1")) + convRate[1] = tag.getByte("Conv1"); + if (tag.hasKey("Conv2")) + convRate[2] = tag.getByte("Conv2"); - for (int i = 0; i < getDrawerCount(); i++) { - IDrawer drawer = getDrawer(i); - if (drawer instanceof CompDrawerData) - ((CompDrawerData) drawer).refresh(); - } - - if (worldObj != null && !worldObj.isRemote) { - //TileEntityDrawersComp.this.markDirty(); - worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); - } + for (int i = 0; i < getDrawerCount(); i++) { + IDrawer drawer = getDrawer(i); + if (drawer instanceof CompDrawerData) + ((CompDrawerData) drawer).refresh(); } - catch (Throwable t) { - trapLoadFailure(t, tag); + + if (worldObj != null && !worldObj.isRemote) { + //TileEntityDrawersComp.this.markDirty(); + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); } } @Override - public void writeToNBT (NBTTagCompound tag) { - super.writeToNBT(tag); - - if (loadDidFail()) - return; + public void writeToPortableNBT (NBTTagCompound tag) { + super.writeToPortableNBT(tag); tag.setInteger("Count", pooledCount); diff --git a/src/com/jaquadro/minecraft/storagedrawers/client/renderer/DrawersItemRenderer.java b/src/com/jaquadro/minecraft/storagedrawers/client/renderer/DrawersItemRenderer.java new file mode 100644 index 000000000..adb417263 --- /dev/null +++ b/src/com/jaquadro/minecraft/storagedrawers/client/renderer/DrawersItemRenderer.java @@ -0,0 +1,151 @@ +package com.jaquadro.minecraft.storagedrawers.client.renderer; + +import com.jaquadro.minecraft.storagedrawers.block.BlockDrawers; +import com.jaquadro.minecraft.storagedrawers.util.RenderHelper; +import net.minecraft.block.Block; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.item.ItemStack; +import net.minecraftforge.client.IItemRenderer; +import net.minecraftforge.common.util.ForgeDirection; +import org.lwjgl.opengl.GL11; + +public class DrawersItemRenderer implements IItemRenderer +{ + private RenderHelper renderHelper = new RenderHelper(); + private ModularBoxRenderer boxRenderer = new ModularBoxRenderer(); + private float[] colorScratch = new float[3]; + + @Override + public boolean handleRenderType (ItemStack item, ItemRenderType type) { + return true; + } + + @Override + public boolean shouldUseRenderHelper (ItemRenderType type, ItemStack item, ItemRendererHelper helper) { + return true; + } + + @Override + public void renderItem (ItemRenderType type, ItemStack item, Object... data) { + RenderBlocks renderer = getRenderer(data); + if (renderer == null) + return; + + Block block = Block.getBlockFromItem(item.getItem()); + if (!(block instanceof BlockDrawers)) + return; + + renderDrawer((BlockDrawers) block, item, renderer, type); + } + + private void renderDrawer (BlockDrawers block, ItemStack item, RenderBlocks renderer, ItemRenderType renderType) { + int side = 4; + boxRenderer.setUnit(.0625); + boxRenderer.setColor(ModularBoxRenderer.COLOR_WHITE); + for (int i = 0; i < 6; i++) + boxRenderer.setIcon(block.getIcon(i, item.getItemDamage()), i); + + if (renderType == ItemRenderType.INVENTORY) { + GL11.glRotatef(90, 0, 1, 0); + GL11.glTranslatef(-.5f, -.5f, -.5f); + } + + switch (side - 2) { + case 0: + renderer.uvRotateTop = 3; + break; + case 1: + renderer.uvRotateTop = 0; + break; + case 2: + renderer.uvRotateTop = 1; + break; + case 3: + renderer.uvRotateTop = 2; + break; + } + + renderExterior(block, 0, 0, 0,side, renderer); + + renderer.uvRotateTop = 0; + + boxRenderer.setUnit(0); + boxRenderer.setInteriorIcon(block.getIcon(side, item.getItemDamage()), ForgeDirection.OPPOSITES[side]); + + renderInterior(block, 0, 0, 0, side, renderer); + + boxRenderer.setExteriorIcon(block.getTapeIcon(), side); + + if (item.hasTagCompound() && item.getTagCompound().hasKey("tile")) { + double depth = block.halfDepth ? .5 : 1; + RenderHelper.instance.setRenderBounds(1 - depth - .005, 0, 0, 1, 1, 1); + RenderHelper.instance.renderFace(side, null, block, block.getTapeIcon(), 1, 1, 1); + } + + if (renderType == ItemRenderType.INVENTORY) { + GL11.glTranslatef(.5f, .5f, .5f); + } + } + + private void renderExterior (BlockDrawers block, int x, int y, int z, int side, RenderBlocks renderer) { + double depth = block.halfDepth ? .5 : 1; + double xMin = 0, xMax = 0, zMin = 0, zMax = 0; + + switch (side) { + case 2: + xMin = 0; xMax = 1; + zMin = 1 - depth; zMax = 1; + break; + case 3: + xMin = 0; xMax = 1; + zMin = 0; zMax = depth; + break; + case 4: + xMin = 1 - depth; xMax = 1; + zMin = 0; zMax = 1; + break; + case 5: + xMin = 0; xMax = depth; + zMin = 0; zMax = 1; + break; + } + + boxRenderer.renderExterior(renderer, block, x, y, z, xMin, 0, zMin, xMax, 1, zMax, 0, ModularBoxRenderer.sideCut[side]); + } + + private void renderInterior (BlockDrawers block, int x, int y, int z, int side, RenderBlocks renderer) { + double unit = block.trimDepth; + double depth = block.halfDepth ? .5 : 1; + double xMin = 0, xMax = 0, zMin = 0, zMax = 0; + + switch (side) { + case 2: + xMin = unit; xMax = 1 - unit; + zMin = 1 - depth; zMax = 1 - depth + unit; + break; + case 3: + xMin = unit; xMax = 1 - unit; + zMin = depth - unit; zMax = depth; + break; + case 4: + xMin = 1 - depth; xMax = 1 - depth + unit; + zMin = unit; zMax = 1 - unit; + break; + case 5: + xMin = depth - unit; xMax = depth; + zMin = unit; zMax = 1 - unit; + break; + } + + boxRenderer.renderInterior(renderer, block, x, y, z, xMin, unit, zMin, xMax, 1 - unit, zMax, 0, ModularBoxRenderer.sideCut[side]); + } + + private RenderBlocks getRenderer (Object[] data) { + for (Object obj : data) { + if (obj instanceof RenderBlocks) + return (RenderBlocks)obj; + } + + return null; + } +} diff --git a/src/com/jaquadro/minecraft/storagedrawers/client/renderer/DrawersRenderer.java b/src/com/jaquadro/minecraft/storagedrawers/client/renderer/DrawersRenderer.java index a426312ba..bbcb90ceb 100644 --- a/src/com/jaquadro/minecraft/storagedrawers/client/renderer/DrawersRenderer.java +++ b/src/com/jaquadro/minecraft/storagedrawers/client/renderer/DrawersRenderer.java @@ -10,6 +10,7 @@ import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; import net.minecraft.block.Block; import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.client.renderer.RenderGlobal; import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; import net.minecraftforge.common.util.ForgeDirection; @@ -19,6 +20,7 @@ public class DrawersRenderer implements ISimpleBlockRenderingHandler { private static final double unit = .0625f; + private RenderHelper renderHelper = new RenderHelper(); private ModularBoxRenderer boxRenderer = new ModularBoxRenderer(); private double[] boxCoord = new double[6]; @@ -128,12 +130,18 @@ private boolean renderWorldBlock (IBlockAccess world, int x, int y, int z, Block renderInterior(block, x, y, z, side, renderer); + if (renderer.overrideBlockTexture != null && renderer.overrideBlockTexture.getIconName().startsWith("destroy_stage")) + return true; + if (StorageDrawers.config.cache.enableIndicatorUpgrades) renderIndicator(block, x, y, z, side, renderer, tile.getEffectiveStatusLevel()); if (StorageDrawers.config.cache.enableLockUpgrades) renderLock(block, x, y, z, side, renderer, tile.isLocked(LockAttribute.LOCK_POPULATED)); if (StorageDrawers.config.cache.enableVoidUpgrades) renderVoid(block, x, y, z, side, renderer, tile.isVoid()); + if (StorageDrawers.config.cache.enableTape) + renderTape(block, x, y, z, side, renderer, tile.isSealed()); + renderShroud(block, x, y, z, side, renderer, tile.isShrouded()); return true; @@ -165,6 +173,19 @@ private void renderVoid (BlockDrawers block, int x, int y, int z, int side, Rend RenderHelper.instance.state.clearRotateTransform(); } + private void renderTape (BlockDrawers block, int x, int y, int z, int side, RenderBlocks renderer, boolean taped) { + if (!taped) + return; + + double depth = block.halfDepth ? .5 : 1; + IIcon iconTape = block.getTapeIcon(); + + RenderHelper.instance.setRenderBounds(0, 0, 0, 1, 1, depth + .005); + RenderHelper.instance.state.setRotateTransform(RenderHelper.ZPOS, side); + RenderHelper.instance.renderFace(RenderHelper.ZPOS, renderer.blockAccess, block, x, y, z, iconTape); + RenderHelper.instance.state.clearRotateTransform(); + } + private static final int[] cut = new int[] { ModularBoxRenderer.CUT_YPOS | ModularBoxRenderer.CUT_YNEG | ModularBoxRenderer.CUT_XPOS | ModularBoxRenderer.CUT_XNEG | ModularBoxRenderer.CUT_ZPOS, ModularBoxRenderer.CUT_YPOS | ModularBoxRenderer.CUT_YNEG | ModularBoxRenderer.CUT_XPOS | ModularBoxRenderer.CUT_XNEG | ModularBoxRenderer.CUT_ZNEG, diff --git a/src/com/jaquadro/minecraft/storagedrawers/client/renderer/TileEntityDrawersRenderer.java b/src/com/jaquadro/minecraft/storagedrawers/client/renderer/TileEntityDrawersRenderer.java index 1c393a793..9ac0a4b57 100644 --- a/src/com/jaquadro/minecraft/storagedrawers/client/renderer/TileEntityDrawersRenderer.java +++ b/src/com/jaquadro/minecraft/storagedrawers/client/renderer/TileEntityDrawersRenderer.java @@ -3,8 +3,10 @@ import com.jaquadro.minecraft.storagedrawers.StorageDrawers; import com.jaquadro.minecraft.storagedrawers.api.render.IRenderLabel; import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawer; +import com.jaquadro.minecraft.storagedrawers.api.storage.attribute.ISealable; import com.jaquadro.minecraft.storagedrawers.block.BlockDrawers; import com.jaquadro.minecraft.storagedrawers.block.tile.TileEntityDrawers; +import com.jaquadro.minecraft.storagedrawers.util.*; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.block.Block; @@ -12,6 +14,7 @@ import net.minecraft.client.entity.EntityClientPlayerMP; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.renderer.*; +import net.minecraft.client.renderer.RenderHelper; import net.minecraft.client.renderer.entity.RenderItem; import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.client.renderer.texture.TextureManager; @@ -255,7 +258,7 @@ public void renderTileEntityAt (TileEntity tile, double x, double y, double z, f if (tileDrawers == null) return; - if (tileDrawers.isShrouded()) + if (tileDrawers.isShrouded() || tileDrawers.isSealed()) return; // Don't bother rendering anything that is (probably) facing away from the player. diff --git a/src/com/jaquadro/minecraft/storagedrawers/config/ConfigManager.java b/src/com/jaquadro/minecraft/storagedrawers/config/ConfigManager.java index 15426ae8e..8a503d434 100644 --- a/src/com/jaquadro/minecraft/storagedrawers/config/ConfigManager.java +++ b/src/com/jaquadro/minecraft/storagedrawers/config/ConfigManager.java @@ -72,6 +72,7 @@ public class ConfigCache { public boolean enableThaumcraftIntegration; public boolean enableMineTweakerIntegration; public boolean enableRefinedRelocationIntegration; + public boolean enableTape; public boolean invertShift; public boolean debugTrace; @@ -223,6 +224,7 @@ public void syncConfig () { cache.enableVoidUpgrades = config.get(Configuration.CATEGORY_GENERAL, "enableVoidUpgrades", true).setLanguageKey(LANG_PREFIX + "prop.enableVoidUpgrades").setRequiresMcRestart(true).getBoolean(); cache.enableShroudUpgrades = config.get(Configuration.CATEGORY_GENERAL, "enableShroudUpgrades", true).setLanguageKey(LANG_PREFIX + "prop.enableShroudUpgrades").setRequiresMcRestart(true).getBoolean(); cache.enableSortingUpgrades = config.get(Configuration.CATEGORY_GENERAL, "enableSortingUpgrades", true).setLanguageKey(LANG_PREFIX + "prop.enableSortingUpgrades").setRequiresMcRestart(true).getBoolean(); + cache.enableTape = config.get(Configuration.CATEGORY_GENERAL, "enableTape", true).setLanguageKey(LANG_PREFIX + "prop.enableTape").setRequiresMcRestart(true).getBoolean(); cache.itemRenderType = config.get(Configuration.CATEGORY_GENERAL, "itemRenderType", "fast", null, new String[]{"fancy", "fast"}).setLanguageKey(LANG_PREFIX + "prop.itemRenderType").getString(); cache.renderStorageUpgrades = config.get(Configuration.CATEGORY_GENERAL, "renderStorageUpgrades", true).setLanguageKey(LANG_PREFIX + "prop.renderStorageUpgrades").getBoolean(); cache.creativeTabVanillaWoods = config.get(Configuration.CATEGORY_GENERAL, "creativeTabVanillaWoods", true).setLanguageKey(LANG_PREFIX + "prop.creativeTabVanillaWoods").getBoolean(); diff --git a/src/com/jaquadro/minecraft/storagedrawers/core/ClientProxy.java b/src/com/jaquadro/minecraft/storagedrawers/core/ClientProxy.java index 0c463fdfc..bff077db9 100644 --- a/src/com/jaquadro/minecraft/storagedrawers/core/ClientProxy.java +++ b/src/com/jaquadro/minecraft/storagedrawers/core/ClientProxy.java @@ -3,13 +3,19 @@ import com.jaquadro.minecraft.storagedrawers.block.tile.TileEntityDrawersComp; import com.jaquadro.minecraft.storagedrawers.block.tile.TileEntityDrawersStandard; import com.jaquadro.minecraft.storagedrawers.client.renderer.ControllerRenderer; +import com.jaquadro.minecraft.storagedrawers.client.renderer.DrawersItemRenderer; import com.jaquadro.minecraft.storagedrawers.client.renderer.DrawersRenderer; import com.jaquadro.minecraft.storagedrawers.client.renderer.TileEntityDrawersRenderer; import cpw.mods.fml.client.registry.ClientRegistry; import cpw.mods.fml.client.registry.RenderingRegistry; +import net.minecraft.block.Block; +import net.minecraft.item.Item; +import net.minecraftforge.client.MinecraftForgeClient; public class ClientProxy extends CommonProxy { + private DrawersItemRenderer itemRenderer = new DrawersItemRenderer(); + @Override public void registerRenderers () { drawersRenderID = RenderingRegistry.getNextAvailableRenderId(); @@ -21,4 +27,9 @@ public void registerRenderers () { ClientRegistry.bindTileEntitySpecialRenderer(TileEntityDrawersStandard.class, new TileEntityDrawersRenderer()); ClientRegistry.bindTileEntitySpecialRenderer(TileEntityDrawersComp.class, new TileEntityDrawersRenderer()); } + + @Override + public void registerDrawer (Block block) { + MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(block), itemRenderer); + } } diff --git a/src/com/jaquadro/minecraft/storagedrawers/core/CommonProxy.java b/src/com/jaquadro/minecraft/storagedrawers/core/CommonProxy.java index ed194a9ee..b66de2884 100644 --- a/src/com/jaquadro/minecraft/storagedrawers/core/CommonProxy.java +++ b/src/com/jaquadro/minecraft/storagedrawers/core/CommonProxy.java @@ -1,5 +1,6 @@ package com.jaquadro.minecraft.storagedrawers.core; +import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; @@ -15,4 +16,6 @@ public void updatePlayerInventory (EntityPlayer player) { if (player instanceof EntityPlayerMP) ((EntityPlayerMP) player).sendContainerToPlayer(player.inventoryContainer); } + + public void registerDrawer (Block block) { } } diff --git a/src/com/jaquadro/minecraft/storagedrawers/core/ModBlocks.java b/src/com/jaquadro/minecraft/storagedrawers/core/ModBlocks.java index 6b42b5274..6c3e65c23 100644 --- a/src/com/jaquadro/minecraft/storagedrawers/core/ModBlocks.java +++ b/src/com/jaquadro/minecraft/storagedrawers/core/ModBlocks.java @@ -74,6 +74,13 @@ public void init () { GameRegistry.registerTileEntityWithAlternatives(TileEntitySlave.class, getQualifiedName("tileControllerSlave"), getQualifiedName(controllerSlave)); + StorageDrawers.proxy.registerDrawer(fullDrawers1); + StorageDrawers.proxy.registerDrawer(fullDrawers2); + StorageDrawers.proxy.registerDrawer(fullDrawers4); + StorageDrawers.proxy.registerDrawer(halfDrawers2); + StorageDrawers.proxy.registerDrawer(halfDrawers4); + StorageDrawers.proxy.registerDrawer(compDrawers); + for (String key : new String[] { "drawerBasic" }) OreDictionary.registerOre(key, new ItemStack(fullDrawers1, 1, OreDictionary.WILDCARD_VALUE)); for (String key : new String[] { "drawerBasic" }) diff --git a/src/com/jaquadro/minecraft/storagedrawers/core/ModItems.java b/src/com/jaquadro/minecraft/storagedrawers/core/ModItems.java index 7ee2abc14..3611241c7 100644 --- a/src/com/jaquadro/minecraft/storagedrawers/core/ModItems.java +++ b/src/com/jaquadro/minecraft/storagedrawers/core/ModItems.java @@ -13,14 +13,16 @@ public class ModItems public static ItemUpgradeLock upgradeLock; public static ItemUpgradeVoid upgradeVoid; public static ItemShroudKey shroudKey; + public static ItemTape tape; public void init () { - upgradeTemplate = new Item().setUnlocalizedName("upgradeTemplate").setTextureName(StorageDrawers.MOD_ID + ":upgrade_template").setCreativeTab(ModCreativeTabs.tabStorageDrawers); - upgrade = new ItemUpgrade("upgrade"); - upgradeStatus = new ItemUpgradeStatus("upgradeStatus"); - upgradeLock = new ItemUpgradeLock("upgradeLock"); - upgradeVoid = new ItemUpgradeVoid("upgradeVoid"); - shroudKey = new ItemShroudKey("shroudKey"); + upgradeTemplate = new Item().setUnlocalizedName(makeName("upgradeTemplate")).setTextureName(StorageDrawers.MOD_ID + ":upgrade_template").setCreativeTab(ModCreativeTabs.tabStorageDrawers); + upgrade = new ItemUpgrade(makeName("upgrade")); + upgradeStatus = new ItemUpgradeStatus(makeName("upgradeStatus")); + upgradeLock = new ItemUpgradeLock(makeName("upgradeLock")); + upgradeVoid = new ItemUpgradeVoid(makeName("upgradeVoid")); + shroudKey = new ItemShroudKey(makeName("shroudKey")); + tape = new ItemTape(makeName("tape")); GameRegistry.registerItem(upgradeTemplate, "upgradeTemplate"); @@ -34,5 +36,11 @@ public void init () { GameRegistry.registerItem(upgradeLock, "upgradeLock"); if (StorageDrawers.config.cache.enableShroudUpgrades) GameRegistry.registerItem(shroudKey, "shroudKey"); + if (StorageDrawers.config.cache.enableTape) + GameRegistry.registerItem(tape, "tape"); + } + + public static String makeName (String name) { + return StorageDrawers.MOD_ID.toLowerCase() + "." + name; } } diff --git a/src/com/jaquadro/minecraft/storagedrawers/core/ModRecipes.java b/src/com/jaquadro/minecraft/storagedrawers/core/ModRecipes.java index 1124113a4..8fad10588 100644 --- a/src/com/jaquadro/minecraft/storagedrawers/core/ModRecipes.java +++ b/src/com/jaquadro/minecraft/storagedrawers/core/ModRecipes.java @@ -109,5 +109,10 @@ public void init () { if (config.cache.enableShroudUpgrades) { GameRegistry.addShapelessRecipe(new ItemStack(ModItems.shroudKey), ModItems.upgradeLock, Items.ender_eye); } + + if (config.cache.enableTape) { + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ModItems.tape), " x ", "yyy", + 'x', "slimeball", 'y', Items.paper)); + } } } diff --git a/src/com/jaquadro/minecraft/storagedrawers/core/api/PackFactory.java b/src/com/jaquadro/minecraft/storagedrawers/core/api/PackFactory.java index da00a13a1..921fffa6c 100644 --- a/src/com/jaquadro/minecraft/storagedrawers/core/api/PackFactory.java +++ b/src/com/jaquadro/minecraft/storagedrawers/core/api/PackFactory.java @@ -1,5 +1,6 @@ package com.jaquadro.minecraft.storagedrawers.core.api; +import com.jaquadro.minecraft.storagedrawers.StorageDrawers; import com.jaquadro.minecraft.storagedrawers.api.pack.BlockConfiguration; import com.jaquadro.minecraft.storagedrawers.api.pack.IPackBlockFactory; import com.jaquadro.minecraft.storagedrawers.api.pack.IPackDataResolver; @@ -40,9 +41,12 @@ public void registerBlock (Block block, String name) { if (block instanceof BlockDrawersPack) { GameRegistry.registerBlock(block, ItemDrawersPack.class, name); OreDictionary.registerOre("drawerBasic", new ItemStack(block, 1, OreDictionary.WILDCARD_VALUE)); + StorageDrawers.proxy.registerDrawer(block); } - else if (block instanceof BlockSortingDrawersPack) + else if (block instanceof BlockSortingDrawersPack) { GameRegistry.registerBlock(block, ItemSortingDrawersPack.class, name); + StorageDrawers.proxy.registerDrawer(block); + } else if (block instanceof BlockTrimPack) GameRegistry.registerBlock(block, ItemTrimPack.class, name); } diff --git a/src/com/jaquadro/minecraft/storagedrawers/integration/RefinedRelocation.java b/src/com/jaquadro/minecraft/storagedrawers/integration/RefinedRelocation.java index f7a942878..a76691d8f 100644 --- a/src/com/jaquadro/minecraft/storagedrawers/integration/RefinedRelocation.java +++ b/src/com/jaquadro/minecraft/storagedrawers/integration/RefinedRelocation.java @@ -81,6 +81,13 @@ public void init () throws Throwable { if (config.cache.enableSortingUpgrades) GameRegistry.registerItem(upgradeSorting, "upgradeSorting"); + StorageDrawers.proxy.registerDrawer(fullDrawers1); + StorageDrawers.proxy.registerDrawer(fullDrawers2); + StorageDrawers.proxy.registerDrawer(fullDrawers4); + StorageDrawers.proxy.registerDrawer(halfDrawers2); + StorageDrawers.proxy.registerDrawer(halfDrawers4); + StorageDrawers.proxy.registerDrawer(compDrawers); + GameRegistry.registerTileEntityWithAlternatives(TileSortingDrawersStandard.class, ModBlocks.getQualifiedName("tileSortingDrawersStandard"), ModBlocks.getQualifiedName(fullDrawers1), ModBlocks.getQualifiedName(fullDrawers2), ModBlocks.getQualifiedName(fullDrawers4), ModBlocks.getQualifiedName(halfDrawers2), ModBlocks.getQualifiedName(halfDrawers4)); diff --git a/src/com/jaquadro/minecraft/storagedrawers/item/ItemCompDrawers.java b/src/com/jaquadro/minecraft/storagedrawers/item/ItemCompDrawers.java index ca19b43c7..28c696c92 100644 --- a/src/com/jaquadro/minecraft/storagedrawers/item/ItemCompDrawers.java +++ b/src/com/jaquadro/minecraft/storagedrawers/item/ItemCompDrawers.java @@ -9,6 +9,8 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.StatCollector; import net.minecraft.world.World; @@ -27,11 +29,16 @@ public boolean placeBlockAt (ItemStack stack, EntityPlayer player, World world, TileEntityDrawers tile = (TileEntityDrawers) world.getTileEntity(x, y, z); if (tile != null) { + int initCapacity = StorageDrawers.config.getBlockBaseStorage("compdrawers"); + tile.setDrawerCapacity(initCapacity); + + if (stack.hasTagCompound() && stack.getTagCompound().hasKey("tile")) + tile.readFromPortableNBT(stack.getTagCompound().getCompoundTag("tile")); + if (side > 1) tile.setDirection(side); - int initCapacity = StorageDrawers.config.getBlockBaseStorage("compdrawers"); - tile.setDrawerCapacity(initCapacity); + tile.setIsSealed(false); } return true; @@ -44,5 +51,9 @@ public void addInformation (ItemStack itemStack, EntityPlayer player, List list, int count = config.getBlockBaseStorage("compdrawers"); list.add(StatCollector.translateToLocalFormatted("storageDrawers.drawers.description", count)); + + if (itemStack.hasTagCompound() && itemStack.getTagCompound().hasKey("tile")) { + list.add(EnumChatFormatting.YELLOW + StatCollector.translateToLocalFormatted("storageDrawers.drawers.sealed")); + } } } diff --git a/src/com/jaquadro/minecraft/storagedrawers/item/ItemDrawers.java b/src/com/jaquadro/minecraft/storagedrawers/item/ItemDrawers.java index 2b270918c..da56da9c3 100644 --- a/src/com/jaquadro/minecraft/storagedrawers/item/ItemDrawers.java +++ b/src/com/jaquadro/minecraft/storagedrawers/item/ItemDrawers.java @@ -13,8 +13,12 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemMultiTexture; import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.StatCollector; import net.minecraft.world.World; +import net.minecraftforge.common.util.Constants; import java.util.List; @@ -35,14 +39,19 @@ public boolean placeBlockAt (ItemStack stack, EntityPlayer player, World world, TileEntityDrawers tile = (TileEntityDrawers) world.getTileEntity(x, y, z); if (tile != null) { - if (side > 1) - tile.setDirection(side); - BlockDrawers block = (BlockDrawers) field_150939_a; if (tile instanceof TileEntityDrawersStandard) ((TileEntityDrawersStandard)tile).setDrawerCount(block.drawerCount); tile.setDrawerCapacity(getCapacityForBlock(block)); + + if (stack.hasTagCompound() && stack.getTagCompound().hasKey("tile")) + tile.readFromPortableNBT(stack.getTagCompound().getCompoundTag("tile")); + + if (side > 1) + tile.setDirection(side); + + tile.setIsSealed(false); } return true; @@ -53,6 +62,10 @@ public boolean placeBlockAt (ItemStack stack, EntityPlayer player, World world, public void addInformation (ItemStack itemStack, EntityPlayer player, List list, boolean par4) { Block block = Block.getBlockFromItem(itemStack.getItem()); list.add(StatCollector.translateToLocalFormatted("storageDrawers.drawers.description", getCapacityForBlock(block))); + + if (itemStack.hasTagCompound() && itemStack.getTagCompound().hasKey("tile")) { + list.add(EnumChatFormatting.YELLOW + StatCollector.translateToLocalFormatted("storageDrawers.drawers.sealed")); + } } protected int getCapacityForBlock (Block block) { diff --git a/src/com/jaquadro/minecraft/storagedrawers/item/ItemTape.java b/src/com/jaquadro/minecraft/storagedrawers/item/ItemTape.java new file mode 100644 index 000000000..1acedd1fd --- /dev/null +++ b/src/com/jaquadro/minecraft/storagedrawers/item/ItemTape.java @@ -0,0 +1,53 @@ +package com.jaquadro.minecraft.storagedrawers.item; + +import com.jaquadro.minecraft.storagedrawers.StorageDrawers; +import com.jaquadro.minecraft.storagedrawers.api.storage.attribute.ISealable; +import com.jaquadro.minecraft.storagedrawers.core.ModCreativeTabs; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.StatCollector; +import net.minecraft.world.World; + +import java.util.List; + +public class ItemTape extends Item +{ + public ItemTape (String name) { + setUnlocalizedName(name); + setMaxStackSize(1); + setMaxDamage(8); + setTextureName(StorageDrawers.MOD_ID + ":tape_roll"); + setCreativeTab(ModCreativeTabs.tabStorageDrawers); + } + + @Override + @SideOnly(Side.CLIENT) + public void addInformation (ItemStack itemStack, EntityPlayer player, List list, boolean par4) { + String name = getUnlocalizedName(itemStack); + list.add(StatCollector.translateToLocalFormatted(name + ".description")); + } + + @Override + public boolean onItemUse (ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) { + if (!player.canPlayerEdit(x, y, z, side, stack)) + return false; + + TileEntity tile = world.getTileEntity(x, y, z); + if (tile instanceof ISealable) { + ISealable tileseal = (ISealable) tile; + if (tileseal.isSealed()) + return false; + + tileseal.setIsSealed(true); + stack.damageItem(1, player); + + return true; + } + + return false; + } +}