Increased ESD performance by making it remember the tiles around

This commit is contained in:
Ellpeck 2016-06-11 15:42:28 +02:00
parent 91ca5aa4a1
commit b8051e6483
6 changed files with 18 additions and 8 deletions

View file

@ -90,6 +90,16 @@ public class BlockInputter extends BlockContainerBase{
return EnumRarity.EPIC; return EnumRarity.EPIC;
} }
@Override
public void neighborChanged(IBlockState state, World world, BlockPos pos, Block block){
if(!world.isRemote){
TileEntity tile = world.getTileEntity(pos);
if(tile instanceof TileEntityInputter){
((TileEntityInputter)tile).initVars();
}
}
}
public static class TheItemBlock extends ItemBlockBase{ public static class TheItemBlock extends ItemBlockBase{
private long lastSysTime; private long lastSysTime;

View file

@ -40,7 +40,6 @@ public class BlockItemViewer extends BlockContainerBase{
TileEntity tile = world.getTileEntity(pos); TileEntity tile = world.getTileEntity(pos);
if(tile instanceof TileEntityItemViewer){ if(tile instanceof TileEntityItemViewer){
((TileEntityItemViewer)tile).saveConnectedRelay(); ((TileEntityItemViewer)tile).saveConnectedRelay();
System.out.println("------------Saving connected on change " + ((TileEntityItemViewer)tile).connectedRelay);
} }
} }
} }

View file

@ -118,11 +118,10 @@ public class BlockLaserRelay extends BlockContainerBase{
@Override @Override
public void neighborChanged(IBlockState state, World world, BlockPos pos, Block block){ public void neighborChanged(IBlockState state, World world, BlockPos pos, Block block){
if(!world.isRemote){ if((this.type == Type.ITEM || this.type == Type.ITEM_WHITELIST) && !world.isRemote){
TileEntity tile = world.getTileEntity(pos); TileEntity tile = world.getTileEntity(pos);
if(tile instanceof TileEntityLaserRelayItem){ if(tile instanceof TileEntityLaserRelayItem){
((TileEntityLaserRelayItem)tile).saveAllHandlersAround(); ((TileEntityLaserRelayItem)tile).saveAllHandlersAround();
System.out.println("------------Saving around on change " + ((TileEntityLaserRelayItem)tile).handlersAround);
} }
} }
} }

View file

@ -49,6 +49,8 @@ public class TileEntityInputter extends TileEntityInventoryBase implements IButt
private boolean lastPullWhite; private boolean lastPullWhite;
private boolean lastPutWhite; private boolean lastPutWhite;
private boolean hasCheckedTilesAround;
public TileEntityInputter(int slots, String name){ public TileEntityInputter(int slots, String name){
super(slots, name); super(slots, name);
} }
@ -348,6 +350,7 @@ public class TileEntityInputter extends TileEntityInventoryBase implements IButt
} }
this.markDirty(); this.markDirty();
this.initVars();
} }
@Override @Override
@ -380,7 +383,10 @@ public class TileEntityInputter extends TileEntityInventoryBase implements IButt
public void updateEntity(){ public void updateEntity(){
super.updateEntity(); super.updateEntity();
if(!this.worldObj.isRemote){ if(!this.worldObj.isRemote){
this.initVars(); if(!this.hasCheckedTilesAround){
this.initVars();
this.hasCheckedTilesAround = true;
}
//Is Block not powered by Redstone? //Is Block not powered by Redstone?
if(!this.isRedstonePowered){ if(!this.isRedstonePowered){

View file

@ -38,8 +38,6 @@ public class TileEntityItemViewer extends TileEntityInventoryBase{
if(!this.worldObj.isRemote && !this.hasCheckedRelayOnLoad){ if(!this.worldObj.isRemote && !this.hasCheckedRelayOnLoad){
this.saveConnectedRelay(); this.saveConnectedRelay();
this.hasCheckedRelayOnLoad = true; this.hasCheckedRelayOnLoad = true;
System.out.println("------------Saving relay on load " + this.connectedRelay);
} }
} }

View file

@ -48,8 +48,6 @@ public class TileEntityLaserRelayItem extends TileEntityLaserRelay{
if(!this.worldObj.isRemote && !this.hasCheckedHandlersOnLoad){ if(!this.worldObj.isRemote && !this.hasCheckedHandlersOnLoad){
this.saveAllHandlersAround(); this.saveAllHandlersAround();
this.hasCheckedHandlersOnLoad = true; this.hasCheckedHandlersOnLoad = true;
System.out.println("------------Saving around on load " + this.handlersAround);
} }
} }