improve hopping item interface performance

This commit is contained in:
Ellpeck 2016-12-18 14:27:10 +01:00
parent eda6fcb587
commit 49bcda43fa

View file

@ -50,6 +50,26 @@ public class TileEntityItemViewerHopping extends TileEntityItemViewer{
} }
} }
} }
else{
if(this.world.getTotalWorldTime()%20 == 0){
List<EntityItem> items = this.world.getEntitiesWithinAABB(EntityItem.class, new AxisAlignedBB(this.pos.getX(), this.pos.getY()+0.5, this.pos.getZ(), this.pos.getX()+1, this.pos.getY()+2, this.pos.getZ()+1));
if(items != null && !items.isEmpty()){
for(EntityItem item : items){
if(item != null && !item.isDead){
for(int i = 0; i < this.itemHandler.getSlots(); i++){
ItemStack left = this.itemHandler.insertItem(i, item.getEntityItem(), false);
item.setEntityItemStack(left);
if(!StackUtil.isValid(left)){
item.setDead();
break;
}
}
}
}
}
}
}
if(this.handlerToPushTo != null){ if(this.handlerToPushTo != null){
outer : for(int i = 0; i < this.itemHandler.getSlots(); i++){ outer : for(int i = 0; i < this.itemHandler.getSlots(); i++){
@ -62,25 +82,6 @@ public class TileEntityItemViewerHopping extends TileEntityItemViewer{
} }
} }
} }
if(this.world.getTotalWorldTime()%20 == 0){
List<EntityItem> items = this.world.getEntitiesWithinAABB(EntityItem.class, new AxisAlignedBB(this.pos.getX(), this.pos.getY()+0.5, this.pos.getZ(), this.pos.getX()+1, this.pos.getY()+2, this.pos.getZ()+1));
if(items != null && !items.isEmpty()){
for(EntityItem item : items){
if(item != null && !item.isDead){
for(int i = 0; i < this.itemHandler.getSlots(); i++){
ItemStack left = this.itemHandler.insertItem(i, item.getEntityItem(), false);
item.setEntityItemStack(left);
if(!StackUtil.isValid(left)){
item.setDead();
break;
}
}
}
}
}
}
} }
} }