diff --git a/src/main/java/com/pengu/thaumcraft/additions/gui/GUICondensator.java b/src/main/java/com/pengu/thaumcraft/additions/gui/GUICondensator.java index 5ad135a..952db93 100644 --- a/src/main/java/com/pengu/thaumcraft/additions/gui/GUICondensator.java +++ b/src/main/java/com/pengu/thaumcraft/additions/gui/GUICondensator.java @@ -12,6 +12,8 @@ import org.lwjgl.opengl.GL11; public class GUICondensator extends GuiContainer { + private static final ResourceLocation TEXTURE = new ResourceLocation("thaumicadditions", "textures/gui/guicondenser.png"); + private TileOldCondensator mw; @@ -23,7 +25,7 @@ public class GUICondensator extends GuiContainer { } public void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) { - Minecraft.getMinecraft().getTextureManager().bindTexture(new ResourceLocation("thaumicadditions", "textures/gui/guicondenser.png")); + Minecraft.getMinecraft().getTextureManager().bindTexture(TEXTURE); this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, this.xSize, this.ySize); int i = this.mw.getProgressScaled(36); GL11.glPushMatrix(); diff --git a/src/main/java/com/pengu/thaumcraft/additions/gui/GUIDarkGenerator.java b/src/main/java/com/pengu/thaumcraft/additions/gui/GUIDarkGenerator.java index de7a878..4e23b60 100644 --- a/src/main/java/com/pengu/thaumcraft/additions/gui/GUIDarkGenerator.java +++ b/src/main/java/com/pengu/thaumcraft/additions/gui/GUIDarkGenerator.java @@ -12,6 +12,8 @@ import net.minecraft.util.ResourceLocation; public class GUIDarkGenerator extends GuiContainer { + private static final ResourceLocation TEXTURE = new ResourceLocation("thaumicadditions", "textures/gui/guidarkgen.png"); + private TileDarkGen mw; @@ -23,7 +25,7 @@ public class GUIDarkGenerator extends GuiContainer { } public void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) { - Minecraft.getMinecraft().getTextureManager().bindTexture(new ResourceLocation("thaumicadditions", "textures/gui/guidarkgen.png")); + Minecraft.getMinecraft().getTextureManager().bindTexture(TEXTURE); this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, this.xSize, this.ySize); this.drawTexturedModalRect(this.guiLeft + 84, this.guiTop + 44, 192, this.mw.getWorldObj().getMoonPhase() * 8, 8, 8); this.drawTexturedModalRect(this.guiLeft + 84 - 4, this.guiTop + 44 - 20, 176, LightUtil.getLightValue(this.mw.getWorldObj(), this.mw.xCoord, this.mw.yCoord, this.mw.zCoord) * 16, 16, 16); diff --git a/src/main/java/com/pengu/thaumcraft/additions/gui/GUIDarkInfuser.java b/src/main/java/com/pengu/thaumcraft/additions/gui/GUIDarkInfuser.java index d1bbb7a..55161a6 100644 --- a/src/main/java/com/pengu/thaumcraft/additions/gui/GUIDarkInfuser.java +++ b/src/main/java/com/pengu/thaumcraft/additions/gui/GUIDarkInfuser.java @@ -12,6 +12,8 @@ import net.minecraft.util.StatCollector; public class GUIDarkInfuser extends GuiContainer { + private static final ResourceLocation TEXTURE = new ResourceLocation("thaumicadditions", "textures/gui/guidarkinfuser.png"); + private TileDarkInfuser mw; @@ -23,7 +25,7 @@ public class GUIDarkInfuser extends GuiContainer { } public void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) { - Minecraft.getMinecraft().getTextureManager().bindTexture(new ResourceLocation("thaumicadditions", "textures/gui/guidarkinfuser.png")); + Minecraft.getMinecraft().getTextureManager().bindTexture(TEXTURE); this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, this.xSize, this.ySize); int i; if(this.mw.cookTime > 0) { diff --git a/src/main/java/com/pengu/thaumcraft/additions/gui/GUIHyperNodeCreator.java b/src/main/java/com/pengu/thaumcraft/additions/gui/GUIHyperNodeCreator.java index 00af28e..7472d0a 100644 --- a/src/main/java/com/pengu/thaumcraft/additions/gui/GUIHyperNodeCreator.java +++ b/src/main/java/com/pengu/thaumcraft/additions/gui/GUIHyperNodeCreator.java @@ -11,6 +11,8 @@ import net.minecraft.util.ResourceLocation; public class GUIHyperNodeCreator extends GuiContainer { + private static final ResourceLocation TEXTURE = new ResourceLocation("thaumicadditions", "textures/gui/guihypernodecreator.png"); + private TileHyperNodeCreator mw; @@ -22,7 +24,7 @@ public class GUIHyperNodeCreator extends GuiContainer { } public void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) { - Minecraft.getMinecraft().getTextureManager().bindTexture(new ResourceLocation("thaumicadditions", "textures/gui/guihypernodecreator.png")); + Minecraft.getMinecraft().getTextureManager().bindTexture(TEXTURE); this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, this.xSize, this.ySize); } diff --git a/src/main/java/com/pengu/thaumcraft/additions/gui/GUIInfuser.java b/src/main/java/com/pengu/thaumcraft/additions/gui/GUIInfuser.java index 3f377d1..e397f38 100644 --- a/src/main/java/com/pengu/thaumcraft/additions/gui/GUIInfuser.java +++ b/src/main/java/com/pengu/thaumcraft/additions/gui/GUIInfuser.java @@ -10,6 +10,8 @@ import net.minecraft.util.ResourceLocation; public class GUIInfuser extends GuiContainer { + private static final ResourceLocation TEXTURE = new ResourceLocation("thaumicadditions", "textures/gui/guiinfuser.png"); + private TileInfuser mw; @@ -21,7 +23,7 @@ public class GUIInfuser extends GuiContainer { } public void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) { - Minecraft.getMinecraft().getTextureManager().bindTexture(new ResourceLocation("thaumicadditions", "textures/gui/guiinfuser.png")); + Minecraft.getMinecraft().getTextureManager().bindTexture(TEXTURE); this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, this.xSize, this.ySize); if(this.mw.cookTime > 0) { int i = this.mw.getCookProgressScaled(47); diff --git a/src/main/java/com/pengu/thaumcraft/additions/gui/GUISealGlobe.java b/src/main/java/com/pengu/thaumcraft/additions/gui/GUISealGlobe.java index 6a15bea..7fb2961 100644 --- a/src/main/java/com/pengu/thaumcraft/additions/gui/GUISealGlobe.java +++ b/src/main/java/com/pengu/thaumcraft/additions/gui/GUISealGlobe.java @@ -14,6 +14,8 @@ import net.minecraft.world.World; public class GUISealGlobe extends GuiContainer { + private static final ResourceLocation TEXTURE = new ResourceLocation("thaumicadditions", "textures/gui/guicrystalball.png"); + private World world; private int x; private int y; @@ -35,7 +37,7 @@ public class GUISealGlobe extends GuiContainer { } public void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) { - Minecraft.getMinecraft().getTextureManager().bindTexture(new ResourceLocation("thaumicadditions", "textures/gui/guicrystalball.png")); + Minecraft.getMinecraft().getTextureManager().bindTexture(TEXTURE); this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, this.xSize, this.ySize); if(this.dir == EnumRise.UP) { this.color += 4.210651F; diff --git a/src/main/java/com/pengu/thaumcraft/additions/gui/GUIThaumicCrystallizer.java b/src/main/java/com/pengu/thaumcraft/additions/gui/GUIThaumicCrystallizer.java index a0464ef..ed6dea6 100644 --- a/src/main/java/com/pengu/thaumcraft/additions/gui/GUIThaumicCrystallizer.java +++ b/src/main/java/com/pengu/thaumcraft/additions/gui/GUIThaumicCrystallizer.java @@ -10,6 +10,8 @@ import net.minecraft.util.ResourceLocation; public class GUIThaumicCrystallizer extends GuiContainer { + private static final ResourceLocation TEXTURE = new ResourceLocation("thaumicadditions", "textures/gui/guicrystalizer.png"); + private TileThaumCrystallizer mw; @@ -21,7 +23,7 @@ public class GUIThaumicCrystallizer extends GuiContainer { } public void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) { - Minecraft.getMinecraft().getTextureManager().bindTexture(new ResourceLocation("thaumicadditions", "textures/gui/guicrystalizer.png")); + Minecraft.getMinecraft().getTextureManager().bindTexture(TEXTURE); this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, this.xSize, this.ySize); int i = this.mw.getCookProgressScaled(47); this.drawTexturedModalRect(this.guiLeft + 160, this.guiTop + 105 + 47 - i, 176, 47 - i, 9, i); diff --git a/src/main/java/com/pengu/thaumcraft/additions/gui/GUIThaumicGenerator.java b/src/main/java/com/pengu/thaumcraft/additions/gui/GUIThaumicGenerator.java index 4e5deeb..ed8ced6 100644 --- a/src/main/java/com/pengu/thaumcraft/additions/gui/GUIThaumicGenerator.java +++ b/src/main/java/com/pengu/thaumcraft/additions/gui/GUIThaumicGenerator.java @@ -10,6 +10,8 @@ import net.minecraft.util.ResourceLocation; public class GUIThaumicGenerator extends GuiContainer { + private static final ResourceLocation TEXTURE = new ResourceLocation("thaumicadditions", "textures/gui/guigenerator.png"); + private TileThaumicGenerator mw; @@ -21,7 +23,7 @@ public class GUIThaumicGenerator extends GuiContainer { } public void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) { - Minecraft.getMinecraft().getTextureManager().bindTexture(new ResourceLocation("thaumicadditions", "textures/gui/guigenerator.png")); + Minecraft.getMinecraft().getTextureManager().bindTexture(TEXTURE); this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, this.xSize, this.ySize); int i = this.mw.amount * 47 / this.mw.maxAmount; this.drawTexturedModalRect(this.guiLeft + 47, this.guiTop + 22 + 47 - i, 102, 47 - i, 9, i); diff --git a/src/main/java/com/pengu/thaumcraft/additions/gui/GUIThaumicRestorer.java b/src/main/java/com/pengu/thaumcraft/additions/gui/GUIThaumicRestorer.java index 19a7365..1ededd2 100644 --- a/src/main/java/com/pengu/thaumcraft/additions/gui/GUIThaumicRestorer.java +++ b/src/main/java/com/pengu/thaumcraft/additions/gui/GUIThaumicRestorer.java @@ -11,6 +11,8 @@ import net.minecraft.util.ResourceLocation; public class GUIThaumicRestorer extends GuiContainer { + private static final ResourceLocation TEXTURE = new ResourceLocation("thaumicadditions", "textures/gui/guirepairer.png"); + private TileThaumicRestorer res; @@ -22,7 +24,7 @@ public class GUIThaumicRestorer extends GuiContainer { } public void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) { - Minecraft.getMinecraft().getTextureManager().bindTexture(new ResourceLocation("thaumicadditions", "textures/gui/guirepairer.png")); + Minecraft.getMinecraft().getTextureManager().bindTexture(TEXTURE); this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, this.xSize, this.ySize); int i = this.res.tick * 31 / 5; this.drawTexturedModalRect(this.guiLeft + 135, this.guiTop + 16 + 31 - i, 176, 31 - i, 7, i); diff --git a/src/main/java/com/pengu/thaumcraft/additions/gui/GUIVoidChest.java b/src/main/java/com/pengu/thaumcraft/additions/gui/GUIVoidChest.java index be99553..e060f9c 100644 --- a/src/main/java/com/pengu/thaumcraft/additions/gui/GUIVoidChest.java +++ b/src/main/java/com/pengu/thaumcraft/additions/gui/GUIVoidChest.java @@ -9,6 +9,8 @@ import net.minecraft.util.ResourceLocation; public class GUIVoidChest extends GuiContainer { + private static final ResourceLocation TEXTURE = new ResourceLocation("thaumicadditions", "textures/gui/guivoidchest.png"); + private TileVoidChest mw; @@ -20,7 +22,7 @@ public class GUIVoidChest extends GuiContainer { } public void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) { - Minecraft.getMinecraft().getTextureManager().bindTexture(new ResourceLocation("thaumicadditions", "textures/gui/guivoidchest.png")); + Minecraft.getMinecraft().getTextureManager().bindTexture(TEXTURE); this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, this.xSize, this.ySize); } diff --git a/src/main/java/com/pengu/thaumcraft/additions/piping/TileVisTube.java b/src/main/java/com/pengu/thaumcraft/additions/piping/TileVisTube.java index b5cbdaf..d0b9edf 100644 --- a/src/main/java/com/pengu/thaumcraft/additions/piping/TileVisTube.java +++ b/src/main/java/com/pengu/thaumcraft/additions/piping/TileVisTube.java @@ -58,8 +58,9 @@ public class TileVisTube extends TileThaumcraft implements IMultiBlockPart, ITub x = this.xCoord + ForgeDirectionHelper.getForgeDirectionXApplyed(fd); y = this.yCoord + ForgeDirectionHelper.getForgeDirectionYApplyed(fd); z = this.zCoord + ForgeDirectionHelper.getForgeDirectionZApplyed(fd); - if(this.worldObj.getTileEntity(x, y, z) instanceof ITubeConnectable) { - ITubeConnectable tube = (ITubeConnectable)this.worldObj.getTileEntity(x, y, z); + TileEntity neighbour = this.worldObj.getTileEntity(x, y, z); // read once per side + if(neighbour instanceof ITubeConnectable) { + ITubeConnectable tube = (ITubeConnectable)neighbour; this.connectivity.put(fd, Boolean.valueOf(tube.canConnect(fd.getOpposite()))); if(((Boolean)this.connectivity.get(fd)).booleanValue()) { this.connectivityExtended.put(fd, Boolean.valueOf(tube.shouldExtendRenderingForTubes(fd.getOpposite()))); @@ -71,8 +72,8 @@ public class TileVisTube extends TileThaumcraft implements IMultiBlockPart, ITub this.connectivityExtended.put(fd, Boolean.valueOf(false)); } - if(this.worldObj.getTileEntity(x, y, z) instanceof ITubable) { - ITubable var12 = (ITubable)this.worldObj.getTileEntity(x, y, z); + if(neighbour instanceof ITubable) { + ITubable var12 = (ITubable)neighbour; if(var12.canConnect(fd.getOpposite()) && !(var12 instanceof TileVisTube)) { if(var12.canAccept(fd.getOpposite(), MagicType.VIS) && this.ejectVis(MagicType.VIS, var12.acceptVis(MagicType.VIS, this.grid.vis, fd.getOpposite()), fd) > 0) { ; @@ -95,7 +96,8 @@ public class TileVisTube extends TileThaumcraft implements IMultiBlockPart, ITub x = this.xCoord + ForgeDirectionHelper.getForgeDirectionXApplyed(fd); y = this.yCoord + ForgeDirectionHelper.getForgeDirectionYApplyed(fd); z = this.zCoord + ForgeDirectionHelper.getForgeDirectionZApplyed(fd); - TileVisTube var13 = this.world().getTileEntity(x, y, z) instanceof TileVisTube?(TileVisTube)this.world().getTileEntity(x, y, z):null; + TileEntity neighbour = this.world().getTileEntity(x, y, z); + TileVisTube var13 = neighbour instanceof TileVisTube?(TileVisTube)neighbour:null; if(var13 != null && var13.canConnect(fd.getOpposite())) { VisGrid grid0 = this.grid; VisGrid grid1 = var13.grid; diff --git a/src/main/java/com/pengu/thaumcraft/additions/playnet/packtetmng/PacketAuraVis.java b/src/main/java/com/pengu/thaumcraft/additions/playnet/packtetmng/PacketAuraVis.java index 31b3029..5aad14a 100644 --- a/src/main/java/com/pengu/thaumcraft/additions/playnet/packtetmng/PacketAuraVis.java +++ b/src/main/java/com/pengu/thaumcraft/additions/playnet/packtetmng/PacketAuraVis.java @@ -2,7 +2,6 @@ package com.pengu.thaumcraft.additions.playnet.packtetmng; import com.pengu.api.thaumicadditions.enums.EnumAT; import com.pengu.thaumcraft.additions.utils.hud.HUD; -import cpw.mods.fml.common.FMLLog; import cpw.mods.fml.common.network.simpleimpl.IMessage; import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; import cpw.mods.fml.common.network.simpleimpl.MessageContext; @@ -16,59 +15,68 @@ public class PacketAuraVis implements IMessage, IMessageHandler buf.readableBytes() / 4) { + throw new IllegalArgumentException("bad aura packet length " + n); + } + + return n; } public void toBytes(ByteBuf buf) { - buf.writeInt(this.amts.length); - int[] var2 = this.amts; - int var3 = var2.length; - - int var4; - for(var4 = 0; var4 < var3; ++var4) { - int a = var2[var4]; - buf.writeInt(a); - } - - buf.writeInt(this.aspects.length); - EnumAT[] var6 = this.aspects; - var3 = var6.length; - - for(var4 = 0; var4 < var3; ++var4) { - EnumAT var7 = var6[var4]; - buf.writeInt(var7.id); - } - + buf.writeInt(this.amts.length); + int[] var2 = this.amts; + int var3 = var2.length; + + int var4; + for(var4 = 0; var4 < var3; ++var4) { + int a = var2[var4]; + buf.writeInt(a); + } + + buf.writeInt(this.aspects.length); + EnumAT[] var6 = this.aspects; + var3 = var6.length; + + for(var4 = 0; var4 < var3; ++var4) { + EnumAT var7 = var6[var4]; + buf.writeInt(var7.id); + } + } } diff --git a/src/main/java/com/pengu/thaumcraft/additions/renderer/RendererDarkGen.java b/src/main/java/com/pengu/thaumcraft/additions/renderer/RendererDarkGen.java index 1c68fa1..b2923d9 100644 --- a/src/main/java/com/pengu/thaumcraft/additions/renderer/RendererDarkGen.java +++ b/src/main/java/com/pengu/thaumcraft/additions/renderer/RendererDarkGen.java @@ -10,16 +10,19 @@ import org.lwjgl.opengl.GL11; public class RendererDarkGen extends TileEntitySpecialRenderer { + private static final ResourceLocation TEXTURE = new ResourceLocation("thaumicadditions", "textures/models/DarkGen.png"); + private final ModelDarkGen modelDarkGen = new ModelDarkGen(); // one instance (each new one also compiled fresh display lists) + public void renderTileEntityAt(TileEntity te, double x, double y, double z, float par1float) { GL11.glPushMatrix(); GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F); - ResourceLocation textures = new ResourceLocation("thaumicadditions", "textures/models/DarkGen.png"); + ResourceLocation textures = TEXTURE; Minecraft.getMinecraft().renderEngine.bindTexture(textures); GL11.glPushMatrix(); GL11.glRotatef(180.0F, 0.0F, 0.0F, 1.0F); GL11.glPushMatrix(); GL11.glRotatef(0.0F, 0.0F, 1.0F, 0.0F); - (new ModelDarkGen()).render((Entity)null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F, false); + this.modelDarkGen.render((Entity)null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F, false); GL11.glPopMatrix(); GL11.glPopMatrix(); GL11.glPopMatrix(); diff --git a/src/main/java/com/pengu/thaumcraft/additions/renderer/RendererHyperNodeCreator.java b/src/main/java/com/pengu/thaumcraft/additions/renderer/RendererHyperNodeCreator.java index 748bfe1..7a2bd8a 100644 --- a/src/main/java/com/pengu/thaumcraft/additions/renderer/RendererHyperNodeCreator.java +++ b/src/main/java/com/pengu/thaumcraft/additions/renderer/RendererHyperNodeCreator.java @@ -11,16 +11,20 @@ import org.lwjgl.opengl.GL11; public class RendererHyperNodeCreator extends TileEntitySpecialRenderer { + private static final ResourceLocation TEXTURE_PRIMALS = new ResourceLocation("thaumicadditions", "textures/models/HyperNodeCreator_primals.png"); + private static final ResourceLocation TEXTURE_ALL = new ResourceLocation("thaumicadditions", "textures/models/HyperNodeCreator_all.png"); + private final ModelHyperNodeCreator modelHyperNodeCreator = new ModelHyperNodeCreator(); // one instance (each new one also compiled fresh display lists) + public void renderTileEntityAt(TileEntity te, double x, double y, double z, float par1float) { GL11.glPushMatrix(); GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F); - ResourceLocation textures = new ResourceLocation("thaumicadditions", "textures/models/HyperNodeCreator_" + (((TileHyperNodeCreator)te).primalsOnly?"primals":"all") + ".png"); + ResourceLocation textures = ((TileHyperNodeCreator)te).primalsOnly ? TEXTURE_PRIMALS : TEXTURE_ALL; Minecraft.getMinecraft().renderEngine.bindTexture(textures); GL11.glPushMatrix(); GL11.glRotatef(180.0F, 0.0F, 0.0F, 1.0F); GL11.glPushMatrix(); GL11.glRotatef(0.0F, 0.0F, 1.0F, 0.0F); - (new ModelHyperNodeCreator()).render((Entity)null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F, ((TileHyperNodeCreator)te).node); + this.modelHyperNodeCreator.render((Entity)null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F, ((TileHyperNodeCreator)te).node); GL11.glPopMatrix(); GL11.glPopMatrix(); GL11.glPopMatrix(); diff --git a/src/main/java/com/pengu/thaumcraft/additions/renderer/RendererInfuser.java b/src/main/java/com/pengu/thaumcraft/additions/renderer/RendererInfuser.java index 75413a0..5032f87 100644 --- a/src/main/java/com/pengu/thaumcraft/additions/renderer/RendererInfuser.java +++ b/src/main/java/com/pengu/thaumcraft/additions/renderer/RendererInfuser.java @@ -13,15 +13,21 @@ import org.lwjgl.opengl.GL11; public class RendererInfuser extends TileEntitySpecialRenderer { + private static final ResourceLocation TOP = new ResourceLocation("thaumicadditions", "textures/models/InfuserTop.png"); + private static final ResourceLocation TOP_DARK = new ResourceLocation("thaumicadditions", "textures/models/InfuserTopDark.png"); + private static final ResourceLocation SYMBOL = new ResourceLocation("thaumicadditions", "textures/models/infusersymbol.png"); + private static final ResourceLocation SYMBOL_DARK = new ResourceLocation("thaumicadditions", "textures/models/darkinfusersymbol.png"); + private final ModelTileInfuser modelTileInfuser = new ModelTileInfuser(); // one instance (each new one also compiled fresh display lists) + public void renderTileEntityAt(TileEntity te, double x, double y, double z, float par1float) { GL11.glPushMatrix(); GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F); - Minecraft.getMinecraft().renderEngine.bindTexture(new ResourceLocation("thaumicadditions", "textures/models/InfuserTop" + (te instanceof TileDarkInfuser?"Dark":"") + ".png")); + Minecraft.getMinecraft().renderEngine.bindTexture((te instanceof TileDarkInfuser ? TOP_DARK : TOP)); GL11.glPushMatrix(); GL11.glRotatef(180.0F, 0.0F, 0.0F, 1.0F); GL11.glPushMatrix(); GL11.glRotatef(0.0F, 0.0F, 1.0F, 0.0F); - (new ModelTileInfuser()).render((Entity)null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F, false); + this.modelTileInfuser.render((Entity)null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F, false); GL11.glPopMatrix(); GL11.glPopMatrix(); GL11.glPopMatrix(); @@ -33,7 +39,7 @@ public class RendererInfuser extends TileEntitySpecialRenderer { GL11.glTranslatef((float)x, (float)y + 0.5F - 0.2185F, (float)z); } - Minecraft.getMinecraft().renderEngine.bindTexture(new ResourceLocation("thaumicadditions", "textures/models/infusersymbol.png")); + Minecraft.getMinecraft().renderEngine.bindTexture(SYMBOL); if(inf.cookTime > 0) { GL11.glTranslatef((float)x + 0.5F, (float)y + 0.5F - 0.2185F, (float)z + 0.5F); GL11.glRotatef((float)Minecraft.getSystemTime() % 3600.0F / 10.0F, 0.0F, 1.0F, 0.0F); @@ -50,7 +56,7 @@ public class RendererInfuser extends TileEntitySpecialRenderer { GL11.glTranslatef((float)x, (float)y + 0.5F - 0.2185F, (float)z); } - Minecraft.getMinecraft().renderEngine.bindTexture(new ResourceLocation("thaumicadditions", "textures/models/darkinfusersymbol.png")); + Minecraft.getMinecraft().renderEngine.bindTexture(SYMBOL_DARK); if(inf1.cookTime + inf1.cookTimeTaint > 0) { GL11.glTranslatef((float)x + 0.5F, (float)y + 0.5F - 0.2185F, (float)z + 0.5F); GL11.glRotatef((float)Minecraft.getSystemTime() % 3600.0F / 10.0F, 0.0F, 1.0F, 0.0F); diff --git a/src/main/java/com/pengu/thaumcraft/additions/renderer/RendererInfuserActivator.java b/src/main/java/com/pengu/thaumcraft/additions/renderer/RendererInfuserActivator.java index fd6c3f7..3efe64c 100644 --- a/src/main/java/com/pengu/thaumcraft/additions/renderer/RendererInfuserActivator.java +++ b/src/main/java/com/pengu/thaumcraft/additions/renderer/RendererInfuserActivator.java @@ -13,10 +13,14 @@ import thaumcraft.client.renderers.item.ItemWandRenderer; public class RendererInfuserActivator extends TileEntitySpecialRenderer { + private static final ResourceLocation TEXTURE = new ResourceLocation("thaumicadditions", "textures/models/InfuserActivator.png"); + private final ModelInfuserActivator modelInfuserActivator = new ModelInfuserActivator(); // one instance (each new one also compiled fresh display lists) + private final ItemWandRenderer wandRenderer = new ItemWandRenderer(); + public void renderTileEntityAt(TileEntity te, double x, double y, double z, float par1float) { GL11.glPushMatrix(); GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F); - ResourceLocation textures = new ResourceLocation("thaumicadditions", "textures/models/InfuserActivator.png"); + ResourceLocation textures = TEXTURE; GL11.glPushMatrix(); GL11.glRotatef(180.0F, 0.0F, 0.0F, 1.0F); GL11.glPushMatrix(); @@ -28,13 +32,13 @@ public class RendererInfuserActivator extends TileEntitySpecialRenderer { float rot = te instanceof TileInfuserActivator?(float)((TileInfuserActivator)te).beforeclick:0.0F; rot = -rot; GL11.glTranslatef(0.0F, 1.4F + rot / 360.0F, 0.0F); - (new ItemWandRenderer()).renderItem(ItemRenderType.ENTITY, ((TileInfuserActivator)te).wandstack, new Object[0]); + this.wandRenderer.renderItem(ItemRenderType.ENTITY, ((TileInfuserActivator)te).wandstack, new Object[0]); GL11.glColor3f(1.0F, 1.0F, 1.0F); GL11.glEnable(2896); GL11.glPopMatrix(); GL11.glPopMatrix(); Minecraft.getMinecraft().renderEngine.bindTexture(textures); - (new ModelInfuserActivator()).render((Entity)null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F); + this.modelInfuserActivator.render((Entity)null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F); GL11.glPopMatrix(); GL11.glPopMatrix(); GL11.glPopMatrix(); diff --git a/src/main/java/com/pengu/thaumcraft/additions/renderer/RendererSeal.java b/src/main/java/com/pengu/thaumcraft/additions/renderer/RendererSeal.java index c788a17..c43a140 100644 --- a/src/main/java/com/pengu/thaumcraft/additions/renderer/RendererSeal.java +++ b/src/main/java/com/pengu/thaumcraft/additions/renderer/RendererSeal.java @@ -12,6 +12,10 @@ import org.lwjgl.opengl.GL11; public class RendererSeal extends TileEntitySpecialRenderer { + private static final ResourceLocation SEAL = new ResourceLocation("thaumicadditions", "textures/models/seal.png"); + private static final ResourceLocation SEAL_OVER = new ResourceLocation("thaumicadditions", "textures/models/seal_over.png"); + private final ModelSeal modelSeal = new ModelSeal(); // one instance (each new one also compiled fresh display lists) + ResourceLocation f0 = new ResourceLocation("thaumicadditions", "textures/blocks/seal_/s_0.png"); ResourceLocation f1 = new ResourceLocation("thaumicadditions", "textures/blocks/seal_/s_1.png"); ResourceLocation f2 = new ResourceLocation("thaumicadditions", "textures/blocks/seal_/s_2.png"); @@ -38,14 +42,14 @@ public class RendererSeal extends TileEntitySpecialRenderer { GL11.glTranslatef(1.0F / (ori == 5?256.0F:-256.0F), 2.32F, 0.0F); } - this.bindTexture(new ResourceLocation("thaumicadditions", "textures/models/seal.png")); - (new ModelSeal()).render((Entity)null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F, te.getBlockMetadata() < 6?ForgeDirection.OPPOSITES[te.getBlockMetadata()]:0); - this.bindTexture(new ResourceLocation("thaumicadditions", "textures/models/seal_over.png")); + this.bindTexture(SEAL); + this.modelSeal.render((Entity)null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F, te.getBlockMetadata() < 6?ForgeDirection.OPPOSITES[te.getBlockMetadata()]:0); + this.bindTexture(SEAL_OVER); float r0 = (float)(((TileSeal)te).color >> 16 & 255) / 255.0F; float g0 = (float)(((TileSeal)te).color >> 8 & 255) / 255.0F; float b0 = (float)(((TileSeal)te).color & 255) / 255.0F; GL11.glColor3f(r0, g0, b0); - (new ModelSeal()).render((Entity)null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F, te.getBlockMetadata() < 6?ForgeDirection.OPPOSITES[te.getBlockMetadata()]:0); + this.modelSeal.render((Entity)null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F, te.getBlockMetadata() < 6?ForgeDirection.OPPOSITES[te.getBlockMetadata()]:0); GL11.glPopMatrix(); GL11.glPushMatrix(); float r1; @@ -58,7 +62,7 @@ public class RendererSeal extends TileEntitySpecialRenderer { b1 = (float)(((TileSeal)te).f.getType().getColor() & 255) / 255.0F; GL11.glPushMatrix(); GL11.glColor3f(r1, g1, b1); - (new ModelSeal()).render((Entity)null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F, te.getBlockMetadata() < 6?ForgeDirection.OPPOSITES[te.getBlockMetadata()]:0); + this.modelSeal.render((Entity)null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F, te.getBlockMetadata() < 6?ForgeDirection.OPPOSITES[te.getBlockMetadata()]:0); GL11.glPopMatrix(); } @@ -69,7 +73,7 @@ public class RendererSeal extends TileEntitySpecialRenderer { b1 = (float)(((TileSeal)te).s.getType().getColor() & 255) / 255.0F; GL11.glPushMatrix(); GL11.glColor3f(r1, g1, b1); - (new ModelSeal()).render((Entity)null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F, te.getBlockMetadata() < 6?ForgeDirection.OPPOSITES[te.getBlockMetadata()]:0); + this.modelSeal.render((Entity)null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F, te.getBlockMetadata() < 6?ForgeDirection.OPPOSITES[te.getBlockMetadata()]:0); GL11.glPopMatrix(); } @@ -80,7 +84,7 @@ public class RendererSeal extends TileEntitySpecialRenderer { b1 = (float)(((TileSeal)te).t.getType().getColor() & 255) / 255.0F; GL11.glPushMatrix(); GL11.glColor3f(r1, g1, b1); - (new ModelSeal()).render((Entity)null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F, te.getBlockMetadata() < 6?ForgeDirection.OPPOSITES[te.getBlockMetadata()]:0); + this.modelSeal.render((Entity)null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F, te.getBlockMetadata() < 6?ForgeDirection.OPPOSITES[te.getBlockMetadata()]:0); GL11.glPopMatrix(); } diff --git a/src/main/java/com/pengu/thaumcraft/additions/renderer/RendererSymboller.java b/src/main/java/com/pengu/thaumcraft/additions/renderer/RendererSymboller.java index e106750..3b9d97d 100644 --- a/src/main/java/com/pengu/thaumcraft/additions/renderer/RendererSymboller.java +++ b/src/main/java/com/pengu/thaumcraft/additions/renderer/RendererSymboller.java @@ -11,16 +11,19 @@ import thaumcraft.common.tiles.TileJarFillable; public class RendererSymboller extends TileEntitySpecialRenderer { + private static final ResourceLocation TEXTURE = new ResourceLocation("thaumicadditions", "textures/models/TileSealSymboller.png"); + private final ModelTileSealSymboller modelTileSealSymboller = new ModelTileSealSymboller(); // one instance (each new one also compiled fresh display lists) + public void renderTileEntityAt(TileEntity te, double x, double y, double z, float floatt) { GL11.glPushMatrix(); GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F); - ResourceLocation textures = new ResourceLocation("thaumicadditions", "textures/models/TileSealSymboller.png"); + ResourceLocation textures = TEXTURE; Minecraft.getMinecraft().renderEngine.bindTexture(textures); GL11.glPushMatrix(); GL11.glRotatef(180.0F, 0.0F, 0.0F, 1.0F); GL11.glPushMatrix(); GL11.glRotatef(0.0F, 0.0F, 1.0F, 0.0F); - (new ModelTileSealSymboller()).render((Entity)null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F, te.getWorldObj().getTileEntity(te.xCoord, te.yCoord + 1, te.zCoord) != null && te.getWorldObj().getTileEntity(te.xCoord, te.yCoord + 1, te.zCoord) instanceof TileJarFillable); + this.modelTileSealSymboller.render((Entity)null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F, te.getWorldObj().getTileEntity(te.xCoord, te.yCoord + 1, te.zCoord) instanceof TileJarFillable); GL11.glPopMatrix(); GL11.glPopMatrix(); GL11.glPopMatrix(); diff --git a/src/main/java/com/pengu/thaumcraft/additions/renderer/RendererTankBasic.java b/src/main/java/com/pengu/thaumcraft/additions/renderer/RendererTankBasic.java index 723a40e..b811bb6 100644 --- a/src/main/java/com/pengu/thaumcraft/additions/renderer/RendererTankBasic.java +++ b/src/main/java/com/pengu/thaumcraft/additions/renderer/RendererTankBasic.java @@ -14,10 +14,18 @@ import org.lwjgl.opengl.GL11; public class RendererTankBasic extends TileEntitySpecialRenderer { + private static final ResourceLocation[] LIQUID_FRAMES = new ResourceLocation[16]; + static { + for(int i = 0; i < LIQUID_FRAMES.length; ++i) { + LIQUID_FRAMES[i] = new ResourceLocation("thaumicadditions", "textures/models/TankLiquid/" + i + ".png"); + } + } + private final ModelTankFill modelTankFill = new ModelTankFill(); // one instance (each new one also compiled fresh display lists) + public void renderTileEntityAt(TileEntity te, double x, double y, double z, float floatt) { GL11.glPushMatrix(); GL11.glTranslated(x + 0.5D, y + 0.001D, z + 0.5D); - Minecraft.getMinecraft().renderEngine.bindTexture(new ResourceLocation("thaumicadditions", "textures/models/TankLiquid/" + (int)(Minecraft.getSystemTime() % 1600L / 100L) + ".png")); + Minecraft.getMinecraft().renderEngine.bindTexture(LIQUID_FRAMES[(int)(Minecraft.getSystemTime() % 1600L / 100L)]); GL11.glPushMatrix(); GL11.glRotatef(180.0F, 0.0F, 0.0F, 1.0F); GL11.glPushMatrix(); @@ -29,7 +37,7 @@ public class RendererTankBasic extends TileEntitySpecialRenderer { Color mesh = ColorUtil.blend(new Color(VisGrid.visColor), new Color(VisGrid.taintColor)); GL11.glColor3f((float)mesh.getRed() / 255.0F, (float)mesh.getGreen() / 255.0F, (float)mesh.getBlue() / 255.0F); if(storedTot > 0.0F) { - (new ModelTankFill()).render((Entity)null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F); + this.modelTankFill.render((Entity)null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F); } } diff --git a/src/main/java/com/pengu/thaumcraft/additions/renderer/RendererThaumicCrystallizer.java b/src/main/java/com/pengu/thaumcraft/additions/renderer/RendererThaumicCrystallizer.java index fde31fd..f6e1bc5 100644 --- a/src/main/java/com/pengu/thaumcraft/additions/renderer/RendererThaumicCrystallizer.java +++ b/src/main/java/com/pengu/thaumcraft/additions/renderer/RendererThaumicCrystallizer.java @@ -2,7 +2,6 @@ package com.pengu.thaumcraft.additions.renderer; import com.pengu.thaumcraft.additions.init.All; import com.pengu.thaumcraft.additions.tileentity.TileThaumCrystallizer; -import java.awt.Color; import java.util.Random; import net.minecraft.client.Minecraft; import net.minecraft.client.entity.EntityClientPlayerMP; @@ -18,6 +17,8 @@ import thaumcraft.common.config.ConfigItems; public class RendererThaumicCrystallizer extends TileEntitySpecialRenderer { + private final ModelCrystal crystal = new ModelCrystal(); // one instance (each new one also compiled a fresh display list) + public void renderTileEntityAt(TileEntity te, double x, double y, double z, float par1float) { if(te instanceof TileThaumCrystallizer) { TileThaumCrystallizer t = (TileThaumCrystallizer)te; @@ -200,10 +201,9 @@ public class RendererThaumicCrystallizer extends TileEntitySpecialRenderer { private void drawCrystal(int ori, float x, float y, float z, float a1, float a2, Random rand, int color, float id) { EntityClientPlayerMP p = Minecraft.getMinecraft().thePlayer; float shade = MathHelper.sin((float)p.ticksExisted % (9.0E16F + id * 16.0F)) * 0.025F + 0.825F; - Color c = new Color(color); - float r = (float)c.getRed() / 220.0F; - float g = (float)c.getGreen() / 220.0F; - float b = (float)c.getBlue() / 220.0F; + float r = (float)(color >> 16 & 255) / 220.0F; + float g = (float)(color >> 8 & 255) / 220.0F; + float b = (float)(color & 255) / 220.0F; GL11.glPushMatrix(); GL11.glEnable(2977); GL11.glEnable(3042); @@ -218,7 +218,7 @@ public class RendererThaumicCrystallizer extends TileEntitySpecialRenderer { int var21 = var19 / 65536; OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float)var20 / 1.0F, (float)var21 / 1.0F); GL11.glColor4f(r, g, b, 1.0F); - (new ModelCrystal()).render(); + this.crystal.render(); GL11.glScalef(1.0F, 1.0F, 1.0F); GL11.glDisable('\u803a'); GL11.glDisable(3042); diff --git a/src/main/java/com/pengu/thaumcraft/additions/renderer/RendererThaumicGenerator.java b/src/main/java/com/pengu/thaumcraft/additions/renderer/RendererThaumicGenerator.java index 2b0150d..36d9be6 100644 --- a/src/main/java/com/pengu/thaumcraft/additions/renderer/RendererThaumicGenerator.java +++ b/src/main/java/com/pengu/thaumcraft/additions/renderer/RendererThaumicGenerator.java @@ -11,16 +11,19 @@ import org.lwjgl.opengl.GL11; public class RendererThaumicGenerator extends TileEntitySpecialRenderer { + private static final ResourceLocation TEXTURE = new ResourceLocation("thaumicadditions", "textures/models/ThaumicGenerator.png"); + private final ModelThaumicGenerator modelThaumicGenerator = new ModelThaumicGenerator(); // one instance (each new one also compiled fresh display lists) + public void renderTileEntityAt(TileEntity te, double x, double y, double z, float par1float) { GL11.glPushMatrix(); GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F); - ResourceLocation textures = new ResourceLocation("thaumicadditions", "textures/models/ThaumicGenerator.png"); + ResourceLocation textures = TEXTURE; Minecraft.getMinecraft().renderEngine.bindTexture(textures); GL11.glPushMatrix(); GL11.glRotatef(180.0F, 0.0F, 0.0F, 1.0F); GL11.glPushMatrix(); GL11.glRotatef(0.0F, 0.0F, 1.0F, 0.0F); - (new ModelThaumicGenerator()).render((Entity)null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F, ((TileThaumicGenerator)te).emitPowerFromSidesListedHere); + this.modelThaumicGenerator.render((Entity)null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F, ((TileThaumicGenerator)te).emitPowerFromSidesListedHere); GL11.glPopMatrix(); GL11.glPopMatrix(); GL11.glPopMatrix(); diff --git a/src/main/java/com/pengu/thaumcraft/additions/renderer/RendererThaumicRestorer.java b/src/main/java/com/pengu/thaumcraft/additions/renderer/RendererThaumicRestorer.java index 97911a0..2d22c1e 100644 --- a/src/main/java/com/pengu/thaumcraft/additions/renderer/RendererThaumicRestorer.java +++ b/src/main/java/com/pengu/thaumcraft/additions/renderer/RendererThaumicRestorer.java @@ -10,16 +10,19 @@ import org.lwjgl.opengl.GL11; public class RendererThaumicRestorer extends TileEntitySpecialRenderer { + private static final ResourceLocation TEXTURE = new ResourceLocation("thaumicadditions", "textures/models/ThaumicRestorer.png"); + private final ModelThaumicRestorer modelThaumicRestorer = new ModelThaumicRestorer(); // one instance (each new one also compiled fresh display lists) + public void renderTileEntityAt(TileEntity te, double x, double y, double z, float par1float) { GL11.glPushMatrix(); GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F); - Minecraft.getMinecraft().renderEngine.bindTexture(new ResourceLocation("thaumicadditions", "textures/models/ThaumicRestorer.png")); + Minecraft.getMinecraft().renderEngine.bindTexture(TEXTURE); GL11.glPushMatrix(); GL11.glRotatef(180.0F, 0.0F, 0.0F, 1.0F); GL11.glPushMatrix(); GL11.glRotatef(0.0F, 0.0F, 1.0F, 0.0F); GL11.glDisable(2896); - (new ModelThaumicRestorer()).render((Entity)null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F); + this.modelThaumicRestorer.render((Entity)null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F); GL11.glEnable(2896); GL11.glPopMatrix(); GL11.glPopMatrix(); diff --git a/src/main/java/com/pengu/thaumcraft/additions/tileentity/TileRendererCreativeNode.java b/src/main/java/com/pengu/thaumcraft/additions/tileentity/TileRendererCreativeNode.java index c58a50f..72d43c0 100644 --- a/src/main/java/com/pengu/thaumcraft/additions/tileentity/TileRendererCreativeNode.java +++ b/src/main/java/com/pengu/thaumcraft/additions/tileentity/TileRendererCreativeNode.java @@ -1,7 +1,6 @@ package com.pengu.thaumcraft.additions.tileentity; import com.pengu.thaumcraft.additions.tileentity.TileCreativeNode; -import java.util.Calendar; import java.util.Random; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.Tessellator; @@ -14,13 +13,19 @@ import org.lwjgl.opengl.GL11; public class TileRendererCreativeNode extends TileEntitySpecialRenderer { + private static final ResourceLocation[] AURA = new ResourceLocation[]{new ResourceLocation("thaumicadditions", "textures/models/aura_1.png"), new ResourceLocation("thaumicadditions", "textures/models/aura_2.png")}; + // Re-seeded per node each frame: setSeed gives the same sequence as new Random(seed) + private final Random rnd = new Random(); + public void renderTileEntityAt(TileEntity te, double x, double y, double z, float floay) { boolean wearsRevealer = false; ItemStack helmet = Minecraft.getMinecraft().thePlayer.inventory.armorItemInSlot(0); if(te instanceof TileCreativeNode) { TileCreativeNode tcn = (TileCreativeNode)te; - Random rnd = new Random((long)(tcn.getId() + "" + tcn.yCoord).hashCode() ^ 256L); - float rot = (float)(Calendar.getInstance().get(14) + rnd.nextInt(1000)) % 1000.0F; + Random rnd = this.rnd; + rnd.setSeed((long)(tcn.getId() + "" + tcn.yCoord).hashCode() ^ 256L); + // millisecond of the current second, as Calendar.getInstance().get(MILLISECOND) gave + float rot = (float)((int)(System.currentTimeMillis() % 1000L) + rnd.nextInt(1000)) % 1000.0F; boolean prevBlend = GL11.glIsEnabled(3042); if(!prevBlend) { GL11.glEnable(3042); @@ -31,7 +36,7 @@ public class TileRendererCreativeNode extends TileEntitySpecialRenderer { GL11.glTranslated(x + 0.5D, y + 0.15000000596046448D, z + 0.5D); GL11.glEnable('\u803a'); GL11.glScalef(1.5F, 1.5F, 1.5F); - Minecraft.getMinecraft().getTextureManager().bindTexture(new ResourceLocation("thaumicadditions", "textures/models/aura_" + (rnd.nextInt(2) + 1) + ".png")); + Minecraft.getMinecraft().getTextureManager().bindTexture(AURA[rnd.nextInt(2)]); Tessellator p_77026_1_ = Tessellator.instance; float f = 0.0F; float f1 = 1.0F; diff --git a/src/main/java/com/pengu/thaumcraft/additions/tileentity/TileThaumicGenerator.java b/src/main/java/com/pengu/thaumcraft/additions/tileentity/TileThaumicGenerator.java index 056da9d..c5318cd 100644 --- a/src/main/java/com/pengu/thaumcraft/additions/tileentity/TileThaumicGenerator.java +++ b/src/main/java/com/pengu/thaumcraft/additions/tileentity/TileThaumicGenerator.java @@ -10,11 +10,26 @@ import com.pengu.util.ForgeDirectionHelper; import cpw.mods.fml.common.Loader; import java.util.ArrayList; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.util.ForgeDirection; import thaumcraft.api.TileThaumcraft; public class TileThaumicGenerator extends TileThaumcraft implements ITubable { + private static final ForgeDirection[] DIRS = new ForgeDirection[]{ForgeDirection.UP, ForgeDirection.DOWN, ForgeDirection.EAST, ForgeDirection.WEST, ForgeDirection.SOUTH, ForgeDirection.NORTH}; + private static final boolean BOTANIA_LOADED = Loader.isModLoaded("Botania"); + private static Botania botania; + + // Botania bridge is stateless: one instance, created only when Botania is loaded + private static Botania botania() { + if(botania == null) { + botania = new Botania(); + } + + return botania; + } + + public int amount = 0; public int maxAmount = 640; public DirectionCombo emitPowerFromSidesListedHere; @@ -25,7 +40,7 @@ public class TileThaumicGenerator extends TileThaumcraft implements ITubable { } public void updateEntity() { - ForgeDirection[] dirs = new ForgeDirection[]{ForgeDirection.UP, ForgeDirection.DOWN, ForgeDirection.EAST, ForgeDirection.WEST, ForgeDirection.SOUTH, ForgeDirection.NORTH}; + ForgeDirection[] dirs = DIRS; this.maxAmount = 640; ArrayList fd = new ArrayList(); int i; @@ -59,31 +74,31 @@ public class TileThaumicGenerator extends TileThaumcraft implements ITubable { if(this.amount > 1) { for(i = 0; i < dirs.length; ++i) { - if(this.worldObj.getTileEntity(this.xCoord + ForgeDirectionHelper.getForgeDirectionXApplyed(dirs[i]), this.yCoord + ForgeDirectionHelper.getForgeDirectionYApplyed(dirs[i]), this.zCoord + ForgeDirectionHelper.getForgeDirectionZApplyed(dirs[i])) != null) { - if(this.worldObj.getTileEntity(this.xCoord + ForgeDirectionHelper.getForgeDirectionXApplyed(dirs[i]), this.yCoord + ForgeDirectionHelper.getForgeDirectionYApplyed(dirs[i]), this.zCoord + ForgeDirectionHelper.getForgeDirectionZApplyed(dirs[i])) instanceof IRJReceiver) { + // one tile lookup per side (it was read up to nine times) + TileEntity te = this.worldObj.getTileEntity(this.xCoord + ForgeDirectionHelper.getForgeDirectionXApplyed(dirs[i]), this.yCoord + ForgeDirectionHelper.getForgeDirectionYApplyed(dirs[i]), this.zCoord + ForgeDirectionHelper.getForgeDirectionZApplyed(dirs[i])); + if(te != null) { + if(te instanceof IRJReceiver) { fd.add(dirs[i]); } - if(this.worldObj.getTileEntity(this.xCoord + ForgeDirectionHelper.getForgeDirectionXApplyed(dirs[i]), this.yCoord + ForgeDirectionHelper.getForgeDirectionYApplyed(dirs[i]), this.zCoord + ForgeDirectionHelper.getForgeDirectionZApplyed(dirs[i])) instanceof IEnergyReceiver) { + if(te instanceof IEnergyReceiver) { fd.add(dirs[i]); } - if(Loader.isModLoaded("Botania") && (new Botania()).canConnect(this.worldObj, this.xCoord, this.yCoord, this.zCoord, dirs[i])) { + if(BOTANIA_LOADED && botania().canConnect(this.worldObj, this.xCoord, this.yCoord, this.zCoord, dirs[i])) { fd.add(dirs[i]); } - } - if(this.worldObj.getTileEntity(this.xCoord + ForgeDirectionHelper.getForgeDirectionXApplyed(dirs[i]), this.yCoord + ForgeDirectionHelper.getForgeDirectionYApplyed(dirs[i]), this.zCoord + ForgeDirectionHelper.getForgeDirectionZApplyed(dirs[i])) != null) { - if(this.worldObj.getTileEntity(this.xCoord + ForgeDirectionHelper.getForgeDirectionXApplyed(dirs[i]), this.yCoord + ForgeDirectionHelper.getForgeDirectionYApplyed(dirs[i]), this.zCoord + ForgeDirectionHelper.getForgeDirectionZApplyed(dirs[i])) instanceof IRJReceiver) { - this.amount -= ((IRJReceiver)this.worldObj.getTileEntity(this.xCoord + ForgeDirectionHelper.getForgeDirectionXApplyed(dirs[i]), this.yCoord + ForgeDirectionHelper.getForgeDirectionYApplyed(dirs[i]), this.zCoord + ForgeDirectionHelper.getForgeDirectionZApplyed(dirs[i]))).receiveRJ(dirs[i], 2000, false) / 1000; + if(te instanceof IRJReceiver) { + this.amount -= ((IRJReceiver)te).receiveRJ(dirs[i], 2000, false) / 1000; } - if(this.worldObj.getTileEntity(this.xCoord + ForgeDirectionHelper.getForgeDirectionXApplyed(dirs[i]), this.yCoord + ForgeDirectionHelper.getForgeDirectionYApplyed(dirs[i]), this.zCoord + ForgeDirectionHelper.getForgeDirectionZApplyed(dirs[i])) instanceof IEnergyReceiver) { - this.amount -= ((IEnergyReceiver)this.worldObj.getTileEntity(this.xCoord + ForgeDirectionHelper.getForgeDirectionXApplyed(dirs[i]), this.yCoord + ForgeDirectionHelper.getForgeDirectionYApplyed(dirs[i]), this.zCoord + ForgeDirectionHelper.getForgeDirectionZApplyed(dirs[i]))).receiveEnergy(dirs[i], 2000, false) / 1000; + if(te instanceof IEnergyReceiver) { + this.amount -= ((IEnergyReceiver)te).receiveEnergy(dirs[i], 2000, false) / 1000; } - if(Loader.isModLoaded("Botania")) { - this.amount -= (new Botania()).handleManaGen(this.worldObj, this.xCoord, this.yCoord, this.zCoord, dirs[i], 2000) / 100; + if(BOTANIA_LOADED) { + this.amount -= botania().handleManaGen(this.worldObj, this.xCoord, this.yCoord, this.zCoord, dirs[i], 2000) / 100; } } } diff --git a/src/main/java/com/pengu/thaumcraft/additions/tileentity/TileTileBooster.java b/src/main/java/com/pengu/thaumcraft/additions/tileentity/TileTileBooster.java index e0d3375..dafeb14 100644 --- a/src/main/java/com/pengu/thaumcraft/additions/tileentity/TileTileBooster.java +++ b/src/main/java/com/pengu/thaumcraft/additions/tileentity/TileTileBooster.java @@ -24,8 +24,8 @@ public class TileTileBooster extends TileThaumcraft { int x = this.xCoord + ForgeDirectionHelper.getForgeDirectionXApplyed(fd); int y = this.yCoord + ForgeDirectionHelper.getForgeDirectionYApplyed(fd); int z = this.zCoord + ForgeDirectionHelper.getForgeDirectionZApplyed(fd); - TileEntity te = this.worldObj.getTileEntity(x, y, z) != null && !(this.worldObj.getTileEntity(x, y, z) instanceof TileTileBooster)?this.worldObj.getTileEntity(x, y, z):null; - if(te != null && te.canUpdate()) { + TileEntity te = this.worldObj.getTileEntity(x, y, z); // read once (was up to three times) + if(te != null && !(te instanceof TileTileBooster) && te.canUpdate()) { for(int i = 0; i < this.speed; ++i) { te.updateEntity(); }