diff --git a/paper-server/patches/sources/net/minecraft/world/level/storage/loot/LootTable.java.patch b/paper-server/patches/sources/net/minecraft/world/level/storage/loot/LootTable.java.patch index 21a8108d1a9f..53f28e336307 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/storage/loot/LootTable.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/storage/loot/LootTable.java.patch @@ -24,13 +24,14 @@ } public void fill(Container container, LootParams params, long seed) { +- LootContext lootContext = new LootContext.Builder(params).withOptionalRandomSeed(seed).create(this.randomSequence); + // CraftBukkit start -+ this.fillInventory(container, params, seed, false); ++ this.fill(container, params, seed == 0L ? null : RandomSource.create(seed), false); + } + -+ public void fillInventory(Container container, LootParams params, long seed, boolean plugin) { ++ public void fill(Container container, LootParams params, RandomSource randomSource, boolean plugin) { + // CraftBukkit end - LootContext lootContext = new LootContext.Builder(params).withOptionalRandomSeed(seed).create(this.randomSequence); ++ LootContext lootContext = new LootContext.Builder(params).withOptionalRandomSource(randomSource).create(this.randomSequence); ObjectArrayList randomItems = this.getRandomItems(lootContext); RandomSource random = lootContext.getRandom(); + // CraftBukkit start diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftLootTable.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftLootTable.java index 5fd22a80e9d0..4f29e9af057f 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftLootTable.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftLootTable.java @@ -27,6 +27,7 @@ import org.bukkit.craftbukkit.inventory.CraftItemStack; import org.bukkit.craftbukkit.util.CraftLocation; import org.bukkit.craftbukkit.util.CraftNamespacedKey; +import org.bukkit.craftbukkit.util.RandomSourceWrapper; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; import org.bukkit.loot.LootContext; @@ -68,8 +69,8 @@ public LootTable getHandle() { @Override public Collection populateLoot(Random random, LootContext context) { Preconditions.checkArgument(context != null, "LootContext cannot be null"); - LootParams nmsContext = this.convertContext(context, random); - List nmsItems = this.handle.getRandomItems(nmsContext); + LootParams nmsContext = this.convertContext(context); + List nmsItems = this.handle.getRandomItems(nmsContext, random == null ? null : new RandomSourceWrapper(random)); Collection bukkit = new ArrayList<>(nmsItems.size()); for (net.minecraft.world.item.ItemStack item : nmsItems) { @@ -86,12 +87,12 @@ public Collection populateLoot(Random random, LootContext context) { public void fillInventory(Inventory inventory, Random random, LootContext context) { Preconditions.checkArgument(inventory != null, "Inventory cannot be null"); Preconditions.checkArgument(context != null, "LootContext cannot be null"); - LootParams nmsContext = this.convertContext(context, random); + LootParams nmsContext = this.convertContext(context); CraftInventory craftInventory = (CraftInventory) inventory; Container handle = craftInventory.getInventory(); // TODO: When events are added, call event here w/ custom reason? - this.getHandle().fillInventory(handle, nmsContext, random.nextLong(), true); + this.getHandle().fill(handle, nmsContext, random == null ? null : new RandomSourceWrapper(random), true); } @Override @@ -99,19 +100,16 @@ public NamespacedKey getKey() { return this.key; } - private LootParams convertContext(LootContext context, Random random) { + private LootParams convertContext(LootContext context) { Preconditions.checkArgument(context != null, "LootContext cannot be null"); Location loc = context.getLocation(); Preconditions.checkArgument(loc.getWorld() != null, "LootContext.getLocation#getWorld cannot be null"); ServerLevel handle = ((CraftWorld) loc.getWorld()).getHandle(); LootParams.Builder builder = new LootParams.Builder(handle); - if (random != null) { - // builder = builder.withRandom(new RandomSourceWrapper(random)); - } this.setMaybe(builder, LootContextParams.ORIGIN, CraftLocation.toVec3D(loc)); if (this.getHandle() != LootTable.EMPTY) { - // builder.luck(context.getLuck()); + builder.withLuck(context.getLuck()); if (context.getLootedEntity() != null) { Entity nmsLootedEntity = ((CraftEntity) context.getLootedEntity()).getHandle();