9
0
mirror of https://github.com/LeavesMC/Leaves.git synced 2025-12-27 19:09:23 +00:00
Files
LeavesMC/patches/server/0110-RNG-Fishing.patch
violetc f40d340092 1.20.6 (#216)
---------

Co-authored-by: MC_XiaoHei <xiaohei.xor7studio@foxmail.com>
Co-authored-by: Bluemangoo <chenfy2006@qq.com>
2024-05-20 23:03:56 +08:00

55 lines
3.4 KiB
Diff

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 f959f1819181b867dfabd19005e730069dffda4d..85d041981641acb2487325f8f874f65ddfb61e67 100644
--- a/src/main/java/net/minecraft/world/entity/projectile/FishingHook.java
+++ b/src/main/java/net/minecraft/world/entity/projectile/FishingHook.java
@@ -506,7 +506,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().reloadableRegistries().getLootTable(BuiltInLootTables.FISHING);
- List<ItemStack> list = loottable.getRandomItems(lootparams);
+ List<ItemStack> list = org.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 4a1a37040a328281ce748486b7f4150b7b0a3b01..849bde24d9a0f64ea9a64d9cd94de979befd1261 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
@@ -96,6 +96,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 6db7a023dd802706935c384df0b0aa430a6e29aa..1199c741a14eaa9f002ee756a3ffb35d22ec26df 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
@@ -136,6 +136,12 @@ public class LootTable {
return this.getRandomItems((new LootContext.Builder(parameters)).create(this.randomSequence));
}
+ // Leaves start - world random
+ public ObjectArrayList<ItemStack> getRandomItems(LootParams parameters, RandomSource randomSource) {
+ return this.getRandomItems((new LootContext.Builder(parameters)).withRandom(randomSource).create(this.randomSequence));
+ }
+ // Leaves end - world random
+
private ObjectArrayList<ItemStack> getRandomItems(LootContext context) {
ObjectArrayList<ItemStack> objectarraylist = new ObjectArrayList();