From 3fed1d8d8d6b1552b8205a01ace2b1c5b205edbc Mon Sep 17 00:00:00 2001 From: Boblet Date: Fri, 20 May 2022 14:43:45 +0200 Subject: [PATCH] ported a few more machines to the new fluid API --- .../machine/TileEntityCoreReceiver.java | 9 +- .../machine/TileEntityMachineTurbine.java | 16 ++- .../machine/TileEntityReactorZirnox.java | 113 ++++++++++-------- .../hbm/textures/items/circuit_demo.png | Bin 0 -> 237 bytes .../hbm/textures/items/circuit_demo2.png | Bin 0 -> 450 bytes .../hbm/textures/items/circuit_demo3.png | Bin 0 -> 253 bytes .../hbm/textures/items/circuit_demo4.png | Bin 0 -> 350 bytes .../hbm/textures/items/circuit_demo5.png | Bin 0 -> 576 bytes .../hbm/textures/items/circuit_demo6.png | Bin 0 -> 255 bytes 9 files changed, 87 insertions(+), 51 deletions(-) create mode 100644 src/main/resources/assets/hbm/textures/items/circuit_demo.png create mode 100644 src/main/resources/assets/hbm/textures/items/circuit_demo2.png create mode 100644 src/main/resources/assets/hbm/textures/items/circuit_demo3.png create mode 100644 src/main/resources/assets/hbm/textures/items/circuit_demo4.png create mode 100644 src/main/resources/assets/hbm/textures/items/circuit_demo5.png create mode 100644 src/main/resources/assets/hbm/textures/items/circuit_demo6.png diff --git a/src/main/java/com/hbm/tileentity/machine/TileEntityCoreReceiver.java b/src/main/java/com/hbm/tileentity/machine/TileEntityCoreReceiver.java index dbe789d6e..ec5e842dd 100644 --- a/src/main/java/com/hbm/tileentity/machine/TileEntityCoreReceiver.java +++ b/src/main/java/com/hbm/tileentity/machine/TileEntityCoreReceiver.java @@ -11,6 +11,7 @@ import com.hbm.tileentity.TileEntityMachineBase; import api.hbm.block.ILaserable; import api.hbm.energy.IEnergyGenerator; +import api.hbm.fluid.IFluidStandardReceiver; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.init.Blocks; @@ -20,7 +21,7 @@ import net.minecraft.util.AxisAlignedBB; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; -public class TileEntityCoreReceiver extends TileEntityMachineBase implements IEnergyGenerator, IFluidAcceptor, ILaserable { +public class TileEntityCoreReceiver extends TileEntityMachineBase implements IEnergyGenerator, IFluidAcceptor, ILaserable, IFluidStandardReceiver { public long power; public long joules; @@ -42,6 +43,7 @@ public class TileEntityCoreReceiver extends TileEntityMachineBase implements IEn if (!worldObj.isRemote) { tank.updateTank(xCoord, yCoord, zCoord, worldObj.provider.dimensionId); + this.subscribeToAllAround(tank.getTankType(), this); power = joules * 5000; @@ -163,4 +165,9 @@ public class TileEntityCoreReceiver extends TileEntityMachineBase implements IEn nbt.setLong("joules", joules); tank.writeToNBT(nbt, "tank"); } + + @Override + public FluidTank[] getReceivingTanks() { + return new FluidTank[] { tank }; + } } diff --git a/src/main/java/com/hbm/tileentity/machine/TileEntityMachineTurbine.java b/src/main/java/com/hbm/tileentity/machine/TileEntityMachineTurbine.java index 4acfb031a..d21369773 100644 --- a/src/main/java/com/hbm/tileentity/machine/TileEntityMachineTurbine.java +++ b/src/main/java/com/hbm/tileentity/machine/TileEntityMachineTurbine.java @@ -17,6 +17,7 @@ import com.hbm.tileentity.TileEntityLoadedBase; import api.hbm.energy.IBatteryItem; import api.hbm.energy.IEnergyGenerator; +import api.hbm.fluid.IFluidStandardTransceiver; import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.ISidedInventory; @@ -25,7 +26,7 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraftforge.common.util.ForgeDirection; -public class TileEntityMachineTurbine extends TileEntityLoadedBase implements ISidedInventory, IFluidContainer, IFluidAcceptor, IFluidSource, IEnergyGenerator { +public class TileEntityMachineTurbine extends TileEntityLoadedBase implements ISidedInventory, IFluidContainer, IFluidAcceptor, IFluidSource, IEnergyGenerator, IFluidStandardTransceiver { private ItemStack slots[]; @@ -221,6 +222,7 @@ public class TileEntityMachineTurbine extends TileEntityLoadedBase implements IS age = 0; } + this.subscribeToAllAround(tanks[0].getTankType(), this); fillFluidInit(tanks[1].getTankType()); for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) @@ -252,6 +254,8 @@ public class TileEntityMachineTurbine extends TileEntityLoadedBase implements IS power = maxPower; } + this.sendFluidToAll(tanks[1].getTankType(), this); + tanks[1].unloadTank(5, 6, slots); for(int i = 0; i < 2; i++) @@ -349,4 +353,14 @@ public class TileEntityMachineTurbine extends TileEntityLoadedBase implements IS public void setPower(long i) { this.power = i; } + + @Override + public FluidTank[] getSendingTanks() { + return new FluidTank[] { tanks[1] }; + } + + @Override + public FluidTank[] getReceivingTanks() { + return new FluidTank[] { tanks[0] }; + } } diff --git a/src/main/java/com/hbm/tileentity/machine/TileEntityReactorZirnox.java b/src/main/java/com/hbm/tileentity/machine/TileEntityReactorZirnox.java index f5885f311..d48cacb7d 100644 --- a/src/main/java/com/hbm/tileentity/machine/TileEntityReactorZirnox.java +++ b/src/main/java/com/hbm/tileentity/machine/TileEntityReactorZirnox.java @@ -26,7 +26,9 @@ import com.hbm.items.machine.ItemZirnoxRod; import com.hbm.lib.Library; import com.hbm.main.MainRegistry; import com.hbm.tileentity.TileEntityMachineBase; +import com.hbm.util.fauxpointtwelve.DirPos; +import api.hbm.fluid.IFluidStandardTransceiver; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.entity.player.EntityPlayer; @@ -36,7 +38,7 @@ import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.Vec3; import net.minecraftforge.common.util.ForgeDirection; -public class TileEntityReactorZirnox extends TileEntityMachineBase implements IFluidContainer, IFluidAcceptor, IFluidSource, IControlReceiver { +public class TileEntityReactorZirnox extends TileEntityMachineBase implements IFluidContainer, IFluidAcceptor, IFluidSource, IControlReceiver, IFluidStandardTransceiver { public int heat; public static final int maxHeat = 100000; @@ -120,54 +122,30 @@ public class TileEntityReactorZirnox extends TileEntityMachineBase implements IF private int[] getNeighbouringSlots(int id) { switch(id) { - case 0: - return new int[] { 1, 7 }; - case 1: - return new int[] { 0, 2, 8 }; - case 2: - return new int[] { 1, 9 }; - case 3: - return new int[] { 4, 10 }; - case 4: - return new int[] { 3, 5, 11 }; - case 5: - return new int[] { 4, 6, 12 }; - case 6: - return new int[] { 5, 13 }; - case 7: - return new int[] { 0, 8, 14 }; - case 8: - return new int[] { 1, 7, 9, 15 }; - case 9: - return new int[] { 2, 8, 16}; - case 10: - return new int[] { 3, 11, 17 }; - case 11: - return new int[] { 4, 10, 12, 18 }; - case 12: - return new int[] { 5, 11, 13, 19 }; - case 13: - return new int[] { 6, 12, 20 }; - case 14: - return new int[] { 7, 15, 21 }; - case 15: - return new int[] { 8, 14, 16, 22 }; - case 16: - return new int[] { 9, 15, 23 }; - case 17: - return new int[] { 10, 18 }; - case 18: - return new int[] { 11, 17, 19 }; - case 19: - return new int[] { 12, 18, 20 }; - case 20: - return new int[] { 13, 19 }; - case 21: - return new int[] { 14, 22 }; - case 22: - return new int[] { 15, 21, 23 }; - case 23: - return new int[] { 16, 22 }; + case 0: return new int[] { 1, 7 }; + case 1: return new int[] { 0, 2, 8 }; + case 2: return new int[] { 1, 9 }; + case 3: return new int[] { 4, 10 }; + case 4: return new int[] { 3, 5, 11 }; + case 5: return new int[] { 4, 6, 12 }; + case 6: return new int[] { 5, 13 }; + case 7: return new int[] { 0, 8, 14 }; + case 8: return new int[] { 1, 7, 9, 15 }; + case 9: return new int[] { 2, 8, 16}; + case 10: return new int[] { 3, 11, 17 }; + case 11: return new int[] { 4, 10, 12, 18 }; + case 12: return new int[] { 5, 11, 13, 19 }; + case 13: return new int[] { 6, 12, 20 }; + case 14: return new int[] { 7, 15, 21 }; + case 15: return new int[] { 8, 14, 16, 22 }; + case 16: return new int[] { 9, 15, 23 }; + case 17: return new int[] { 10, 18 }; + case 18: return new int[] { 11, 17, 19 }; + case 19: return new int[] { 12, 18, 20 }; + case 20: return new int[] { 13, 19 }; + case 21: return new int[] { 14, 22 }; + case 22: return new int[] { 15, 21, 23 }; + case 23: return new int[] { 16, 22 }; } return null; @@ -187,6 +165,10 @@ public class TileEntityReactorZirnox extends TileEntityMachineBase implements IF if(age == 9 || age == 19) { fillFluidInit(steam.getTankType()); } + + if(worldObj.getTotalWorldTime() % 20 == 0) { + this.updateConnections(); + } carbonDioxide.loadTank(24, 26, slots); water.loadTank(25, 27, slots); @@ -217,6 +199,10 @@ public class TileEntityReactorZirnox extends TileEntityMachineBase implements IF } } + + for(DirPos pos : getConPos()) { + this.sendFluid(steam.getTankType(), worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir()); + } checkIfMeltdown(); @@ -395,6 +381,25 @@ public class TileEntityReactorZirnox extends TileEntityMachineBase implements IF fillFluid(this.xCoord + rot.offsetX * -3, this.yCoord + 1, this.zCoord + rot.offsetZ * -3, getTact(), type); fillFluid(this.xCoord + rot.offsetX * -3, this.yCoord + 3, this.zCoord + rot.offsetZ * -3, getTact(), type); } + + private void updateConnections() { + for(DirPos pos : getConPos()) { + this.trySubscribe(water.getTankType(), worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir()); + this.trySubscribe(carbonDioxide.getTankType(), worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir()); + } + } + + private DirPos[] getConPos() { + ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata() - BlockDummyable.offset); + ForgeDirection rot = dir.getRotation(ForgeDirection.UP); + + return new DirPos[] { + new DirPos(this.xCoord + rot.offsetX * 3, this.yCoord + 1, this.zCoord + rot.offsetZ * 3, rot), + new DirPos(this.xCoord + rot.offsetX * 3, this.yCoord + 3, this.zCoord + rot.offsetZ * 3, rot), + new DirPos(this.xCoord + rot.offsetX * -3, this.yCoord + 1, this.zCoord + rot.offsetZ * -3, rot.getOpposite()), + new DirPos(this.xCoord + rot.offsetX * -3, this.yCoord + 3, this.zCoord + rot.offsetZ * -3, rot.getOpposite()) + }; + } public boolean getTact() { if(age >= 0 && age < 10) { @@ -496,4 +501,14 @@ public class TileEntityReactorZirnox extends TileEntityMachineBase implements IF this.markDirty(); } + @Override + public FluidTank[] getSendingTanks() { + return new FluidTank[] { steam }; + } + + @Override + public FluidTank[] getReceivingTanks() { + return new FluidTank[] { water, carbonDioxide }; + } + } \ No newline at end of file diff --git a/src/main/resources/assets/hbm/textures/items/circuit_demo.png b/src/main/resources/assets/hbm/textures/items/circuit_demo.png new file mode 100644 index 0000000000000000000000000000000000000000..bf2fda53ffb2d6eddec65363b4272486e3c0d43d GIT binary patch literal 237 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`EX7WqAsj$Z!;#Vf5Ow-PVFe{<%XnVkQ}z@LWzSjbKq0HX}*L!;{& zRd?%$a(jdRRPMdOG&J|yWf26}EvLMVUF|>w=wAE5lsLNLIQr=I^Qk@nf&d#mlW50f zeRr9k^XN}IyNVacPC>N>bLYLB&XkZr;ajL2Vtyz9XtxSRPHsF~$>E}>VDYw}{8rIg zSnr(heZRU2?(evqj-wsTarA+ObRTnPJ&2%0h6RC$@Gb1Wr2Py!Y#qzR05AV_eHkYRA|g324j4toJeCTtEe)D&VfMt5T7w?CI*Ngy0Rh6OTW&za4<4Y3(2Cs2+? sJD?pQ>|JIW)%vurEVFYz!1 yOxtab_5bAaTo)@nS5l{Z(RHcAx#fTD`>YvexEl3awyOi(&*16m=d#Wzp$PyU6ht3ZI!c5@n$+ndv>ae-lynxN&kYs{ zQMxr-uy$;q-<`(x$1{ICeE4fbc5`p!V)w6FMc-d6)g)*Zp5O#twTjFjDC69bjtFKD&i*a~ zzf19!0nv9g&TxJZX3(aJOoz7HRFNgCn5_Yrw*Xc_Cs0iiaWO&HELpqx=ycDR!uj`n z=m4NV2G8*Gs3z$gM0mJ2a(P}=5MmkUZiRh_!YAARe1uN-bh<~}OfYn(?ZqtVJ^j#(Axc^Jh-{Df}P!0X>X}=`O!VQ2+n{07*qoM6N<$f>~>nv;Y7A literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/hbm/textures/items/circuit_demo5.png b/src/main/resources/assets/hbm/textures/items/circuit_demo5.png new file mode 100644 index 0000000000000000000000000000000000000000..b2e7c5b4b75c4d388c5537bd950cbd6272fbac0e GIT binary patch literal 576 zcmV-G0>AxXvTz=-0yx4w}~yf>sijr;d@?q&-vhA zml}zS56>C^NeJ!rj@sYAEPcrE{%(`yZ!?si*VN)m&qzX$gs}OfqyX%bZuXRgBo))E zY2!LA>^X(&!1nzb*Uxw+<|`zn7#8)Iu|`4?f+Q^(_kK`++yZ9>J89t`%mNVe6`PdN zeT_c+i$Qz6qpYsYTzLwwkp*DO%OOb%oE0P`01QipFV8CD=wmUxnl|=~qPlbifNO8| zkc5TAqs$*~oQodz3Uqrgu^h2ugZ&MR>qOc=n8j+_yiHed9mwx25MCal2O;4=GpxY( z7xmLieDEnp%mXVaNJ_Bcg6lxH2l_}89>ZJb>vU5vFj2IQ0Jl0n$?q(n zk2Lx)5I8&v1_2;G3mM;FY98%L11ASuPo{yf8yA)E}MS0ET-ys8mw*9(0ym*ZFFlJ>Iv}Dd>*zSJ#Bg+dxnaqGajBPVd-sBC8TBmx}gmeF{ z|5e|=@3;P;JUONM`r;?gr=FbQ5b(jqQ16-9x+!cAei*!&Zl!54`G~05-j9~*Gm2&$ z?ccOB=vJ{L^A=eVYdfZmf0vop^+beNeNeXeEu?AAa9EeW{DIKEg@43K7Ui