Simple way to get slot id

Discussion in 'Resources' started by CarPet, May 28, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    CarPet

    There are many ways out there to find the id of a slot you are looking for.

    This is the outcome of the little amount of code that goes into this :
    2014-05-28_22.34.20.png

    It puts the amount of items according the slot id
    This is just the raw code:
    Code:java
    1. for(int i = 0; i < 40; i++) {
    2. player.getInventory().setItem(i, new ItemStack(Material.STONE, i + 1));
    3. }

    The way I used this:
    Code:java
    1. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    2. Player player = (Player) sender;
    3. if(cmd.getName().equalsIgnoreCase("is") || cmd.getName().equalsIgnoreCase("inventoryslots")) {
    4. player.getInventory().clear();
    5. for(int i = 0; i < 40; i++) {
    6. player.getInventory().setItem(i, new ItemStack(Material.STONE, i + 1));
    7. }
    8. }
    9. return false;
    10. }
     
  2. Offline

    SmellyPenguin

    First hotbar slot ID is 0, not 1 >.>
     
    bigteddy98 likes this.
  3. CarPet
    Your armor ids are wrong, and you don't have the crafting slot ids.
    Show Spoiler

    [​IMG]


    Edit: Actually all of them are wrong because as SmellyPenguin said, the first slot is 0, not 1.
     
    KingFaris11 likes this.
  4. Offline

    filoghost

    Or you could just use the image, without coding it:
    [​IMG]
     
  5. filoghost
    Open the spoiler.
     
Thread Status:
Not open for further replies.

Share This Page