Fix Laser's hasWork trigger

This commit is contained in:
CovertJaguar 2013-08-29 04:51:28 -07:00
parent 54e7e372ec
commit 45e73c28b1

View file

@ -23,6 +23,7 @@ import buildcraft.core.TileBuildCraft;
import buildcraft.core.proxy.CoreProxy; import buildcraft.core.proxy.CoreProxy;
import buildcraft.core.triggers.ActionMachineControl; import buildcraft.core.triggers.ActionMachineControl;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.ForgeDirection; import net.minecraftforge.common.ForgeDirection;
@ -58,12 +59,6 @@ public class TileLaser extends TileBuildCraft implements IPowerReceptor, IAction
if (!CoreProxy.proxy.isSimulating(worldObj)) if (!CoreProxy.proxy.isSimulating(worldObj))
return; return;
// Disable the laser and do nothing if no energy is available.
if (powerHandler.getEnergyStored() == 0) {
removeLaser();
return;
}
// If a gate disabled us, remove laser and do nothing. // If a gate disabled us, remove laser and do nothing.
if (lastMode == ActionMachineControl.Mode.Off) { if (lastMode == ActionMachineControl.Mode.Off) {
removeLaser(); removeLaser();
@ -83,6 +78,12 @@ public class TileLaser extends TileBuildCraft implements IPowerReceptor, IAction
return; return;
} }
// Disable the laser and do nothing if no energy is available.
if (powerHandler.getEnergyStored() == 0) {
removeLaser();
return;
}
// We have a table and can work, so we create a laser if // We have a table and can work, so we create a laser if
// necessary. // necessary.
if (laser == null) { if (laser == null) {
@ -101,19 +102,19 @@ public class TileLaser extends TileBuildCraft implements IPowerReceptor, IAction
if (laser != null) { if (laser != null) {
laser.pushPower(power); laser.pushPower(power);
} }
onPowerSent(power); onPowerSent(power);
sendNetworkUpdate(); sendNetworkUpdate();
} }
protected float getMaxPowerSent(){ protected float getMaxPowerSent() {
return 4; return 4;
} }
protected void onPowerSent(float power) { protected void onPowerSent(float power) {
} }
protected boolean canFindTable() { protected boolean canFindTable() {
return searchTracker.markTimeIfDelay(worldObj, nextLaserSearch); return searchTracker.markTimeIfDelay(worldObj, nextLaserSearch);
} }
@ -162,7 +163,7 @@ public class TileLaser extends TileBuildCraft implements IPowerReceptor, IAction
break; break;
} }
LinkedList<BlockIndex> targets = new LinkedList<BlockIndex>(); List<BlockIndex> targets = new LinkedList<BlockIndex>();
for (int x = minX; x <= maxX; ++x) { for (int x = minX; x <= maxX; ++x) {
for (int y = minY; y <= maxY; ++y) { for (int y = minY; y <= maxY; ++y) {
@ -181,7 +182,7 @@ public class TileLaser extends TileBuildCraft implements IPowerReceptor, IAction
} }
} }
if (targets.size() == 0) if (targets.isEmpty())
return; return;
BlockIndex b = targets.get(worldObj.rand.nextInt(targets.size())); BlockIndex b = targets.get(worldObj.rand.nextInt(targets.size()));
@ -280,7 +281,7 @@ public class TileLaser extends TileBuildCraft implements IPowerReceptor, IAction
@Override @Override
public boolean isActive() { public boolean isActive() {
return laser != null; return isValidTable();
} }
@Override @Override