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!
This commit is contained in:
Aidan Brady 2013-04-05 16:26:48 -04:00
parent 4cebdea5a0
commit 5f496a00ec
27 changed files with 886 additions and 187 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

View file

@ -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);
}

View file

@ -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

View file

@ -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);

View file

@ -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)
{

View file

@ -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;
}
}

View file

@ -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;
}
}

View file

@ -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);
}
}

View file

@ -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();
}
}

View file

@ -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();
}
}

View file

@ -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)
{

View file

@ -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;

View file

@ -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");
}
/**

View file

@ -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);
}

View file

@ -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;
}
}

View file

@ -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());

View file

@ -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;

View file

@ -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;
}
}

View file

@ -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);
}

View file

@ -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);

View file

@ -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);
}
}

View file

@ -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());

View file

@ -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<Integer, Integer> fuels = new HashMap<Integer, Integer>();
@ -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;
}
}
}

View file

@ -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;
}
}

View file

@ -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)

View file

@ -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);