From afe7188b290a1708b4dc938f6c275a983e008115 Mon Sep 17 00:00:00 2001 From: Pheonix Date: Sat, 9 Apr 2022 23:28:35 +0100 Subject: [PATCH] yet more electrolysis funnies --- .../container/ContainerElectrolyser.java | 45 +++++ .../hbm/inventory/gui/GUIElectrolyser.java | 2 +- .../hbm/render/item/ItemRenderLibrary.java | 11 ++ .../java/com/hbm/tileentity/TileMappings.java | 1 + .../machine/TileEntityElectrolyser.java | 29 +++- .../machine/TileEntityTowerLarge.java | 162 +++++++++--------- 6 files changed, 161 insertions(+), 89 deletions(-) diff --git a/src/main/java/com/hbm/inventory/container/ContainerElectrolyser.java b/src/main/java/com/hbm/inventory/container/ContainerElectrolyser.java index b734b213f..dd87db602 100644 --- a/src/main/java/com/hbm/inventory/container/ContainerElectrolyser.java +++ b/src/main/java/com/hbm/inventory/container/ContainerElectrolyser.java @@ -1,5 +1,6 @@ package com.hbm.inventory.container; +import com.hbm.inventory.SlotMachineOutput; import com.hbm.tileentity.machine.TileEntityElectrolyser; import net.minecraft.entity.player.EntityPlayer; @@ -16,7 +17,51 @@ public class ContainerElectrolyser extends Container { electrolyser = tile; + //0 - battery + //1-2 - upgrade slots + //3-4 - fluid ID + //5-10 - fluid I/O + //11-13 - dissolved outputs + + //14 - crystal input + //15 - niter input + //16-17 - casting slots + //18-23 - other material outputs + + this.addSlotToContainer(new Slot(tile, 0, 186, 109)); + + this.addSlotToContainer(new Slot(tile, 1, 186, 140)); + this.addSlotToContainer(new Slot(tile, 2, 186, 158)); + + this.addSlotToContainer(new Slot(tile, 3, 6, 18)); + this.addSlotToContainer(new SlotMachineOutput(tile, 4, 6, 54)); + + this.addSlotToContainer(new Slot(tile, 5, 24, 18)); + this.addSlotToContainer(new SlotMachineOutput(tile, 6, 24, 54)); + + this.addSlotToContainer(new Slot(tile, 7, 78, 18)); + this.addSlotToContainer(new SlotMachineOutput(tile, 8, 78, 54)); + + this.addSlotToContainer(new Slot(tile, 9, 134, 18)); + this.addSlotToContainer(new SlotMachineOutput(tile, 10, 134, 54)); + + for(int i = 0; i < 3; i++) { + this.addSlotToContainer(new SlotMachineOutput(tile, 11+i, 154, 18+(18*i))); + } + + this.addSlotToContainer(new Slot(tile, 14, 10, 90)); + + this.addSlotToContainer(new Slot(tile, 15, 37, 122)); + + this.addSlotToContainer(new SlotMachineOutput(tile, 16, 60, 112)); + this.addSlotToContainer(new SlotMachineOutput(tile, 16, 98, 112)); + + for(int i = 0; i < 2; i++) { + for(int j = 0; j < 3; j++) { + this.addSlotToContainer(new SlotMachineOutput(tile, 17+(i*3)+j, 136+(18*i), 86+(18*j))); + } + } for(int i = 0; i < 3; i++) { for(int j = 0; j < 9; j++) { diff --git a/src/main/java/com/hbm/inventory/gui/GUIElectrolyser.java b/src/main/java/com/hbm/inventory/gui/GUIElectrolyser.java index 3698ccf84..33bfb2f9c 100644 --- a/src/main/java/com/hbm/inventory/gui/GUIElectrolyser.java +++ b/src/main/java/com/hbm/inventory/gui/GUIElectrolyser.java @@ -45,7 +45,7 @@ public class GUIElectrolyser extends GuiInfoContainer { protected void drawGuiContainerForegroundLayer(int i, int j) { String name = this.electrolyser.hasCustomInventoryName() ? this.electrolyser.getInventoryName() : I18n.format(this.electrolyser.getInventoryName()); - this.fontRendererObj.drawString(name, 90 + this.xSize / 2 - this.fontRendererObj.getStringWidth(name) / 2, 7, 0xffffff); + this.fontRendererObj.drawString(name, (this.xSize / 2 - this.fontRendererObj.getStringWidth(name) / 2) - 16, 7, 0xffffff); this.fontRendererObj.drawString(I18n.format("container.inventory"), 8, this.ySize - 94, 4210752); } } diff --git a/src/main/java/com/hbm/render/item/ItemRenderLibrary.java b/src/main/java/com/hbm/render/item/ItemRenderLibrary.java index dcfb4853f..15af36104 100644 --- a/src/main/java/com/hbm/render/item/ItemRenderLibrary.java +++ b/src/main/java/com/hbm/render/item/ItemRenderLibrary.java @@ -1237,6 +1237,17 @@ public class ItemRenderLibrary { GL11.glShadeModel(GL11.GL_FLAT); }}); + renderers.put(Item.getItemFromBlock(ModBlocks.machine_electrolyser), new ItemRenderBase( ) { + public void renderInventory() { + GL11.glScaled(3, 3, 3); + } + public void renderCommon() { + GL11.glScaled(0.5, 0.5, 0.5); + GL11.glShadeModel(GL11.GL_SMOOTH); + bindTexture(ResourceManager.electrolyser_tex); ResourceManager.electrolyser.renderAll(); + GL11.glShadeModel(GL11.GL_FLAT); + }}); + renderers.put(Item.getItemFromBlock(ModBlocks.red_pylon_large), new ItemRenderBase( ) { public void renderInventory() { GL11.glTranslated(0, -5, 0); diff --git a/src/main/java/com/hbm/tileentity/TileMappings.java b/src/main/java/com/hbm/tileentity/TileMappings.java index ca2701011..dd2d04436 100644 --- a/src/main/java/com/hbm/tileentity/TileMappings.java +++ b/src/main/java/com/hbm/tileentity/TileMappings.java @@ -250,6 +250,7 @@ public class TileMappings { put(TileEntityDeuteriumTower.class, "tileentity_deuterium_tower"); put(TileEntityMachineLiquefactor.class, "tileentity_liquefactor"); put(TileEntityMachineSolidifier.class, "tileentity_solidifier"); + put(TileEntityElectrolyser.class, "tileentity_electrolyser"); put(TileEntityMachineChemplant.class, "tileentity_chemical_plant"); put(TileEntityMachineChemfac.class, "tileentity_chemfac"); diff --git a/src/main/java/com/hbm/tileentity/machine/TileEntityElectrolyser.java b/src/main/java/com/hbm/tileentity/machine/TileEntityElectrolyser.java index a29b18979..58864d289 100644 --- a/src/main/java/com/hbm/tileentity/machine/TileEntityElectrolyser.java +++ b/src/main/java/com/hbm/tileentity/machine/TileEntityElectrolyser.java @@ -3,6 +3,7 @@ package com.hbm.tileentity.machine; import java.util.ArrayList; import java.util.List; +import com.hbm.blocks.BlockDummyable; import com.hbm.interfaces.IFluidAcceptor; import com.hbm.interfaces.IFluidSource; import com.hbm.inventory.FluidTank; @@ -14,8 +15,10 @@ import com.hbm.tileentity.TileEntityMachineBase; import api.hbm.energy.IEnergyUser; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.init.Blocks; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.AxisAlignedBB; +import net.minecraftforge.common.util.ForgeDirection; public class TileEntityElectrolyser extends TileEntityMachineBase implements IEnergyUser, IFluidSource, IFluidAcceptor{ @@ -51,6 +54,8 @@ public class TileEntityElectrolyser extends TileEntityMachineBase implements IEn if(!worldObj.isRemote) { + this.tanks[0].updateTank(xCoord, yCoord, zCoord, worldObj.provider.dimensionId); + NBTTagCompound data = new NBTTagCompound(); data.setLong("power", this.power); @@ -60,11 +65,27 @@ public class TileEntityElectrolyser extends TileEntityMachineBase implements IEn data.setInteger("processFluidTime", this.processFluidTime); data.setInteger("processOreTime", this.processOreTime); this.networkPack(data, 50); + + fillFluidInit(tanks[1].getTankType()); + fillFluidInit(tanks[2].getTankType()); } } -AxisAlignedBB bb = null; + @Override + public void fillFluidInit(FluidType type) { + + ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata() - BlockDummyable.offset); + ForgeDirection rot = dir.getRotation(ForgeDirection.UP); + + fillFluid(xCoord + dir.offsetX * 5 + rot.offsetX * -1, yCoord-1, zCoord + dir.offsetZ * 5 + rot.offsetZ * -1, getTact(), type); + fillFluid(xCoord + dir.offsetX * 5 + rot.offsetX * -1, yCoord-1, zCoord + dir.offsetZ * 5 + rot.offsetZ * 1, getTact(), type); + fillFluid(xCoord + dir.offsetX * -5 + rot.offsetX * -1, yCoord-1, zCoord + dir.offsetZ * 5 + rot.offsetZ * -1, getTact(), type); + fillFluid(xCoord + dir.offsetX * -5 + rot.offsetX * -1, yCoord-1, zCoord + dir.offsetZ * 5 + rot.offsetZ * 1, getTact(), type); + + } + + AxisAlignedBB bb = null; @Override public AxisAlignedBB getRenderBoundingBox() { @@ -138,12 +159,6 @@ AxisAlignedBB bb = null; return 0; } - @Override - public void fillFluidInit(FluidType type) { - // TODO Auto-generated method stub - - } - @Override public void fillFluid(int x, int y, int z, boolean newTact, FluidType type) { Library.transmitFluid(x, y, z, newTact, this, worldObj, type); diff --git a/src/main/java/com/hbm/tileentity/machine/TileEntityTowerLarge.java b/src/main/java/com/hbm/tileentity/machine/TileEntityTowerLarge.java index eb366d2ef..f5a4b067b 100644 --- a/src/main/java/com/hbm/tileentity/machine/TileEntityTowerLarge.java +++ b/src/main/java/com/hbm/tileentity/machine/TileEntityTowerLarge.java @@ -1,81 +1,81 @@ -package com.hbm.tileentity.machine; - -import com.hbm.inventory.FluidTank; -import com.hbm.inventory.fluid.FluidType; -import com.hbm.inventory.fluid.Fluids; -import com.hbm.main.MainRegistry; - -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.AxisAlignedBB; -import net.minecraftforge.common.util.ForgeDirection; - -public class TileEntityTowerLarge extends TileEntityCondenser { - - public TileEntityTowerLarge() { - tanks = new FluidTank[2]; - tanks[0] = new FluidTank(Fluids.SPENTSTEAM, 10000, 0); - tanks[1] = new FluidTank(Fluids.WATER, 10000, 1); - } - - @Override - public void updateEntity() { - super.updateEntity(); - - if(worldObj.isRemote) { - - if(this.waterTimer > 0 && this.worldObj.getTotalWorldTime() % 4 == 0) { - NBTTagCompound data = new NBTTagCompound(); - data.setString("type", "tower"); - data.setFloat("lift", 0.5F); - data.setFloat("base", 1F); - data.setFloat("max", 10F); - data.setInteger("life", 750 + worldObj.rand.nextInt(250)); - - data.setDouble("posX", xCoord + 0.5 + worldObj.rand.nextDouble() * 3 - 1.5); - data.setDouble("posZ", zCoord + 0.5 + worldObj.rand.nextDouble() * 3 - 1.5); - data.setDouble("posY", yCoord + 1); - - MainRegistry.proxy.effectNT(data); - } - } - } - - @Override - public void fillFluidInit(FluidType type) { - - for(int i = 2; i <= 6; i++) { - ForgeDirection dir = ForgeDirection.getOrientation(i); - ForgeDirection rot = dir.getRotation(ForgeDirection.UP); - fillFluid(xCoord + dir.offsetX * 5, yCoord, zCoord + dir.offsetZ * 5, getTact(), type); - fillFluid(xCoord + dir.offsetX * 5 + rot.offsetX * 3, yCoord, zCoord + dir.offsetZ * 5 + rot.offsetZ * 3, getTact(), type); - fillFluid(xCoord + dir.offsetX * 5 + rot.offsetX * -3, yCoord, zCoord + dir.offsetZ * 5 + rot.offsetZ * -3, getTact(), type); - } - } - - AxisAlignedBB bb = null; - - @Override - public AxisAlignedBB getRenderBoundingBox() { - - if(bb == null) { - bb = AxisAlignedBB.getBoundingBox( - xCoord - 4, - yCoord, - zCoord - 4, - xCoord + 5, - yCoord + 13, - zCoord + 5 - ); - } - - return bb; - } - - @Override - @SideOnly(Side.CLIENT) - public double getMaxRenderDistanceSquared() { - return 65536.0D; - } -} +package com.hbm.tileentity.machine; + +import com.hbm.inventory.FluidTank; +import com.hbm.inventory.fluid.FluidType; +import com.hbm.inventory.fluid.Fluids; +import com.hbm.main.MainRegistry; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.AxisAlignedBB; +import net.minecraftforge.common.util.ForgeDirection; + +public class TileEntityTowerLarge extends TileEntityCondenser { + + public TileEntityTowerLarge() { + tanks = new FluidTank[2]; + tanks[0] = new FluidTank(Fluids.SPENTSTEAM, 10000, 0); + tanks[1] = new FluidTank(Fluids.WATER, 10000, 1); + } + + @Override + public void updateEntity() { + super.updateEntity(); + + if(worldObj.isRemote) { + + if(this.waterTimer > 0 && this.worldObj.getTotalWorldTime() % 4 == 0) { + NBTTagCompound data = new NBTTagCompound(); + data.setString("type", "tower"); + data.setFloat("lift", 0.5F); + data.setFloat("base", 1F); + data.setFloat("max", 10F); + data.setInteger("life", 750 + worldObj.rand.nextInt(250)); + + data.setDouble("posX", xCoord + 0.5 + worldObj.rand.nextDouble() * 3 - 1.5); + data.setDouble("posZ", zCoord + 0.5 + worldObj.rand.nextDouble() * 3 - 1.5); + data.setDouble("posY", yCoord + 1); + + MainRegistry.proxy.effectNT(data); + } + } + } + + @Override + public void fillFluidInit(FluidType type) { + + for(int i = 2; i <= 6; i++) { + ForgeDirection dir = ForgeDirection.getOrientation(i); + ForgeDirection rot = dir.getRotation(ForgeDirection.UP); + fillFluid(xCoord + dir.offsetX * 5, yCoord, zCoord + dir.offsetZ * 5, getTact(), type); + fillFluid(xCoord + dir.offsetX * 5 + rot.offsetX * 3, yCoord, zCoord + dir.offsetZ * 5 + rot.offsetZ * 3, getTact(), type); + fillFluid(xCoord + dir.offsetX * 5 + rot.offsetX * -3, yCoord, zCoord + dir.offsetZ * 5 + rot.offsetZ * -3, getTact(), type); + } + } + + AxisAlignedBB bb = null; + + @Override + public AxisAlignedBB getRenderBoundingBox() { + + if(bb == null) { + bb = AxisAlignedBB.getBoundingBox( + xCoord - 4, + yCoord, + zCoord - 4, + xCoord + 5, + yCoord + 13, + zCoord + 5 + ); + } + + return bb; + } + + @Override + @SideOnly(Side.CLIENT) + public double getMaxRenderDistanceSquared() { + return 65536.0D; + } +}