These changes make shit work. I don't know why, but it fucking works.

This commit is contained in:
Raoul Van den Berge
2016-05-15 21:08:41 +02:00
parent 0b2cf310ec
commit f5707d6d5d

View File

@@ -48,6 +48,8 @@ public abstract class TileMachine extends TileBase implements ISynchronizedConta
} else { } else {
if (newController == null) { if (newController == null) {
onDisconnected(world); onDisconnected(world);
} else {
connected = true;
} }
} }
} }
@@ -66,7 +68,7 @@ public abstract class TileMachine extends TileBase implements ISynchronizedConta
TileEntity tile = worldObj.getTileEntity(new BlockPos(controllerX, controllerY, controllerZ)); TileEntity tile = worldObj.getTileEntity(new BlockPos(controllerX, controllerY, controllerZ));
if (tile instanceof TileController) { if (tile instanceof TileController) {
search = !tryConnect(worldObj, (TileController) tile); search = !tryConnect((TileController) tile);
} }
} }
@@ -76,7 +78,7 @@ public abstract class TileMachine extends TileBase implements ISynchronizedConta
} }
if (connected && !redstoneMode.isEnabled(worldObj, pos)) { if (connected && !redstoneMode.isEnabled(worldObj, pos)) {
onDisconnected(worldObj); onDisconnected(worldObj, false);
} }
if (!(this instanceof TileCable)) { if (!(this instanceof TileCable)) {
@@ -86,13 +88,13 @@ public abstract class TileMachine extends TileBase implements ISynchronizedConta
} }
public void onConnected(World world, TileController controller) { public void onConnected(World world, TileController controller) {
if (tryConnect(world, controller)) { if (tryConnect(controller)) {
world.notifyNeighborsOfStateChange(pos, block); world.notifyNeighborsOfStateChange(pos, block);
} }
} }
private boolean tryConnect(World world, TileController controller) { private boolean tryConnect(TileController controller) {
if (!controller.canRun() || !redstoneMode.isEnabled(world, pos)) { if (!controller.canRun()) {
return false; return false;
} }
@@ -105,9 +107,13 @@ 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 (this.controller != null) { if (removeController && this.controller != null) {
this.controller.removeMachine(this); this.controller.removeMachine(this);
this.controller = null; this.controller = null;
} }