From 5aee91636c1e12261d58b1192b21d5d98fb3885b Mon Sep 17 00:00:00 2001 From: Boblet Date: Tue, 17 Jun 2025 16:30:00 +0200 Subject: [PATCH] i stuck my ballsack in the coolant line & it got obliterated by delta P --- changelog | 12 ++ .../java/api/hbm/fluidmk2/IFluidUserMK2.java | 2 +- .../machine/MachineChemicalFactory.java | 8 +- .../gui/GUIMachineChemicalFactory.java | 16 +- .../hbm/inventory/recipes/MixerRecipes.java | 2 +- .../weapon/sedna/factory/XFactoryEnergy.java | 8 +- .../hbm/module/ModuleMachineChemplant.java | 12 +- .../hbm/tileentity/TileEntityProxyCombo.java | 161 +++++++++--------- .../hbm/tileentity/TileEntityProxyDyn.java | 24 +++ .../java/com/hbm/tileentity/TileMappings.java | 1 + .../TileEntityMachineChemicalFactory.java | 105 ++++++++++-- .../TileEntityMachineChemicalPlant.java | 2 +- 12 files changed, 242 insertions(+), 111 deletions(-) create mode 100644 src/main/java/com/hbm/tileentity/TileEntityProxyDyn.java diff --git a/changelog b/changelog index b84be97b5..fd3dc6df8 100644 --- a/changelog +++ b/changelog @@ -1,3 +1,13 @@ +## Added +* New chemical factory + * New form factor, uses a smaller 5x5 footprint + * Only does four recipes instead of eight + * Double base speed, but also double power draw + * Three upgrade slots, upgrades follow the same rules as on the new chemplant + * Upgrades stack with the double base speed + * Stackable! + * Water consumption rate is fixed at 100mB/t for each active recipe + ## Changed * The DNT suit now has a damage threshold of 1,000 * Compressed biomass now has a nice cube shape @@ -6,6 +16,8 @@ * Reeds now drop sticks when broken * Switching the recipe in the new chemplant now annihilates residual fluid that is not overwritten by the new recipe * I don't know why people wanted this, but here you go +* The alternate recipe for oxyhydrogen now uses compressed air instead of nothing +* Improved threaded Mk5, should be a smidge faster now ## Fixed * Chemical plant ports. For real this time. diff --git a/src/main/java/api/hbm/fluidmk2/IFluidUserMK2.java b/src/main/java/api/hbm/fluidmk2/IFluidUserMK2.java index 1e60f7585..755c415c5 100644 --- a/src/main/java/api/hbm/fluidmk2/IFluidUserMK2.java +++ b/src/main/java/api/hbm/fluidmk2/IFluidUserMK2.java @@ -9,7 +9,7 @@ public interface IFluidUserMK2 extends IFluidConnectorMK2, ILoadedTile { public static final int HIGHEST_VALID_PRESSURE = 5; public static final int[] DEFAULT_PRESSURE_RANGE = new int[] {0, 0}; - public static final boolean particleDebug = false; + public static final boolean particleDebug = true; public FluidTank[] getAllTanks(); } diff --git a/src/main/java/com/hbm/blocks/machine/MachineChemicalFactory.java b/src/main/java/com/hbm/blocks/machine/MachineChemicalFactory.java index 56ea88967..787f030b9 100644 --- a/src/main/java/com/hbm/blocks/machine/MachineChemicalFactory.java +++ b/src/main/java/com/hbm/blocks/machine/MachineChemicalFactory.java @@ -1,7 +1,7 @@ package com.hbm.blocks.machine; import com.hbm.blocks.BlockDummyable; -import com.hbm.tileentity.TileEntityProxyCombo; +import com.hbm.tileentity.TileEntityProxyDyn; import com.hbm.tileentity.machine.TileEntityMachineChemicalFactory; import net.minecraft.block.material.Material; @@ -19,7 +19,7 @@ public class MachineChemicalFactory extends BlockDummyable { @Override public TileEntity createNewTileEntity(World world, int meta) { if(meta >= 12) return new TileEntityMachineChemicalFactory(); - if(meta >= 6) return new TileEntityProxyCombo().inventory().power().fluid(); + if(meta >= 6) return new TileEntityProxyDyn().inventory().power().fluid(); return null; } @@ -35,8 +35,8 @@ public class MachineChemicalFactory extends BlockDummyable { public void fillSpace(World world, int x, int y, int z, ForgeDirection dir, int o) { super.fillSpace(world, x, y, z, dir, o); - x -= dir.offsetX; - z -= dir.offsetZ; + x -= dir.offsetX * 2; + z -= dir.offsetZ * 2; for(int i = -2; i <= 2; i++) for(int j = -2; j <= 2; j++) { if(Math.abs(i) == 2 || Math.abs(j) == 2) this.makeExtra(world, x + i, y, z + j); diff --git a/src/main/java/com/hbm/inventory/gui/GUIMachineChemicalFactory.java b/src/main/java/com/hbm/inventory/gui/GUIMachineChemicalFactory.java index 07824714e..4b756e87b 100644 --- a/src/main/java/com/hbm/inventory/gui/GUIMachineChemicalFactory.java +++ b/src/main/java/com/hbm/inventory/gui/GUIMachineChemicalFactory.java @@ -34,10 +34,13 @@ public class GUIMachineChemicalFactory extends GuiInfoContainer { super.drawScreen(mouseX, mouseY, f); for(int i = 0; i < 3; i++) for(int j = 0; j < 4; j++) { - chemplant.inputTanks[i].renderTankInfo(this, mouseX, mouseY, guiLeft + 60 + i * 5, guiTop + 20 + j * 22, 4, 16); - chemplant.outputTanks[i].renderTankInfo(this, mouseX, mouseY, guiLeft + 189 + i * 5, guiTop + 20 + j * 22, 4, 16); + chemplant.inputTanks[i + j * 3].renderTankInfo(this, mouseX, mouseY, guiLeft + 60 + i * 5, guiTop + 20 + j * 22, 4, 16); + chemplant.outputTanks[i + j * 3].renderTankInfo(this, mouseX, mouseY, guiLeft + 189 + i * 5, guiTop + 20 + j * 22, 4, 16); } + chemplant.water.renderTankInfo(this, mouseX, mouseY, guiLeft + 224, guiTop + 125, 7, 52); + chemplant.lps.renderTankInfo(this, mouseX, mouseY, guiLeft + 233, guiTop + 125, 7, 52); + this.drawElectricityInfo(this, mouseX, mouseY, guiLeft + 224, guiTop + 18, 16, 68, chemplant.power, chemplant.maxPower); for(int i = 0; i < 4; i++) if(guiLeft + 74 <= mouseX && guiLeft + 74 + 18 > mouseX && guiTop + 19 + i * 22 < mouseY && guiTop + 19 + i * 22 + 18 >= mouseY) { @@ -84,16 +87,16 @@ public class GUIMachineChemicalFactory extends GuiInfoContainer { GenericRecipe recipe = ChemicalPlantRecipes.INSTANCE.recipeNameMap.get(chemplant.chemplantModule[g].recipe); /// LEFT LED - if(chemplant.didProcess) { + if(chemplant.didProcess[g]) { drawTexturedModalRect(guiLeft + 113, guiTop + 21 + g * 22, 4, 222, 4, 4); } else if(recipe != null) { drawTexturedModalRect(guiLeft + 113, guiTop + 21 + g * 22, 0, 222, 4, 4); } /// RIGHT LED - if(chemplant.didProcess) { + if(chemplant.didProcess[g]) { drawTexturedModalRect(guiLeft + 121, guiTop + 21 + g * 22, 4, 222, 4, 4); - } else if(recipe != null && chemplant.power >= recipe.power) { + } else if(recipe != null && chemplant.power >= recipe.power && chemplant.canCool()) { drawTexturedModalRect(guiLeft + 121, guiTop + 21 + g * 22, 0, 222, 4, 4); } } @@ -128,5 +131,8 @@ public class GUIMachineChemicalFactory extends GuiInfoContainer { chemplant.inputTanks[i + j * 3].renderTank(guiLeft + 60 + i * 5, guiTop + 36 + j * 22, this.zLevel, 4, 16); chemplant.outputTanks[i + j * 3].renderTank(guiLeft + 189 + i * 5, guiTop + 36 + j * 22, this.zLevel, 4, 16); } + + chemplant.water.renderTank(guiLeft + 224, guiTop + 177, this.zLevel, 7, 52); + chemplant.lps.renderTank(guiLeft + 233, guiTop + 177, this.zLevel, 7, 52); } } diff --git a/src/main/java/com/hbm/inventory/recipes/MixerRecipes.java b/src/main/java/com/hbm/inventory/recipes/MixerRecipes.java index 670f016e1..e20cf1b56 100644 --- a/src/main/java/com/hbm/inventory/recipes/MixerRecipes.java +++ b/src/main/java/com/hbm/inventory/recipes/MixerRecipes.java @@ -79,7 +79,7 @@ public class MixerRecipes extends SerializableRecipe { register(Fluids.SYNGAS, new MixerRecipe(1_000, 50).setStack1(new FluidStack(Fluids.COALOIL, 500)).setStack2(new FluidStack(Fluids.STEAM, 500))); register(Fluids.OXYHYDROGEN, - new MixerRecipe(1_000, 50).setStack1(new FluidStack(Fluids.HYDROGEN, 500)), + new MixerRecipe(1_000, 50).setStack1(new FluidStack(Fluids.HYDROGEN, 500)).setStack2(new FluidStack(Fluids.AIR, 2_000)), new MixerRecipe(1_000, 50).setStack1(new FluidStack(Fluids.HYDROGEN, 500)).setStack2(new FluidStack(Fluids.OXYGEN, 500))); register(Fluids.PETROIL_LEADED, new MixerRecipe(12_000, 40).setStack1(new FluidStack(Fluids.PETROIL, 10_000)).setSolid(new ComparableStack(ModItems.fuel_additive, 1, 0))); diff --git a/src/main/java/com/hbm/items/weapon/sedna/factory/XFactoryEnergy.java b/src/main/java/com/hbm/items/weapon/sedna/factory/XFactoryEnergy.java index 1d30e41ce..4167419d7 100644 --- a/src/main/java/com/hbm/items/weapon/sedna/factory/XFactoryEnergy.java +++ b/src/main/java/com/hbm/items/weapon/sedna/factory/XFactoryEnergy.java @@ -166,9 +166,9 @@ public class XFactoryEnergy { energy_las_overcharge = new BulletConfig().setItem(EnumAmmo.CAPACITOR_OVERCHARGE).setCasing(new ItemStack(ModItems.ingot_polymer, 2), 4).setupDamageClass(DamageClass.LASER).setBeam().setSpread(0.0F).setLife(5).setRenderRotations(false).setDoesPenetrate(true).setOnBeamImpact(BulletConfig.LAMBDA_STANDARD_BEAM_HIT); energy_las_ir = new BulletConfig().setItem(EnumAmmo.CAPACITOR_IR).setCasing(new ItemStack(ModItems.ingot_polymer, 2), 4).setupDamageClass(DamageClass.FIRE).setBeam().setSpread(0.0F).setLife(5).setRenderRotations(false).setOnBeamImpact(LAMBDA_IR_HIT); - energy_emerald = energy_las.clone().setArmorPiercing(0.5F).setThresholdNegation(5F); - energy_emerald_overcharge = energy_las_overcharge.clone().setArmorPiercing(0.5F).setThresholdNegation(5F); - energy_emerald_ir = energy_las_ir.clone().setArmorPiercing(0.5F).setThresholdNegation(5F); + energy_emerald = energy_las.clone().setArmorPiercing(0.5F).setThresholdNegation(10F); + energy_emerald_overcharge = energy_las_overcharge.clone().setArmorPiercing(0.5F).setThresholdNegation(15F); + energy_emerald_ir = energy_las_ir.clone().setArmorPiercing(0.5F).setThresholdNegation(10F); ModItems.gun_tesla_cannon = new ItemGunBaseNT(WeaponQuality.A_SIDE, new GunConfig() .dura(1_000).draw(10).inspect(33).crosshair(Crosshair.CIRCLE) @@ -194,7 +194,7 @@ public class XFactoryEnergy { ModItems.gun_laser_pistol_pew_pew = new ItemGunBaseNT(WeaponQuality.B_SIDE, new GunConfig() .dura(500).draw(10).inspect(26).crosshair(Crosshair.CIRCLE) .rec(new Receiver(0) - .dmg(20F).rounds(5).delay(10).spread(0.25F).spreadHipfire(1F).reload(45).jam(37).sound("hbm:weapon.fire.laserPistol", 1.0F, 0.8F) + .dmg(30F).rounds(5).delay(10).spread(0.25F).spreadHipfire(1F).reload(45).jam(37).sound("hbm:weapon.fire.laserPistol", 1.0F, 0.8F) .mag(new MagazineFullReload(0, 10).addConfigs(energy_las, energy_las_overcharge, energy_las_ir)) .offset(0.75, -0.0625 * 1.5, -0.1875) .setupStandardFire().recoil(LAMBDA_RECOIL_ENERGY)) diff --git a/src/main/java/com/hbm/module/ModuleMachineChemplant.java b/src/main/java/com/hbm/module/ModuleMachineChemplant.java index c68e9cae6..4c6cbdbcd 100644 --- a/src/main/java/com/hbm/module/ModuleMachineChemplant.java +++ b/src/main/java/com/hbm/module/ModuleMachineChemplant.java @@ -135,14 +135,14 @@ public class ModuleMachineChemplant { } } - public void update(double speed, double power) { + public void update(double speed, double power, boolean extraCondition) { GenericRecipe recipe = ChemicalPlantRecipes.INSTANCE.recipeNameMap.get(this.recipe); this.setupTanks(recipe); this.didProcess = false; this.markDirty = false; - if(this.canProcess(recipe, speed, power)) { + if(extraCondition && this.canProcess(recipe, speed, power)) { this.process(recipe, speed, power); this.didProcess = true; } else { @@ -179,12 +179,12 @@ public class ModuleMachineChemplant { } public void readFromNBT(NBTTagCompound nbt) { - this.progress = nbt.getDouble("progress"); - this.recipe = nbt.getString("recipe"); + this.progress = nbt.getDouble("progress" + index); + this.recipe = nbt.getString("recipe" + index); } public void writeToNBT(NBTTagCompound nbt) { - nbt.setDouble("progress", progress); - nbt.setString("recipe", recipe); + nbt.setDouble("progress" + index, progress); + nbt.setString("recipe" + index, recipe); } } diff --git a/src/main/java/com/hbm/tileentity/TileEntityProxyCombo.java b/src/main/java/com/hbm/tileentity/TileEntityProxyCombo.java index 405551c32..c38e5f51e 100644 --- a/src/main/java/com/hbm/tileentity/TileEntityProxyCombo.java +++ b/src/main/java/com/hbm/tileentity/TileEntityProxyCombo.java @@ -75,15 +75,18 @@ public class TileEntityProxyCombo extends TileEntityProxyBase implements IEnergy return this; } - //fewer messy recursive operations - public TileEntity getTile() { - + /** Returns the actual tile entity that represents the core. Only for internal use. */ + protected TileEntity getTile() { if(tile == null || tile.isInvalid()) { tile = this.getTE(); } - return tile; } + + /** Returns the core tile entity, or a delegate object. */ + protected Object getCoreObject() { + return getTile(); + } @Override public void setPower(long i) { @@ -91,8 +94,8 @@ public class TileEntityProxyCombo extends TileEntityProxyBase implements IEnergy if(!power) return; - if(getTile() instanceof IEnergyReceiverMK2) { - ((IEnergyReceiverMK2)getTile()).setPower(i); + if(getCoreObject() instanceof IEnergyReceiverMK2) { + ((IEnergyReceiverMK2)getCoreObject()).setPower(i); } } @@ -102,8 +105,8 @@ public class TileEntityProxyCombo extends TileEntityProxyBase implements IEnergy if(!power) return 0; - if(getTile() instanceof IEnergyReceiverMK2) { - return ((IEnergyReceiverMK2)getTile()).getPower(); + if(getCoreObject() instanceof IEnergyReceiverMK2) { + return ((IEnergyReceiverMK2)getCoreObject()).getPower(); } return 0; @@ -115,8 +118,8 @@ public class TileEntityProxyCombo extends TileEntityProxyBase implements IEnergy if(!power) return 0; - if(getTile() instanceof IEnergyReceiverMK2) { - return ((IEnergyReceiverMK2)getTile()).getMaxPower(); + if(getCoreObject() instanceof IEnergyReceiverMK2) { + return ((IEnergyReceiverMK2)getCoreObject()).getMaxPower(); } return 0; @@ -128,8 +131,8 @@ public class TileEntityProxyCombo extends TileEntityProxyBase implements IEnergy if(!this.power) return power; - if(getTile() instanceof IEnergyReceiverMK2) { - return ((IEnergyReceiverMK2)getTile()).transferPower(power); + if(getCoreObject() instanceof IEnergyReceiverMK2) { + return ((IEnergyReceiverMK2)getCoreObject()).transferPower(power); } return power; @@ -141,8 +144,8 @@ public class TileEntityProxyCombo extends TileEntityProxyBase implements IEnergy if(!power) return false; - if(getTile() instanceof IEnergyReceiverMK2) { - return ((IEnergyReceiverMK2)getTile()).canConnect(dir); + if(getCoreObject() instanceof IEnergyReceiverMK2) { + return ((IEnergyReceiverMK2)getCoreObject()).canConnect(dir); } return true; @@ -154,8 +157,8 @@ public class TileEntityProxyCombo extends TileEntityProxyBase implements IEnergy public FluidTank[] getAllTanks() { if(!fluid) return EMPTY_TANKS; - if(getTile() instanceof IFluidReceiverMK2) { - return ((IFluidReceiverMK2)getTile()).getAllTanks(); + if(getCoreObject() instanceof IFluidReceiverMK2) { + return ((IFluidReceiverMK2)getCoreObject()).getAllTanks(); } return EMPTY_TANKS; @@ -165,8 +168,8 @@ public class TileEntityProxyCombo extends TileEntityProxyBase implements IEnergy public long transferFluid(FluidType type, int pressure, long amount) { if(!fluid) return amount; - if(getTile() instanceof IFluidReceiverMK2) { - return ((IFluidReceiverMK2)getTile()).transferFluid(type, pressure, amount); + if(getCoreObject() instanceof IFluidReceiverMK2) { + return ((IFluidReceiverMK2)getCoreObject()).transferFluid(type, pressure, amount); } return amount; @@ -176,8 +179,8 @@ public class TileEntityProxyCombo extends TileEntityProxyBase implements IEnergy public long getDemand(FluidType type, int pressure) { if(!fluid) return 0; - if(getTile() instanceof IFluidReceiverMK2) { - return ((IFluidReceiverMK2)getTile()).getDemand(type, pressure); + if(getCoreObject() instanceof IFluidReceiverMK2) { + return ((IFluidReceiverMK2)getCoreObject()).getDemand(type, pressure); } return 0; @@ -189,8 +192,8 @@ public class TileEntityProxyCombo extends TileEntityProxyBase implements IEnergy if(!this.fluid) return false; - if(getTile() instanceof IFluidConnectorMK2) { - return ((IFluidConnectorMK2) getTile()).canConnect(type, dir); + if(getCoreObject() instanceof IFluidConnectorMK2) { + return ((IFluidConnectorMK2) getCoreObject()).canConnect(type, dir); } return true; } @@ -201,8 +204,8 @@ public class TileEntityProxyCombo extends TileEntityProxyBase implements IEnergy if(!inventory) return 0; - if(getTile() instanceof ISidedInventory) { - return ((ISidedInventory)getTile()).getSizeInventory(); + if(getCoreObject() instanceof ISidedInventory) { + return ((ISidedInventory)getCoreObject()).getSizeInventory(); } return 0; @@ -214,8 +217,8 @@ public class TileEntityProxyCombo extends TileEntityProxyBase implements IEnergy if(!inventory) return null; - if(getTile() instanceof ISidedInventory) { - return ((ISidedInventory)getTile()).getStackInSlot(slot); + if(getCoreObject() instanceof ISidedInventory) { + return ((ISidedInventory)getCoreObject()).getStackInSlot(slot); } return null; @@ -224,8 +227,8 @@ public class TileEntityProxyCombo extends TileEntityProxyBase implements IEnergy @Override public ItemStack decrStackSize(int i, int j) { - if(getTile() instanceof ISidedInventory) { - return ((ISidedInventory)getTile()).decrStackSize(i, j); + if(getCoreObject() instanceof ISidedInventory) { + return ((ISidedInventory)getCoreObject()).decrStackSize(i, j); } return null; @@ -237,8 +240,8 @@ public class TileEntityProxyCombo extends TileEntityProxyBase implements IEnergy if(!inventory) return null; - if(getTile() instanceof ISidedInventory) { - return ((ISidedInventory)getTile()).getStackInSlotOnClosing(slot); + if(getCoreObject() instanceof ISidedInventory) { + return ((ISidedInventory)getCoreObject()).getStackInSlotOnClosing(slot); } return null; @@ -250,8 +253,8 @@ public class TileEntityProxyCombo extends TileEntityProxyBase implements IEnergy if(!inventory) return; - if(getTile() instanceof ISidedInventory) { - ((ISidedInventory)getTile()).setInventorySlotContents(slot, stack); + if(getCoreObject() instanceof ISidedInventory) { + ((ISidedInventory)getCoreObject()).setInventorySlotContents(slot, stack); } } @@ -261,8 +264,8 @@ public class TileEntityProxyCombo extends TileEntityProxyBase implements IEnergy if(!inventory) return null; - if(getTile() instanceof ISidedInventory) { - return ((ISidedInventory)getTile()).getInventoryName(); + if(getCoreObject() instanceof ISidedInventory) { + return ((ISidedInventory)getCoreObject()).getInventoryName(); } return null; @@ -274,8 +277,8 @@ public class TileEntityProxyCombo extends TileEntityProxyBase implements IEnergy if(!inventory) return false; - if(getTile() instanceof ISidedInventory) { - return ((ISidedInventory)getTile()).hasCustomInventoryName(); + if(getCoreObject() instanceof ISidedInventory) { + return ((ISidedInventory)getCoreObject()).hasCustomInventoryName(); } return false; @@ -287,8 +290,8 @@ public class TileEntityProxyCombo extends TileEntityProxyBase implements IEnergy if(!inventory) return 0; - if(getTile() instanceof ISidedInventory) { - return ((ISidedInventory)getTile()).getInventoryStackLimit(); + if(getCoreObject() instanceof ISidedInventory) { + return ((ISidedInventory)getCoreObject()).getInventoryStackLimit(); } return 0; @@ -300,8 +303,8 @@ public class TileEntityProxyCombo extends TileEntityProxyBase implements IEnergy if(!inventory) return false; - if(getTile() instanceof ISidedInventory) { - return ((ISidedInventory)getTile()).isUseableByPlayer(player); + if(getCoreObject() instanceof ISidedInventory) { + return ((ISidedInventory)getCoreObject()).isUseableByPlayer(player); } return false; @@ -313,8 +316,8 @@ public class TileEntityProxyCombo extends TileEntityProxyBase implements IEnergy if(!inventory) return; - if(getTile() instanceof ISidedInventory) { - ((ISidedInventory)getTile()).openInventory(); + if(getCoreObject() instanceof ISidedInventory) { + ((ISidedInventory)getCoreObject()).openInventory(); } } @@ -324,8 +327,8 @@ public class TileEntityProxyCombo extends TileEntityProxyBase implements IEnergy if(!inventory) return; - if(getTile() instanceof ISidedInventory) { - ((ISidedInventory)getTile()).closeInventory(); + if(getCoreObject() instanceof ISidedInventory) { + ((ISidedInventory)getCoreObject()).closeInventory(); } } @@ -335,11 +338,11 @@ public class TileEntityProxyCombo extends TileEntityProxyBase implements IEnergy if(!inventory) return false; - if(getTile() instanceof ISidedInventory) { + if(getCoreObject() instanceof ISidedInventory) { - if(getTile() instanceof IConditionalInvAccess) return ((IConditionalInvAccess) getTile()).isItemValidForSlot(xCoord, yCoord, zCoord, slot, stack); + if(getCoreObject() instanceof IConditionalInvAccess) return ((IConditionalInvAccess) getCoreObject()).isItemValidForSlot(xCoord, yCoord, zCoord, slot, stack); - return ((ISidedInventory)getTile()).isItemValidForSlot(slot, stack); + return ((ISidedInventory)getCoreObject()).isItemValidForSlot(slot, stack); } return false; @@ -351,11 +354,11 @@ public class TileEntityProxyCombo extends TileEntityProxyBase implements IEnergy if(!inventory) return new int[0]; - if(getTile() instanceof ISidedInventory) { + if(getCoreObject() instanceof ISidedInventory) { - if(getTile() instanceof IConditionalInvAccess) return ((IConditionalInvAccess) getTile()).getAccessibleSlotsFromSide(xCoord, yCoord, zCoord, side); + if(getCoreObject() instanceof IConditionalInvAccess) return ((IConditionalInvAccess) getCoreObject()).getAccessibleSlotsFromSide(xCoord, yCoord, zCoord, side); - return ((ISidedInventory)getTile()).getAccessibleSlotsFromSide(side); + return ((ISidedInventory)getCoreObject()).getAccessibleSlotsFromSide(side); } return new int[0]; @@ -367,11 +370,11 @@ public class TileEntityProxyCombo extends TileEntityProxyBase implements IEnergy if(!inventory) return false; - if(getTile() instanceof ISidedInventory) { + if(getCoreObject() instanceof ISidedInventory) { - if(getTile() instanceof IConditionalInvAccess) return ((IConditionalInvAccess) getTile()).canInsertItem(xCoord, yCoord, zCoord, i, stack, j); + if(getCoreObject() instanceof IConditionalInvAccess) return ((IConditionalInvAccess) getCoreObject()).canInsertItem(xCoord, yCoord, zCoord, i, stack, j); - return ((ISidedInventory)getTile()).canInsertItem(i, stack, j); + return ((ISidedInventory)getCoreObject()).canInsertItem(i, stack, j); } return false; @@ -383,11 +386,11 @@ public class TileEntityProxyCombo extends TileEntityProxyBase implements IEnergy if(!inventory) return false; - if(getTile() instanceof ISidedInventory) { + if(getCoreObject() instanceof ISidedInventory) { - if(getTile() instanceof IConditionalInvAccess) return ((IConditionalInvAccess) getTile()).canExtractItem(xCoord, yCoord, zCoord, i, stack, j); + if(getCoreObject() instanceof IConditionalInvAccess) return ((IConditionalInvAccess) getCoreObject()).canExtractItem(xCoord, yCoord, zCoord, i, stack, j); - return ((ISidedInventory)getTile()).canExtractItem(i, stack, j); + return ((ISidedInventory)getCoreObject()).canExtractItem(i, stack, j); } return false; @@ -426,8 +429,8 @@ public class TileEntityProxyCombo extends TileEntityProxyBase implements IEnergy if(!this.heat) return 0; - if(getTile() instanceof IHeatSource) { - return ((IHeatSource)getTile()).getHeatStored(); + if(getCoreObject() instanceof IHeatSource) { + return ((IHeatSource)getCoreObject()).getHeatStored(); } return 0; @@ -439,39 +442,39 @@ public class TileEntityProxyCombo extends TileEntityProxyBase implements IEnergy if(!this.heat) return; - if(getTile() instanceof IHeatSource) { - ((IHeatSource)getTile()).useUpHeat(heat); + if(getCoreObject() instanceof IHeatSource) { + ((IHeatSource)getCoreObject()).useUpHeat(heat); } } @Override public boolean canAcceptPartialPour(World world, int x, int y, int z, double dX, double dY, double dZ, ForgeDirection side, Mats.MaterialStack stack) { - if(this.moltenMetal && getTile() instanceof ICrucibleAcceptor){ - return ((ICrucibleAcceptor)getTile()).canAcceptPartialPour(world, x, y, z, dX, dY, dZ, side, stack); + if(this.moltenMetal && getCoreObject() instanceof ICrucibleAcceptor){ + return ((ICrucibleAcceptor)getCoreObject()).canAcceptPartialPour(world, x, y, z, dX, dY, dZ, side, stack); } return false; } @Override public Mats.MaterialStack pour(World world, int x, int y, int z, double dX, double dY, double dZ, ForgeDirection side, Mats.MaterialStack stack) { - if(this.moltenMetal && getTile() instanceof ICrucibleAcceptor){ - return ((ICrucibleAcceptor)getTile()).pour(world, x, y, z, dX, dY, dZ, side, stack); + if(this.moltenMetal && getCoreObject() instanceof ICrucibleAcceptor){ + return ((ICrucibleAcceptor)getCoreObject()).pour(world, x, y, z, dX, dY, dZ, side, stack); } return null; } @Override public boolean canAcceptPartialFlow(World world, int x, int y, int z, ForgeDirection side, Mats.MaterialStack stack) { - if(this.moltenMetal && getTile() instanceof ICrucibleAcceptor){ - return ((ICrucibleAcceptor)getTile()).canAcceptPartialFlow(world, x, y, z, side, stack); + if(this.moltenMetal && getCoreObject() instanceof ICrucibleAcceptor){ + return ((ICrucibleAcceptor)getCoreObject()).canAcceptPartialFlow(world, x, y, z, side, stack); } return false; } @Override public Mats.MaterialStack flow(World world, int x, int y, int z, ForgeDirection side, Mats.MaterialStack stack) { - if(this.moltenMetal && getTile() instanceof ICrucibleAcceptor){ - return ((ICrucibleAcceptor)getTile()).flow(world, x, y, z, side, stack); + if(this.moltenMetal && getCoreObject() instanceof ICrucibleAcceptor){ + return ((ICrucibleAcceptor)getCoreObject()).flow(world, x, y, z, side, stack); } return null; } @@ -481,9 +484,9 @@ public class TileEntityProxyCombo extends TileEntityProxyBase implements IEnergy public String getComponentName() { if(this.worldObj == null) // OC is going too fast, grab from NBT! return componentName; - if(this.getTile() instanceof OCComponent) { + if(this.getCoreObject() instanceof OCComponent) { if (componentName == null || componentName.equals(OCComponent.super.getComponentName())) { - componentName = ((OCComponent) this.getTile()).getComponentName(); + componentName = ((OCComponent) this.getCoreObject()).getComponentName(); } return componentName; } @@ -493,44 +496,44 @@ public class TileEntityProxyCombo extends TileEntityProxyBase implements IEnergy @Override @Optional.Method(modid = "OpenComputers") public boolean canConnectNode(ForgeDirection side) { - if(this.getTile() instanceof OCComponent) + if(this.getCoreObject() instanceof OCComponent) return (this.getBlockMetadata() >= 6 && this.getBlockMetadata() <= 11) && (power || fluid) && - ((OCComponent) this.getTile()).canConnectNode(side); + ((OCComponent) this.getCoreObject()).canConnectNode(side); return OCComponent.super.canConnectNode(null); } @Override @Optional.Method(modid = "OpenComputers") public String[] methods() { - if(this.getTile() instanceof OCComponent) - return ((OCComponent) this.getTile()).methods(); + if(this.getCoreObject() instanceof OCComponent) + return ((OCComponent) this.getCoreObject()).methods(); return OCComponent.super.methods(); } @Override @Optional.Method(modid = "OpenComputers") public Object[] invoke(String method, Context context, Arguments args) throws Exception { - if(this.getTile() instanceof OCComponent) - return ((OCComponent) this.getTile()).invoke(method, context, args); + if(this.getCoreObject() instanceof OCComponent) + return ((OCComponent) this.getCoreObject()).invoke(method, context, args); return OCComponent.super.invoke(null, null, null); } @Override public String[] getFunctionInfo() { - if(getTile() instanceof IRORInfo) return ((IRORInfo) getTile()).getFunctionInfo(); + if(getCoreObject() instanceof IRORInfo) return ((IRORInfo) getCoreObject()).getFunctionInfo(); return new String[0]; } @Override public String provideRORValue(String name) { - if(getTile() instanceof IRORValueProvider) return ((IRORValueProvider) getTile()).provideRORValue(name); + if(getCoreObject() instanceof IRORValueProvider) return ((IRORValueProvider) getCoreObject()).provideRORValue(name); return null; } @Override public String runRORFunction(String name, String[] params) { - if(getTile() instanceof IRORInteractive) return ((IRORInteractive) getTile()).runRORFunction(name, params); + if(getCoreObject() instanceof IRORInteractive) return ((IRORInteractive) getCoreObject()).runRORFunction(name, params); return null; } } diff --git a/src/main/java/com/hbm/tileentity/TileEntityProxyDyn.java b/src/main/java/com/hbm/tileentity/TileEntityProxyDyn.java new file mode 100644 index 000000000..56f4a85c6 --- /dev/null +++ b/src/main/java/com/hbm/tileentity/TileEntityProxyDyn.java @@ -0,0 +1,24 @@ +package com.hbm.tileentity; + +public class TileEntityProxyDyn extends TileEntityProxyCombo { + + @Override + public Object getCoreObject() { + + Object o = super.getCoreObject(); + + if(o instanceof IProxyDelegateProvider) { + Object delegate = ((IProxyDelegateProvider) o).getDelegateForPosition(xCoord, yCoord, zCoord); + if(delegate != null) return delegate; + } + + return o; + } + + /** Based on the position of the proxy, produces a delegate instead of returning the core tile entity. God this fucking sucks. */ + public static interface IProxyDelegateProvider { + + /** Returns the delegate based on the proxy's position. Retunring NULL skips the delegate and reverts back to original core behavior */ + public Object getDelegateForPosition(int x, int y, int z); + } +} diff --git a/src/main/java/com/hbm/tileentity/TileMappings.java b/src/main/java/com/hbm/tileentity/TileMappings.java index 36e0f3d04..c883e8a05 100644 --- a/src/main/java/com/hbm/tileentity/TileMappings.java +++ b/src/main/java/com/hbm/tileentity/TileMappings.java @@ -222,6 +222,7 @@ public class TileMappings { put(TileEntityProxyInventory.class, "tileentity_proxy_inventory"); put(TileEntityProxyEnergy.class, "tileentity_proxy_power"); put(TileEntityProxyCombo.class, "tileentity_proxy_combo"); + put(TileEntityProxyDyn.class, "tileentity_proxy_dyn"); put(TileEntityProxyConductor.class, "tileentity_proxy_conductor"); put(TileEntityBedrockOre.class, "tileentity_bedrock_ore"); diff --git a/src/main/java/com/hbm/tileentity/machine/TileEntityMachineChemicalFactory.java b/src/main/java/com/hbm/tileentity/machine/TileEntityMachineChemicalFactory.java index 1487d194a..e1b443410 100644 --- a/src/main/java/com/hbm/tileentity/machine/TileEntityMachineChemicalFactory.java +++ b/src/main/java/com/hbm/tileentity/machine/TileEntityMachineChemicalFactory.java @@ -17,6 +17,7 @@ import com.hbm.module.ModuleMachineChemplant; import com.hbm.tileentity.IGUIProvider; import com.hbm.tileentity.IUpgradeInfoProvider; import com.hbm.tileentity.TileEntityMachineBase; +import com.hbm.tileentity.TileEntityProxyDyn.IProxyDelegateProvider; import com.hbm.util.BobMathUtil; import com.hbm.util.fauxpointtwelve.DirPos; import com.hbm.util.i18n.I18nUtil; @@ -35,15 +36,18 @@ import net.minecraft.util.EnumChatFormatting; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; -public class TileEntityMachineChemicalFactory extends TileEntityMachineBase implements IEnergyReceiverMK2, IFluidStandardTransceiverMK2, IUpgradeInfoProvider, IControlReceiver, IGUIProvider { +public class TileEntityMachineChemicalFactory extends TileEntityMachineBase implements IEnergyReceiverMK2, IFluidStandardTransceiverMK2, IUpgradeInfoProvider, IControlReceiver, IGUIProvider, IProxyDelegateProvider { public FluidTank[] allTanks; public FluidTank[] inputTanks; public FluidTank[] outputTanks; + + public FluidTank water; + public FluidTank lps; public long power; public long maxPower = 10_000_000; - public boolean didProcess = false; + public boolean[] didProcess = new boolean[4]; public boolean frame = false; public int anim; @@ -51,6 +55,8 @@ public class TileEntityMachineChemicalFactory extends TileEntityMachineBase impl public ModuleMachineChemplant[] chemplantModule; public UpgradeManagerNT upgradeManager = new UpgradeManagerNT(this); + + protected DelegateChemicalFactoy delegate = new DelegateChemicalFactoy(); public TileEntityMachineChemicalFactory() { super(32); @@ -61,11 +67,17 @@ public class TileEntityMachineChemicalFactory extends TileEntityMachineBase impl this.inputTanks[i] = new FluidTank(Fluids.NONE, 24_000); this.outputTanks[i] = new FluidTank(Fluids.NONE, 24_000); } + + this.water = new FluidTank(Fluids.WATER, 4_000); + this.lps = new FluidTank(Fluids.SPENTSTEAM, 4_000); - this.allTanks = new FluidTank[this.inputTanks.length + this.outputTanks.length]; + this.allTanks = new FluidTank[this.inputTanks.length + this.outputTanks.length + 2]; for(int i = 0; i < inputTanks.length; i++) this.allTanks[i] = this.inputTanks[i]; for(int i = 0; i < outputTanks.length; i++) this.allTanks[i + this.inputTanks.length] = this.outputTanks[i]; + this.allTanks[this.allTanks.length - 2] = this.water; + this.allTanks[this.allTanks.length - 1] = this.lps; + this.chemplantModule = new ModuleMachineChemplant[4]; for(int i = 0; i < 4; i++) this.chemplantModule[i] = new ModuleMachineChemplant(i, this, slots) .itemInput(5 + i * 7, 6 + i * 7, 7 + i * 7) @@ -129,6 +141,12 @@ public class TileEntityMachineChemicalFactory extends TileEntityMachineBase impl for(FluidTank tank : inputTanks) if(tank.getTankType() != Fluids.NONE) this.trySubscribe(tank.getTankType(), worldObj, pos); for(FluidTank tank : outputTanks) if(tank.getFill() > 0) this.tryProvide(tank, worldObj, pos); } + + for(DirPos pos : getCoolPos()) { + delegate.trySubscribe(worldObj, pos); + delegate.trySubscribe(water.getTankType(), worldObj, pos); + this.tryProvide(lps, worldObj, pos); + } double speed = 1D; double pow = 1D; @@ -139,14 +157,17 @@ public class TileEntityMachineChemicalFactory extends TileEntityMachineBase impl pow -= Math.min(upgradeManager.getLevel(UpgradeType.POWER), 3) * 0.25D; pow += Math.min(upgradeManager.getLevel(UpgradeType.SPEED), 3) * 1D; pow += Math.min(upgradeManager.getLevel(UpgradeType.OVERDRIVE), 3) * 10D / 3D; - - this.didProcess = false; boolean markDirty = false; for(int i = 0; i < 4; i++) { - this.chemplantModule[i].update(speed * 2D, pow); - this.didProcess |= this.chemplantModule[i].didProcess; + this.chemplantModule[i].update(speed * 2D, pow * 2D, canCool()); + this.didProcess[i] = this.chemplantModule[i].didProcess; markDirty |= this.chemplantModule[i].markDirty; + + if(this.chemplantModule[i].didProcess) { + this.water.setFill(this.water.getFill() - 100); + this.lps.setFill(this.lps.getFill() + 100); + } } if(markDirty) this.markDirty(); @@ -156,7 +177,7 @@ public class TileEntityMachineChemicalFactory extends TileEntityMachineBase impl } else { this.prevAnim = this.anim; - if(this.didProcess) this.anim++; + for(boolean n : didProcess) if(n) { this.anim++; break; } if(worldObj.getTotalWorldTime() % 20 == 0) { frame = !worldObj.getBlock(xCoord, yCoord + 3, zCoord).isAir(worldObj, xCoord, yCoord + 3, zCoord); @@ -164,6 +185,10 @@ public class TileEntityMachineChemicalFactory extends TileEntityMachineBase impl } } + public boolean canCool() { + return water.getFill() >= 100 && lps.getFill() <= lps.getMaxFill() - 100; + } + public DirPos[] getConPos() { ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata() - 10); ForgeDirection rot = dir.getRotation(ForgeDirection.UP); @@ -206,9 +231,11 @@ public class TileEntityMachineChemicalFactory extends TileEntityMachineBase impl super.serialize(buf); for(FluidTank tank : inputTanks) tank.serialize(buf); for(FluidTank tank : outputTanks) tank.serialize(buf); + water.serialize(buf); + lps.serialize(buf); buf.writeLong(power); buf.writeLong(maxPower); - buf.writeBoolean(didProcess); + for(boolean b : didProcess) buf.writeBoolean(b); for(int i = 0; i < 4; i++) this.chemplantModule[i].serialize(buf); } @@ -217,11 +244,37 @@ public class TileEntityMachineChemicalFactory extends TileEntityMachineBase impl super.deserialize(buf); for(FluidTank tank : inputTanks) tank.deserialize(buf); for(FluidTank tank : outputTanks) tank.deserialize(buf); + water.deserialize(buf); + lps.deserialize(buf); this.power = buf.readLong(); this.maxPower = buf.readLong(); - this.didProcess = buf.readBoolean(); + for(int i = 0; i < 4; i++) this.didProcess[i] = buf.readBoolean(); for(int i = 0; i < 4; i++) this.chemplantModule[i].deserialize(buf); } + + @Override + public void readFromNBT(NBTTagCompound nbt) { + super.readFromNBT(nbt); + + for(int i = 0; i < inputTanks.length; i++) this.inputTanks[i].readFromNBT(nbt, "i" + i); + for(int i = 0; i < outputTanks.length; i++) this.outputTanks[i].readFromNBT(nbt, "i" + i); + + this.power = nbt.getLong("power"); + this.maxPower = nbt.getLong("maxPower"); + for(int i = 0; i < 4; i++) this.chemplantModule[i].readFromNBT(nbt); + } + + @Override + public void writeToNBT(NBTTagCompound nbt) { + super.writeToNBT(nbt); + + for(int i = 0; i < inputTanks.length; i++) this.inputTanks[i].writeToNBT(nbt, "i" + i); + for(int i = 0; i < outputTanks.length; i++) this.outputTanks[i].writeToNBT(nbt, "i" + i); + + nbt.setLong("power", power); + nbt.setLong("maxPower", maxPower); + for(int i = 0; i < 4; i++) this.chemplantModule[i].writeToNBT(nbt); + } @Override public long getPower() { return power; } @Override public void setPower(long power) { this.power = power; } @@ -290,4 +343,36 @@ public class TileEntityMachineChemicalFactory extends TileEntityMachineBase impl upgrades.put(UpgradeType.OVERDRIVE, 3); return upgrades; } + + public DirPos[] coolantLine; // we could make the same fucking array 50,000 times per tick, or we just make it once + + @Override // all the delegating shit so the proxies on the coolant lines only access coolant (and power and inventory) but not the recipe fluids + public Object getDelegateForPosition(int x, int y, int z) { + ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata() - 10); + ForgeDirection rot = dir.getRotation(ForgeDirection.UP); + + if(coolantLine == null) coolantLine = new DirPos[] { + new DirPos(xCoord + rot.offsetX + dir.offsetX * 2, yCoord, zCoord + rot.offsetZ + dir.offsetZ * 2, dir), + new DirPos(xCoord - rot.offsetX + dir.offsetX * 2, yCoord, zCoord - rot.offsetZ + dir.offsetZ * 2, dir), + new DirPos(xCoord + rot.offsetX - dir.offsetX * 2, yCoord, zCoord + rot.offsetZ - dir.offsetZ * 2, dir.getOpposite()), + new DirPos(xCoord - rot.offsetX - dir.offsetX * 2, yCoord, zCoord - rot.offsetZ - dir.offsetZ * 2, dir.getOpposite()), + }; + + for(DirPos pos : coolantLine) if(pos.compare(x, y, z)) return this.delegate; // this actually fucking works + + return null; + } + + public class DelegateChemicalFactoy implements IEnergyReceiverMK2, IFluidStandardTransceiverMK2 { + + @Override public long getPower() { return TileEntityMachineChemicalFactory.this.getPower(); } + @Override public void setPower(long power) { TileEntityMachineChemicalFactory.this.setPower(power); } + @Override public long getMaxPower() { return TileEntityMachineChemicalFactory.this.getMaxPower(); } + @Override public boolean isLoaded() { return TileEntityMachineChemicalFactory.this.isLoaded(); } + + @Override public FluidTank[] getReceivingTanks() { return new FluidTank[] {TileEntityMachineChemicalFactory.this.water}; } + @Override public FluidTank[] getSendingTanks() { return new FluidTank[] {TileEntityMachineChemicalFactory.this.lps}; } + + @Override public FluidTank[] getAllTanks() { return TileEntityMachineChemicalFactory.this.getAllTanks(); } + } } diff --git a/src/main/java/com/hbm/tileentity/machine/TileEntityMachineChemicalPlant.java b/src/main/java/com/hbm/tileentity/machine/TileEntityMachineChemicalPlant.java index 8181d3497..8047c02e4 100644 --- a/src/main/java/com/hbm/tileentity/machine/TileEntityMachineChemicalPlant.java +++ b/src/main/java/com/hbm/tileentity/machine/TileEntityMachineChemicalPlant.java @@ -106,7 +106,7 @@ public class TileEntityMachineChemicalPlant extends TileEntityMachineBase implem pow += Math.min(upgradeManager.getLevel(UpgradeType.SPEED), 3) * 1D; pow += Math.min(upgradeManager.getLevel(UpgradeType.OVERDRIVE), 3) * 10D / 3D; - this.chemplantModule.update(speed, pow); + this.chemplantModule.update(speed, pow, true); this.didProcess = this.chemplantModule.didProcess; if(this.chemplantModule.markDirty) this.markDirty();