Better fix
This commit is contained in:
@@ -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
|
||||||
|
|||||||
@@ -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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user