Uploaded image for project: 'Spigot'
  1. Spigot
  2. SPIGOT-7924

Registering a ShapelessRecipe throws an IndexOutOfBoundsException

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • None
    • None
    • None
    • openjdk version "22.0.1" 2024-04-16
      OpenJDK Runtime Environment (build 22.0.1+8-16)
      OpenJDK 64-Bit Server VM (build 22.0.1+8-16, mixed mode, sharing)

       

      Windows 11

    • CraftBukkit version 4349-Spigot-a084d85-d50f505 (MC: 1.21.2) (Implementing API version 1.21.2-R0.1-SNAPSHOT)
    • Yes

      Steps to reproduce:

      • Create a plugin that registers a shapeless recipe
      • Run a Spigot 1.21.2 server with this plugin in the server's plugins/ directory

      Registering a ShapelessRecipe using Bukkit.addRecipe causes an error. Minimal reproducible example (attached):

      // Register a recipe that turns a dirt block into a diamond
      ShapelessRecipe myRecipe = new ShapelessRecipe(new NamespacedKey(this, "diamond"), new ItemStack(Material.DIAMOND, 1));
      myRecipe.addIngredient(Material.DIRT);
      Bukkit.addRecipe(myRecipe);

      Running this throws this error:

      [15:12:46] [Server thread/ERROR]: Error occurred while enabling ExamplePlugin v0.0.1 (Is it up to date?)
      java.lang.IndexOutOfBoundsException: Index 0 out of bounds for length 0
              at java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:100) ~[?:?]
              at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:106) ~[?:?]
              at java.base/jdk.internal.util.Preconditions.checkIndex(Preconditions.java:302) ~[?:?]
              at java.base/java.util.Objects.checkIndex(Objects.java:365) ~[?:?]
              at java.base/java.util.ArrayList.set(ArrayList.java:471) ~[?:?]
              at org.bukkit.craftbukkit.v1_21_R2.inventory.CraftShapelessRecipe.addToCraftingManager(CraftShapelessRecipe.java:45) ~[spigot-1.21.2-R0.1-SNAPSHOT.jar:4349-Spigot-a084d85-d50f505]
              at org.bukkit.craftbukkit.v1_21_R2.CraftServer.addRecipe(CraftServer.java:1414) ~[spigot-1.21.2-R0.1-SNAPSHOT.jar:4349-Spigot-a084d85-d50f505]
              at org.bukkit.Bukkit.addRecipe(Bukkit.java:933) ~[spigot-api-1.21.2-R0.1-SNAPSHOT.jar:?]
              at dev.jorel.Main.onEnable(Main.java:17) ~[?:?]
              at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:267) ~[spigot-api-1.21.2-R0.1-SNAPSHOT.jar:?]
              at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:342) ~[spigot-api-1.21.2-R0.1-SNAPSHOT.jar:?]
              at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:492) ~[spigot-api-1.21.2-R0.1-SNAPSHOT.jar:?]
              at org.bukkit.craftbukkit.v1_21_R2.CraftServer.enablePlugin(CraftServer.java:579) ~[spigot-1.21.2-R0.1-SNAPSHOT.jar:4349-Spigot-a084d85-d50f505]
              at org.bukkit.craftbukkit.v1_21_R2.CraftServer.enablePlugins(CraftServer.java:493) ~[spigot-1.21.2-R0.1-SNAPSHOT.jar:4349-Spigot-a084d85-d50f505]
              at net.minecraft.server.MinecraftServer.loadWorld0(MinecraftServer.java:656) ~[spigot-1.21.2-R0.1-SNAPSHOT.jar:4349-Spigot-a084d85-d50f505]
              at net.minecraft.server.MinecraftServer.loadLevel(MinecraftServer.java:441) ~[spigot-1.21.2-R0.1-SNAPSHOT.jar:4349-Spigot-a084d85-d50f505]
              at net.minecraft.server.dedicated.DedicatedServer.e(DedicatedServer.java:268) ~[spigot-1.21.2-R0.1-SNAPSHOT.jar:4349-Spigot-a084d85-d50f505]
              at net.minecraft.server.MinecraftServer.y(MinecraftServer.java:1032) ~[spigot-1.21.2-R0.1-SNAPSHOT.jar:4349-Spigot-a084d85-d50f505]
              at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:329) ~[spigot-1.21.2-R0.1-SNAPSHOT.jar:4349-Spigot-a084d85-d50f505]
              at java.base/java.lang.Thread.run(Thread.java:1570) [?:?]

      This did not occur in Spigot 1.21.1.

            Unassigned Unassigned
            Skepter Jorel Ali
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: