From e53f48b08f9f966af97be137eb649c55ccb7b149 Mon Sep 17 00:00:00 2001 From: Adubbz Date: Fri, 26 Sep 2014 21:42:37 +1000 Subject: [PATCH] Trying (without luck) to get the inventory models rendering --- .../cpw/mods/ironchest/BlockIronChest.java | 20 +++++++++---------- .../java/cpw/mods/ironchest/IronChest.java | 2 ++ .../cpw/mods/ironchest/IronChestType.java | 4 ++-- .../mods/ironchest/client/ClientProxy.java | 2 +- .../client/IronChestRenderHelper.java | 16 +++++++++------ .../client/TileEntityIronChestRenderer.java | 5 ++++- .../models/block/BlockIronChest.json | 6 ------ .../ironchest/models/item/BlockIronChest.json | 9 +-------- 8 files changed, 30 insertions(+), 34 deletions(-) delete mode 100755 src/main/resources/assets/ironchest/models/block/BlockIronChest.json diff --git a/src/main/java/cpw/mods/ironchest/BlockIronChest.java b/src/main/java/cpw/mods/ironchest/BlockIronChest.java index da717e2..bc543a8 100755 --- a/src/main/java/cpw/mods/ironchest/BlockIronChest.java +++ b/src/main/java/cpw/mods/ironchest/BlockIronChest.java @@ -40,13 +40,13 @@ import net.minecraftforge.fml.relauncher.SideOnly; public class BlockIronChest extends BlockContainer { - public static final PropertyEnum VARIANT_PROP = PropertyEnum.func_177709_a("variant", IronChestType.class); + public static final PropertyEnum VARIANT_PROP = PropertyEnum.create("variant", IronChestType.class); public BlockIronChest() { super(Material.iron); - this.setDefaultBlockState(this.blockState.getBaseState().setProperty(VARIANT_PROP, IronChestType.IRON)); + this.setDefaultBlockState(this.blockState.getBaseState().withProperty(VARIANT_PROP, IronChestType.IRON)); this.setBlockBounds(0.0625F, 0F, 0.0625F, 0.9375F, 0.875F, 0.9375F); this.setHardness(3.0F); @@ -66,6 +66,12 @@ public class BlockIronChest extends BlockContainer return false; } + @Override + public int getRenderType() + { + return 2; + } + @Override public boolean onBlockActivated(World world, BlockPos pos, IBlockState blockState, EntityPlayer player, EnumFacing direction, float p_180639_6_, float p_180639_7_, float p_180639_8_) { @@ -112,13 +118,13 @@ public class BlockIronChest extends BlockContainer @Override public IBlockState getBlockStateFromMeta(int meta) { - return this.getDefaultBlockState().setProperty(VARIANT_PROP, IronChestType.values()[IronChestType.validateMeta(meta)]); + return this.getDefaultBlockState().withProperty(VARIANT_PROP, IronChestType.values()[meta]); } @Override public int getMetaFromBlockState(IBlockState blockState) { - return IronChestType.validateMeta(((IronChestType)blockState.getValue(VARIANT_PROP)).ordinal()); + return ((IronChestType)blockState.getValue(VARIANT_PROP)).ordinal(); } @Override @@ -127,12 +133,6 @@ public class BlockIronChest extends BlockContainer return new BlockState(this, new IProperty[] { VARIANT_PROP }); } - /*@Override - public int getRenderType() - { - return 22; - }*/ - /*@Override public ArrayList getDrops(World world, int x, int y, int z, int metadata, int fortune) { diff --git a/src/main/java/cpw/mods/ironchest/IronChest.java b/src/main/java/cpw/mods/ironchest/IronChest.java index 958ba47..83bc6ea 100755 --- a/src/main/java/cpw/mods/ironchest/IronChest.java +++ b/src/main/java/cpw/mods/ironchest/IronChest.java @@ -58,6 +58,8 @@ public class IronChest ChestChangerType.buildItems(); ironChestBlock = new BlockIronChest(); GameRegistry.registerBlock(ironChestBlock, ItemIronChest.class, "BlockIronChest"); + Minecraft.getMinecraft().getRenderItem().getItemModelMesher().getModelManager().getBlockModelShapes().func_178123_a(ironChestBlock); + ModelHelper.loadInventoryModel(ironChestBlock, "ironchest:BlockIronChest"); for (IronChestType typ : IronChestType.values()) { diff --git a/src/main/java/cpw/mods/ironchest/IronChestType.java b/src/main/java/cpw/mods/ironchest/IronChestType.java index 09694a5..9849323 100755 --- a/src/main/java/cpw/mods/ironchest/IronChestType.java +++ b/src/main/java/cpw/mods/ironchest/IronChestType.java @@ -67,7 +67,7 @@ public enum IronChestType implements IStringSerializable } @Override - public String getID() + public String getName() { return name().toLowerCase(); } @@ -182,7 +182,7 @@ public enum IronChestType implements IStringSerializable public static int validateMeta(int i) { - if (i < values().length && values()[i] != IronChestType.WOOD) + if (i < values().length && values()[i].size > 0) { return i; } diff --git a/src/main/java/cpw/mods/ironchest/client/ClientProxy.java b/src/main/java/cpw/mods/ironchest/client/ClientProxy.java index a56853d..9ff1c48 100755 --- a/src/main/java/cpw/mods/ironchest/client/ClientProxy.java +++ b/src/main/java/cpw/mods/ironchest/client/ClientProxy.java @@ -28,7 +28,7 @@ public class ClientProxy extends CommonProxy @Override public void registerRenderInformation() { - //tileEntityRendererChestHelper.instance = new IronChestRenderHelper(); + TileEntityRendererChestHelper.instance = new IronChestRenderHelper(); } @Override diff --git a/src/main/java/cpw/mods/ironchest/client/IronChestRenderHelper.java b/src/main/java/cpw/mods/ironchest/client/IronChestRenderHelper.java index dd27f42..fd44c88 100755 --- a/src/main/java/cpw/mods/ironchest/client/IronChestRenderHelper.java +++ b/src/main/java/cpw/mods/ironchest/client/IronChestRenderHelper.java @@ -15,6 +15,7 @@ import java.util.Map; import net.minecraft.block.Block; import net.minecraft.client.renderer.tileentity.TileEntityRendererChestHelper; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; +import net.minecraft.item.ItemStack; import com.google.common.collect.Maps; @@ -22,27 +23,30 @@ import cpw.mods.ironchest.IronChest; import cpw.mods.ironchest.IronChestType; import cpw.mods.ironchest.TileEntityIronChest; -/*public class IronChestRenderHelper extends TileEntityRendererChestHelper { +public class IronChestRenderHelper extends TileEntityRendererChestHelper +{ private Map itemRenders = Maps.newHashMap(); public IronChestRenderHelper() { for (IronChestType typ : IronChestType.values()) { - itemRenders.put(typ.ordinal(), (TileEntityIronChest) IronChest.ironChestBlock.createTileEntity(null, typ.ordinal())); + itemRenders.put(typ.ordinal(), (TileEntityIronChest) IronChest.ironChestBlock.createNewTileEntity(null, typ.ordinal())); } } @Override - public void renderChest(Block block, int i, float f) + public void renderChest(ItemStack itemStack) { + Block block = Block.getBlockFromItem(itemStack.getItem()); + if (block == IronChest.ironChestBlock) { - TileEntityRendererDispatcher.instance.renderTileEntityAt(itemRenders.get(i), 0.0D, 0.0D, 0.0D, 0.0F); + TileEntityRendererDispatcher.instance.renderTileEntityAt(itemRenders.get(itemStack.getMetadata()), 0.0D, 0.0D, 0.0D, 0.0F); } else { - super.renderChest(block, i, f); + super.renderChest(itemStack); } } -}*/ +} diff --git a/src/main/java/cpw/mods/ironchest/client/TileEntityIronChestRenderer.java b/src/main/java/cpw/mods/ironchest/client/TileEntityIronChestRenderer.java index 8f6c2ab..a3866c9 100755 --- a/src/main/java/cpw/mods/ironchest/client/TileEntityIronChestRenderer.java +++ b/src/main/java/cpw/mods/ironchest/client/TileEntityIronChestRenderer.java @@ -37,6 +37,7 @@ import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap.Builder; import cpw.mods.ironchest.BlockIronChest; +import cpw.mods.ironchest.IronChest; import cpw.mods.ironchest.IronChestType; import cpw.mods.ironchest.MappableItemStackWrapper; import cpw.mods.ironchest.TileEntityIronChest; @@ -94,12 +95,14 @@ public class TileEntityIronChestRenderer extends TileEntitySpecialRenderer } int facing = 3; IronChestType type = tile.getType(); - if (tile != null && tile.hasWorldObj()) { + + if (tile != null && tile.hasWorldObj() && tile.getWorld().getBlockState(tile.getPos()).getBlock() == IronChest.ironChestBlock) { facing = tile.getFacing(); type = tile.getType(); IBlockState state = tile.getWorld().getBlockState(tile.getPos()); type = (IronChestType)state.getValue(BlockIronChest.VARIANT_PROP); } + bindTexture(locations.get(type)); glPushMatrix(); glEnable(32826 /* GL_RESCALE_NORMAL_EXT */); diff --git a/src/main/resources/assets/ironchest/models/block/BlockIronChest.json b/src/main/resources/assets/ironchest/models/block/BlockIronChest.json deleted file mode 100755 index 8d6a8b4..0000000 --- a/src/main/resources/assets/ironchest/models/block/BlockIronChest.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "parent": "block/cube_all", - "textures": { - "all": "blocks/clay" - } -} diff --git a/src/main/resources/assets/ironchest/models/item/BlockIronChest.json b/src/main/resources/assets/ironchest/models/item/BlockIronChest.json index d055f0b..9935acc 100755 --- a/src/main/resources/assets/ironchest/models/item/BlockIronChest.json +++ b/src/main/resources/assets/ironchest/models/item/BlockIronChest.json @@ -1,10 +1,3 @@ { - "parent": "ironchest:block/BlockIronChest", - "display": { - "thirdperson": { - "rotation": [ 10, -45, 170 ], - "translation": [ 0, 1.5, -2.75 ], - "scale": [ 0.375, 0.375, 0.375 ] - } - } + "parent": "builtin/entity" }