1.15.2 LootTable does not work

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

Thread Status:
Not open for further replies.
  1. Hey, I want to generate the loot in a chest with this code, but I always get the error that it needs a position although I have specified one. (Sry my english)


    Code (Java):
     

                org.bukkit.block.Chest chest = (org.bukkit.block.Chest) block.getState();

                if(chest.getLootTable() != null){
                    LootTable lootTable = chest.getLootTable();
                    LootContext.Builder builder = new LootContext.Builder( chest.getLocation() );
                    LootContext build = builder.build();
                    Random random = new Random();
                    Collection<ItemStack> itemStacks = lootTable.populateLoot( random, build );
                    for ( ItemStack itemStack : itemStacks) {
                        System.out.println( itemStack.getType().name() + " : " +itemStack.getAmount() );
                    }
                }
    Code (Text):
    [08:17:31] [Server thread/WARN]: [SpigotConverter] Task #371 for SpigotConverter v1.0.0 generated an exception
    java.lang.IllegalArgumentException: Missing required parameters: [<parameter minecraft:position>]
            at net.minecraft.server.v1_15_R1.LootTableInfo$Builder.build(SourceFile:208) ~[spigot-1.15.1.jar:git-Spigot-037559e-e8cb2f5]
            at org.bukkit.craftbukkit.v1_15_R1.CraftLootTable.convertContext(CraftLootTable.java:95) ~[spigot-1.15.1.jar:git-Spigot-037559e-e8cb2f5]
            at org.bukkit.craftbukkit.v1_15_R1.CraftLootTable.populateLoot(CraftLootTable.java:43) ~[spigot-1.15.1.jar:git-Spigot-037559e-e8cb2f5]
            at de.lucgameshd.spigot.converter.converter.blocks.ChestConverter.convert(ChestConverter.java:47) ~[?:?]
            at de.lucgameshd.spigot.converter.handler.RequestChunkHandler.lambda$null$0(RequestChunkHandler.java:94) ~[?:?]
            at org.bukkit.craftbukkit.v1_15_R1.scheduler.CraftTask.run(CraftTask.java:81) ~[spigot-1.15.1.jar:git-Spigot-037559e-e8cb2f5]
            at org.bukkit.craftbukkit.v1_15_R1.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:394) [spigot-1.15.1.jar:git-Spigot-037559e-e8cb2f5]
            at net.minecraft.server.v1_15_R1.MinecraftServer.b(MinecraftServer.java:1030) [spigot-1.15.1.jar:git-Spigot-037559e-e8cb2f5]
            at net.minecraft.server.v1_15_R1.DedicatedServer.b(DedicatedServer.java:393) [spigot-1.15.1.jar:git-Spigot-037559e-e8cb2f5]
            at net.minecraft.server.v1_15_R1.MinecraftServer.a(MinecraftServer.java:978) [spigot-1.15.1.jar:git-Spigot-037559e-e8cb2f5]
            at net.minecraft.server.v1_15_R1.MinecraftServer.run(MinecraftServer.java:823) [spigot-1.15.1.jar:git-Spigot-037559e-e8cb2f5]
            at java.lang.Thread.run(Thread.java:748) [?:1.8.0_232]
     
    #1 LucGamesHD, Jan 18, 2020
    Last edited: Jan 18, 2020
Thread Status:
Not open for further replies.