@Override
  protected void worldChanged(World world) {
    // Grab world characteristics.
    GameMode gamemode = world.getDataMap().get(VanillaData.GAMEMODE);
    Difficulty difficulty = world.getDataMap().get(VanillaData.DIFFICULTY);
    Dimension dimension = world.getDataMap().get(VanillaData.DIMENSION);
    WorldType worldType = world.getDataMap().get(VanillaData.WORLD_TYPE);

    // TODO Handle infinite height
    if (first) {
      first = false;
      int entityId = owner.getEntity().getId();
      VanillaPlayer vc = (VanillaPlayer) owner.getEntity().getController();
      LoginRequestMessage idMsg =
          new LoginRequestMessage(
              entityId,
              worldType.toString(),
              gamemode.getId(),
              (byte) dimension.getId(),
              difficulty.getId(),
              (byte) session.getEngine().getMaxPlayers());
      owner.getSession().send(false, true, idMsg);
      owner.getSession().setState(State.GAME);
      for (int slot = 0; slot < 4; slot++) {
        ItemStack slotItem = vc.getInventory().getArmor().getItem(slot);
        owner.getSession().send(false, new EntityEquipmentMessage(entityId, slot, slotItem));
      }
    } else {
      owner
          .getSession()
          .send(
              false,
              new RespawnMessage(
                  dimension.getId(),
                  difficulty.getId(),
                  gamemode.getId(),
                  256,
                  worldType.toString()));
    }

    Point pos = world.getSpawnPoint().getPosition();
    SpawnPositionMessage SPMsg =
        new SpawnPositionMessage((int) pos.getX(), (int) pos.getY(), (int) pos.getZ());
    owner.getSession().send(false, SPMsg);
  }
Exemplo n.º 2
0
 public CraftingTableWindow(VanillaPlayer owner, CraftingTableInventory craftingInventory) {
   super(1, "Crafting", owner, craftingInventory);
   this.setInventory(owner.getInventory().getItems(), craftingInventory);
   this.setSlotIndexMap(SLOTS);
 }