Merge pull request #2521 from mikkerlo/push-tumznvpzvzqq

Stop mining laser if redstone is supplied.
This commit is contained in:
HbmMods 2025-11-10 16:06:52 +01:00 committed by GitHub
commit eaf0cfa24a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -24,6 +24,8 @@ import com.hbm.tileentity.IUpgradeInfoProvider;
import com.hbm.tileentity.TileEntityMachineBase; import com.hbm.tileentity.TileEntityMachineBase;
import com.hbm.util.BobMathUtil; import com.hbm.util.BobMathUtil;
import com.hbm.util.InventoryUtil; import com.hbm.util.InventoryUtil;
import com.hbm.util.fauxpointtwelve.BlockPos;
import com.hbm.util.fauxpointtwelve.DirPos;
import com.hbm.util.i18n.I18nUtil; import com.hbm.util.i18n.I18nUtil;
import api.hbm.block.IDrillInteraction; import api.hbm.block.IDrillInteraction;
@ -60,6 +62,7 @@ public class TileEntityMachineMiningLaser extends TileEntityMachineBase implemen
public FluidTank tank; public FluidTank tank;
public boolean isOn; public boolean isOn;
private boolean redstonePowered;
public int targetX; public int targetX;
public int targetY; public int targetY;
public int targetZ; public int targetZ;
@ -88,6 +91,25 @@ public class TileEntityMachineMiningLaser extends TileEntityMachineBase implemen
private double clientBreakProgress; 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 @Override
public void updateEntity() { public void updateEntity() {
@ -95,10 +117,9 @@ public class TileEntityMachineMiningLaser extends TileEntityMachineBase implemen
this.updateConnections(); this.updateConnections();
this.sendFluid(tank, worldObj, xCoord + 2, yCoord, zCoord, Library.POS_X); for (DirPos pos : getConPos()) {
this.sendFluid(tank, worldObj, xCoord - 2, yCoord, zCoord, Library.NEG_X); this.sendFluid(tank, worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir());
this.sendFluid(tank, worldObj, xCoord, yCoord + 2, zCoord, Library.POS_Z); }
this.sendFluid(tank, worldObj, xCoord, yCoord - 2, zCoord, Library.NEG_Z);
power = Library.chargeTEFromItems(slots, 0, power, maxPower); power = Library.chargeTEFromItems(slots, 0, power, maxPower);
@ -113,7 +134,16 @@ public class TileEntityMachineMiningLaser extends TileEntityMachineBase implemen
lastTargetY = targetY; lastTargetY = targetY;
lastTargetZ = targetZ; 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); upgradeManager.checkSlots(this, slots, 1, 8);
int cycles = 1 + upgradeManager.getLevel(UpgradeType.OVERDRIVE); int cycles = 1 + upgradeManager.getLevel(UpgradeType.OVERDRIVE);
@ -165,10 +195,9 @@ public class TileEntityMachineMiningLaser extends TileEntityMachineBase implemen
beam = false; beam = false;
} }
this.tryFillContainer(xCoord + 2, yCoord, zCoord); for (DirPos pos : getConPos()) {
this.tryFillContainer(xCoord - 2, yCoord, zCoord); this.tryFillContainer(pos.getX(), pos.getY(), pos.getZ());
this.tryFillContainer(xCoord, yCoord, zCoord + 2); }
this.tryFillContainer(xCoord, yCoord, zCoord - 2);
this.networkPackNT(250); this.networkPackNT(250);
} }
@ -192,6 +221,7 @@ public class TileEntityMachineMiningLaser extends TileEntityMachineBase implemen
buf.writeBoolean(this.isOn); buf.writeBoolean(this.isOn);
buf.writeDouble(this.clientBreakProgress); buf.writeDouble(this.clientBreakProgress);
tank.serialize(buf); tank.serialize(buf);
buf.writeBoolean(this.redstonePowered);
} }
@Override @Override
@ -208,6 +238,7 @@ public class TileEntityMachineMiningLaser extends TileEntityMachineBase implemen
this.isOn = buf.readBoolean(); this.isOn = buf.readBoolean();
this.breakProgress = buf.readDouble(); this.breakProgress = buf.readDouble();
tank.deserialize(buf); tank.deserialize(buf);
this.redstonePowered = buf.readBoolean();
} }
private void buildDam() { private void buildDam() {
@ -612,6 +643,7 @@ public class TileEntityMachineMiningLaser extends TileEntityMachineBase implemen
tank.readFromNBT(nbt, "oil"); tank.readFromNBT(nbt, "oil");
isOn = nbt.getBoolean("isOn"); isOn = nbt.getBoolean("isOn");
redstonePowered = false;
} }
@Override @Override