コード例 #1
0
 public boolean addItemStackToInventory(ItemStack itemstack) {
   if (!itemstack.isItemDamaged()) {
     int i;
     do {
       i = itemstack.stackSize;
       itemstack.stackSize = func_21083_d(itemstack);
     } while (itemstack.stackSize > 0 && itemstack.stackSize < i);
     return itemstack.stackSize < i;
   }
   int j = getFirstEmptyStack();
   if (j >= 0) {
     mainInventory[j] = ItemStack.func_20117_a(itemstack);
     mainInventory[j].animationsToGo = 5;
     itemstack.stackSize = 0;
     return true;
   } else {
     return false;
   }
 }
コード例 #2
0
 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;
 }