Only update when needed

main
astoria 2 years ago
parent 3d91d26747
commit 1127fca76d

@ -11,8 +11,7 @@ public abstract class AbstractWireTileEntity extends TileEntity {
public boolean initialized = false; public boolean initialized = false;
public boolean hasSettings = false; public boolean hasSettings = false;
@Override public void update() {
public void updateEntity() {
updateIO(); updateIO();
} }
@ -79,6 +78,7 @@ public abstract class AbstractWireTileEntity extends TileEntity {
for (int i = 0; i < outputs.length; ++i) { for (int i = 0; i < outputs.length; ++i) {
if (outputs[i].wire != null && outputs[i].wire.thisslot > -1) { if (outputs[i].wire != null && outputs[i].wire.thisslot > -1) {
WireConnection wire = outputs[i].wire; WireConnection wire = outputs[i].wire;
Boolean doUpdate = false;
AbstractWireTileEntity otherChip = (AbstractWireTileEntity)this.worldObj.getBlockTileEntity(wire.x, wire.y, wire.z); AbstractWireTileEntity otherChip = (AbstractWireTileEntity)this.worldObj.getBlockTileEntity(wire.x, wire.y, wire.z);
if(otherChip == null){ if(otherChip == null){
this.outputs[i].wire = new WireConnection(); this.outputs[i].wire = new WireConnection();
@ -90,10 +90,14 @@ public abstract class AbstractWireTileEntity extends TileEntity {
} }
if(outputs[i].floatvalue != otherChip.inputs[wire.thatslot].floatvalue) { if(outputs[i].floatvalue != otherChip.inputs[wire.thatslot].floatvalue) {
otherChip.inputs[wire.thatslot].floatvalue = outputs[i].floatvalue; otherChip.inputs[wire.thatslot].floatvalue = outputs[i].floatvalue;
doUpdate = true;
} }
if(!outputs[i].stringvalue.equals(otherChip.inputs[wire.thatslot].stringvalue)) { if(!outputs[i].stringvalue.equals(otherChip.inputs[wire.thatslot].stringvalue)) {
otherChip.inputs[wire.thatslot].stringvalue = outputs[i].stringvalue; otherChip.inputs[wire.thatslot].stringvalue = outputs[i].stringvalue;
doUpdate = true;
} }
if(doUpdate)
otherChip.update();
} }
} }
} }

@ -66,8 +66,10 @@ public class RedstoneLinkTile extends AbstractWireTile {
RedstoneLinkTileEntity link = (RedstoneLinkTileEntity) world.getBlockTileEntity(i, j, k); RedstoneLinkTileEntity link = (RedstoneLinkTileEntity) world.getBlockTileEntity(i, j, k);
if (world.isBlockGettingPowered(i, j, k)) { if (world.isBlockGettingPowered(i, j, k)) {
link.outputs[0].floatvalue = 1.0f; link.outputs[0].floatvalue = 1.0f;
link.updateIO();
} else { } else {
link.outputs[0].floatvalue = 0.0f; link.outputs[0].floatvalue = 0.0f;
link.updateIO();
} }
} }

@ -9,13 +9,13 @@ public class ChipTileEntity extends AbstractWireTileEntity {
private boolean shouldIncrement = true; private boolean shouldIncrement = true;
@Override @Override
public void updateEntity() { public void update() {
switch (mode) { switch (mode) {
case "count": case "count":
doIncrement(); doIncrement();
updateIO();
break; break;
} }
updateIO();
} }
public void doIncrement() { public void doIncrement() {

@ -31,7 +31,7 @@ public class RedstoneLinkTileEntity extends AbstractWireTileEntity {
nbttagcompound.setBoolean("activity", this.isActive); nbttagcompound.setBoolean("activity", this.isActive);
} }
@Override @Override
public void updateEntity() { public void update() {
if(inputs[0].floatvalue > 0 && !this.isActive && worldObj.blockExists(xCoord, yCoord, zCoord) && worldObj.getBlockId(xCoord, yCoord, zCoord) == WireMod.LinkTileInactive.blockID){ if(inputs[0].floatvalue > 0 && !this.isActive && worldObj.blockExists(xCoord, yCoord, zCoord) && worldObj.getBlockId(xCoord, yCoord, zCoord) == WireMod.LinkTileInactive.blockID){
this.shouldnotremove = true; this.shouldnotremove = true;
RedstoneLinkTile.updateLinkBlockState(true, this.worldObj, this.xCoord, this.yCoord, this.zCoord); RedstoneLinkTile.updateLinkBlockState(true, this.worldObj, this.xCoord, this.yCoord, this.zCoord);
@ -43,6 +43,5 @@ public class RedstoneLinkTileEntity extends AbstractWireTileEntity {
this.shouldnotremove = false; this.shouldnotremove = false;
this.isActive = false; this.isActive = false;
} }
updateIO();
} }
} }

Loading…
Cancel
Save