Made the Phantom Redstoneface not update twice when binding to an already active redstone

This commit is contained in:
Ellpeck 2016-05-05 17:50:18 +02:00
parent 6a0d4ca611
commit 9d04c236c7
2 changed files with 33 additions and 18 deletions

View file

@ -21,8 +21,6 @@ public class TileEntityPhantomRedstoneface extends TileEntityPhantomface{
@Override
public void updateEntity(){
super.updateEntity();
if(!this.worldObj.isRemote){
if(this.isBoundThingInRange()){
IBlockState boundState = this.worldObj.getBlockState(this.boundPosition);
@ -37,13 +35,21 @@ public class TileEntityPhantomRedstoneface extends TileEntityPhantomface{
}
}
}
if(!Arrays.equals(this.providesStrong, this.lastProvidesStrong) || !Arrays.equals(this.providesWeak, this.lastProvidesWeak)){
System.arraycopy(this.providesWeak, 0, this.lastProvidesWeak, 0, this.providesWeak.length);
System.arraycopy(this.providesStrong, 0, this.lastProvidesStrong, 0, this.providesStrong.length);
this.worldObj.notifyNeighborsOfStateChange(this.pos, PosUtil.getBlock(this.pos, this.worldObj));
}
}
super.updateEntity();
}
@Override
protected boolean doesNeedUpdateSend(){
return super.doesNeedUpdateSend() || !Arrays.equals(this.providesStrong, this.lastProvidesStrong) || !Arrays.equals(this.providesWeak, this.lastProvidesWeak);
}
@Override
protected void onUpdateSent(){
System.arraycopy(this.providesWeak, 0, this.lastProvidesWeak, 0, this.providesWeak.length);
System.arraycopy(this.providesStrong, 0, this.lastProvidesStrong, 0, this.providesStrong.length);
super.onUpdateSent();
}
}

View file

@ -90,15 +90,9 @@ public class TileEntityPhantomface extends TileEntityInventoryBase implements IP
this.boundPosition = null;
}
if(this.boundPosition != this.boundPosBefore || (this.boundPosition != null && PosUtil.getBlock(this.boundPosition, this.worldObj) != this.boundBlockBefore) || this.rangeBefore != this.range){
this.rangeBefore = this.range;
this.boundPosBefore = this.boundPosition;
this.boundBlockBefore = this.boundPosition == null ? null : PosUtil.getBlock(this.boundPosition, this.worldObj);
this.worldObj.notifyNeighborsOfStateChange(this.pos, PosUtil.getBlock(this.pos, this.worldObj));
this.sendUpdate();
this.markDirty();
if(this.doesNeedUpdateSend()){
this.onUpdateSent();
System.out.println("UPDAT!");
}
}
else{
@ -108,6 +102,21 @@ public class TileEntityPhantomface extends TileEntityInventoryBase implements IP
}
}
protected boolean doesNeedUpdateSend(){
return this.boundPosition != this.boundPosBefore || (this.boundPosition != null && PosUtil.getBlock(this.boundPosition, this.worldObj) != this.boundBlockBefore) || this.rangeBefore != this.range;
}
protected void onUpdateSent(){
this.rangeBefore = this.range;
this.boundPosBefore = this.boundPosition;
this.boundBlockBefore = this.boundPosition == null ? null : PosUtil.getBlock(this.boundPosition, this.worldObj);
this.worldObj.notifyNeighborsOfStateChange(this.pos, PosUtil.getBlock(this.pos, this.worldObj));
this.sendUpdate();
this.markDirty();
}
@Override
public boolean isItemValidForSlot(int slot, ItemStack stack){
return false;