示例#1
0
  public BlockEntity getBlockEntity(Position pos) {
    for (BlockEntity entity : this.entities) {
      if (entity.getPosition().equals(pos)) return entity;
    }

    return null;
  }
示例#2
0
  public BlockEntity getBlockEntityFromId(int id) {
    for (BlockEntity entity : this.entities) {
      if (entity.getEntityId() == id) return entity;
    }

    return null;
  }
示例#3
0
 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);
     }
   }
 }
示例#4
0
  public void tick() {
    for (Player player : this.players) {
      ((ServerPlayer) player).tick();
    }

    for (BlockEntity entity : this.entities) {
      if (entity.getController() != null) entity.getController().tick();
    }
  }
示例#5
0
 public void removeBlockEntity(BlockEntity entity) {
   this.removeBlockEntity(entity.getEntityId());
 }
示例#6
0
  public BlockEntity spawnBlockEntity(BlockEntity entity, Position pos) {
    this.entities.add(entity);
    entity.setPosition(pos);

    return entity;
  }