From abccb682085aeb0ef6ef97a6ac3ac4c9cfb2101f Mon Sep 17 00:00:00 2001 From: Adubbz Date: Fri, 26 Sep 2014 12:45:55 +1000 Subject: [PATCH] Began work on rendering. All chest variants now appear in the creative menu --- 18 Mappings.txt | 284 +----------------- .../cpw/mods/ironchest/BlockIronChest.java | 13 +- .../cpw/mods/ironchest/IronChestType.java | 2 +- .../mods/ironchest/client/ClientProxy.java | 4 +- .../client/TileEntityIronChestRenderer.java | 59 ++-- 5 files changed, 42 insertions(+), 320 deletions(-) diff --git a/18 Mappings.txt b/18 Mappings.txt index 1668932..c22f284 100644 --- a/18 Mappings.txt +++ b/18 Mappings.txt @@ -1,286 +1,4 @@ --—Block—- -func_180660_a - getItemDropped -func_180654_a - setBlockBoundsBasedOnState -func_180640_a - getCollisionBoundingBoxFromPool -func_180646_a - getSelectedBoundingBoxFromPool -func_180639_a - onBlockActivated -func_180649_a - onBlockClicked -func_176196_c - canPlaceBlockAt -func_176204_a - onNeighborBlockChange -func_180650_b - updateTick -func_180655_c - randomDisplayTick -func_180644_h - getRenderColor -func_180662_a - colorMultiplier -func_175671_l - getBlockLightValue -func_180659_g - getMapColor -func_180641_l - getComparatorInputOverride -func_176222_j - getDamageValue -func_176207_c - getMixedBrightnessForBlock -func_176225_a - shouldSideBeRendered -func_176195_g - getBlockHardness -func_176209_a - canCollideCheck -func_180638_a - addCollisionBoxesToList -func_180665_b - getItem -func_176208_a - onBlockHarvested -func_180653_a - dropBlockAsItemWithChance -func_180657_a - harvestBlock -func_180643_i - createStackedBlock -func_176213_c - onBlockAdded -func_180633_a - onBlockPlacedBy -func_180651_a - damageDropped -func_180663_b - breakBlock -func_180656_a - isProvidingWeakPower -func_180642_a - onBlockPlaced - -—Item— -func_180614_a - onItemUse - -—IBlockAccess— -func_180494_b - getBiomeGenForCoords -func_175625_s - getTileEntity - -—World—- -func_175698_g - setBlockToAir -func_175656_a - setBlock -func_175718_b - playAuxSFX -func_180498_a - playAuxSFXAtEntity -func_175623_d - isAirBlock -func_175690_a - setTileEntity -func_175689_h - markBlockForUpdate -func_175641_c - addBlockEvent -func_180501_a - setBlock -func_175726_f - getChunkFromBlockCoords - -—Entity— -func_174818_b - getDistanceSq - -—RegistryNamespaced— -func_177775_a - addObject - -—IInventory—- -func_174889_b - openInventory -func_174886_c - closeInventory -func_174888_l - clearInventory -func_174887_a_ - getField -func_174885_b - setField -func_174890_g - getFieldCount -func_174876_a - createContainer - -—IInteractionObject— -func_174875_k - getGuiID - -—ItemRenderer— -func_178099_a - renderItem - -field_178112_h - itemRenderer - -—RenderItem— -func_180451_a - renderEffect - -—————————— -ESTIMATES -—————————— - -—IBlockAccess— -func_180495_p - getBlockState - -—World— -func_175701_a - isPosInBoundaries - -—Chunk— -func_177435_g - getBlockState - -—Block—- -func_180661_e - createBlockState -func_176194_O - getBlockState -func_180632_j - setDefaultBlockState -func_176223_P - getDefaultBlockState -func_176203_a - getBlockStateFromMeta -func_176201_c - getMetaFromBlockState -func_176215_a - registerBlock -func_176219_a - registerBlock - -field_176227_L - blockState -field_176228_M - defaultBlockState - -—BlockDirt— -field_176386_a - VARIANT_PROP -field_176385_b - SNOWY_PROP - -—BlockDirt.DirtType— -func_176925_a - getMetadata - -field_176931_e - metadata - -—IBlockState— -func_177227_a - getPropertyNames -func_177229_b - getValue -func_177226_a - setProperty -func_177228_b - getProperties - -—BlockState— -func_177622_c - getBlock -func_177623_d - getProperties -func_177620_e - getAllowedValues -func_177619_a - getValidStates -func_177621_b - getBaseState - -field_177627_c - block -field_177625_e - validStates - -—BlockStateBase— -func_177232_a - validatePropertyValue - -—BlockState.StateImplementation— -func_177230_c - getBlock - -field_177239_a - block -field_177237_b - properties - -—PropertyHelper— -field_177704_a - propertyClass -field_177703_b - name - -—IProperty— -func_177701_a - getName -func_177700_c - getAllowedValues -func_177699_b - getPropertyClass - -—TileEntity— -func_174877_v - getPos - -field_174879_c - pos - -—MapPopulator— -func_179400_b - populateLinkedHashMap -func_179399_a - populateLinkedHashMap - -—Cartesian— - -func_179319_b - createArray -func_179322_b - toArray - -—Cartestian.GetList— -func_179324_a - toList - -—RegistryNamespaced— -func_177774_c - getKeyForObject - -—Vec3i— -func_177958_n - getX -func_177956_o - getY -func_177952_p - getZ -func_177954_c - getDistanceSq -func_177951_i - getDistanceSq - -field_177962_a - x -field_177960_b - y -field_177961_c - z - -—BlockPos— -field_177992_a - ORIGIN - -—IStringSerializable— -func_176610_l - getID - -—ModelBakery— -func_177580_d - getModelLocation -func_177584_b - getBlockStateLocation -func_177586_a - getModelBlockDefinition -func_177590_d - loadItemModels -func_177592_e - registerSubModels -func_177596_a - getSubModels -func_177570_a - setupModelRegistry - -field_177604_a - MODEL_MISSING -field_177608_m - itemModelGenerator -field_177613_u - subModels -field_177605_n - modelRegistry - -—ItemModelGenerator— -field_178398_a - LAYERS - -—RenderItem— -func_175037_a - getItemModelMesher -func_175048_a - loadInventoryModel -func_175047_a - loadInventoryModel -func_175029_a - loadInventoryModel -func_175031_a - loadInventoryModel -func_175041_b - loadInventoryModels - -field_175059_m - itemModelMesher - -—Minecraft— -func_175597_ag - getItemRenderer -func_175599_af - getRenderItem - -field_175617_aL - modelManager -field_175620_Y - itemRenderer -field_175621_X - renderItem -field_175616_W - renderManager - -—GlStateManager— -func_179094_E - pushMatrix -func_179121_F - popMatrix -func_179114_b - rotate -func_179152_a - scale -func_179139_a - scale -func_179109_b - translate -func_179137_b - translate - -—GLStateManager.BooleanState— -func_179198_a - setDisabled -func_179200_b - setEnabled - -—ItemModelMesher— -func_178083_a - getModelManager -func_178084_b - getItemStackDamage -func_178081_c - getItemID -func_178088_b - getModelForItem -func_178089_a - getModelForItemStack -func_178087_a - getItemTexture -func_178082_a - getItemTexture -func_178086_a - loadItemModel -func_178085_b - resetModels -func_178080_a - addItemMeshDefinition - -field_178090_d - modelManager -field_178093_a - modelLocations -field_178091_b - itemModels -field_178092_c - itemMeshDefinitions - -—IBakedModel— -func_177554_e - getTexture - -—ModelManager— -func_174953_a - getModel -func_174951_a - getDefaultModel - -field_174955_d - defaultModel -field_174958_a - modelRegistry - -—IWorldNamable— -getCommandSenderName - getName -isCustomInventoryName - hasCustomName -getFormattedCommandSenderName - getFormattedName - -—LockCode- -func_180159_b - getLock -func_180158_b - fromNBT -func_180157_a - toNBT -func_180160_a - isEmpty - -field_180161_b - lock -field_180162_a - EMPTY_CODE - -—ILockableContainer— -func_174891_i - getLockCode -func_174892_a - setLockCode -func_174893_q_ - isLocked - -—TileEntityLockable— - -field_174901_a - lockCode +—MAPPINGS NOW IN MCPBOT— —————————— FIXES diff --git a/src/main/java/cpw/mods/ironchest/BlockIronChest.java b/src/main/java/cpw/mods/ironchest/BlockIronChest.java index 3bf73d9..da717e2 100755 --- a/src/main/java/cpw/mods/ironchest/BlockIronChest.java +++ b/src/main/java/cpw/mods/ironchest/BlockIronChest.java @@ -10,6 +10,7 @@ ******************************************************************************/ package cpw.mods.ironchest; +import java.util.List; import java.util.Random; import net.minecraft.block.Block; @@ -23,8 +24,10 @@ import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Items; import net.minecraft.inventory.Container; import net.minecraft.inventory.IInventory; +import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; @@ -32,6 +35,8 @@ import net.minecraft.util.BlockPos; import net.minecraft.util.EnumFacing; import net.minecraft.util.MathHelper; import net.minecraft.world.World; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; public class BlockIronChest extends BlockContainer { @@ -43,7 +48,7 @@ public class BlockIronChest extends BlockContainer this.setDefaultBlockState(this.blockState.getBaseState().setProperty(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.setUnlocalizedName("IronChest"); this.setCreativeTab(CreativeTabs.tabDecorations); @@ -91,7 +96,7 @@ public class BlockIronChest extends BlockContainer return IronChestType.makeEntity(metadata); } - /*@Override + @Override @SideOnly(Side.CLIENT) public void getSubBlocks(Item itemIn, CreativeTabs tab, List list) { @@ -99,10 +104,10 @@ public class BlockIronChest extends BlockContainer { if (type.isValidForCreativeMode()) { - list.add(new ItemStack(this, 1, type.ordinal())); + list.add(new ItemStack(itemIn, 1, type.ordinal())); } } - }*/ + } @Override public IBlockState getBlockStateFromMeta(int meta) diff --git a/src/main/java/cpw/mods/ironchest/IronChestType.java b/src/main/java/cpw/mods/ironchest/IronChestType.java index 4bec13e..09694a5 100755 --- a/src/main/java/cpw/mods/ironchest/IronChestType.java +++ b/src/main/java/cpw/mods/ironchest/IronChestType.java @@ -182,7 +182,7 @@ public enum IronChestType implements IStringSerializable public static int validateMeta(int i) { - if (i < values().length && values()[i].size > 0) + if (i < values().length && values()[i] != IronChestType.WOOD) { 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 63cb7de..a56853d 100755 --- a/src/main/java/cpw/mods/ironchest/client/ClientProxy.java +++ b/src/main/java/cpw/mods/ironchest/client/ClientProxy.java @@ -28,13 +28,13 @@ public class ClientProxy extends CommonProxy @Override public void registerRenderInformation() { - //TileEntityRendererChestHelper.instance = new IronChestRenderHelper(); + //tileEntityRendererChestHelper.instance = new IronChestRenderHelper(); } @Override public void registerTileEntitySpecialRenderer(IronChestType typ) { - //ClientRegistry.bindTileEntitySpecialRenderer(typ.clazz, new TileEntityIronChestRenderer()); + ClientRegistry.bindTileEntitySpecialRenderer(typ.clazz, new TileEntityIronChestRenderer()); } @Override diff --git a/src/main/java/cpw/mods/ironchest/client/TileEntityIronChestRenderer.java b/src/main/java/cpw/mods/ironchest/client/TileEntityIronChestRenderer.java index 4f36891..8f6c2ab 100755 --- a/src/main/java/cpw/mods/ironchest/client/TileEntityIronChestRenderer.java +++ b/src/main/java/cpw/mods/ironchest/client/TileEntityIronChestRenderer.java @@ -23,6 +23,7 @@ import java.util.HashMap; import java.util.Map; import java.util.Random; +import net.minecraft.block.state.IBlockState; import net.minecraft.client.model.ModelChest; import net.minecraft.client.renderer.entity.RenderItem; import net.minecraft.client.renderer.entity.RenderManager; @@ -34,17 +35,18 @@ import net.minecraft.util.ResourceLocation; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap.Builder; -import com.google.common.primitives.SignedBytes; +import cpw.mods.ironchest.BlockIronChest; import cpw.mods.ironchest.IronChestType; import cpw.mods.ironchest.MappableItemStackWrapper; import cpw.mods.ironchest.TileEntityIronChest; -/*public class TileEntityIronChestRenderer extends TileEntitySpecialRenderer { - @SuppressWarnings("unused") +public class TileEntityIronChestRenderer extends TileEntitySpecialRenderer +{ private static Map renderList = new HashMap(); private static Map locations; + static { Builder builder = ImmutableMap.builder(); for (IronChestType typ : IronChestType.values()) { @@ -52,22 +54,19 @@ import cpw.mods.ironchest.TileEntityIronChest; } locations = builder.build(); } + private Random random; - - @SuppressWarnings("unused") - private RenderBlocks renderBlocks; - private RenderItem itemRenderer; + private ModelChest model; private static float[][] shifts = { { 0.3F, 0.45F, 0.3F }, { 0.7F, 0.45F, 0.3F }, { 0.3F, 0.45F, 0.7F }, { 0.7F, 0.45F, 0.7F }, { 0.3F, 0.1F, 0.3F }, { 0.7F, 0.1F, 0.3F }, { 0.3F, 0.1F, 0.7F }, { 0.7F, 0.1F, 0.7F }, { 0.5F, 0.32F, 0.5F }, }; - + public TileEntityIronChestRenderer() { model = new ModelChest(); random = new Random(); - renderBlocks = new RenderBlocks(); - itemRenderer = new RenderItem() { + /*itemRenderer = new RenderItem(null, null) { @Override public byte getMiniBlockCount(ItemStack stack, byte original) { return SignedBytes.saturatedCast(Math.min(stack.stackSize / 32, 15) + 1); @@ -85,10 +84,11 @@ import cpw.mods.ironchest.TileEntityIronChest; return false; } }; - itemRenderer.setRenderManager(RenderManager.instance); + itemRenderer.setRenderManager(RenderManager.instance);*/ } - /*public void render(TileEntityIronChest tile, double x, double y, double z, float partialTick) { + public void render(TileEntityIronChest tile, double x, double y, double z, float partialTick) + { if (tile == null) { return; } @@ -97,13 +97,13 @@ import cpw.mods.ironchest.TileEntityIronChest; if (tile != null && tile.hasWorldObj()) { facing = tile.getFacing(); type = tile.getType(); - int typ = tile.getWorldObj().getBlockMetadata(tile.xCoord, tile.yCoord, tile.zCoord); - type = IronChestType.values()[typ]; + 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 *//*); - /*glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + glEnable(32826 /* GL_RESCALE_NORMAL_EXT */); + glColor4f(1.0F, 1.0F, 1.0F, 1.0F); glTranslatef((float) x, (float) y + 1.0F, (float) z + 1.0F); glScalef(1.0F, -1F, -1F); glTranslatef(0.5F, 0.5F, 0.5F); @@ -128,10 +128,10 @@ import cpw.mods.ironchest.TileEntityIronChest; model.chestLid.rotateAngleX = -((lidangle * 3.141593F) / 2.0F); // Render the chest itself model.renderAll(); - glDisable(32826 /* GL_RESCALE_NORMAL_EXT *//*); - /*glPopMatrix(); + glDisable(32826 /* GL_RESCALE_NORMAL_EXT */); + glPopMatrix(); glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - if (type.isTransparent() && tile.getDistanceFrom(this.field_147501_a.field_147560_j, this.field_147501_a.field_147561_k, this.field_147501_a.field_147558_l) < 128d) { + if (type.isTransparent() && tile.getDistanceSq(this.rendererDispatcher.field_147560_j, this.rendererDispatcher.field_147561_k, this.rendererDispatcher.field_147558_l) < 128d) { random.setSeed(254L); float shiftX; float shiftY; @@ -144,9 +144,9 @@ import cpw.mods.ironchest.TileEntityIronChest; blockScale = 0.85F; } glPushMatrix(); - glDisable(2896 /* GL_LIGHTING *//*); - /*glTranslatef((float) x, (float) y, (float) z); - EntityItem customitem = new EntityItem(field_147501_a.field_147550_f); + glDisable(2896 /* GL_LIGHTING */); + glTranslatef((float) x, (float) y, (float) z); + EntityItem customitem = new EntityItem(this.getWorld()); customitem.hoverStart = 0f; for (ItemStack item : tile.getTopItemStacks()) { if (shift > shifts.length) { @@ -165,20 +165,19 @@ import cpw.mods.ironchest.TileEntityIronChest; glRotatef(timeD, 0.0F, 1.0F, 0.0F); glScalef(blockScale, blockScale, blockScale); customitem.setEntityItemStack(item); - itemRenderer.doRender(customitem, 0, 0, 0, 0, 0); + //itemRenderer.doRender(customitem, 0, 0, 0, 0, 0); glPopMatrix(); } - glEnable(2896 /* GL_LIGHTING *//*); - /*glPopMatrix(); + glEnable(2896 /* GL_LIGHTING */); + glPopMatrix(); glColor4f(1.0F, 1.0F, 1.0F, 1.0F); } } - - /*@Override - public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z, float partialTick) + + @Override + public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z, float partialTick, int p_180535_9_) { render((TileEntityIronChest) tileentity, x, y, z, partialTick); } - private ModelChest model; -}*/ +}