Better fix

This commit is contained in:
Raoul Van den Berge
2016-05-15 21:44:04 +02:00
parent f5707d6d5d
commit b4109cd70b
3 changed files with 23 additions and 23 deletions

View File

@@ -24,7 +24,7 @@ public class MessageMachineConnectedUpdate implements IMessage, IMessageHandler<
this.x = machine.getPos().getX(); this.x = machine.getPos().getX();
this.y = machine.getPos().getY(); this.y = machine.getPos().getY();
this.z = machine.getPos().getZ(); this.z = machine.getPos().getZ();
this.connected = machine.isConnected(); this.connected = machine.isConnected() && machine.mayUpdate();
} }
@Override @Override

View File

@@ -119,6 +119,9 @@ public class TileController extends TileBase implements IEnergyReceiver, ISynchr
if (canRun()) { if (canRun()) {
for (TileMachine machine : machines) { for (TileMachine machine : machines) {
if (!machine.mayUpdate()) {
continue;
}
machine.updateMachine(); machine.updateMachine();
if (machine instanceof TileWirelessTransmitter) { if (machine instanceof TileWirelessTransmitter) {
@@ -618,22 +621,25 @@ public class TileController extends TileBase implements IEnergyReceiver, ISynchr
List<ClientSideMachine> m = new ArrayList<ClientSideMachine>(); List<ClientSideMachine> m = new ArrayList<ClientSideMachine>();
for (TileMachine machine : machines) { for (TileMachine machine : machines) {
IBlockState state = worldObj.getBlockState(machine.getPos()); if (machine.mayUpdate()) {
IBlockState state = worldObj.getBlockState(machine.getPos());
ClientSideMachine clientMachine = new ClientSideMachine(); ClientSideMachine clientMachine = new ClientSideMachine();
clientMachine.energyUsage = machine.getEnergyUsage(); clientMachine.energyUsage = machine.getEnergyUsage();
clientMachine.amount = 1; clientMachine.amount = 1;
clientMachine.stack = new ItemStack(state.getBlock(), 1, state.getBlock().getMetaFromState(state)); clientMachine.stack = new ItemStack(state.getBlock(), 1, state.getBlock().getMetaFromState(state));
if (m.contains(clientMachine)) { if (m.contains(clientMachine)) {
for (ClientSideMachine other : m) { for (ClientSideMachine other : m) {
if (other.equals(clientMachine)) { if (other.equals(clientMachine)) {
other.amount++; other.amount++;
break;
}
} }
} else {
m.add(clientMachine);
} }
} else {
m.add(clientMachine);
} }
} }

View File

@@ -48,8 +48,6 @@ public abstract class TileMachine extends TileBase implements ISynchronizedConta
} else { } else {
if (newController == null) { if (newController == null) {
onDisconnected(world); onDisconnected(world);
} else {
connected = true;
} }
} }
} }
@@ -77,16 +75,16 @@ public abstract class TileMachine extends TileBase implements ISynchronizedConta
} }
} }
if (connected && !redstoneMode.isEnabled(worldObj, pos)) {
onDisconnected(worldObj, false);
}
if (!(this instanceof TileCable)) { if (!(this instanceof TileCable)) {
RefinedStorageUtils.sendToAllAround(worldObj, pos, new MessageMachineConnectedUpdate(this)); RefinedStorageUtils.sendToAllAround(worldObj, pos, new MessageMachineConnectedUpdate(this));
} }
} }
} }
public boolean mayUpdate() {
return redstoneMode.isEnabled(worldObj, pos);
}
public void onConnected(World world, TileController controller) { public void onConnected(World world, TileController controller) {
if (tryConnect(controller)) { if (tryConnect(controller)) {
world.notifyNeighborsOfStateChange(pos, block); world.notifyNeighborsOfStateChange(pos, block);
@@ -107,13 +105,9 @@ public abstract class TileMachine extends TileBase implements ISynchronizedConta
} }
public void onDisconnected(World world) { public void onDisconnected(World world) {
onDisconnected(world, true);
}
public void onDisconnected(World world, boolean removeController) {
this.connected = false; this.connected = false;
if (removeController && this.controller != null) { if (this.controller != null) {
this.controller.removeMachine(this); this.controller.removeMachine(this);
this.controller = null; this.controller = null;
} }