From 3a71e193ac1c41a03e9cc5dca288ec188c78819d Mon Sep 17 00:00:00 2001 From: tterrag1098 Date: Tue, 13 Jan 2015 01:09:10 -0500 Subject: [PATCH] #1657 Remove caching of IIcons in soul binder renderer. --- .../machine/soul/SoulBinderRenderer.java | 32 +++++++------------ 1 file changed, 12 insertions(+), 20 deletions(-) diff --git a/src/main/java/crazypants/enderio/machine/soul/SoulBinderRenderer.java b/src/main/java/crazypants/enderio/machine/soul/SoulBinderRenderer.java index 383e3602..60f86ac2 100644 --- a/src/main/java/crazypants/enderio/machine/soul/SoulBinderRenderer.java +++ b/src/main/java/crazypants/enderio/machine/soul/SoulBinderRenderer.java @@ -20,8 +20,6 @@ import crazypants.util.ForgeDirectionOffsets; public class SoulBinderRenderer implements ISimpleBlockRenderingHandler { - private IIcon soulariumIcon; - private IIcon darkSteelIcon; private float skullScale = 0.5f; private BoundingBox scaledBB = BoundingBox.UNIT_CUBE.scale(skullScale, skullScale, skullScale); private IIcon[] icons = new IIcon[6]; @@ -39,9 +37,7 @@ public class SoulBinderRenderer implements ISimpleBlockRenderingHandler { @Override public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { - if(soulariumIcon == null) { - soulariumIcon = EnderIO.blockSoulFuser.getIcon(ForgeDirection.EAST.ordinal(), 0); - } + IIcon soulariumIcon = EnderIO.blockSoulFuser.getIcon(ForgeDirection.EAST.ordinal(), 0); //Horrible hack to get the MC lighting engine to set the correct values for me if(renderer != null && world != null) { @@ -54,23 +50,24 @@ public class SoulBinderRenderer implements ISimpleBlockRenderingHandler { Tessellator.instance.addTranslation(x, y, z); bb = BoundingBox.UNIT_CUBE.scale(0.85, 0.85, 0.85); - setIcons(soulariumIcon, ForgeDirection.NORTH); + setIcons(soulariumIcon, soulariumIcon, ForgeDirection.NORTH); CubeRenderer.render(bb, icons, true); float slabWidth = 0.15f; bb = BoundingBox.UNIT_CUBE.scale(1, slabWidth, 1); bb = bb.translate(0, 0.5f - (slabWidth / 2), 0); - setIcons(EnderIO.blockSoulFuser.getIcon(ForgeDirection.UP.ordinal(), 0), ForgeDirection.UP); + setIcons(soulariumIcon, EnderIO.blockSoulFuser.getIcon(ForgeDirection.UP.ordinal(), 0), ForgeDirection.UP); CubeRenderer.render(bb, icons, true); bb = BoundingBox.UNIT_CUBE.scale(1, slabWidth, 1); bb = bb.translate(0, -0.5f + (slabWidth / 2), 0); - setIcons(soulariumIcon, ForgeDirection.NORTH); + setIcons(soulariumIcon, soulariumIcon, ForgeDirection.NORTH); CubeRenderer.render(bb, icons, true); IIcon endermanIcon; - int facing = ForgeDirection.SOUTH.ordinal();; + int facing = ForgeDirection.SOUTH.ordinal(); + if(world == null || !(world.getTileEntity(x, y, z) instanceof TileSoulBinder)) { endermanIcon = EnderIO.blockSoulFuser.endermanSkullIcon; } else { @@ -79,32 +76,27 @@ public class SoulBinderRenderer implements ISimpleBlockRenderingHandler { endermanIcon = sb.isActive() ? EnderIO.blockSoulFuser.endermanSkullIconOn : EnderIO.blockSoulFuser.endermanSkullIcon; } - renderSkull(forFacing(ForgeDirection.SOUTH, facing), endermanIcon); - renderSkull(forFacing(ForgeDirection.WEST, facing), EnderIO.blockSoulFuser.skeletonSkullIcon); - renderSkull(forFacing(ForgeDirection.NORTH, facing), EnderIO.blockSoulFuser.zombieSkullIcon); - renderSkull(forFacing(ForgeDirection.EAST, facing), EnderIO.blockSoulFuser.creeperSkullIcon); + renderSkull(forFacing(ForgeDirection.SOUTH, facing), soulariumIcon, endermanIcon); + renderSkull(forFacing(ForgeDirection.WEST, facing), soulariumIcon, EnderIO.blockSoulFuser.skeletonSkullIcon); + renderSkull(forFacing(ForgeDirection.NORTH, facing), soulariumIcon, EnderIO.blockSoulFuser.zombieSkullIcon); + renderSkull(forFacing(ForgeDirection.EAST, facing), soulariumIcon, EnderIO.blockSoulFuser.creeperSkullIcon); Tessellator.instance.addTranslation(-x, -y, -z); return true; } - private ForgeDirection forFacing(ForgeDirection side, int facing) { return ForgeDirection.values()[ClientProxy.sideAndFacingToSpriteOffset[side.ordinal()][facing]]; } - private void renderSkull(ForgeDirection face, IIcon faceIcon) { + private void renderSkull(ForgeDirection face, IIcon soulariumIcon, IIcon faceIcon) { BoundingBox bb; bb = scaledBB.translate(ForgeDirectionOffsets.offsetScaled(face, 0.5 - skullScale / 2)); - setIcons(faceIcon, face); + setIcons(soulariumIcon, faceIcon, face); CubeRenderer.render(bb, icons, true); } - private void setIcons(IIcon faceIcon, ForgeDirection faceSide) { - setIcons(soulariumIcon, faceIcon, faceSide); - } - private void setIcons(IIcon defaultIcon, IIcon faceIcon, ForgeDirection faceSide) { for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) { icons[dir.ordinal()] = dir == faceSide ? faceIcon : defaultIcon;