Solved How can I give a player a shulker box containing items?

Discussion in 'Spigot Plugin Development' started by Rektb, Jul 16, 2018.

  1. He needs to set the itemStack meta to bsm, no?
     
    • Winner Winner x 1
  2. Well, it still doesn't work
     
  3. ScarabCoder

    ScarabCoder Retired Resource Staff
    Retired

    Right, @Rektb try setting the item meta to the item stack (I think I already said that before).
     
    • Winner Winner x 1
  4. It worked perfectly!! Thanks a lot.
    Code (Text):

    ItemStack itemStack = new ItemStack(Material.BLACK_SHULKER_BOX);
    BlockStateMeta bsm = (BlockStateMeta) itemStack.getItemMeta();
    ShulkerBox box = (ShulkerBox) bsm.getBlockState();
    box.getInventory().setContents(e.getInventory().getContents());
    bsm.setBlockState(box);
    box.update();
    itemStack.setItemMeta(bsm);
    p.getInventory().remove(p.getInventory().getItemInMainHand());
    p.getInventory().setItem(p.getInventory().getHeldItemSlot(), itemStack);
     
     
    • Like Like x 4
  5. The code you sent shows that you set the item meta blockstate, try to set the itemmeta of the itemstack to bsm