Package net.minecraft.inventory

Examples of net.minecraft.inventory.Slot


    int i=0;
    for(Point p : points) {
      final int slot = i;
      i++;
      addSlotToContainer(new Slot(tileEntity, slot, p.x, p.y) {
        @Override
        public boolean isItemValid(ItemStack itemStack) {
          return tileEntity.isItemValidForSlot(slot, itemStack);
        }
View Full Code Here


    int x = 8;
    int y = 17;
    int index = -1;
    for (int i = 0; i < 3; ++i) {
      for (int j = 0; j < 9; ++j) {
        addSlotToContainer(new Slot(te, ++index, x + j * 18, y + i * 18));
      }
    }

    y = 84;
    // add players inventory
    for (int i = 0; i < 3; ++i) {
      for (int j = 0; j < 9; ++j) {
        addSlotToContainer(new Slot(inventory, j + i * 9 + 9, x + j * 18, y + i * 18));
      }
    }
    for (int i = 0; i < 9; ++i) {
      addSlotToContainer(new Slot(inventory, i, x + i * 18, y + 58));
    }
  }
View Full Code Here

    return true;
  }

  public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int par2) {
    ItemStack itemstack = null;
    Slot slot = (Slot) this.inventorySlots.get(par2);

    if(slot != null && slot.getHasStack()) {
      ItemStack itemstack1 = slot.getStack();
      itemstack = itemstack1.copy();

      if(par2 < this.numRows * 9) {
        if(!this.mergeItemStack(itemstack1, this.numRows * 9, this.inventorySlots.size(), true)) {
          return null;
        }
      } else if(!this.mergeItemStack(itemstack1, 0, this.numRows * 9, false)) {
        return null;
      }

      if(itemstack1.stackSize == 0) {
        slot.putStack((ItemStack) null);
      } else {
        slot.onSlotChanged();
      }
    }
    return itemstack;
  }
View Full Code Here

    }

    // add players inventory
    for (int i = 0; i < 3; ++i) {
      for (int j = 0; j < 9; ++j) {
        addSlotToContainer(new Slot(playerInv, j + i * 9 + 9, 8 + j * 18, 83 + i * 18));
      }
    }

    for (int i = 0; i < 9; ++i) {
      addSlotToContainer(new Slot(playerInv, i, 8 + i * 18, 141));
    }

  }
