From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: violetc <58360096+s-yh-china@users.noreply.github.com> Date: Mon, 4 Sep 2023 22:09:10 +0800 Subject: [PATCH] RNG Fishing diff --git a/src/main/java/net/minecraft/world/entity/projectile/FishingHook.java b/src/main/java/net/minecraft/world/entity/projectile/FishingHook.java index c07801c2eba35cc97a3a967d6d6f3fb15e5a84af..d576bd2d2b6b38f0384bb2bc044f11ceebc65b97 100644 --- a/src/main/java/net/minecraft/world/entity/projectile/FishingHook.java +++ b/src/main/java/net/minecraft/world/entity/projectile/FishingHook.java @@ -504,7 +504,7 @@ public class FishingHook extends Projectile { } else if (this.nibble > 0) { LootParams lootparams = (new LootParams.Builder((ServerLevel) this.level())).withParameter(LootContextParams.ORIGIN, this.position()).withParameter(LootContextParams.TOOL, usedItem).withParameter(LootContextParams.THIS_ENTITY, this).withLuck((float) this.luck + entityhuman.getLuck()).create(LootContextParamSets.FISHING); LootTable loottable = this.level().getServer().getLootData().getLootTable(BuiltInLootTables.FISHING); - List list = loottable.getRandomItems(lootparams); + List list = top.leavesmc.leaves.LeavesConfig.rngFishing ? loottable.getRandomItems(lootparams, this.random) : loottable.getRandomItems(lootparams); // Leaves - world random CriteriaTriggers.FISHING_ROD_HOOKED.trigger((ServerPlayer) entityhuman, usedItem, this, list); Iterator iterator = list.iterator(); diff --git a/src/main/java/net/minecraft/world/level/storage/loot/LootContext.java b/src/main/java/net/minecraft/world/level/storage/loot/LootContext.java index d042b04108c3fe244caa6b9fc293c83ac7200a57..58d27f27dc3b60ba7d4e14f86431890481275cdd 100644 --- a/src/main/java/net/minecraft/world/level/storage/loot/LootContext.java +++ b/src/main/java/net/minecraft/world/level/storage/loot/LootContext.java @@ -95,6 +95,13 @@ public class LootContext { this.params = parameters; } + // Leaves start - world random + public LootContext.Builder withRandom(RandomSource random) { + this.random = random; + return this; + } + // Leaves end - world random + public LootContext.Builder withOptionalRandomSeed(long seed) { if (seed != 0L) { this.random = RandomSource.create(seed); diff --git a/src/main/java/net/minecraft/world/level/storage/loot/LootTable.java b/src/main/java/net/minecraft/world/level/storage/loot/LootTable.java index 05af6fa0585406c4922d2eb174f7e53f4269acd6..3fcbb53f1244adc46e1bdf681f72598b10fb6fb1 100644 --- a/src/main/java/net/minecraft/world/level/storage/loot/LootTable.java +++ b/src/main/java/net/minecraft/world/level/storage/loot/LootTable.java @@ -132,6 +132,12 @@ public class LootTable { return this.getRandomItems((new LootContext.Builder(parameters)).create(this.randomSequence)); } + // Leaves start - world random + public ObjectArrayList getRandomItems(LootParams parameters, RandomSource randomSource) { + return this.getRandomItems((new LootContext.Builder(parameters)).withRandom(randomSource).create(this.randomSequence)); + } + // Leaves end - world random + private ObjectArrayList getRandomItems(LootContext context) { ObjectArrayList objectarraylist = new ObjectArrayList();