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

Error Using Virtual Merchant GUI

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • None
    • None
    • This server is running CraftBukkit version git-Spigot-baafee9-043d31d (MC: 1.14.2) (Implementing API version 1.14.2-R0.1-SNAPSHOT)
    • Yes

      • compile this code
      • give yourself some cobblestone
      • execute the function
      • click on the recipe
      • shift click on pickaxe (result)
      • you can see an error in console
      • close inventory and see the cobblestone back in inventory + pickaxe

      Code:

      void openTestTradeMachine(Player player)
      {
       Merchant merchant = Bukkit.createMerchant("Test trade machine");
      
       List<MerchantRecipe> merchantRecipes = new ArrayList<>();
       ItemStack result = new ItemStack(Material.DIAMOND_PICKAXE);
      
       MerchantRecipe recipe = new MerchantRecipe(result, 10);
       recipe.setExperienceReward(false);
      
       ItemStack ingredient1 = new ItemStack(Material.COBBLESTONE);
       ingredient1.setAmount(12);
       recipe.addIngredient(ingredient1);
      
       merchantRecipes.add(recipe);
       merchant.setRecipes(merchantRecipes);
       player.openMerchant(merchant, true);
      }
      

      Error:

      [12:29:21] [Server thread/FATAL]: Error executing task on Server
      java.lang.ClassCastException: org.bukkit.craftbukkit.v1_14_R1.inventory.CraftMerchantCustom$MinecraftMerchant cannot be cast to net.minecraft.server.v1_14_R1.Entity
              at net.minecraft.server.v1_14_R1.ContainerMerchant.j(ContainerMerchant.java:116) ~[spigot-1.14.2.jar:git-Spigot-baafee9-043d31d]
              at net.minecraft.server.v1_14_R1.ContainerMerchant.shiftClick(ContainerMerchant.java:85) ~[spigot-1.14.2.jar:git-Spigot-baafee9-043d31d]
              at net.minecraft.server.v1_14_R1.Container.a(Container.java:311) ~[spigot-1.14.2.jar:git-Spigot-baafee9-043d31d]
              at net.minecraft.server.v1_14_R1.PlayerConnection.a(PlayerConnection.java:2170) ~[spigot-1.14.2.jar:git-Spigot-baafee9-043d31d]
              at net.minecraft.server.v1_14_R1.PacketPlayInWindowClick.a(SourceFile:33) ~[spigot-1.14.2.jar:git-Spigot-baafee9-043d31d]
              at net.minecraft.server.v1_14_R1.PacketPlayInWindowClick.a(SourceFile:10) ~[spigot-1.14.2.jar:git-Spigot-baafee9-043d31d]
              at net.minecraft.server.v1_14_R1.PlayerConnectionUtils.lambda$0(PlayerConnectionUtils.java:13) ~[spigot-1.14.2.jar:git-Spigot-baafee9-043d31d]
              at net.minecraft.server.v1_14_R1.TickTask.run(SourceFile:18) ~[spigot-1.14.2.jar:git-Spigot-baafee9-043d31d]
              at net.minecraft.server.v1_14_R1.IAsyncTaskHandler.executeTask(SourceFile:135) [spigot-1.14.2.jar:git-Spigot-baafee9-043d31d]
              at net.minecraft.server.v1_14_R1.IAsyncTaskHandlerReentrant.executeTask(SourceFile:23) [spigot-1.14.2.jar:git-Spigot-baafee9-043d31d]
              at net.minecraft.server.v1_14_R1.IAsyncTaskHandler.executeNext(SourceFile:114) [spigot-1.14.2.jar:git-Spigot-baafee9-043d31d]
              at net.minecraft.server.v1_14_R1.MinecraftServer.aW(MinecraftServer.java:895) [spigot-1.14.2.jar:git-Spigot-baafee9-043d31d]
              at net.minecraft.server.v1_14_R1.MinecraftServer.executeNext(MinecraftServer.java:888) [spigot-1.14.2.jar:git-Spigot-baafee9-043d31d]
              at net.minecraft.server.v1_14_R1.IAsyncTaskHandler.executeAll(SourceFile:99) [spigot-1.14.2.jar:git-Spigot-baafee9-043d31d]
              at net.minecraft.server.v1_14_R1.MinecraftServer.sleepForTick(MinecraftServer.java:871) [spigot-1.14.2.jar:git-Spigot-baafee9-043d31d]
              at net.minecraft.server.v1_14_R1.MinecraftServer.run(MinecraftServer.java:805) [spigot-1.14.2.jar:git-Spigot-baafee9-043d31d]
              at java.lang.Thread.run(Unknown Source) [?:1.8.0_161]
      

       

            Unassigned Unassigned
            LoneDev LoneDev
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: