Stop mining laser if redstone is supplied.

This commit is contained in:
Mikhail Semenov 2025-11-02 22:37:29 +01:00
parent b278d27b9b
commit 6e7be25614

View File

@ -24,6 +24,8 @@ import com.hbm.tileentity.IUpgradeInfoProvider;
import com.hbm.tileentity.TileEntityMachineBase;
import com.hbm.util.BobMathUtil;
import com.hbm.util.InventoryUtil;
import com.hbm.util.fauxpointtwelve.BlockPos;
import com.hbm.util.fauxpointtwelve.DirPos;
import com.hbm.util.i18n.I18nUtil;
import api.hbm.block.IDrillInteraction;
@ -60,6 +62,7 @@ public class TileEntityMachineMiningLaser extends TileEntityMachineBase implemen
public FluidTank tank;
public boolean isOn;
private boolean redstonePowered;
public int targetX;
public int targetY;
public int targetZ;
@ -88,6 +91,25 @@ public class TileEntityMachineMiningLaser extends TileEntityMachineBase implemen
private double clientBreakProgress;
private DirPos[] getConPos() {
return new DirPos[] {
new DirPos(xCoord + 2, yCoord, zCoord, Library.POS_X),
new DirPos(xCoord - 2, yCoord, zCoord, Library.NEG_X),
new DirPos(xCoord, yCoord, zCoord + 2, Library.POS_Z),
new DirPos(xCoord, yCoord, zCoord - 2, Library.NEG_Z),
};
}
private boolean isMultiblockRedstonePowered() {
for (DirPos conPos : getConPos()) {
BlockPos pos = conPos.offset(conPos.getDir().getOpposite());
if(this.worldObj.isBlockIndirectlyGettingPowered(pos.getX(), pos.getY(), pos.getZ())) {
return true;
}
}
return false;
}
@Override
public void updateEntity() {
@ -95,10 +117,9 @@ public class TileEntityMachineMiningLaser extends TileEntityMachineBase implemen
this.updateConnections();
this.sendFluid(tank, worldObj, xCoord + 2, yCoord, zCoord, Library.POS_X);
this.sendFluid(tank, worldObj, xCoord - 2, yCoord, zCoord, Library.NEG_X);
this.sendFluid(tank, worldObj, xCoord, yCoord + 2, zCoord, Library.POS_Z);
this.sendFluid(tank, worldObj, xCoord, yCoord - 2, zCoord, Library.NEG_Z);
for (DirPos pos : getConPos()) {
this.sendFluid(tank, worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir());
}
power = Library.chargeTEFromItems(slots, 0, power, maxPower);
@ -113,7 +134,16 @@ public class TileEntityMachineMiningLaser extends TileEntityMachineBase implemen
lastTargetY = targetY;
lastTargetZ = targetZ;
if(isOn) {
boolean prevRedstone = this.redstonePowered;
this.redstonePowered = this.isMultiblockRedstonePowered();
if(prevRedstone != this.redstonePowered) {
this.markDirty();
}
boolean shouldRun = this.isOn && !this.redstonePowered;
if(shouldRun) {
upgradeManager.checkSlots(this, slots, 1, 8);
int cycles = 1 + upgradeManager.getLevel(UpgradeType.OVERDRIVE);
@ -165,10 +195,9 @@ public class TileEntityMachineMiningLaser extends TileEntityMachineBase implemen
beam = false;
}
this.tryFillContainer(xCoord + 2, yCoord, zCoord);
this.tryFillContainer(xCoord - 2, yCoord, zCoord);
this.tryFillContainer(xCoord, yCoord, zCoord + 2);
this.tryFillContainer(xCoord, yCoord, zCoord - 2);
for (DirPos pos : getConPos()) {
this.tryFillContainer(pos.getX(), pos.getY(), pos.getZ());
}
this.networkPackNT(250);
}
@ -192,6 +221,7 @@ public class TileEntityMachineMiningLaser extends TileEntityMachineBase implemen
buf.writeBoolean(this.isOn);
buf.writeDouble(this.clientBreakProgress);
tank.serialize(buf);
buf.writeBoolean(this.redstonePowered);
}
@Override
@ -208,10 +238,11 @@ public class TileEntityMachineMiningLaser extends TileEntityMachineBase implemen
this.isOn = buf.readBoolean();
this.breakProgress = buf.readDouble();
tank.deserialize(buf);
this.redstonePowered = buf.readBoolean();
}
private void buildDam() {
for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
if(worldObj.getBlock(targetX + dir.offsetX, targetY + dir.offsetY, targetZ + dir.offsetZ).getMaterial().isLiquid()) worldObj.setBlock(targetX + dir.offsetX, targetY + dir.offsetY, targetZ + dir.offsetZ, ModBlocks.barricade);
}
@ -612,6 +643,7 @@ public class TileEntityMachineMiningLaser extends TileEntityMachineBase implemen
tank.readFromNBT(nbt, "oil");
isOn = nbt.getBoolean("isOn");
redstonePowered = false;
}
@Override