Trying (without luck) to get the inventory models rendering

This commit is contained in:
Adubbz 2014-09-26 21:42:37 +10:00
parent abccb68208
commit e53f48b08f
8 changed files with 30 additions and 34 deletions

View File

@ -40,13 +40,13 @@ import net.minecraftforge.fml.relauncher.SideOnly;
public class BlockIronChest extends BlockContainer 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() public BlockIronChest()
{ {
super(Material.iron); 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.setBlockBounds(0.0625F, 0F, 0.0625F, 0.9375F, 0.875F, 0.9375F);
this.setHardness(3.0F); this.setHardness(3.0F);
@ -66,6 +66,12 @@ public class BlockIronChest extends BlockContainer
return false; return false;
} }
@Override
public int getRenderType()
{
return 2;
}
@Override @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_) 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 @Override
public IBlockState getBlockStateFromMeta(int meta) 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 @Override
public int getMetaFromBlockState(IBlockState blockState) public int getMetaFromBlockState(IBlockState blockState)
{ {
return IronChestType.validateMeta(((IronChestType)blockState.getValue(VARIANT_PROP)).ordinal()); return ((IronChestType)blockState.getValue(VARIANT_PROP)).ordinal();
} }
@Override @Override
@ -127,12 +133,6 @@ public class BlockIronChest extends BlockContainer
return new BlockState(this, new IProperty[] { VARIANT_PROP }); return new BlockState(this, new IProperty[] { VARIANT_PROP });
} }
/*@Override
public int getRenderType()
{
return 22;
}*/
/*@Override /*@Override
public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune) public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune)
{ {

View File

@ -58,6 +58,8 @@ public class IronChest
ChestChangerType.buildItems(); ChestChangerType.buildItems();
ironChestBlock = new BlockIronChest(); ironChestBlock = new BlockIronChest();
GameRegistry.registerBlock(ironChestBlock, ItemIronChest.class, "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()) for (IronChestType typ : IronChestType.values())
{ {

View File

@ -67,7 +67,7 @@ public enum IronChestType implements IStringSerializable
} }
@Override @Override
public String getID() public String getName()
{ {
return name().toLowerCase(); return name().toLowerCase();
} }
@ -182,7 +182,7 @@ public enum IronChestType implements IStringSerializable
public static int validateMeta(int i) public static int validateMeta(int i)
{ {
if (i < values().length && values()[i] != IronChestType.WOOD) if (i < values().length && values()[i].size > 0)
{ {
return i; return i;
} }

View File

@ -28,7 +28,7 @@ public class ClientProxy extends CommonProxy
@Override @Override
public void registerRenderInformation() public void registerRenderInformation()
{ {
//tileEntityRendererChestHelper.instance = new IronChestRenderHelper(); TileEntityRendererChestHelper.instance = new IronChestRenderHelper();
} }
@Override @Override

View File

@ -15,6 +15,7 @@ import java.util.Map;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.client.renderer.tileentity.TileEntityRendererChestHelper; import net.minecraft.client.renderer.tileentity.TileEntityRendererChestHelper;
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
import net.minecraft.item.ItemStack;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
@ -22,27 +23,30 @@ import cpw.mods.ironchest.IronChest;
import cpw.mods.ironchest.IronChestType; import cpw.mods.ironchest.IronChestType;
import cpw.mods.ironchest.TileEntityIronChest; import cpw.mods.ironchest.TileEntityIronChest;
/*public class IronChestRenderHelper extends TileEntityRendererChestHelper { public class IronChestRenderHelper extends TileEntityRendererChestHelper
{
private Map<Integer, TileEntityIronChest> itemRenders = Maps.newHashMap(); private Map<Integer, TileEntityIronChest> itemRenders = Maps.newHashMap();
public IronChestRenderHelper() public IronChestRenderHelper()
{ {
for (IronChestType typ : IronChestType.values()) 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 @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) 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 else
{ {
super.renderChest(block, i, f); super.renderChest(itemStack);
}
} }
} }
}*/

View File

@ -37,6 +37,7 @@ import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableMap.Builder; import com.google.common.collect.ImmutableMap.Builder;
import cpw.mods.ironchest.BlockIronChest; import cpw.mods.ironchest.BlockIronChest;
import cpw.mods.ironchest.IronChest;
import cpw.mods.ironchest.IronChestType; import cpw.mods.ironchest.IronChestType;
import cpw.mods.ironchest.MappableItemStackWrapper; import cpw.mods.ironchest.MappableItemStackWrapper;
import cpw.mods.ironchest.TileEntityIronChest; import cpw.mods.ironchest.TileEntityIronChest;
@ -94,12 +95,14 @@ public class TileEntityIronChestRenderer extends TileEntitySpecialRenderer
} }
int facing = 3; int facing = 3;
IronChestType type = tile.getType(); 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(); facing = tile.getFacing();
type = tile.getType(); type = tile.getType();
IBlockState state = tile.getWorld().getBlockState(tile.getPos()); IBlockState state = tile.getWorld().getBlockState(tile.getPos());
type = (IronChestType)state.getValue(BlockIronChest.VARIANT_PROP); type = (IronChestType)state.getValue(BlockIronChest.VARIANT_PROP);
} }
bindTexture(locations.get(type)); bindTexture(locations.get(type));
glPushMatrix(); glPushMatrix();
glEnable(32826 /* GL_RESCALE_NORMAL_EXT */); glEnable(32826 /* GL_RESCALE_NORMAL_EXT */);

View File

@ -1,6 +0,0 @@
{
"parent": "block/cube_all",
"textures": {
"all": "blocks/clay"
}
}

View File

@ -1,10 +1,3 @@
{ {
"parent": "ironchest:block/BlockIronChest", "parent": "builtin/entity"
"display": {
"thirdperson": {
"rotation": [ 10, -45, 170 ],
"translation": [ 0, 1.5, -2.75 ],
"scale": [ 0.375, 0.375, 0.375 ]
}
}
} }