From 5f496a00ec16cdddb268fa23668fc6438d314a67 Mon Sep 17 00:00:00 2001 From: Aidan Brady Date: Fri, 5 Apr 2013 16:26:48 -0400 Subject: [PATCH] v5.5.4 Beta #6 *A new model for the Metallurgic Infuser. *Fixed and made better the auto-updater. *Reverted to LiquidSlot-based tank on the Bio-Generator. *Sustained liquid in the Electrolytic Separator and Electric Pump. *Better liquid cleanups. Still need to add recipe for Electric Pump! --- .../mods/mekanism/render/ElectricPump.png | Bin 0 -> 2343 bytes .../mekanism/render/MetallurgicInfuser.png | Bin 0 -> 4344 bytes .../client/BlockRenderingHandler.java | 18 ++ .../mekanism/client/ClientProxy.java | 2 + src/minecraft/mekanism/client/GuiCredits.java | 40 +++- .../mekanism/client/GuiElectricPump.java | 14 +- .../mekanism/client/ModelElectricPump.java | 187 +++++++++++++++++ .../client/ModelMetallurgicInfuser.java | 193 ++++++++++++++++++ .../mekanism/client/ModelTransmitter.java | 6 - .../mekanism/client/RenderElectricPump.java | 29 +++ .../client/RenderMetallurgicInfuser.java | 38 ++++ .../mekanism/client/ThreadClientUpdate.java | 19 +- .../mekanism/common/BlockMachine.java | 37 ++-- .../mekanism/common/CommonProxy.java | 2 + .../mekanism/common/ISustainedTank.java | 34 +++ .../mekanism/common/ItemBlockMachine.java | 68 +++++- src/minecraft/mekanism/common/Mekanism.java | 9 +- .../mekanism/common/MekanismUtils.java | 13 +- .../common/TileEntityElectricPump.java | 56 +++-- .../generators/client/GuiBioGenerator.java | 4 +- .../generators/common/BlockGenerator.java | 16 +- .../generators/common/ItemBlockGenerator.java | 72 ++++++- .../generators/common/MekanismGenerators.java | 3 + .../common/TileEntityBioGenerator.java | 179 +++++++--------- .../TileEntityElectrolyticSeparator.java | 27 ++- .../common/TileEntityHydrogenGenerator.java | 4 +- .../mekanism/tools/common/MekanismTools.java | 3 + 27 files changed, 886 insertions(+), 187 deletions(-) create mode 100644 bin/minecraft/mods/mekanism/render/ElectricPump.png create mode 100644 bin/minecraft/mods/mekanism/render/MetallurgicInfuser.png create mode 100644 src/minecraft/mekanism/client/ModelElectricPump.java create mode 100644 src/minecraft/mekanism/client/ModelMetallurgicInfuser.java create mode 100644 src/minecraft/mekanism/client/RenderElectricPump.java create mode 100644 src/minecraft/mekanism/client/RenderMetallurgicInfuser.java create mode 100644 src/minecraft/mekanism/common/ISustainedTank.java diff --git a/bin/minecraft/mods/mekanism/render/ElectricPump.png b/bin/minecraft/mods/mekanism/render/ElectricPump.png new file mode 100644 index 0000000000000000000000000000000000000000..0cf809d596ad44bf10dd9cdc40400dada229cf03 GIT binary patch literal 2343 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 P(Ex%2!u%V5jX(QeKG9Mo literal 0 HcmV?d00001 diff --git a/src/minecraft/mekanism/client/BlockRenderingHandler.java b/src/minecraft/mekanism/client/BlockRenderingHandler.java index 1ed33fc43..b90a51a55 100644 --- a/src/minecraft/mekanism/client/BlockRenderingHandler.java +++ b/src/minecraft/mekanism/client/BlockRenderingHandler.java @@ -15,6 +15,8 @@ import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; public class BlockRenderingHandler implements ISimpleBlockRenderingHandler { public ModelTheoreticalElementizer theoreticalElementizer = new ModelTheoreticalElementizer(); + public ModelElectricPump electricPump = new ModelElectricPump(); + public ModelMetallurgicInfuser metallurgicInfuser = new ModelMetallurgicInfuser(); @Override public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) @@ -32,6 +34,22 @@ public class BlockRenderingHandler implements ISimpleBlockRenderingHandler GL11.glBindTexture(3553, FMLClientHandler.instance().getClient().renderEngine.getTexture("/mods/mekanism/render/TheoreticalElementizer.png")); theoreticalElementizer.render(0.0560F); } + else if(metadata == MachineType.ELECTRIC_PUMP.meta) + { + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); + GL11.glRotatef(90F, 0.0F, -1.0F, 0.0F); + GL11.glTranslated(0.0F, -0.9F, 0.0F); + GL11.glBindTexture(3553, FMLClientHandler.instance().getClient().renderEngine.getTexture("/mods/mekanism/render/ElectricPump.png")); + electricPump.render(0.0560F); + } + else if(metadata == MachineType.METALLURGIC_INFUSER.meta) + { + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); + GL11.glRotatef(270F, 0.0F, -1.0F, 0.0F); + GL11.glTranslated(0.0F, 0.3F, 0.0F); + GL11.glBindTexture(3553, FMLClientHandler.instance().getClient().renderEngine.getTexture("/mods/mekanism/render/MetallurgicInfuser.png")); + metallurgicInfuser.render(0.0625F); + } else { renderItem(renderer, metadata, block); } diff --git a/src/minecraft/mekanism/client/ClientProxy.java b/src/minecraft/mekanism/client/ClientProxy.java index 0fa519fad..8d18a80e6 100644 --- a/src/minecraft/mekanism/client/ClientProxy.java +++ b/src/minecraft/mekanism/client/ClientProxy.java @@ -59,8 +59,10 @@ public class ClientProxy extends CommonProxy public void registerSpecialTileEntities() { ClientRegistry.registerTileEntity(TileEntityTheoreticalElementizer.class, "TheoreticalElementizer", new RenderTheoreticalElementizer()); + ClientRegistry.registerTileEntity(TileEntityMetallurgicInfuser.class, "MetallurgicInfuser", new RenderMetallurgicInfuser()); ClientRegistry.registerTileEntity(TileEntityPressurizedTube.class, "PressurizedTube", new RenderPressurizedTube()); ClientRegistry.registerTileEntity(TileEntityUniversalCable.class, "UniversalCable", new RenderUniversalCable()); + ClientRegistry.registerTileEntity(TileEntityElectricPump.class, "ElectricPump", new RenderElectricPump()); } @Override diff --git a/src/minecraft/mekanism/client/GuiCredits.java b/src/minecraft/mekanism/client/GuiCredits.java index dc1f1ccbc..fb6688b48 100644 --- a/src/minecraft/mekanism/client/GuiCredits.java +++ b/src/minecraft/mekanism/client/GuiCredits.java @@ -1,5 +1,6 @@ package mekanism.client; +import cpw.mods.fml.common.Loader; import mekanism.api.EnumColor; import mekanism.common.Mekanism; import mekanism.common.MekanismUtils; @@ -9,6 +10,8 @@ import net.minecraft.client.gui.GuiScreen; public class GuiCredits extends GuiScreen { private static String updateProgress = ""; + private boolean updatedRecently; + private boolean notified = false; @Override public void initGui() @@ -16,18 +19,14 @@ public class GuiCredits extends GuiScreen buttonList.clear(); buttonList.add(new GuiButton(0, width / 2 - 100, height / 4 + 72 + 12, "Update")); buttonList.add(new GuiButton(1, width / 2 - 100, height / 4 + 96 + 12, "Cancel")); - ((GuiButton)buttonList.get(0)).enabled = !MekanismUtils.isNotOutdated(); - } - - @Override - public void onGuiClosed() - { - updateProgress = ""; + ((GuiButton)buttonList.get(0)).enabled = !MekanismUtils.isNotOutdated() && !ThreadClientUpdate.hasUpdated; } public static void onFinishedDownloading() { updateProgress = "Successfully updated. Restart Minecraft to load."; + System.out.println("[Mekanism] Successfully updated to latest version (" + Mekanism.latestVersionNumber + ")."); + ThreadClientUpdate.hasUpdated = true; } public static void onErrorDownloading() @@ -46,11 +45,21 @@ public class GuiCredits extends GuiScreen { if(!MekanismUtils.isNotOutdated()) { + updatedRecently = true; updateProgress = "Downloading latest version..."; guibutton.enabled = false; + new ThreadClientUpdate("http://dl.dropbox.com/u/90411166/Mekanism-v" + Mekanism.latestVersionNumber + ".jar", 0); - new ThreadClientUpdate("http://dl.dropbox.com/u/90411166/MekanismGenerators-v" + Mekanism.latestVersionNumber + ".jar", 1); - new ThreadClientUpdate("http://dl.dropbox.com/u/90411166/MekanismTools-v" + Mekanism.latestVersionNumber + ".jar", 2); + + if(Loader.isModLoaded("MekanismGenerators")) + { + new ThreadClientUpdate("http://dl.dropbox.com/u/90411166/MekanismGenerators-v" + Mekanism.latestVersionNumber + ".jar", 1); + } + + if(Loader.isModLoaded("MekanismTools")) + { + new ThreadClientUpdate("http://dl.dropbox.com/u/90411166/MekanismTools-v" + Mekanism.latestVersionNumber + ".jar", 2); + } } else { updateProgress = "You already have the latest version."; @@ -76,6 +85,19 @@ public class GuiCredits extends GuiScreen @Override public void drawScreen(int i, int j, float f) { + if(updatedRecently && ThreadClientUpdate.modulesBeingDownloaded == 0 && !updateProgress.contains("Error")) + { + if(!notified) + { + onFinishedDownloading(); + notified = true; + } + } + else if(ThreadClientUpdate.hasUpdated && !notified) + { + updateProgress = "You have already downloaded the update. Restart MC!"; + } + drawDefaultBackground(); drawCenteredString(fontRenderer, EnumColor.DARK_BLUE + "Mekanism" + EnumColor.GREY + " by aidancbrady", width / 2, (height / 4 - 60) + 20, 0xffffff); writeText(EnumColor.GREY + "Your version: " + (MekanismUtils.isNotOutdated() ? Mekanism.versionNumber : EnumColor.DARK_RED + Mekanism.versionNumber.toString() + EnumColor.GREY + " -- OUTDATED"), 36); diff --git a/src/minecraft/mekanism/client/GuiElectricPump.java b/src/minecraft/mekanism/client/GuiElectricPump.java index 4fbf3e1ae..52a3f203c 100644 --- a/src/minecraft/mekanism/client/GuiElectricPump.java +++ b/src/minecraft/mekanism/client/GuiElectricPump.java @@ -23,15 +23,23 @@ public class GuiElectricPump extends GuiContainer super(new ContainerElectricPump(inventory, tentity)); tileEntity = tentity; } - + @Override - protected void drawGuiContainerForegroundLayer(int par1, int par2) + protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); + fontRenderer.drawString(tileEntity.fullName, 45, 6, 0x404040); fontRenderer.drawString("Inventory", 8, (ySize - 94) + 2, 0x404040); fontRenderer.drawString(ElectricityDisplay.getDisplayShort(tileEntity.electricityStored, ElectricUnit.JOULES), 51, 26, 0x00CD00); fontRenderer.drawString(tileEntity.liquidTank.getLiquid() != null ? tileEntity.liquidTank.getLiquidName() + ": " + tileEntity.liquidTank.getLiquid().amount : "No liquid.", 51, 35, 0x00CD00); fontRenderer.drawString(tileEntity.getVoltage() + "v", 51, 44, 0x00CD00); + + if(xAxis >= 7 && xAxis <= 23 && yAxis >= 14 && yAxis <= 72) + { + drawCreativeTabHoveringText(tileEntity.liquidTank.getLiquid() != null ? tileEntity.liquidTank.getLiquidName() + ": " + tileEntity.liquidTank.getLiquid().amount + "mB" : "Empty", xAxis, yAxis); + } } @Override @@ -81,7 +89,7 @@ public class GuiElectricPump extends GuiContainer mc.renderEngine.bindTexture(liquid.canonical().getTextureSheet()); drawTexturedModelRectFromIcon(width + yPos, height + xPos + 58 - renderRemaining - start, liquid.canonical().getRenderingIcon(), 16, 16 - (16 - renderRemaining)); - start = start + 16; + start+=16; if(renderRemaining == 0 || scale == 0) { diff --git a/src/minecraft/mekanism/client/ModelElectricPump.java b/src/minecraft/mekanism/client/ModelElectricPump.java new file mode 100644 index 000000000..528e54385 --- /dev/null +++ b/src/minecraft/mekanism/client/ModelElectricPump.java @@ -0,0 +1,187 @@ +package mekanism.client; + +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.model.ModelRenderer; +import net.minecraft.entity.Entity; + +public class ModelElectricPump extends ModelBase +{ + ModelRenderer COREBOX; + ModelRenderer INPUTSLOT2; + ModelRenderer INPUTSLOT3; + ModelRenderer INPUTSLOT4; + ModelRenderer INPUTSLOT5; + ModelRenderer INPUTSLOT1; + ModelRenderer PIPE3; + ModelRenderer PIPE2; + ModelRenderer TOPPIPE3; + ModelRenderer PIPE1; + ModelRenderer CORESLOT; + ModelRenderer PIPE4; + ModelRenderer TOPPIPE2; + ModelRenderer DISPLAY2; + ModelRenderer TOPPIPE1; + ModelRenderer TOPPIPE4; + ModelRenderer DISPLAY1; + + public ModelElectricPump() + { + textureWidth = 128; + textureHeight = 128; + + COREBOX = new ModelRenderer(this, 0, 0); + COREBOX.addBox(0F, 0F, 0F, 12, 12, 12); + COREBOX.setRotationPoint(-6F, 10F, -6F); + COREBOX.setTextureSize(128, 128); + COREBOX.mirror = true; + setRotation(COREBOX, 0F, 0F, 0F); + INPUTSLOT2 = new ModelRenderer(this, 0, 24); + INPUTSLOT2.addBox(0F, 0F, 0F, 2, 6, 6); + INPUTSLOT2.setRotationPoint(6F, 13F, -3F); + INPUTSLOT2.setTextureSize(128, 128); + INPUTSLOT2.mirror = true; + setRotation(INPUTSLOT2, 0F, 0F, 0F); + INPUTSLOT3 = new ModelRenderer(this, 16, 24); + INPUTSLOT3.addBox(0F, 0F, 0F, 6, 6, 2); + INPUTSLOT3.setRotationPoint(-3F, 13F, 6F); + INPUTSLOT3.setTextureSize(128, 128); + INPUTSLOT3.mirror = true; + setRotation(INPUTSLOT3, 0F, 0F, 0F); + INPUTSLOT4 = new ModelRenderer(this, 16, 24); + INPUTSLOT4.addBox(0F, 0F, 0F, 6, 6, 2); + INPUTSLOT4.setRotationPoint(-3F, 13F, -8F); + INPUTSLOT4.setTextureSize(128, 128); + INPUTSLOT4.mirror = true; + setRotation(INPUTSLOT4, 0F, 0F, 0F); + INPUTSLOT5 = new ModelRenderer(this, 0, 44); + INPUTSLOT5.addBox(0F, 0F, 0F, 6, 2, 6); + INPUTSLOT5.setRotationPoint(-3F, 22F, -3F); + INPUTSLOT5.setTextureSize(128, 128); + INPUTSLOT5.mirror = true; + setRotation(INPUTSLOT5, 0F, 0F, 0F); + INPUTSLOT1 = new ModelRenderer(this, 0, 24); + INPUTSLOT1.addBox(0F, 0F, 0F, 2, 6, 6); + INPUTSLOT1.setRotationPoint(-8F, 13F, -3F); + INPUTSLOT1.setTextureSize(128, 128); + INPUTSLOT1.mirror = true; + setRotation(INPUTSLOT1, 0F, 0F, 0F); + PIPE3 = new ModelRenderer(this, 48, 0); + PIPE3.addBox(0F, 0F, 0F, 2, 4, 1); + PIPE3.setRotationPoint(-1F, 9F, 6F); + PIPE3.setTextureSize(128, 128); + PIPE3.mirror = true; + setRotation(PIPE3, 0F, 0F, 0F); + PIPE2 = new ModelRenderer(this, 54, 0); + PIPE2.addBox(0F, 0F, 0F, 1, 4, 2); + PIPE2.setRotationPoint(6F, 9F, -1F); + PIPE2.setTextureSize(128, 128); + PIPE2.mirror = true; + setRotation(PIPE2, 0F, 0F, 0F); + TOPPIPE3 = new ModelRenderer(this, 60, 6); + TOPPIPE3.addBox(0F, 0F, 0F, 2, 1, 3); + TOPPIPE3.setRotationPoint(-1F, 9F, 3F); + TOPPIPE3.setTextureSize(128, 128); + TOPPIPE3.mirror = true; + setRotation(TOPPIPE3, 0F, 0F, 0F); + PIPE1 = new ModelRenderer(this, 54, 0); + PIPE1.addBox(0F, 0F, 0F, 1, 4, 2); + PIPE1.setRotationPoint(-7F, 9F, -1F); + PIPE1.setTextureSize(128, 128); + PIPE1.mirror = true; + setRotation(PIPE1, 0F, 0F, 0F); + CORESLOT = new ModelRenderer(this, 0, 52); + CORESLOT.addBox(0F, 0F, 0F, 6, 2, 6); + CORESLOT.setRotationPoint(-3F, 8F, -3F); + CORESLOT.setTextureSize(128, 128); + CORESLOT.mirror = true; + setRotation(CORESLOT, 0F, 0F, 0F); + PIPE4 = new ModelRenderer(this, 48, 0); + PIPE4.addBox(0F, 0F, 0F, 2, 4, 1); + PIPE4.setRotationPoint(-1F, 9F, -7F); + PIPE4.setTextureSize(128, 128); + PIPE4.mirror = true; + setRotation(PIPE4, 0F, 0F, 0F); + TOPPIPE2 = new ModelRenderer(this, 60, 0); + TOPPIPE2.addBox(0F, 0F, 0F, 3, 1, 2); + TOPPIPE2.setRotationPoint(3F, 9F, -1F); + TOPPIPE2.setTextureSize(128, 128); + TOPPIPE2.mirror = true; + setRotation(TOPPIPE2, 0F, 0F, 0F); + DISPLAY2 = new ModelRenderer(this, 70, 0); + DISPLAY2.addBox(-4F, 0F, 0F, 3, 1, 10); + DISPLAY2.setRotationPoint(6F, 9F, -5F); + DISPLAY2.setTextureSize(128, 128); + DISPLAY2.mirror = true; + setRotation(DISPLAY2, 0F, 0F, 0F); + TOPPIPE1 = new ModelRenderer(this, 60, 0); + TOPPIPE1.addBox(0F, 0F, 0F, 3, 1, 2); + TOPPIPE1.setRotationPoint(-6F, 9F, -1F); + TOPPIPE1.setTextureSize(128, 128); + TOPPIPE1.mirror = true; + setRotation(TOPPIPE1, 0F, 0F, 0F); + TOPPIPE4 = new ModelRenderer(this, 60, 6); + TOPPIPE4.addBox(0F, 0F, 0F, 2, 1, 3); + TOPPIPE4.setRotationPoint(-1F, 9F, -6F); + TOPPIPE4.setTextureSize(128, 128); + TOPPIPE4.mirror = true; + setRotation(TOPPIPE4, 0F, 0F, 0F); + DISPLAY1 = new ModelRenderer(this, 70, 0); + DISPLAY1.addBox(-4F, 0F, 0F, 3, 1, 10); + DISPLAY1.setRotationPoint(-1F, 9F, -5F); + DISPLAY1.setTextureSize(128, 128); + DISPLAY1.mirror = true; + setRotation(DISPLAY1, 0F, 0F, 0F); + } + + public void render(float size) + { + COREBOX.render(size); + INPUTSLOT2.render(size); + INPUTSLOT3.render(size); + INPUTSLOT4.render(size); + INPUTSLOT5.render(size); + INPUTSLOT1.render(size); + PIPE3.render(size); + PIPE2.render(size); + TOPPIPE3.render(size); + PIPE1.render(size); + CORESLOT.render(size); + PIPE4.render(size); + TOPPIPE2.render(size); + DISPLAY2.render(size); + TOPPIPE1.render(size); + TOPPIPE4.render(size); + DISPLAY1.render(size); + } + + @Override + public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) + { + super.render(entity, f, f1, f2, f3, f4, f5); + setRotationAngles(f, f1, f2, f3, f4, f5, entity); + COREBOX.render(f5); + INPUTSLOT2.render(f5); + INPUTSLOT3.render(f5); + INPUTSLOT4.render(f5); + INPUTSLOT5.render(f5); + INPUTSLOT1.render(f5); + PIPE3.render(f5); + PIPE2.render(f5); + TOPPIPE3.render(f5); + PIPE1.render(f5); + CORESLOT.render(f5); + PIPE4.render(f5); + TOPPIPE2.render(f5); + DISPLAY2.render(f5); + TOPPIPE1.render(f5); + TOPPIPE4.render(f5); + DISPLAY1.render(f5); + } + + private void setRotation(ModelRenderer model, float x, float y, float z) + { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } +} \ No newline at end of file diff --git a/src/minecraft/mekanism/client/ModelMetallurgicInfuser.java b/src/minecraft/mekanism/client/ModelMetallurgicInfuser.java new file mode 100644 index 000000000..4515bfcbb --- /dev/null +++ b/src/minecraft/mekanism/client/ModelMetallurgicInfuser.java @@ -0,0 +1,193 @@ +package mekanism.client; + +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.model.ModelRenderer; +import net.minecraft.entity.Entity; + +public class ModelMetallurgicInfuser extends ModelBase +{ + public ModelRenderer PANEL; + public ModelRenderer MACHINE; + public ModelRenderer CENTER_CIRCUIT; + public ModelRenderer PIPE_1; + public ModelRenderer PIPE_2; + public ModelRenderer GUI_STAND; + public ModelRenderer GUI_SCREEN; + public ModelRenderer PIPE_2_TOP; + public ModelRenderer PIPE_1_TOP; + public ModelRenderer FRONT_PANEL; + public ModelRenderer WIRE_1; + public ModelRenderer WIRE_2; + public ModelRenderer SIDE_WIRE_1; + public ModelRenderer SIDE_WIRE_2; + public ModelRenderer VERTICAL_WIRE; + public ModelRenderer TUBE; + + public ModelMetallurgicInfuser() + { + textureWidth = 256; + textureHeight = 256; + + PANEL = new ModelRenderer(this, 0, 0); + PANEL.addBox(-8.0F, -0.5F, -8.0F, 16, 1, 16, 0); + PANEL.setRotationPoint(0.0F, -0.5F, 0.0F); + PANEL.setTextureSize(256, 256); + PANEL.mirror = true; + setRotation(PANEL, 0F, 0F, 0F); + + MACHINE = new ModelRenderer(this, 80, 0); + MACHINE.addBox(-4.0F, -5.0F, -4.0F, 8, 10, 8, 0); + MACHINE.setRotationPoint(2.0F, -6.0F, 0.0F); + MACHINE.setTextureSize(256, 256); + MACHINE.mirror = true; + setRotation(MACHINE, 0F, 0F, 0F); + + CENTER_CIRCUIT = new ModelRenderer(this, 64, 0); + CENTER_CIRCUIT.addBox(-2.0F, -0.5F, -2.0F, 4, 1, 4, 0); + CENTER_CIRCUIT.setRotationPoint(2.0F, -11.5F, 0.0F); + CENTER_CIRCUIT.setTextureSize(256, 256); + CENTER_CIRCUIT.mirror = true; + setRotation(CENTER_CIRCUIT, 0F, 0F, 0F); + + PIPE_1 = new ModelRenderer(this, 0, 32); + PIPE_1.addBox(-1.0F, -5.5F, -0.5F, 2, 11, 1, 0); + PIPE_1.setRotationPoint(2.0F, -6.0F, -4.5F); + PIPE_1.setTextureSize(256, 256); + PIPE_1.mirror = true; + setRotation(PIPE_1, 0F, 0F, 0F); + + PIPE_2 = new ModelRenderer(this, 0, 32); + PIPE_2.addBox(-1.0F, -5.5F, -0.5F, 2, 11, 1, 0); + PIPE_2.setRotationPoint(2.0F, -6.0F, 4.5F); + PIPE_2.setTextureSize(256, 256); + PIPE_2.mirror = true; + setRotation(PIPE_2, 0F, 0F, 0F); + + GUI_STAND = new ModelRenderer(this, 32, 32); + GUI_STAND.addBox(-0.5F, -3.5F, -0.5F, 1, 7, 1, 0); + GUI_STAND.setRotationPoint(-5.0F, -4.5F, 0.0F); + GUI_STAND.setTextureSize(256, 256); + GUI_STAND.mirror = true; + setRotation(GUI_STAND, 0F, 0F, 0F); + + GUI_SCREEN = new ModelRenderer(this, 48, 32); + GUI_SCREEN.addBox(-1.5F, -0.5F, -3.0F, 3, 1, 6, 0); + GUI_SCREEN.setRotationPoint(-5.0F, -8.0F, 0.0F); + GUI_SCREEN.setTextureSize(256, 256); + GUI_SCREEN.mirror = true; + setRotation(GUI_SCREEN, 0F, 0F, -0.5F); + + PIPE_2_TOP = new ModelRenderer(this, 16, 32); + PIPE_2_TOP.addBox(-1.0F, -0.5F, -1.0F, 2, 1, 2, 0); + PIPE_2_TOP.setRotationPoint(2.0F, -11.0F, 3.0F); + PIPE_2_TOP.setTextureSize(256, 256); + PIPE_2_TOP.mirror = true; + setRotation(PIPE_2_TOP, 0F, 0F, 0F); + + PIPE_1_TOP = new ModelRenderer(this, 16, 32); + PIPE_1_TOP.addBox(-1.0F, -0.5F, -1.0F, 2, 1, 2, 0); + PIPE_1_TOP.setRotationPoint(2.0F, -11.0F, -3.0F); + PIPE_1_TOP.setTextureSize(256, 256); + PIPE_1_TOP.mirror = true; + setRotation(PIPE_1_TOP, 0F, 0F, 0F); + + FRONT_PANEL = new ModelRenderer(this, 32, 64); + FRONT_PANEL.addBox(-0.5F, -1.5F, -5.0F, 1, 3, 10, 0); + FRONT_PANEL.setRotationPoint(-7.0F, -2.5F, 0.0F); + FRONT_PANEL.setTextureSize(256, 256); + FRONT_PANEL.mirror = true; + setRotation(FRONT_PANEL, 0F, 0F, 0F); + + WIRE_1 = new ModelRenderer(this, 48, 48); + WIRE_1.addBox(-2.0F, -0.5F, -0.5F, 4, 1, 1, 0); + WIRE_1.setRotationPoint(-0.5F, -1.0F, -4.5F); + WIRE_1.setTextureSize(256, 256); + WIRE_1.mirror = true; + setRotation(WIRE_1, 0F, 0F, 0F); + + WIRE_2 = new ModelRenderer(this, 0, 48); + WIRE_2.addBox(-3.0F, -0.5F, -0.5F, 6, 1, 1, 0); + WIRE_2.setRotationPoint(-1.5F, -1.0F, 4.5F); + WIRE_2.setTextureSize(256, 256); + WIRE_2.mirror = true; + setRotation(WIRE_2, 0F, 0F, 0F); + + SIDE_WIRE_1 = new ModelRenderer(this, 32, 48); + SIDE_WIRE_1.addBox(-0.5F, -0.5F, -2.5F, 1, 1, 5, 0); + SIDE_WIRE_1.setRotationPoint(-4.0F, -1.0F, 2.0F); + SIDE_WIRE_1.setTextureSize(256, 256); + SIDE_WIRE_1.mirror = true; + setRotation(SIDE_WIRE_1, 0F, 0F, 0F); + + SIDE_WIRE_2 = new ModelRenderer(this, 64, 48); + SIDE_WIRE_2.addBox(-0.5F, -0.5F, -1.5F, 1, 1, 3, 0); + SIDE_WIRE_2.setRotationPoint(-2.0F, -1.0F, -2.5F); + SIDE_WIRE_2.setTextureSize(256, 256); + SIDE_WIRE_2.mirror = true; + setRotation(SIDE_WIRE_2, 0F, 0F, 0F); + + VERTICAL_WIRE = new ModelRenderer(this, 0, 64); + VERTICAL_WIRE.addBox(-0.5F, -3.0F, -0.5F, 1, 6, 1, 0); + VERTICAL_WIRE.setRotationPoint(-2.0F, -4.5F, -1.5F); + VERTICAL_WIRE.setTextureSize(256, 256); + VERTICAL_WIRE.mirror = true; + setRotation(VERTICAL_WIRE, 0F, 0F, 0F); + + TUBE = new ModelRenderer(this, 16, 64); + TUBE.addBox(-2.5F, -0.5F, -1.0F, 5, 1, 2, 0); + TUBE.setRotationPoint(-4.0F, -3.0F, 2.0F); + TUBE.setTextureSize(256, 256); + TUBE.mirror = true; + setRotation(TUBE, 0F, 0F, 0F); + + } + + public void render(float size) + { + PANEL.render(size); + MACHINE.render(size); + CENTER_CIRCUIT.render(size); + PIPE_1.render(size); + PIPE_2.render(size); + GUI_STAND.render(size); + GUI_SCREEN.render(size); + PIPE_2_TOP.render(size); + PIPE_1_TOP.render(size); + FRONT_PANEL.render(size); + WIRE_1.render(size); + WIRE_2.render(size); + SIDE_WIRE_1.render(size); + SIDE_WIRE_2.render(size); + VERTICAL_WIRE.render(size); + TUBE.render(size); + } + + @Override + public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) + { + this.setRotationAngles(f, f1, f2, f3, f4, f5, entity); + PANEL.render(f5); + MACHINE.render(f5); + CENTER_CIRCUIT.render(f5); + PIPE_1.render(f5); + PIPE_2.render(f5); + GUI_STAND.render(f5); + GUI_SCREEN.render(f5); + PIPE_2_TOP.render(f5); + PIPE_1_TOP.render(f5); + FRONT_PANEL.render(f5); + WIRE_1.render(f5); + WIRE_2.render(f5); + SIDE_WIRE_1.render(f5); + SIDE_WIRE_2.render(f5); + VERTICAL_WIRE.render(f5); + TUBE.render(f5); + } + + private void setRotation(ModelRenderer model, float x, float y, float z) + { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } +} diff --git a/src/minecraft/mekanism/client/ModelTransmitter.java b/src/minecraft/mekanism/client/ModelTransmitter.java index 9ea4f3289..dfc08519b 100644 --- a/src/minecraft/mekanism/client/ModelTransmitter.java +++ b/src/minecraft/mekanism/client/ModelTransmitter.java @@ -110,10 +110,4 @@ public class ModelTransmitter extends ModelBase { model.rotateAngleY = y; model.rotateAngleZ = z; } - - @Override - public void setRotationAngles(float x, float y, float z, float f3, float f4, float f5, Entity entity) - { - super.setRotationAngles(x, y, z, f3, f4, f5, entity); - } } diff --git a/src/minecraft/mekanism/client/RenderElectricPump.java b/src/minecraft/mekanism/client/RenderElectricPump.java new file mode 100644 index 000000000..8170f227e --- /dev/null +++ b/src/minecraft/mekanism/client/RenderElectricPump.java @@ -0,0 +1,29 @@ +package mekanism.client; + +import org.lwjgl.opengl.GL11; + +import mekanism.common.TileEntityElectricPump; +import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; +import net.minecraft.tileentity.TileEntity; + +public class RenderElectricPump extends TileEntitySpecialRenderer +{ + private ModelElectricPump model = new ModelElectricPump(); + + @Override + public void renderTileEntityAt(TileEntity var1, double var2, double var4, double var6, float var8) + { + renderAModelAt((TileEntityElectricPump) var1, var2, var4, var6, 1F); + } + + private void renderAModelAt(TileEntityElectricPump tileEntity, double x, double y, double z, float f) + { + GL11.glPushMatrix(); + GL11.glTranslatef((float) x + 0.5f, (float) y + 1.5f, (float) z + 0.5f); + bindTextureByName("/mods/mekanism/render/ElectricPump.png"); + + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); + model.render(0.0625F); + GL11.glPopMatrix(); + } +} diff --git a/src/minecraft/mekanism/client/RenderMetallurgicInfuser.java b/src/minecraft/mekanism/client/RenderMetallurgicInfuser.java new file mode 100644 index 000000000..9fd77fa8b --- /dev/null +++ b/src/minecraft/mekanism/client/RenderMetallurgicInfuser.java @@ -0,0 +1,38 @@ +package mekanism.client; + +import org.lwjgl.opengl.GL11; + +import mekanism.common.TileEntityMetallurgicInfuser; +import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; +import net.minecraft.tileentity.TileEntity; + +public class RenderMetallurgicInfuser extends TileEntitySpecialRenderer +{ + private ModelMetallurgicInfuser model = new ModelMetallurgicInfuser(); + + @Override + public void renderTileEntityAt(TileEntity var1, double var2, double var4, double var6, float var8) + { + renderAModelAt((TileEntityMetallurgicInfuser) var1, var2, var4, var6, 1F); + } + + private void renderAModelAt(TileEntityMetallurgicInfuser tileEntity, double x, double y, double z, float f) + { + GL11.glPushMatrix(); + GL11.glTranslatef((float) x + 0.5f, (float) y + 1.5f, (float) z + 0.5f); + bindTextureByName("/mods/mekanism/render/MetallurgicInfuser.png"); + + switch(tileEntity.facing) + { + case 2: GL11.glRotatef(90, 0.0F, 1.0F, 0.0F); break; + case 3: GL11.glRotatef(270, 0.0F, 1.0F, 0.0F); break; + case 4: GL11.glRotatef(180, 0.0F, 1.0F, 0.0F); break; + case 5: GL11.glRotatef(0, 0.0F, 1.0F, 0.0F); break; + } + + GL11.glTranslatef(0, -1.5F, 0); + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); + model.render(0.0625F); + GL11.glPopMatrix(); + } +} diff --git a/src/minecraft/mekanism/client/ThreadClientUpdate.java b/src/minecraft/mekanism/client/ThreadClientUpdate.java index 6f2bb158e..2fcda7735 100644 --- a/src/minecraft/mekanism/client/ThreadClientUpdate.java +++ b/src/minecraft/mekanism/client/ThreadClientUpdate.java @@ -8,6 +8,7 @@ import java.net.URL; import mekanism.common.Mekanism; import net.minecraft.client.Minecraft; + /** * Thread that downloads the latest release of Mekanism. The older file is deleted and the newly downloaded file takes it's place. * @author AidanBrady @@ -21,8 +22,12 @@ public class ThreadClientUpdate extends Thread private byte[] buffer = new byte[10240]; private URL url; + public static int modulesBeingDownloaded; + public static boolean hasUpdated; + public ThreadClientUpdate(String location, int type) { + modulesBeingDownloaded++; downloadType = type; try { url = new URL(location); @@ -37,7 +42,7 @@ public class ThreadClientUpdate extends Thread public void run() { String downloadName = downloadType == 0 ? "" : (downloadType == 1 ? "Generators" : "Tools"); - File download = new File(new StringBuilder().append(Minecraft.getMinecraftDir()).append("/mods/Mekanism" + downloadName + "-v" + Mekanism.latestVersionNumber + ".jar").toString()); + File download = new File(new StringBuilder().append(Minecraft.getMinecraftDir()).append(File.separator + "mods" + File.separator + "Mekanism" + downloadName + "-v" + Mekanism.latestVersionNumber + ".jar").toString()); try { prepareForDownload(); download.createNewFile(); @@ -54,18 +59,14 @@ public class ThreadClientUpdate extends Thread outputStream.close(); stream.close(); - if(downloadType == 0) - { - GuiCredits.onFinishedDownloading(); - System.out.println("[Mekanism] Successfully updated to latest version (" + Mekanism.latestVersionNumber + ")."); - } - + modulesBeingDownloaded--; finalize(); } catch(Throwable e) { GuiCredits.onErrorDownloading(); System.err.println("[Mekanism] Error while finishing update thread: " + e.getMessage()); try { + modulesBeingDownloaded--; finalize(); } catch (Throwable e1) { System.err.println("[Mekanism] Error while finalizing update thread: " + e1.getMessage()); @@ -74,11 +75,11 @@ public class ThreadClientUpdate extends Thread } /** - * Prepares to update to the latest version of Mekanism by deleting the files "Mekanism.cfg" and "Mekanism.jar." + * Prepares to update to the latest version of Mekanism by removing the old files. */ public void prepareForDownload() { - File[] modsList = new File(new StringBuilder().append(Minecraft.getMinecraftDir()).append("/mods").toString()).listFiles(); + File[] modsList = new File(new StringBuilder().append(Minecraft.getMinecraftDir()).append(File.separator + "mods").toString()).listFiles(); for(File file : modsList) { diff --git a/src/minecraft/mekanism/common/BlockMachine.java b/src/minecraft/mekanism/common/BlockMachine.java index ea3a49ba0..3bf5def63 100644 --- a/src/minecraft/mekanism/common/BlockMachine.java +++ b/src/minecraft/mekanism/common/BlockMachine.java @@ -101,8 +101,6 @@ public class BlockMachine extends BlockContainer implements IDismantleable icons[10][1] = register.registerIcon("mekanism:EnergizedSmelterFrontOn"); icons[10][2] = register.registerIcon("mekanism:SteelCasing"); icons[11][0] = register.registerIcon("mekanism:Teleporter"); - icons[12][0] = register.registerIcon("mekanism:ElectricPumpFront"); - icons[12][1] = register.registerIcon("mekanism:ElectricPumpSide"); } @Override @@ -307,16 +305,6 @@ public class BlockMachine extends BlockContainer implements IDismantleable { return icons[11][0]; } - else if(meta == 12) - { - if(side == 1) - { - return icons[12][0]; - } - else { - return icons[12][1]; - } - } return null; } @@ -454,16 +442,6 @@ public class BlockMachine extends BlockContainer implements IDismantleable { return icons[11][0]; } - else if(metadata == 12) - { - if(side == 1) - { - return icons[12][0]; - } - else { - return icons[12][1]; - } - } return null; } @@ -683,6 +661,17 @@ public class BlockMachine extends BlockContainer implements IDismantleable ISustainedInventory inventory = (ISustainedInventory)itemStack.getItem(); inventory.setInventory(((ISustainedInventory)tileEntity).getInventory(), itemStack); + if(((ISustainedTank)itemStack.getItem()).hasTank(itemStack)) + { + if(tileEntity instanceof ISustainedTank) + { + if(((ISustainedTank)tileEntity).getLiquidStack() != null) + { + ((ISustainedTank)itemStack.getItem()).setLiquidStack(((ISustainedTank)tileEntity).getLiquidStack(), itemStack); + } + } + } + if(tileEntity instanceof TileEntityFactory) { IFactory factoryItem = (IFactory)itemStack.getItem(); @@ -730,11 +719,11 @@ public class BlockMachine extends BlockContainer implements IDismantleable BASIC_FACTORY(5, 11, 6000, TileEntityFactory.class, false), ADVANCED_FACTORY(6, 11, 10000, TileEntityAdvancedFactory.class, false), ELITE_FACTORY(7, 11, 14000, TileEntityEliteFactory.class, false), - METALLURGIC_INFUSER(8, 12, 2000, TileEntityMetallurgicInfuser.class, false), + METALLURGIC_INFUSER(8, 12, 2000, TileEntityMetallurgicInfuser.class, true), PURIFICATION_CHAMBER(9, 15, 12000, TileEntityPurificationChamber.class, false), ENERGIZED_SMELTER(10, 16, 2000, TileEntityEnergizedSmelter.class, false), TELEPORTER(11, 13, 5000000, TileEntityTeleporter.class, false), - ELECTRIC_PUMP(12, 17, 10000, TileEntityElectricPump.class, false); + ELECTRIC_PUMP(12, 17, 10000, TileEntityElectricPump.class, true); public int meta; public int guiId; diff --git a/src/minecraft/mekanism/common/CommonProxy.java b/src/minecraft/mekanism/common/CommonProxy.java index b534124fc..fa2d47d64 100644 --- a/src/minecraft/mekanism/common/CommonProxy.java +++ b/src/minecraft/mekanism/common/CommonProxy.java @@ -22,8 +22,10 @@ public class CommonProxy public void registerSpecialTileEntities() { GameRegistry.registerTileEntity(TileEntityTheoreticalElementizer.class, "TheoreticalElementizer"); + GameRegistry.registerTileEntity(TileEntityMetallurgicInfuser.class, "MetallurgicInfuser"); GameRegistry.registerTileEntity(TileEntityPressurizedTube.class, "PressurizedTube"); GameRegistry.registerTileEntity(TileEntityUniversalCable.class, "UniversalCable"); + GameRegistry.registerTileEntity(TileEntityElectricPump.class, "ElectricPump"); } /** diff --git a/src/minecraft/mekanism/common/ISustainedTank.java b/src/minecraft/mekanism/common/ISustainedTank.java new file mode 100644 index 000000000..7d720f121 --- /dev/null +++ b/src/minecraft/mekanism/common/ISustainedTank.java @@ -0,0 +1,34 @@ +package mekanism.common; + +import net.minecraft.nbt.NBTTagList; +import net.minecraftforge.liquids.LiquidStack; +import net.minecraftforge.liquids.LiquidTank; + +/** + * Internal interface used in blocks and items that are capable of storing sustained tanks. + * @author AidanBrady + * + */ +public interface ISustainedTank +{ + /** + * Sets the tank tag list to a new value. + * @param nbtTags - NBTTagList value to set + * @param data - ItemStack parameter if using on item + */ + public void setLiquidStack(LiquidStack liquidStack, Object... data); + + /** + * Gets the tank tag list from an item or block. + * @param data - ItemStack parameter if using on item + * @return inventory tag list + */ + public LiquidStack getLiquidStack(Object... data); + + /** + * Whether or not this block or item has an internal tank. + * @param data - ItemStack parameter if using on item + * @return if the block or item has an internal tank + */ + public boolean hasTank(Object... data); +} diff --git a/src/minecraft/mekanism/common/ItemBlockMachine.java b/src/minecraft/mekanism/common/ItemBlockMachine.java index e880c7b14..e41cf3521 100644 --- a/src/minecraft/mekanism/common/ItemBlockMachine.java +++ b/src/minecraft/mekanism/common/ItemBlockMachine.java @@ -24,6 +24,8 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagFloat; import net.minecraft.nbt.NBTTagList; import net.minecraft.world.World; +import net.minecraftforge.liquids.LiquidDictionary; +import net.minecraftforge.liquids.LiquidStack; /** * Item class for handling multiple machine block IDs. @@ -43,7 +45,7 @@ import net.minecraft.world.World; * @author AidanBrady * */ -public class ItemBlockMachine extends ItemBlock implements IItemElectric, ICustomElectricItem, IUpgradeManagement, IFactory, ISustainedInventory +public class ItemBlockMachine extends ItemBlock implements IItemElectric, ICustomElectricItem, IUpgradeManagement, IFactory, ISustainedInventory, ISustainedTank { public Block metaBlock; @@ -131,6 +133,14 @@ public class ItemBlockMachine extends ItemBlock implements IItemElectric, ICusto list.add(EnumColor.BRIGHT_GREEN + "Stored Energy: " + EnumColor.GREY + ElectricityDisplay.getDisplayShort(getJoules(itemstack), ElectricUnit.JOULES)); list.add(EnumColor.BRIGHT_GREEN + "Voltage: " + EnumColor.GREY + getVoltage(itemstack) + "v"); + if(hasTank(itemstack)) + { + if(getLiquidStack(itemstack) != null) + { + list.add(EnumColor.PINK + LiquidDictionary.findLiquidName(getLiquidStack(itemstack)) + ": " + EnumColor.GREY + getLiquidStack(itemstack).amount + "mB"); + } + } + if(supportsUpgrades(itemstack)) { list.add(EnumColor.PURPLE + "Energy: " + EnumColor.GREY + "x" + (getEnergyMultiplier(itemstack)+1)); @@ -238,6 +248,14 @@ public class ItemBlockMachine extends ItemBlock implements IItemElectric, ICusto ((TileEntityFactory)tileEntity).recipeType = getRecipeType(stack); } + if(tileEntity instanceof ISustainedTank) + { + if(hasTank(stack) && getLiquidStack(stack) != null) + { + ((ISustainedTank)tileEntity).setLiquidStack(getLiquidStack(stack), stack); + } + } + ((ISustainedInventory)tileEntity).setInventory(getInventory(stack)); tileEntity.electricityStored = getJoules(stack); @@ -463,4 +481,52 @@ public class ItemBlockMachine extends ItemBlock implements IItemElectric, ICusto return null; } + + @Override + public void setLiquidStack(LiquidStack liquidStack, Object... data) + { + if(liquidStack == null || liquidStack.amount == 0 || liquidStack.itemID == 0) + { + return; + } + + if(data[0] instanceof ItemStack) + { + ItemStack itemStack = (ItemStack)data[0]; + + if(itemStack.stackTagCompound == null) + { + itemStack.setTagCompound(new NBTTagCompound()); + } + + itemStack.stackTagCompound.setTag("liquidTank", liquidStack.writeToNBT(new NBTTagCompound())); + } + } + + @Override + public LiquidStack getLiquidStack(Object... data) + { + if(data[0] instanceof ItemStack) + { + ItemStack itemStack = (ItemStack)data[0]; + + if(itemStack.stackTagCompound == null) + { + return null; + } + + if(itemStack.stackTagCompound.hasKey("liquidTank")) + { + return LiquidStack.loadLiquidStackFromNBT(itemStack.stackTagCompound.getCompoundTag("liquidTank")); + } + } + + return null; + } + + @Override + public boolean hasTank(Object... data) + { + return data[0] instanceof ItemStack && ((ItemStack)data[0]).getItem() instanceof ISustainedTank && ((ItemStack)data[0]).getItemDamage() == 12; + } } diff --git a/src/minecraft/mekanism/common/Mekanism.java b/src/minecraft/mekanism/common/Mekanism.java index 48b0a6f86..b8c5396d8 100644 --- a/src/minecraft/mekanism/common/Mekanism.java +++ b/src/minecraft/mekanism/common/Mekanism.java @@ -5,6 +5,7 @@ import ic2.api.Ic2Recipes; import java.io.File; import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.logging.Logger; @@ -85,6 +86,9 @@ public class Mekanism /** Mekanism creative tab */ public static CreativeTabMekanism tabMekanism = new CreativeTabMekanism(); + /** List of Mekanism modules loaded */ + public static List modulesLoaded = new ArrayList(); + /** The latest version number which is received from the Mekanism server */ public static String latestVersionNumber; @@ -919,11 +923,9 @@ public class Mekanism GameRegistry.registerTileEntity(TileEntityFactory.class, "SmeltingFactory"); GameRegistry.registerTileEntity(TileEntityAdvancedFactory.class, "AdvancedSmeltingFactory"); GameRegistry.registerTileEntity(TileEntityEliteFactory.class, "UltimateSmeltingFactory"); - GameRegistry.registerTileEntity(TileEntityMetallurgicInfuser.class, "MetallurgicInfuser"); GameRegistry.registerTileEntity(TileEntityTeleporter.class, "MekanismTeleporter"); GameRegistry.registerTileEntity(TileEntityPurificationChamber.class, "PurificationChamber"); GameRegistry.registerTileEntity(TileEntityEnergizedSmelter.class, "EnergizedSmelter"); - GameRegistry.registerTileEntity(TileEntityElectricPump.class, "ElectricPump"); //Load tile entities that have special renderers. proxy.registerSpecialTileEntities(); @@ -971,6 +973,9 @@ public class Mekanism @Init public void init(FMLInitializationEvent event) { + //Add this module to the core list + modulesLoaded.add(this); + //Register the mod's ore handler GameRegistry.registerWorldGenerator(new OreHandler()); diff --git a/src/minecraft/mekanism/common/MekanismUtils.java b/src/minecraft/mekanism/common/MekanismUtils.java index 1c852b3c1..94a787312 100644 --- a/src/minecraft/mekanism/common/MekanismUtils.java +++ b/src/minecraft/mekanism/common/MekanismUtils.java @@ -55,7 +55,7 @@ import cpw.mods.fml.server.FMLServerHandler; */ public final class MekanismUtils { - public static int[][] ADJACENT_COORDS = {{0, -1, 0}, {0, 1, 0}, {0, 0, -1}, {0, 0, 1}, {-1, 0, 0}, {1, 0, 0}}; + public static int[][] ADJACENT_COORDS = {{0, -1, 0}, {0, 1, 0}, {0, 0, -1}, {0, 0, 1}, {-1, 0, 0}, {1, 0, 0}}; /** * Checks for a new version of Mekanism. @@ -598,6 +598,11 @@ public final class MekanismUtils { return new LiquidStack(Block.waterStill.blockID, LiquidContainerRegistry.BUCKET_VOLUME, 0); } + else if((id == Block.waterStill.blockID || id == Block.waterMoving.blockID) && meta != 0) + { + world.setBlockToAir(x, y, z); + return null; + } else if((id == Block.lavaStill.blockID || id == Block.lavaMoving.blockID) && meta == 0) { return new LiquidStack(Block.lavaStill.blockID, LiquidContainerRegistry.BUCKET_VOLUME, 0); @@ -615,9 +620,13 @@ public final class MekanismUtils { return new LiquidStack(liquid.stillLiquidId(), LiquidContainerRegistry.BUCKET_VOLUME, liquid.stillLiquidMeta()); } - else { + else if(meta == 0) + { return new LiquidStack(liquid.stillLiquidId(), LiquidContainerRegistry.BUCKET_VOLUME, 0); } + else { + world.setBlockToAir(x, y, z); + } } return null; diff --git a/src/minecraft/mekanism/common/TileEntityElectricPump.java b/src/minecraft/mekanism/common/TileEntityElectricPump.java index 90db474fd..d3823e047 100644 --- a/src/minecraft/mekanism/common/TileEntityElectricPump.java +++ b/src/minecraft/mekanism/common/TileEntityElectricPump.java @@ -32,7 +32,7 @@ import net.minecraftforge.liquids.LiquidContainerRegistry; import net.minecraftforge.liquids.LiquidStack; import net.minecraftforge.liquids.LiquidTank; -public class TileEntityElectricPump extends TileEntityElectricBlock implements ITankContainer +public class TileEntityElectricPump extends TileEntityElectricBlock implements ITankContainer, ISustainedTank { public LiquidTank liquidTank; @@ -117,6 +117,24 @@ public class TileEntityElectricPump extends TileEntityElectricBlock implements I } } + if(liquidTank.getLiquid() != null) + { + for(ForgeDirection orientation : ForgeDirection.VALID_DIRECTIONS) + { + TileEntity tileEntity = VectorHelper.getTileEntityFromSide(worldObj, new Vector3(xCoord, yCoord, zCoord), orientation); + + if(tileEntity instanceof ITankContainer) + { + liquidTank.drain(((ITankContainer)tileEntity).fill(orientation.getOpposite(), liquidTank.getLiquid(), true), true); + + if(liquidTank.getLiquid() == null || liquidTank.getLiquid().amount <= 0) + { + break; + } + } + } + } + if(!worldObj.isRemote && worldObj.getWorldTime() % 20 == 0) { if(electricityStored >= 100 && (liquidTank.getLiquid() == null || liquidTank.getLiquid().amount+LiquidContainerRegistry.BUCKET_VOLUME <= 10000)) @@ -185,24 +203,6 @@ public class TileEntityElectricPump extends TileEntityElectricBlock implements I } } } - - if(liquidTank.getLiquid() != null) - { - for(ForgeDirection orientation : ForgeDirection.VALID_DIRECTIONS) - { - TileEntity tileEntity = VectorHelper.getTileEntityFromSide(worldObj, new Vector3(xCoord, yCoord, zCoord), orientation); - - if(tileEntity instanceof ITankContainer) - { - liquidTank.drain(((ITankContainer)tileEntity).fill(orientation.getOpposite(), liquidTank.getLiquid(), true), true); - - if(liquidTank.getLiquid() == null || liquidTank.getLiquid().amount <= 0) - { - break; - } - } - } - } } @Override @@ -387,4 +387,22 @@ public class TileEntityElectricPump extends TileEntityElectricBlock implements I { return liquidTank; } + + @Override + public void setLiquidStack(LiquidStack liquidStack, Object... data) + { + liquidTank.setLiquid(liquidStack); + } + + @Override + public LiquidStack getLiquidStack(Object... data) + { + return liquidTank.getLiquid(); + } + + @Override + public boolean hasTank(Object... data) + { + return true; + } } diff --git a/src/minecraft/mekanism/generators/client/GuiBioGenerator.java b/src/minecraft/mekanism/generators/client/GuiBioGenerator.java index ecab395a4..565303145 100644 --- a/src/minecraft/mekanism/generators/client/GuiBioGenerator.java +++ b/src/minecraft/mekanism/generators/client/GuiBioGenerator.java @@ -26,10 +26,10 @@ public class GuiBioGenerator extends GuiContainer @Override protected void drawGuiContainerForegroundLayer(int par1, int par2) { - fontRenderer.drawString(tileEntity.fullName, 45, 6, 0x404040); + fontRenderer.drawString(tileEntity.fullName, 45, 6, 0x404040); fontRenderer.drawString("Inventory", 8, (ySize - 96) + 2, 0x404040); fontRenderer.drawString(ElectricityDisplay.getDisplayShort(tileEntity.electricityStored, ElectricUnit.JOULES), 51, 26, 0x00CD00); - fontRenderer.drawString("BioFuel: " + (tileEntity.bioFuelTank.getLiquid() != null ? tileEntity.bioFuelTank.getLiquid().amount : 0), 51, 35, 0x00CD00); + fontRenderer.drawString("BioFuel: " + tileEntity.bioFuelSlot.liquidStored, 51, 35, 0x00CD00); fontRenderer.drawString(tileEntity.getVoltage() + "v", 51, 44, 0x00CD00); } diff --git a/src/minecraft/mekanism/generators/common/BlockGenerator.java b/src/minecraft/mekanism/generators/common/BlockGenerator.java index c915052df..3c17cbc3b 100644 --- a/src/minecraft/mekanism/generators/common/BlockGenerator.java +++ b/src/minecraft/mekanism/generators/common/BlockGenerator.java @@ -8,6 +8,7 @@ import buildcraft.api.tools.IToolWrench; import mekanism.common.IActiveState; import mekanism.common.IBoundingBlock; import mekanism.common.ISustainedInventory; +import mekanism.common.ISustainedTank; import mekanism.common.Mekanism; import mekanism.common.MekanismUtils; import mekanism.common.TileEntityBasicBlock; @@ -519,6 +520,17 @@ public class BlockGenerator extends BlockContainer implements IDismantleable ISustainedInventory inventory = (ISustainedInventory)itemStack.getItem(); inventory.setInventory(((ISustainedInventory)tileEntity).getInventory(), itemStack); + if(((ISustainedTank)itemStack.getItem()).hasTank(itemStack)) + { + if(tileEntity instanceof ISustainedTank) + { + if(((ISustainedTank)tileEntity).getLiquidStack() != null) + { + ((ISustainedTank)itemStack.getItem()).setLiquidStack(((ISustainedTank)tileEntity).getLiquidStack(), itemStack); + } + } + } + return itemStack; } @@ -554,8 +566,8 @@ public class BlockGenerator extends BlockContainer implements IDismantleable { HEAT_GENERATOR(0, 0, 160000, TileEntityHeatGenerator.class, true), SOLAR_GENERATOR(1, 1, 96000, TileEntitySolarGenerator.class, false), - ELECTROLYTIC_SEPARATOR(2, 2, 9600, TileEntityElectrolyticSeparator.class, true), - HYDROGEN_GENERATOR(3, 3, 400000, TileEntityHydrogenGenerator.class, true), + ELECTROLYTIC_SEPARATOR(2, 2, 20000, TileEntityElectrolyticSeparator.class, true), + HYDROGEN_GENERATOR(3, 3, 40000, TileEntityHydrogenGenerator.class, true), BIO_GENERATOR(4, 4, 160000, TileEntityBioGenerator.class, true), ADVANCED_SOLAR_GENERATOR(5, 1, 200000, TileEntityAdvancedSolarGenerator.class, true); diff --git a/src/minecraft/mekanism/generators/common/ItemBlockGenerator.java b/src/minecraft/mekanism/generators/common/ItemBlockGenerator.java index 5a0bc9c95..733af62cf 100644 --- a/src/minecraft/mekanism/generators/common/ItemBlockGenerator.java +++ b/src/minecraft/mekanism/generators/common/ItemBlockGenerator.java @@ -14,6 +14,7 @@ import universalelectricity.core.electricity.ElectricityPack; import universalelectricity.core.item.IItemElectric; import mekanism.api.EnumColor; import mekanism.common.ISustainedInventory; +import mekanism.common.ISustainedTank; import mekanism.common.Mekanism; import mekanism.common.TileEntityElectricBlock; import mekanism.generators.common.BlockGenerator.GeneratorType; @@ -26,6 +27,8 @@ import net.minecraft.nbt.NBTTagFloat; import net.minecraft.nbt.NBTTagList; import net.minecraft.util.Icon; import net.minecraft.world.World; +import net.minecraftforge.liquids.LiquidDictionary; +import net.minecraftforge.liquids.LiquidStack; /** * Item class for handling multiple generator block IDs. @@ -38,7 +41,7 @@ import net.minecraft.world.World; * @author AidanBrady * */ -public class ItemBlockGenerator extends ItemBlock implements IItemElectric, ICustomElectricItem, ISustainedInventory +public class ItemBlockGenerator extends ItemBlock implements IItemElectric, ICustomElectricItem, ISustainedInventory, ISustainedTank { public Block metaBlock; @@ -104,6 +107,15 @@ public class ItemBlockGenerator extends ItemBlock implements IItemElectric, ICus else { list.add(EnumColor.BRIGHT_GREEN + "Stored Energy: " + EnumColor.GREY + ElectricityDisplay.getDisplayShort(getJoules(itemstack), ElectricUnit.JOULES)); list.add(EnumColor.BRIGHT_GREEN + "Voltage: " + EnumColor.GREY + getVoltage(itemstack) + "v"); + + if(hasTank(itemstack)) + { + if(getLiquidStack(itemstack) != null) + { + list.add(EnumColor.PINK + LiquidDictionary.findLiquidName(getLiquidStack(itemstack)) + ": " + EnumColor.GREY + getLiquidStack(itemstack).amount + "mB"); + } + } + list.add(EnumColor.AQUA + "Inventory: " + EnumColor.GREY + (getInventory(itemstack) != null && getInventory(itemstack).tagList != null && !getInventory(itemstack).tagList.isEmpty())); } } @@ -227,7 +239,17 @@ public class ItemBlockGenerator extends ItemBlock implements IItemElectric, ICus { TileEntityElectricBlock tileEntity = (TileEntityElectricBlock)world.getBlockTileEntity(x, y, z); tileEntity.electricityStored = getJoules(stack); + ((ISustainedInventory)tileEntity).setInventory(getInventory(stack)); + + if(tileEntity instanceof ISustainedTank) + { + if(hasTank(stack) && getLiquidStack(stack) != null) + { + ((ISustainedTank)tileEntity).setLiquidStack(getLiquidStack(stack), stack); + } + } + return true; } @@ -364,4 +386,52 @@ public class ItemBlockGenerator extends ItemBlock implements IItemElectric, ICus return null; } + + @Override + public void setLiquidStack(LiquidStack liquidStack, Object... data) + { + if(liquidStack == null || liquidStack.amount == 0 || liquidStack.itemID == 0) + { + return; + } + + if(data[0] instanceof ItemStack) + { + ItemStack itemStack = (ItemStack)data[0]; + + if(itemStack.stackTagCompound == null) + { + itemStack.setTagCompound(new NBTTagCompound()); + } + + itemStack.stackTagCompound.setTag("liquidTank", liquidStack.writeToNBT(new NBTTagCompound())); + } + } + + @Override + public LiquidStack getLiquidStack(Object... data) + { + if(data[0] instanceof ItemStack) + { + ItemStack itemStack = (ItemStack)data[0]; + + if(itemStack.stackTagCompound == null) + { + return null; + } + + if(itemStack.stackTagCompound.hasKey("liquidTank")) + { + return LiquidStack.loadLiquidStackFromNBT(itemStack.stackTagCompound.getCompoundTag("liquidTank")); + } + } + + return null; + } + + @Override + public boolean hasTank(Object... data) + { + return data[0] instanceof ItemStack && ((ItemStack)data[0]).getItem() instanceof ISustainedTank && (((ItemStack)data[0]).getItemDamage() == 2); + } } diff --git a/src/minecraft/mekanism/generators/common/MekanismGenerators.java b/src/minecraft/mekanism/generators/common/MekanismGenerators.java index 92a033bee..e4312f179 100644 --- a/src/minecraft/mekanism/generators/common/MekanismGenerators.java +++ b/src/minecraft/mekanism/generators/common/MekanismGenerators.java @@ -46,6 +46,9 @@ public class MekanismGenerators @Init public void init(FMLInitializationEvent event) { + //Add this module to the core list + Mekanism.modulesLoaded.add(this); + //Set up the GUI handler NetworkRegistry.instance().registerGuiHandler(this, new GeneratorsGuiHandler()); diff --git a/src/minecraft/mekanism/generators/common/TileEntityBioGenerator.java b/src/minecraft/mekanism/generators/common/TileEntityBioGenerator.java index fd4612b28..29c044ab2 100644 --- a/src/minecraft/mekanism/generators/common/TileEntityBioGenerator.java +++ b/src/minecraft/mekanism/generators/common/TileEntityBioGenerator.java @@ -36,16 +36,16 @@ public class TileEntityBioGenerator extends TileEntityGenerator implements ITank /** The Sound instance for this machine. */ @SideOnly(Side.CLIENT) public Sound audio; - + /** Where the crush piston should be on the model. */ public float crushMatrix = 0; - + /** The amount of electricity this machine can produce with a unit of fuel. */ public final int GENERATION = 50; - + /** The LiquidSlot biofuel instance for this generator. */ - public LiquidTank bioFuelTank = new LiquidTank(24000); - + public LiquidSlot bioFuelSlot = new LiquidSlot(24000, Mekanism.hooks.ForestryBiofuelID); + /** Which fuels work on this generator. */ public static Map fuels = new HashMap(); @@ -53,17 +53,17 @@ public class TileEntityBioGenerator extends TileEntityGenerator implements ITank { super("Bio-Generator", 160000, 100); inventory = new ItemStack[2]; - + if(Mekanism.hooks.ForestryLoaded) { - fuels.put(Mekanism.hooks.ForestryBiofuelID, GENERATION); + fuels.put(Mekanism.hooks.ForestryBiofuelID, 16); } } - + public float getMatrix() { float matrix = 0; - + if(crushMatrix <= 2) { return crushMatrix; @@ -72,12 +72,12 @@ public class TileEntityBioGenerator extends TileEntityGenerator implements ITank return 2 - (crushMatrix-2); } } - + @Override public void onUpdate() { super.onUpdate(); - + if(worldObj.isRemote) { if(crushMatrix < 4) @@ -88,37 +88,38 @@ public class TileEntityBioGenerator extends TileEntityGenerator implements ITank crushMatrix = 0; } } - + if(inventory[1] != null && electricityStored > 0) { setJoules(getJoules() - ElectricItemHelper.chargeItem(inventory[1], getJoules(), getVoltage())); - + if(Mekanism.hooks.IC2Loaded && inventory[1].getItem() instanceof IElectricItem) { double sent = ElectricItem.charge(inventory[1], (int)(electricityStored*Mekanism.TO_IC2), 3, false, false)*Mekanism.FROM_IC2; setJoules(electricityStored - sent); } } - + if(inventory[0] != null) { LiquidStack liquid = LiquidContainerRegistry.getLiquidForFilledItem(inventory[0]); - + if(liquid != null) { if(fuels.containsKey(liquid.itemID)) { - if(bioFuelTank.getLiquid() == null || bioFuelTank.getLiquid().amount+liquid.amount <= bioFuelTank.getCapacity()) + int liquidToAdd = liquid.amount*fuels.get(liquid.itemID); + + if(bioFuelSlot.liquidStored+liquidToAdd <= bioFuelSlot.MAX_LIQUID) { - bioFuelTank.fill(liquid, true); - + bioFuelSlot.setLiquid(bioFuelSlot.liquidStored+liquidToAdd); if(LiquidContainerRegistry.isBucket(inventory[0])) { inventory[0] = new ItemStack(Item.bucketEmpty); } else { inventory[0].stackSize--; - + if(inventory[0].stackSize == 0) { inventory[0] = null; @@ -132,18 +133,18 @@ public class TileEntityBioGenerator extends TileEntityGenerator implements ITank ItemStack prevStack = inventory[0].copy(); if(fuel > 0) { - int fuelNeeded = bioFuelTank.getLiquid() != null ? bioFuelTank.getCapacity() - bioFuelTank.getLiquid().amount : bioFuelTank.getCapacity(); + int fuelNeeded = bioFuelSlot.MAX_LIQUID - bioFuelSlot.liquidStored; if(fuel <= fuelNeeded) { - bioFuelTank.fill(new LiquidStack(Mekanism.hooks.ForestryBiofuelID, fuel), true); + bioFuelSlot.liquidStored += fuel; inventory[0].stackSize--; - + if(prevStack.isItemEqual(new ItemStack(Item.bucketLava))) { inventory[0] = new ItemStack(Item.bucketEmpty); } } - + if(inventory[0].stackSize == 0) { inventory[0] = null; @@ -151,16 +152,15 @@ public class TileEntityBioGenerator extends TileEntityGenerator implements ITank } } } - + if(canOperate()) { if(!worldObj.isRemote) { setActive(true); } - - setJoules(electricityStored + fuels.get(bioFuelTank.getLiquid().itemID)); - bioFuelTank.drain(1, true); + bioFuelSlot.setLiquid(bioFuelSlot.liquidStored - 1); + setJoules(electricityStored + GENERATION); } else { if(!worldObj.isRemote) @@ -169,24 +169,7 @@ public class TileEntityBioGenerator extends TileEntityGenerator implements ITank } } } - - @Override - public boolean func_102008_b(int slotID, ItemStack itemstack, int side) - { - if(slotID == 1) - { - return (itemstack.getItem() instanceof IItemElectric && ((IItemElectric)itemstack.getItem()).getReceiveRequest(itemstack).getWatts() == 0) || - (itemstack.getItem() instanceof IElectricItem && (!(itemstack.getItem() instanceof IItemElectric) || - ((IItemElectric)itemstack.getItem()).getReceiveRequest(itemstack).getWatts() == 0)); - } - else if(slotID == 0) - { - return LiquidContainerRegistry.isEmptyContainer(itemstack); - } - - return false; - } - + @Override public boolean isStackValidForSlot(int slotID, ItemStack itemstack) { @@ -199,25 +182,22 @@ public class TileEntityBioGenerator extends TileEntityGenerator implements ITank return itemstack.getItem() instanceof IElectricItem || (itemstack.getItem() instanceof IItemElectric && ((IItemElectric)itemstack.getItem()).getReceiveRequest(itemstack).amperes != 0); } - + return true; } - + @Override public boolean canOperate() { - return electricityStored < MAX_ELECTRICITY && bioFuelTank.getLiquid() != null && bioFuelTank.getLiquid().amount > 0; + return electricityStored < MAX_ELECTRICITY && bioFuelSlot.liquidStored > 0; } - + @Override public void readFromNBT(NBTTagCompound nbtTags) { super.readFromNBT(nbtTags); - if(nbtTags.hasKey("bioFuelTank")) - { - bioFuelTank.readFromNBT(nbtTags.getCompoundTag("bioFuelTank")); - } + bioFuelSlot.liquidStored = nbtTags.getInteger("bioFuelStored"); } @Override @@ -225,12 +205,9 @@ public class TileEntityBioGenerator extends TileEntityGenerator implements ITank { super.writeToNBT(nbtTags); - if(bioFuelTank.getLiquid() != null) - { - nbtTags.setTag("bioFuelTank", bioFuelTank.writeToNBT(new NBTTagCompound())); - } + nbtTags.setInteger("bioFuelStored", bioFuelSlot.liquidStored); } - + @Override public int getEnvironmentBoost() { @@ -241,7 +218,7 @@ public class TileEntityBioGenerator extends TileEntityGenerator implements ITank { return itemstack.itemID == MekanismGenerators.BioFuel.itemID ? 100 : 0; } - + /** * Gets the scaled fuel level for the GUI. * @param i - multiplier @@ -249,15 +226,9 @@ public class TileEntityBioGenerator extends TileEntityGenerator implements ITank */ public int getScaledFuelLevel(int i) { - return bioFuelTank.getLiquid() != null ? bioFuelTank.getLiquid().amount*i / bioFuelTank.getCapacity() : 0; + return bioFuelSlot.liquidStored*i / bioFuelSlot.MAX_LIQUID; } - - @Override - public int[] getSizeInventorySide(int side) - { - return ForgeDirection.getOrientation(side) == MekanismUtils.getRight(facing) ? new int[] {1} : new int[] {0}; - } - + @Override public int getStartInventorySide(ForgeDirection side) { @@ -265,51 +236,37 @@ public class TileEntityBioGenerator extends TileEntityGenerator implements ITank { return 1; } - + return 0; } - + @Override public int getSizeInventorySide(ForgeDirection side) { return 1; } - + @Override public boolean canSetFacing(int facing) { return facing != 0 && facing != 1; } - + @Override public void handlePacketData(ByteArrayDataInput dataStream) { super.handlePacketData(dataStream); - - int amount = dataStream.readInt(); - - if(amount != 0) - { - bioFuelTank.setLiquid(new LiquidStack(Mekanism.hooks.ForestryBiofuelID, amount)); - } + bioFuelSlot.liquidStored = dataStream.readInt(); } - + @Override public ArrayList getNetworkedData(ArrayList data) { super.getNetworkedData(data); - - if(bioFuelTank.getLiquid() != null) - { - data.add(bioFuelTank.getLiquid().amount); - } - else { - data.add(0); - } - + data.add(bioFuelSlot.liquidStored); return data; } - + @Override public String[] getMethodNames() { @@ -330,9 +287,9 @@ public class TileEntityBioGenerator extends TileEntityGenerator implements ITank case 3: return new Object[] {(MAX_ELECTRICITY-electricityStored)}; case 4: - return new Object[] {bioFuelTank.getLiquid() != null ? bioFuelTank.getLiquid().amount : 0}; + return new Object[] {bioFuelSlot.liquidStored}; case 5: - return new Object[] {bioFuelTank.getLiquid() != null ? bioFuelTank.getCapacity()-bioFuelTank.getLiquid().amount : 0}; + return new Object[] {bioFuelSlot.MAX_LIQUID-bioFuelSlot.liquidStored}; default: System.err.println("[Mekanism] Attempted to call unknown method with computer ID " + computer.getID()); return null; @@ -342,17 +299,37 @@ public class TileEntityBioGenerator extends TileEntityGenerator implements ITank @Override public int fill(ForgeDirection from, LiquidStack resource, boolean doFill) { - return fill(0, resource, doFill); + if(from != ForgeDirection.getOrientation(facing)) + { + if(resource.itemID == Mekanism.hooks.ForestryBiofuelID) + { + int fuelTransfer = 0; + int fuelNeeded = bioFuelSlot.MAX_LIQUID - bioFuelSlot.liquidStored; + int attemptTransfer = resource.amount; + + if(attemptTransfer <= fuelNeeded) + { + fuelTransfer = attemptTransfer; + } + else { + fuelTransfer = fuelNeeded; + } + + if(doFill) + { + bioFuelSlot.setLiquid(bioFuelSlot.liquidStored + fuelTransfer); + } + + return fuelTransfer; + } + } + + return 0; } @Override public int fill(int tankIndex, LiquidStack resource, boolean doFill) { - if(resource.itemID == Mekanism.hooks.ForestryBiofuelID && tankIndex == 0) - { - return bioFuelTank.fill(resource, doFill); - } - return 0; } @@ -371,12 +348,12 @@ public class TileEntityBioGenerator extends TileEntityGenerator implements ITank @Override public ILiquidTank[] getTanks(ForgeDirection direction) { - return new ILiquidTank[] {bioFuelTank}; + return new ILiquidTank[] {new LiquidTank(bioFuelSlot.liquidID, bioFuelSlot.liquidStored, bioFuelSlot.MAX_LIQUID)}; } - + @Override public ILiquidTank getTank(ForgeDirection direction, LiquidStack type) { - return bioFuelTank; + return null; } -} +} \ No newline at end of file diff --git a/src/minecraft/mekanism/generators/common/TileEntityElectrolyticSeparator.java b/src/minecraft/mekanism/generators/common/TileEntityElectrolyticSeparator.java index af65a0346..1aa866d65 100644 --- a/src/minecraft/mekanism/generators/common/TileEntityElectrolyticSeparator.java +++ b/src/minecraft/mekanism/generators/common/TileEntityElectrolyticSeparator.java @@ -14,6 +14,7 @@ import mekanism.api.IGasStorage; import mekanism.api.IStorageTank; import mekanism.api.IStrictEnergyAcceptor; import mekanism.api.ITubeConnection; +import mekanism.common.ISustainedTank; import mekanism.common.LiquidSlot; import mekanism.common.Mekanism; import mekanism.common.MekanismUtils; @@ -40,7 +41,7 @@ import com.google.common.io.ByteArrayDataInput; import dan200.computer.api.IComputerAccess; import dan200.computer.api.IPeripheral; -public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock implements IGasStorage, IEnergySink, ITankContainer, IPeripheral, ITubeConnection, IStrictEnergyAcceptor +public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock implements IGasStorage, IEnergySink, ITankContainer, IPeripheral, ITubeConnection, IStrictEnergyAcceptor, ISustainedTank { /** This separator's water slot. */ public LiquidTank waterTank = new LiquidTank(24000); @@ -65,7 +66,7 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp public TileEntityElectrolyticSeparator() { - super("Electrolytic Separator", 9600); + super("Electrolytic Separator", 20000); inventory = new ItemStack[4]; outputType = EnumGas.HYDROGEN; dumpType = EnumGas.NONE; @@ -189,7 +190,7 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp if(oxygenStored < MAX_GAS && hydrogenStored < MAX_GAS && waterTank.getLiquid() != null && waterTank.getLiquid().amount-2 >= 0 && electricityStored-4 > 0) { waterTank.drain(2, true); - setJoules(electricityStored - 10); + setJoules(electricityStored - 200); setGas(EnumGas.OXYGEN, oxygenStored + 1); setGas(EnumGas.HYDROGEN, hydrogenStored + 2); } @@ -426,7 +427,7 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp int amount = dataStream.readInt(); if(amount != 0) { - waterTank.setLiquid(new LiquidStack(Block.waterStill.blockID, dataStream.readInt(), 0)); + waterTank.setLiquid(new LiquidStack(Block.waterStill.blockID, amount, 0)); } oxygenStored = dataStream.readInt(); @@ -660,4 +661,22 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp { return side == ForgeDirection.getOrientation(facing); } + + @Override + public void setLiquidStack(LiquidStack liquidStack, Object... data) + { + waterTank.setLiquid(liquidStack); + } + + @Override + public LiquidStack getLiquidStack(Object... data) + { + return waterTank.getLiquid(); + } + + @Override + public boolean hasTank(Object... data) + { + return true; + } } diff --git a/src/minecraft/mekanism/generators/common/TileEntityHydrogenGenerator.java b/src/minecraft/mekanism/generators/common/TileEntityHydrogenGenerator.java index 4adb7dbfe..b39036a2a 100644 --- a/src/minecraft/mekanism/generators/common/TileEntityHydrogenGenerator.java +++ b/src/minecraft/mekanism/generators/common/TileEntityHydrogenGenerator.java @@ -33,7 +33,7 @@ public class TileEntityHydrogenGenerator extends TileEntityGenerator implements public TileEntityHydrogenGenerator() { - super("Hydrogen Generator", 400000, 1200); + super("Hydrogen Generator", 40000, 400); inventory = new ItemStack[2]; } @@ -89,7 +89,7 @@ public class TileEntityHydrogenGenerator extends TileEntityGenerator implements } hydrogenStored-=2; - setJoules(electricityStored + 600); + setJoules(electricityStored + 200); } else { if(!worldObj.isRemote) diff --git a/src/minecraft/mekanism/tools/common/MekanismTools.java b/src/minecraft/mekanism/tools/common/MekanismTools.java index c7f297341..d92234a82 100644 --- a/src/minecraft/mekanism/tools/common/MekanismTools.java +++ b/src/minecraft/mekanism/tools/common/MekanismTools.java @@ -133,6 +133,9 @@ public class MekanismTools @Init public void init(FMLInitializationEvent event) { + //Add this module to the core list + Mekanism.modulesLoaded.add(this); + //Register this class to the event bus for special mob spawning (mobs with Mekanism armor/tools) MinecraftForge.EVENT_BUS.register(this);