slightly less broken blast furnace IO

This commit is contained in:
Boblet 2022-11-10 16:44:39 +01:00
parent 9caaa89405
commit d494df6ead
3 changed files with 49 additions and 9 deletions

View File

@ -1336,7 +1336,7 @@ public class ModEventHandler {
private static final String hash = "41eb77f138ce350932e33b6b26b233df9aad0c0c80c6a49cb9a54ddd8fae3f83";
//@SubscribeEvent
@SubscribeEvent
public void onClickSign(PlayerInteractEvent event) {
int x = event.x;

View File

@ -26,7 +26,7 @@ public class TileEntityDiFurnace extends TileEntity implements ISidedInventory,
public static final int maxPower = 12800;
public static final int processingSpeed = 400;
private static final int[] slots_io = new int[] { 0, 1, 2 };
private static final int[] slots_io = new int[] { 0, 1, 2, 3 };
public byte sideFuel = 1;
public byte sideUpper = 1;
public byte sideLower = 1;
@ -212,13 +212,14 @@ public class TileEntityDiFurnace extends TileEntity implements ISidedInventory,
if(i == 0 && this.sideUpper != j) return false;
if(i == 1 && this.sideLower != j) return false;
if(i == 2 && this.sideFuel != j) return false;
if(i == 3) return false;
return this.isItemValidForSlot(i, itemStack);
}
@Override
public boolean canExtractItem(int i, ItemStack itemStack, int j) {
return true;
return i == 3;
}
public int getDiFurnaceProgressScaled(int i) {

View File

@ -3,13 +3,17 @@ 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.fluid.FluidType;
import com.hbm.inventory.fluid.Fluids;
import com.hbm.inventory.fluid.tank.FluidTank;
import com.hbm.inventory.fluid.trait.FT_Coolable;
import com.hbm.inventory.fluid.trait.FT_Coolable.CoolingType;
import com.hbm.lib.Library;
import com.hbm.tileentity.TileEntityLoadedBase;
import com.hbm.util.fauxpointtwelve.DirPos;
import api.hbm.energy.IEnergyGenerator;
import api.hbm.fluid.IFluidStandardTransceiver;
@ -21,8 +25,7 @@ import net.minecraftforge.common.util.ForgeDirection;
public class TileEntitySteamEngine extends TileEntityLoadedBase implements IFluidAcceptor, IFluidSource, IEnergyGenerator, IFluidStandardTransceiver {
public long power;
public static final long maxPower = 1_000_000L;
public long powerBuffer;
public float rotor;
public float lastRotor;
@ -35,10 +38,46 @@ public class TileEntitySteamEngine extends TileEntityLoadedBase implements IFlui
tanks[0] = new FluidTank(Fluids.STEAM, 8_000, 0);
tanks[1] = new FluidTank(Fluids.SPENTSTEAM, 80, 1);
}
@Override
public void updateEntity() {
if(!worldObj.isRemote) {
this.powerBuffer = 0;
tanks[0].setTankType(Fluids.STEAM);
tanks[1].setTankType(Fluids.SPENTSTEAM);
FT_Coolable trait = tanks[0].getTankType().getTrait(FT_Coolable.class);
double eff = trait.getEfficiency(CoolingType.TURBINE) * 0.75D;
int inputOps = tanks[0].getFill() / trait.amountReq;
int outputOps = (tanks[1].getMaxFill() - tanks[1].getFill()) / trait.amountProduced;
int ops = Math.min(inputOps, outputOps);
tanks[0].setFill(tanks[0].getFill() - ops * trait.amountReq);
tanks[1].setFill(tanks[1].getFill() + ops * trait.amountProduced);
this.powerBuffer += (ops * trait.heatEnergy * eff);
for(DirPos pos : getConPos()) if(this.powerBuffer > 0) this.sendPower(worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir());
if(tanks[1].getFill() > 0) fillFluidInit(tanks[1].getTankType());
}
}
protected DirPos[] getConPos() {
ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata() - BlockDummyable.offset);
ForgeDirection rot = dir.getRotation(ForgeDirection.UP);
return new DirPos[] {
new DirPos(xCoord + rot.offsetX * 2, yCoord + 2, zCoord + rot.offsetZ * 2, rot),
new DirPos(xCoord + rot.offsetX * 2 + dir.offsetX, yCoord + 2, zCoord + rot.offsetZ * 2 + dir.offsetZ, rot),
new DirPos(xCoord + rot.offsetX * 2 - dir.offsetX, yCoord + 2, zCoord + rot.offsetZ * 2 - dir.offsetZ, rot)
};
}
@Override
public void fillFluidInit(FluidType type) {
for(DirPos pos : getConPos()) fillFluid(pos.getX(), pos.getY(), pos.getZ(), getTact(), type);
}
@Override
@ -117,17 +156,17 @@ public class TileEntitySteamEngine extends TileEntityLoadedBase implements IFlui
@Override
public long getPower() {
return power;
return powerBuffer;
}
@Override
public long getMaxPower() {
return maxPower;
return powerBuffer;
}
@Override
public void setPower(long power) {
this.power = power;
this.powerBuffer = power;
}
@Override