Only update when needed

main
astoria 1 year ago
parent 3d91d26747
commit 1127fca76d

@ -11,8 +11,7 @@ public abstract class AbstractWireTileEntity extends TileEntity {
public boolean initialized = false;
public boolean hasSettings = false;
@Override
public void updateEntity() {
public void update() {
updateIO();
}
@ -79,6 +78,7 @@ public abstract class AbstractWireTileEntity extends TileEntity {
for (int i = 0; i < outputs.length; ++i) {
if (outputs[i].wire != null && outputs[i].wire.thisslot > -1) {
WireConnection wire = outputs[i].wire;
Boolean doUpdate = false;
AbstractWireTileEntity otherChip = (AbstractWireTileEntity)this.worldObj.getBlockTileEntity(wire.x, wire.y, wire.z);
if(otherChip == null){
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) {
otherChip.inputs[wire.thatslot].floatvalue = outputs[i].floatvalue;
doUpdate = true;
}
if(!outputs[i].stringvalue.equals(otherChip.inputs[wire.thatslot].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);
if (world.isBlockGettingPowered(i, j, k)) {
link.outputs[0].floatvalue = 1.0f;
link.updateIO();
} else {
link.outputs[0].floatvalue = 0.0f;
link.updateIO();
}
}

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

@ -31,7 +31,7 @@ public class RedstoneLinkTileEntity extends AbstractWireTileEntity {
nbttagcompound.setBoolean("activity", this.isActive);
}
@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){
this.shouldnotremove = true;
RedstoneLinkTile.updateLinkBlockState(true, this.worldObj, this.xCoord, this.yCoord, this.zCoord);
@ -43,6 +43,5 @@ public class RedstoneLinkTileEntity extends AbstractWireTileEntity {
this.shouldnotremove = false;
this.isActive = false;
}
updateIO();
}
}

Loading…
Cancel
Save