mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-26 00:38:35 +01:00
Made the Phantom Redstoneface not update twice when binding to an already active redstone
This commit is contained in:
parent
6a0d4ca611
commit
9d04c236c7
2 changed files with 33 additions and 18 deletions
|
@ -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)){
|
||||
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);
|
||||
|
||||
this.worldObj.notifyNeighborsOfStateChange(this.pos, PosUtil.getBlock(this.pos, this.worldObj));
|
||||
}
|
||||
}
|
||||
super.onUpdateSent();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -90,7 +90,23 @@ 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){
|
||||
if(this.doesNeedUpdateSend()){
|
||||
this.onUpdateSent();
|
||||
System.out.println("UPDAT!");
|
||||
}
|
||||
}
|
||||
else{
|
||||
if(this.boundPosition != null){
|
||||
this.renderParticles();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
|
@ -100,13 +116,6 @@ public class TileEntityPhantomface extends TileEntityInventoryBase implements IP
|
|||
this.sendUpdate();
|
||||
this.markDirty();
|
||||
}
|
||||
}
|
||||
else{
|
||||
if(this.boundPosition != null){
|
||||
this.renderParticles();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int slot, ItemStack stack){
|
||||
|
|
Loading…
Reference in a new issue