mirror of
https://github.com/LeavesMC/Leaves.git
synced 2025-12-27 19:09:23 +00:00
55 lines
3.4 KiB
Diff
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 79ed9104efd9695aee9f9f45d342900d88a7ef02..b16f8f6cae5ad27b5889e2349d95359902b60bd8 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/projectile/FishingHook.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/projectile/FishingHook.java
|
|
@@ -522,7 +522,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();
|
|
|