Solved Can't craft Nether Wart

Discussion in 'Plugin Development' started by Korotaxx, Mar 17, 2020.

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

    Korotaxx

    I'm trying to make a recipe for nether warts, but it keeps giving me a null pointer exeption.

    Thats my code:
    Code:
    public void onEnable() {
    
    ItemStack nwar = new ItemStack(Material.NETHER_WARTS);
    
    getServer().addRecipe(new ShapedRecipe(nwar).shape("eee", "ese", "eee").setIngredient('e', Material.SPIDER_EYE).setIngredient('s', Material.SEEDS)); // nether wart
    
    }
     
  2. Online

    timtower Administrator Administrator Moderator

    @Korotaxx On what line do you get the exception?
    Try to split that single line into multiple.
     
  3. Offline

    Korotaxx

    I don't get the exeption in the plugin itself, but from the server.
    Code:
    java.util.concurrent.ExecutionException: java.lang.NullPointerException
            at java.util.concurrent.FutureTask.report(Unknown Source) ~[?:1.8.0_231]
            at java.util.concurrent.FutureTask.get(Unknown Source) ~[?:1.8.0_231]
            at net.minecraft.server.v1_8_R3.SystemUtils.a(SourceFile:45) [spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.MinecraftServer.B(MinecraftServer.java:715) [spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:374) [spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:654) [spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:557) [spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24]
            at java.lang.Thread.run(Unknown Source) [?:1.8.0_231]
    Caused by: java.lang.NullPointerException
            at net.minecraft.server.v1_8_R3.ShapedRecipes.craftItem(ShapedRecipes.java:150) ~[spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.CraftingManager.craft(CraftingManager.java:297) ~[spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.ContainerWorkbench.a(ContainerWorkbench.java:56) ~[spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.InventoryCrafting.setItem(InventoryCrafting.java:129) ~[spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.Slot.set(Slot.java:55) ~[spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24]
            at org.bukkit.craftbukkit.v1_8_R3.inventory.CraftInventoryView.setItem(CraftInventoryView.java:54) ~[spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.Container.clickItem(Container.java:196) ~[spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.PlayerConnection.a(PlayerConnection.java:1595) ~[spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.PacketPlayInWindowClick.a(SourceFile:31) ~[spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.PacketPlayInWindowClick.a(SourceFile:9) ~[spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.PlayerConnectionUtils$1.run(SourceFile:13) ~[spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24]
            at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) ~[?:1.8.0_231]
            at java.util.concurrent.FutureTask.run(Unknown Source) ~[?:1.8.0_231]
            at net.minecraft.server.v1_8_R3.SystemUtils.a(SourceFile:44) ~[spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24]
            ... 5 more
     
  4. Online

    timtower Administrator Administrator Moderator

    @Korotaxx Does it change if you make the nwar variable a field in the class?
     
  5. Offline

    Korotaxx

    How do you create a field? Im not really good at Java programming.:(

    No it doesnt change anything.

    I got the mistake. Material.NETHER_WARTS refers to the block. Material.NETHER_STALKS refers to the item.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Mar 17, 2020
  6. Online

    timtower Administrator Administrator Moderator

    Bukkit never stops to amaze me.
    Nice catch.
     
Thread Status:
Not open for further replies.

Share This Page