public void addStat(StatBase statbase, int i) {
    if (statbase == null) {
      return;
    }
    if (!statbase.isIndependent) {
      for (; i > 100; i -= 100) {
        playerNetServerHandler.sendPacket(new Packet200Statistic(statbase.statId, 100));
      }

      playerNetServerHandler.sendPacket(new Packet200Statistic(statbase.statId, i));
    }
  }
 public void displayGUIEnchantment(int i, int j, int k) {
   getNextWidowId();
   playerNetServerHandler.sendPacket(new Packet100OpenWindow(currentWindowId, 4, "Enchanting", 9));
   currentCraftingInventory = new ContainerEnchantment(inventory, worldObj, i, j, k);
   currentCraftingInventory.windowId = currentWindowId;
   currentCraftingInventory.onCraftGuiOpened(this);
 }
 public void handlePackets() {
   field_22003_h = false;
   netManager.processReadPackets();
   if (field_15_f - field_22004_g > 20) {
     sendPacket(new Packet0KeepAlive());
   }
 }
 private void getTileEntityInfo(TileEntity tileentity) {
   if (tileentity != null) {
     Packet packet = tileentity.getDescriptionPacket();
     if (packet != null) {
       playerNetServerHandler.sendPacket(packet);
     }
   }
 }
 public void updateHeldItem() {
   if (isChangingQuantityOnly) {
     return;
   } else {
     playerNetServerHandler.sendPacket(new Packet103SetSlot(-1, -1, inventory.getItemStack()));
     return;
   }
 }
 public void displayGUIChest(IInventory iinventory) {
   getNextWidowId();
   playerNetServerHandler.sendPacket(
       new Packet100OpenWindow(
           currentWindowId, 0, iinventory.getInvName(), iinventory.getSizeInventory()));
   currentCraftingInventory = new ContainerChest(inventory, iinventory);
   currentCraftingInventory.windowId = currentWindowId;
   currentCraftingInventory.onCraftGuiOpened(this);
 }
 public void updateCraftingInventorySlot(Container container, int i, ItemStack itemstack) {
   if (container.getSlot(i) instanceof SlotCrafting) {
     return;
   }
   if (isChangingQuantityOnly) {
     return;
   } else {
     playerNetServerHandler.sendPacket(new Packet103SetSlot(container.windowId, i, itemstack));
     return;
   }
 }
 public EnumStatus sleepInBedAt(int i, int j, int k) {
   EnumStatus enumstatus = super.sleepInBedAt(i, j, k);
   if (enumstatus == EnumStatus.OK) {
     EntityTracker entitytracker = mcServer.getEntityTracker(dimension);
     Packet17Sleep packet17sleep = new Packet17Sleep(this, 0, i, j, k);
     entitytracker.sendPacketToTrackedPlayers(this, packet17sleep);
     playerNetServerHandler.teleportTo(posX, posY, posZ, rotationYaw, rotationPitch);
     playerNetServerHandler.sendPacket(packet17sleep);
   }
   return enumstatus;
 }
 public void displayGUIFurnace(TileEntityFurnace tileentityfurnace) {
   getNextWidowId();
   playerNetServerHandler.sendPacket(
       new Packet100OpenWindow(
           currentWindowId,
           2,
           tileentityfurnace.getInvName(),
           tileentityfurnace.getSizeInventory()));
   currentCraftingInventory = new ContainerFurnace(inventory, tileentityfurnace);
   currentCraftingInventory.windowId = currentWindowId;
   currentCraftingInventory.onCraftGuiOpened(this);
 }
 public void displayGUIBrewingStand(TileEntityBrewingStand tileentitybrewingstand) {
   getNextWidowId();
   playerNetServerHandler.sendPacket(
       new Packet100OpenWindow(
           currentWindowId,
           5,
           tileentitybrewingstand.getInvName(),
           tileentitybrewingstand.getSizeInventory()));
   currentCraftingInventory = new ContainerBrewingStand(inventory, tileentitybrewingstand);
   currentCraftingInventory.windowId = currentWindowId;
   currentCraftingInventory.onCraftGuiOpened(this);
 }
 public void displayGUIDispenser(TileEntityDispenser tileentitydispenser) {
   getNextWidowId();
   playerNetServerHandler.sendPacket(
       new Packet100OpenWindow(
           currentWindowId,
           3,
           tileentitydispenser.getInvName(),
           tileentitydispenser.getSizeInventory()));
   currentCraftingInventory = new ContainerDispenser(inventory, tileentitydispenser);
   currentCraftingInventory.windowId = currentWindowId;
   currentCraftingInventory.onCraftGuiOpened(this);
 }
 public void kickPlayer(String s) {
   playerEntity.func_30002_A();
   sendPacket(new Packet255KickDisconnect(s));
   netManager.serverShutdown();
   mcServer.configManager.sendPacketToAllPlayers(
       new Packet3Chat(
           (new StringBuilder())
               .append("\247e")
               .append(playerEntity.username)
               .append(" left the game.")
               .toString()));
   mcServer.configManager.playerLoggedOut(playerEntity);
   connectionClosed = true;
 }
 private void handleSlashCommand(String s) {
   if (s.toLowerCase().startsWith("/me ")) {
     s =
         (new StringBuilder())
             .append("* ")
             .append(playerEntity.username)
             .append(" ")
             .append(s.substring(s.indexOf(" ")).trim())
             .toString();
     logger.info(s);
     mcServer.configManager.sendPacketToAllPlayers(new Packet3Chat(s));
   } else if (s.toLowerCase().startsWith("/kill")) {
     playerEntity.attackEntityFrom(null, 1000);
   } else if (s.toLowerCase().startsWith("/tell ")) {
     String as[] = s.split(" ");
     if (as.length >= 3) {
       s = s.substring(s.indexOf(" ")).trim();
       s = s.substring(s.indexOf(" ")).trim();
       s =
           (new StringBuilder())
               .append("\2477")
               .append(playerEntity.username)
               .append(" whispers ")
               .append(s)
               .toString();
       logger.info((new StringBuilder()).append(s).append(" to ").append(as[1]).toString());
       if (!mcServer.configManager.sendPacketToPlayer(as[1], new Packet3Chat(s))) {
         sendPacket(new Packet3Chat("\247cThere's no player by that name online."));
       }
     }
   } else if (mcServer.configManager.isOp(playerEntity.username)) {
     String s1 = s.substring(1);
     logger.info(
         (new StringBuilder())
             .append(playerEntity.username)
             .append(" issued server command: ")
             .append(s1)
             .toString());
     mcServer.addCommand(s1, this);
   } else {
     String s2 = s.substring(1);
     logger.info(
         (new StringBuilder())
             .append(playerEntity.username)
             .append(" tried command: ")
             .append(s2)
             .toString());
   }
 }
 public void func_40107_e(int i) {
   if (dimension == 1 && i == 1) {
     triggerAchievement(AchievementList.theEnd2);
     worldObj.removePlayerForLogoff(this);
     field_41032_j = true;
     playerNetServerHandler.sendPacket(new Packet70Bed(4, 0));
   } else {
     triggerAchievement(AchievementList.theEnd);
     ChunkCoordinates chunkcoordinates = mcServer.getWorldManager(i).func_40212_d();
     if (chunkcoordinates != null) {
       playerNetServerHandler.teleportTo(
           chunkcoordinates.posX, chunkcoordinates.posY, chunkcoordinates.posZ, 0.0F, 0.0F);
     }
     mcServer.configManager.sendPlayerToOtherDimension(this, 1);
     field_35220_ce = -1;
     lastHealth = -1;
     field_35221_cc = -1;
   }
 }
 protected void func_35199_C() {
   playerNetServerHandler.sendPacket(new Packet38EntityStatus(entityId, (byte) 9));
   super.func_35199_C();
 }
 public void addChatMessage(String s) {
   StringTranslate stringtranslate = StringTranslate.getInstance();
   String s1 = stringtranslate.translateKey(s);
   playerNetServerHandler.sendPacket(new Packet3Chat(s1));
 }
 public void usePersonalCraftingInventory() {
   playerNetServerHandler.sendPacket(new Packet101CloseWindow(currentCraftingInventory.windowId));
   closeCraftingGui();
 }
 public void updateCraftingInventoryInfo(Container container, int i, int j) {
   playerNetServerHandler.sendPacket(new Packet105UpdateProgressbar(container.windowId, i, j));
 }
 public void updateCraftingInventory(Container container, List list) {
   playerNetServerHandler.sendPacket(new Packet104WindowItems(container.windowId, list));
   playerNetServerHandler.sendPacket(new Packet103SetSlot(-1, -1, inventory.getItemStack()));
 }
 public void log(String s) {
   sendPacket(new Packet3Chat((new StringBuilder()).append("\2477").append(s).toString()));
 }
  public void onUpdateEntity(boolean flag) {
    super.onUpdate();
    for (int i = 0; i < inventory.getSizeInventory(); i++) {
      ItemStack itemstack = inventory.getStackInSlot(i);
      if (itemstack == null
          || !Item.itemsList[itemstack.itemID].func_28019_b()
          || playerNetServerHandler.getNumChunkDataPackets() > 2) {
        continue;
      }
      Packet packet =
          ((ItemMapBase) Item.itemsList[itemstack.itemID])
              .getUpdatePacket(itemstack, worldObj, this);
      if (packet != null) {
        playerNetServerHandler.sendPacket(packet);
      }
    }

    if (flag && !loadedChunks.isEmpty()) {
      ChunkCoordIntPair chunkcoordintpair = (ChunkCoordIntPair) loadedChunks.get(0);
      if (chunkcoordintpair != null) {
        boolean flag1 = false;
        if (playerNetServerHandler.getNumChunkDataPackets() < 4) {
          flag1 = true;
        }
        if (flag1) {
          WorldServer worldserver = mcServer.getWorldManager(dimension);
          loadedChunks.remove(chunkcoordintpair);
          playerNetServerHandler.sendPacket(
              new Packet51MapChunk(
                  chunkcoordintpair.chunkXPos * 16,
                  0,
                  chunkcoordintpair.chunkZPos * 16,
                  16,
                  worldserver.worldYMax,
                  16,
                  worldserver));
          List list =
              worldserver.getTileEntityList(
                  chunkcoordintpair.chunkXPos * 16,
                  0,
                  chunkcoordintpair.chunkZPos * 16,
                  chunkcoordintpair.chunkXPos * 16 + 16,
                  worldserver.worldYMax,
                  chunkcoordintpair.chunkZPos * 16 + 16);
          for (int j = 0; j < list.size(); j++) {
            getTileEntityInfo((TileEntity) list.get(j));
          }
        }
      }
    }
    if (inPortal) {
      if (mcServer.propertyManagerObj.getBooleanProperty("allow-nether", true)) {
        if (currentCraftingInventory != personalCraftingInventory) {
          usePersonalCraftingInventory();
        }
        if (ridingEntity != null) {
          mountEntity(ridingEntity);
        } else {
          timeInPortal += 0.0125F;
          if (timeInPortal >= 1.0F) {
            timeInPortal = 1.0F;
            timeUntilPortal = 10;
            byte byte0 = 0;
            if (dimension == -1) {
              byte0 = 0;
            } else {
              byte0 = -1;
            }
            mcServer.configManager.sendPlayerToOtherDimension(this, byte0);
            field_35220_ce = -1;
            lastHealth = -1;
            field_35221_cc = -1;
            triggerAchievement(AchievementList.portal);
          }
        }
        inPortal = false;
      }
    } else {
      if (timeInPortal > 0.0F) {
        timeInPortal -= 0.05F;
      }
      if (timeInPortal < 0.0F) {
        timeInPortal = 0.0F;
      }
    }
    if (timeUntilPortal > 0) {
      timeUntilPortal--;
    }
    if (getEntityHealth() != lastHealth
        || field_35221_cc != foodStats.getFoodLevel()
        || (foodStats.getSaturationLevel() == 0.0F) != field_35222_cd) {
      playerNetServerHandler.sendPacket(
          new Packet8UpdateHealth(
              getEntityHealth(), foodStats.getFoodLevel(), foodStats.getSaturationLevel()));
      lastHealth = getEntityHealth();
      field_35221_cc = foodStats.getFoodLevel();
      field_35222_cd = foodStats.getSaturationLevel() == 0.0F;
    }
    if (experienceTotal != field_35220_ce) {
      field_35220_ce = experienceTotal;
      playerNetServerHandler.sendPacket(
          new Packet43Experience(experience, experienceTotal, experienceLevel));
    }
  }
 protected void onChangedPotionEffect(PotionEffect potioneffect) {
   super.onChangedPotionEffect(potioneffect);
   playerNetServerHandler.sendPacket(new Packet41EntityEffect(entityId, potioneffect));
 }
 public void mountEntity(Entity entity) {
   super.mountEntity(entity);
   playerNetServerHandler.sendPacket(new Packet39AttachEntity(this, ridingEntity));
   playerNetServerHandler.teleportTo(posX, posY, posZ, rotationYaw, rotationPitch);
 }
 protected void onFinishedPotionEffect(PotionEffect potioneffect) {
   super.onFinishedPotionEffect(potioneffect);
   playerNetServerHandler.sendPacket(new Packet42RemoveEntityEffect(entityId, potioneffect));
 }
 public void handlePlace(Packet15Place packet15place) {
   WorldServer worldserver = mcServer.getWorldManager(playerEntity.dimension);
   ItemStack itemstack = playerEntity.inventory.getCurrentItem();
   boolean flag =
       worldserver.field_819_z =
           worldserver.worldProvider.worldType != 0
               || mcServer.configManager.isOp(playerEntity.username);
   if (packet15place.direction == 255) {
     if (itemstack == null) {
       return;
     }
     playerEntity.itemInWorldManager.func_6154_a(playerEntity, worldserver, itemstack);
   } else {
     int i = packet15place.xPosition;
     int j = packet15place.yPosition;
     int k = packet15place.zPosition;
     int l = packet15place.direction;
     ChunkCoordinates chunkcoordinates = worldserver.getSpawnPoint();
     int i1 = (int) MathHelper.abs(i - chunkcoordinates.posX);
     int j1 = (int) MathHelper.abs(k - chunkcoordinates.posZ);
     if (i1 > j1) {
       j1 = i1;
     }
     if (hasMoved
         && playerEntity.getDistanceSq((double) i + 0.5D, (double) j + 0.5D, (double) k + 0.5D)
             < 64D
         && (j1 > 16 || flag)) {
       playerEntity.itemInWorldManager.activeBlockOrUseItem(
           playerEntity, worldserver, itemstack, i, j, k, l);
     }
     playerEntity.playerNetServerHandler.sendPacket(new Packet53BlockChange(i, j, k, worldserver));
     if (l == 0) {
       j--;
     }
     if (l == 1) {
       j++;
     }
     if (l == 2) {
       k--;
     }
     if (l == 3) {
       k++;
     }
     if (l == 4) {
       i--;
     }
     if (l == 5) {
       i++;
     }
     playerEntity.playerNetServerHandler.sendPacket(new Packet53BlockChange(i, j, k, worldserver));
   }
   itemstack = playerEntity.inventory.getCurrentItem();
   if (itemstack != null && itemstack.stackSize == 0) {
     playerEntity.inventory.mainInventory[playerEntity.inventory.currentItem] = null;
   }
   playerEntity.isChangingQuantityOnly = true;
   playerEntity.inventory.mainInventory[playerEntity.inventory.currentItem] =
       ItemStack.func_20117_a(
           playerEntity.inventory.mainInventory[playerEntity.inventory.currentItem]);
   Slot slot =
       playerEntity.currentCraftingInventory.func_20127_a(
           playerEntity.inventory, playerEntity.inventory.currentItem);
   playerEntity.currentCraftingInventory.updateCraftingMatrix();
   playerEntity.isChangingQuantityOnly = false;
   if (!ItemStack.areItemStacksEqual(
       playerEntity.inventory.getCurrentItem(), packet15place.itemStack)) {
     sendPacket(
         new Packet103SetSlot(
             playerEntity.currentCraftingInventory.windowId,
             slot.id,
             playerEntity.inventory.getCurrentItem()));
   }
   worldserver.field_819_z = false;
 }