diff --git a/IronChests2/client/cpw/mods/ironchest/client/TileEntityIronChestRenderer.java b/IronChests2/client/cpw/mods/ironchest/client/TileEntityIronChestRenderer.java index 4008ba0..7877923 100644 --- a/IronChests2/client/cpw/mods/ironchest/client/TileEntityIronChestRenderer.java +++ b/IronChests2/client/cpw/mods/ironchest/client/TileEntityIronChestRenderer.java @@ -22,6 +22,7 @@ import net.minecraft.src.TileEntitySpecialRenderer; import net.minecraft.src.forge.ForgeHooksClient; import net.minecraft.src.forge.ICustomItemRenderer; import net.minecraft.src.forge.MinecraftForgeClient; +import cpw.mods.ironchest.IronChestType; import cpw.mods.ironchest.TileEntityIronChest; public class TileEntityIronChestRenderer extends TileEntitySpecialRenderer { @@ -38,11 +39,18 @@ public class TileEntityIronChestRenderer extends TileEntitySpecialRenderer { } public void render(TileEntityIronChest tile, double x, double y, double z, float partialTick) { + if (tile==null) { + return; + } int facing = 3; + IronChestType type=tile.getType(); if (tile != null && tile.worldObj != null) { facing = tile.getFacing(); + type=tile.getType(); + int typ=tile.worldObj.getBlockMetadata(tile.xCoord,tile.yCoord,tile.zCoord); + type=IronChestType.values()[typ]; } - bindTextureByName(tile.getType().getModelTexture()); + bindTextureByName(type.getModelTexture()); glPushMatrix(); glEnable(32826 /* GL_RESCALE_NORMAL_EXT */); @@ -75,7 +83,7 @@ public class TileEntityIronChestRenderer extends TileEntitySpecialRenderer { glPopMatrix(); glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - if (tile.getType().isTransparent()) { + if (type.isTransparent()) { random.setSeed(254L); float shiftX; float shiftY; diff --git a/IronChests2/common/cpw/mods/ironchest/BlockIronChest.java b/IronChests2/common/cpw/mods/ironchest/BlockIronChest.java index 234b228..23165b0 100644 --- a/IronChests2/common/cpw/mods/ironchest/BlockIronChest.java +++ b/IronChests2/common/cpw/mods/ironchest/BlockIronChest.java @@ -17,13 +17,14 @@ import net.minecraft.src.mod_IronChest; import net.minecraft.src.forge.IMultipassRender; import net.minecraft.src.forge.ITextureProvider; -public class BlockIronChest extends BlockContainer implements ITextureProvider, IMultipassRender { +public class BlockIronChest extends BlockContainer implements ITextureProvider { private Random random; public BlockIronChest(int id) { super(id, Material.iron); setBlockName("IronChest"); setHardness(3.0F); + setRequiresSelfNotify(); random=new Random(); } @@ -56,18 +57,19 @@ public class BlockIronChest extends BlockContainer implements ITextureProvider, } public int getBlockTexture(IBlockAccess worldAccess, int i, int j, int k, int l) { + IronChestType type=IronChestType.values()[l]; TileEntity te = worldAccess.getBlockTileEntity(i, j, k); - if (te != null && te instanceof TileEntityIronChest) { - TileEntityIronChest icte=(TileEntityIronChest) te; - if (l==0 || l==1) { // Top and Bottom - return icte.getType().getTextureRow()*16+1; - } else if (l==icte.getFacing()) { // Front - return icte.getType().getTextureRow()*16+2; - } else { // Back and Sides - return icte.getType().getTextureRow()*16; - } + 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; } - return 0; } @Override @@ -181,8 +183,8 @@ public class BlockIronChest extends BlockContainer implements ITextureProvider, } } - @Override +/* @Override public boolean canRenderInPass(int n) { return n==0; - } + }*/ } \ No newline at end of file diff --git a/IronChests2/common/cpw/mods/ironchest/ItemChestChanger.java b/IronChests2/common/cpw/mods/ironchest/ItemChestChanger.java index 357c108..e0d9ffc 100644 --- a/IronChests2/common/cpw/mods/ironchest/ItemChestChanger.java +++ b/IronChests2/common/cpw/mods/ironchest/ItemChestChanger.java @@ -29,8 +29,7 @@ public class ItemChestChanger extends Item implements ITextureProvider { return false; } world.setBlockTileEntity(X, Y, Z, newchest); - world.setBlockMetadata(X, Y, Z, newchest.getType().ordinal()); - world.markBlockNeedsUpdate(X, Y, Z); + world.setBlockMetadataWithNotify(X, Y, Z, newchest.getType().ordinal()); world.notifyBlocksOfNeighborChange(X, Y, Z, world.getBlockId(X, Y, Z)); stack.stackSize=0; return true; diff --git a/IronChests2/common/cpw/mods/ironchest/TileEntityIronChest.java b/IronChests2/common/cpw/mods/ironchest/TileEntityIronChest.java index 62b7cb4..e61484d 100644 --- a/IronChests2/common/cpw/mods/ironchest/TileEntityIronChest.java +++ b/IronChests2/common/cpw/mods/ironchest/TileEntityIronChest.java @@ -299,4 +299,14 @@ public class TileEntityIronChest extends TileEntity implements IInventory { public ItemStack[] getTopItemStacks() { return topStacks; } + + public TileEntityIronChest updateFromMetadata(int l) { + if (worldObj!=null && worldObj.isRemote) { + if (l!=type.ordinal()) { + worldObj.setBlockTileEntity(xCoord, yCoord, zCoord, IronChestType.makeEntity(l)); + return (TileEntityIronChest)worldObj.getBlockTileEntity(xCoord, yCoord, zCoord); + } + } + return this; + } }