View Full Code Here

    smelter = te;
  }

  @Override
  protected void addMachineSlots(InventoryPlayer playerInv) {
    addSlotToContainer(new Slot(tileEntity, 0, 54, 17) {
      @Override
      public boolean isItemValid(ItemStack itemStack) {
        return tileEntity.isItemValidForSlot(0, itemStack);
      }
    });
    addSlotToContainer(new Slot(tileEntity, 1, 79, 7) {
      @Override
      public boolean isItemValid(ItemStack itemStack) {
        return tileEntity.isItemValidForSlot(1, itemStack);
      }
    });
    addSlotToContainer(new Slot(tileEntity, 2, 103, 17) {
      @Override
      public boolean isItemValid(ItemStack itemStack) {
        return tileEntity.isItemValidForSlot(2, itemStack);
      }
    });
View Full Code Here

  public ContainerCapacitorBank(final Entity player, InventoryPlayer playerInv, TileCapacitorBank te) {

    tileEntity = te;
    int armorOffset = 21;
    addSlotToContainer(new Slot(tileEntity, 0, 59 + armorOffset, 59) {
      @Override
      public boolean isItemValid(ItemStack itemStack) {
        return tileEntity.isItemValidForSlot(0, itemStack);
      }
    });

    addSlotToContainer(new Slot(tileEntity, 1, 79 + armorOffset, 59) {
      @Override
      public boolean isItemValid(ItemStack itemStack) {
        return tileEntity.isItemValidForSlot(1, itemStack);
      }
    });

    addSlotToContainer(new Slot(tileEntity, 2, 99 + armorOffset, 59) {
      @Override
      public boolean isItemValid(ItemStack itemStack) {
        return tileEntity.isItemValidForSlot(2, itemStack);
      }
    });

    addSlotToContainer(new Slot(tileEntity, 3, 119 + armorOffset, 59) {
      @Override
      public boolean isItemValid(ItemStack itemStack) {
        return tileEntity.isItemValidForSlot(3, itemStack);
      }
    });

    // add players inventory
    for (int i = 0; i < 3; ++i) {
      for (int j = 0; j < 9; ++j) {
        addSlotToContainer(new Slot(playerInv, j + i * 9 + 9, + armorOffset + 8 + j * 18, 84 + i * 18));
      }
    }

    for (int i = 0; i < 9; ++i) {
      addSlotToContainer(new Slot(playerInv, i, + armorOffset + 8 + i * 18, 142));
    }

    //armor slots
    for (int i = 0; i < 4; ++i) {
      final int k = i;
      addSlotToContainer(new Slot(playerInv, playerInv.getSizeInventory() - 1 - i, -15 + armorOffset, 30 + i * 18) {

        @Override
        public int getSlotStackLimit() {
          return 1;
        }
View Full Code Here

    int endPlayerSlot = startPlayerSlot + 26;
    int startHotBarSlot = endPlayerSlot + 1;
    int endHotBarSlot = startHotBarSlot + 9;

    ItemStack copystack = null;
    Slot slot = (Slot) inventorySlots.get(slotIndex);
    if(slot != null && slot.getHasStack()) {

      ItemStack origStack = slot.getStack();
      copystack = origStack.copy();

      if(slotIndex < 4) {
        // merge from machine input slots to inventory
        if(!mergeItemStack(origStack, startPlayerSlot, endHotBarSlot, false)) {
          return null;
        }

      } else {
        //Check from inv-> charge then inv->hotbar or hotbar->inv
        if(slotIndex >= startPlayerSlot) {
          if(!tileEntity.isItemValidForSlot(0, origStack) || !mergeItemStack(origStack, 0, 4, false)) {

            if(slotIndex <= endPlayerSlot) {
              if(!mergeItemStack(origStack, startHotBarSlot, endHotBarSlot, false)) {
                return null;
              }
            } else if(slotIndex >= startHotBarSlot && slotIndex <= endHotBarSlot) {
              if(!mergeItemStack(origStack, startPlayerSlot, endPlayerSlot, false)) {
                return null;
              }
            }

          }
        }
      }

      if(origStack.stackSize == 0) {
        slot.putStack((ItemStack) null);
      } else {
        slot.onSlotChanged();
      }

      slot.onSlotChanged();

      if(origStack.stackSize == copystack.stackSize) {
        return null;
      }

      slot.onPickupFromSlot(entityPlayer, origStack);
    }

    return copystack;
  }
View Full Code Here

    int y = 10;   
    for (int row = 0; row < 3; row++) {
      x = 62;
      for (int col = 0; col < 4; col++) {
        final int index = (row * 4) + col;
        addSlotToContainer(new Slot(tileEntity, index, x, y) {
          @Override
          public boolean isItemValid(ItemStack itemStack) {
            return tileEntity.isItemValidForSlot(index, itemStack);
          }
        });
View Full Code Here

    super(playerInv, te);
  }

  @Override
  protected void addMachineSlots(InventoryPlayer playerInv) {
    addSlotToContainer(new Slot(tileEntity, 0, 80, 12) {
      @Override
      public boolean isItemValid(ItemStack itemStack) {
        return tileEntity.isItemValidForSlot(0, itemStack);
      }
    });
    addSlotToContainer(new Slot(tileEntity, 1, 122, 23) {
      @Override
      public boolean isItemValid(ItemStack itemStack) {
        return tileEntity.isItemValidForSlot(1, itemStack);
      }
    });

    addSlotToContainer(new Slot(tileEntity, 2, 49, 59) {
      @Override
      public boolean isItemValid(ItemStack par1ItemStack) {
        return false;
      }
    });
    addSlotToContainer(new Slot(tileEntity, 3, 70, 59) {
      @Override
      public boolean isItemValid(ItemStack par1ItemStack) {
        return false;
      }
    });
    addSlotToContainer(new Slot(tileEntity, 4, 91, 59) {
      @Override
      public boolean isItemValid(ItemStack par1ItemStack) {
        return false;
      }
    });
    addSlotToContainer(new Slot(tileEntity, 5, 112, 59) {
      @Override
      public boolean isItemValid(ItemStack par1ItemStack) {
        return false;
      }
    });
View Full Code Here

  public ContainerEnchanter(EntityPlayer player, InventoryPlayer playerInv, TileEnchanter te) {

    enchanter = te;

    addSlotToContainer(new Slot(te, 0, 27, 35) {

      @Override
      public int getSlotStackLimit() {
        return 1;
      }

      @Override
      public boolean isItemValid(ItemStack itemStack) {
        return enchanter.isItemValidForSlot(0, itemStack);
      }

      @Override
      public void onSlotChanged() {
        updateOutput();
      }

    });

    addSlotToContainer(new Slot(te, 1, 76, 35) {

      @Override
      public boolean isItemValid(ItemStack itemStack) {
        return enchanter.isItemValidForSlot(1, itemStack);
      }

      @Override
      public void onSlotChanged() {
        updateOutput();
      }

    });

    addSlotToContainer(new Slot(te, 2, 134, 35) {

      @Override
      public int getSlotStackLimit() {
        return 1;
      }

      @Override
      public boolean isItemValid(ItemStack itemStack) {
        return false;
      }

      public void onPickupFromSlot(EntityPlayer player, ItemStack stack) {
        if(!player.capabilities.isCreativeMode) {
          player.addExperienceLevel(-enchanter.getCurrentEnchantmentCost());
        }
        EnchantmentData enchData = enchanter.getCurrentEnchantmentData();
        ItemStack curStack = enchanter.getStackInSlot(1);
        if(enchData == null || curStack == null || enchData.enchantmentLevel >= curStack.stackSize) {
          enchanter.setInventorySlotContents(1, (ItemStack) null);
        } else {
          curStack = curStack.copy();
          curStack.stackSize -= enchData.enchantmentLevel;
          enchanter.setInventorySlotContents(1, curStack);
          enchanter.markDirty();
        }

        enchanter.setInventorySlotContents(0, (ItemStack) null);
        //TODO: Sound
        //          if (!p_i1800_2_.isRemote) {
        //              p_i1800_2_.playAuxSFX(1021, p_i1800_3_, p_i1800_4_, p_i1800_5_, 0);
        //          }
      }

      @Override
      public boolean canTakeStack(EntityPlayer player) {
        return playerHasEnoughLevels(player);
      }

    });

    int x = 8;
    int y = 84;
    // add players inventory
    for (int i = 0; i < 3; ++i) {
      for (int j = 0; j < 9; ++j) {
        addSlotToContainer(new Slot(playerInv, j + i * 9 + 9, x + j * 18, y + i * 18));
      }
    }

    for (int i = 0; i < 9; ++i) {
      addSlotToContainer(new Slot(playerInv, i, x + i * 18, y + 58));
    }
  }
View Full Code Here

TOP

Related Classes of net.minecraft.inventory.Slot

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.