1.15.2 Can't add certain blocks to my inventory

Discussion in 'Spigot Plugin Development' started by diamante_0018, Jan 18, 2020.

  1. So I have this piece of code in my java plugin that in theory is very simple. Unfortunately, it appears that because of the game mechanics it doesn't work.

    Code (Java):
    Player player = (Player) sender;
                ItemStack type;
             
                if (args[0].equals("fire")) {
                    type = new ItemStack(Material.FIRE,Integer.parseInt(args[1]));
                    player.getInventory().addItem(type);
                }
                else if (args[0].equals("water")) {
                    type = new ItemStack(Material.WATER,Integer.parseInt(args[1]));
                    player.getInventory().addItem(type);
                }
                else if (args[0].equals("lava")) {
                    type = new ItemStack(Material.LAVA,Integer.parseInt(args[1]));
                    player.getInventory().addItem(type);
                }
                else if (args[0].equals("nether")) {
                    type = new ItemStack(Material.NETHER_PORTAL,Integer.parseInt(args[1]));
                    player.getInventory().addItem(type);
                }
                else if (args[0].equals("end")) {
                    type = new ItemStack(Material.END_PORTAL,Integer.parseInt(args[1]));
                    player.getInventory().addItem(type);
                }
                else if (args[0].equals("end2")) {
                    type = new ItemStack(Material.END_GATEWAY,Integer.parseInt(args[1]));
                    player.getInventory().addItem(type);
                }
                else {
                    player.sendMessage("Invalid inputs");
                    return false;
                }
    You can see that what I'm trying to do is add to the inventory some unobtainable blocks. The plugin works with normal materials such a stone but these "illegal" items don't get added to the inventory.
    Is somebody here familiar with how the spigot client handles these blocks? How to get around this? (if it's possible).
    The spigot API provides some legacy blocks, am I supposed to use them instead?
    Thanks in advance.
     
  2. This was removed in 1.8. These materials can no longer be in an inventory as an item.
    There is no way around it.

    From the wiki: