public BlockEntity getBlockEntity(Position pos) { for (BlockEntity entity : this.entities) { if (entity.getPosition().equals(pos)) return entity; } return null; }
public BlockEntity getBlockEntityFromId(int id) { for (BlockEntity entity : this.entities) { if (entity.getEntityId() == id) return entity; } return null; }
public void removeBlockEntity(int id) { for (BlockEntity entity : this.entities) { if (entity.getEntityId() == id) { if (entity.getController() != null) entity.getController().onDeath(); EventFactory.callEvent(new EntityDeathEvent(entity)); this.entities.remove(entity); } } }
public void tick() { for (Player player : this.players) { ((ServerPlayer) player).tick(); } for (BlockEntity entity : this.entities) { if (entity.getController() != null) entity.getController().tick(); } }
public void removeBlockEntity(BlockEntity entity) { this.removeBlockEntity(entity.getEntityId()); }
public BlockEntity spawnBlockEntity(BlockEntity entity, Position pos) { this.entities.add(entity); entity.setPosition(pos); return entity; }