Skip to content

Commit

Permalink
Loot world random (LeavesMC#120)
Browse files Browse the repository at this point in the history
  • Loading branch information
s-yh-china authored and Lumine1909 committed Apr 21, 2024
1 parent f7ff769 commit c922c38
Show file tree
Hide file tree
Showing 12 changed files with 69 additions and 32 deletions.
39 changes: 27 additions & 12 deletions patches/server/0004-Leaves-Server-Config-And-Command.patch
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,10 @@ index e1c99d941c7bb954bf3ac83d5002dbf58fd833b0..4760b943da08771a42fcb22eba4d586d
.withRequiredArg()
diff --git a/src/main/java/top/leavesmc/leaves/LeavesConfig.java b/src/main/java/top/leavesmc/leaves/LeavesConfig.java
new file mode 100644
index 0000000000000000000000000000000000000000..c02c51f824be1173d24b20394b5855fc857fc0a4
index 0000000000000000000000000000000000000000..d739f8b96caea228335543f412546d187c7f246c
--- /dev/null
+++ b/src/main/java/top/leavesmc/leaves/LeavesConfig.java
@@ -0,0 +1,1005 @@
@@ -0,0 +1,1020 @@
+package top.leavesmc.leaves;
+
+import com.destroystokyo.paper.util.SneakyThrow;
Expand Down Expand Up @@ -160,7 +160,7 @@ index 0000000000000000000000000000000000000000..c02c51f824be1173d24b20394b5855fc
+public final class LeavesConfig {
+
+ public static final String CONFIG_HEADER = "Configuration file for Leaves.";
+ public static final int CURRENT_CONFIG_VERSION = 4;
+ public static final int CURRENT_CONFIG_VERSION = 5;
+
+ private static final Object[] EMPTY = new Object[0];
+
Expand Down Expand Up @@ -266,6 +266,20 @@ index 0000000000000000000000000000000000000000..c02c51f824be1173d24b20394b5855fc
+ alternativeBlockPlacement = carpetAlternative ? "CARPET" : "NONE";
+ config.set("settings.protocol.carpet-alternative-block-placement", null);
+ }
+
+ case 4 -> {
+ shearsInDispenserCanZeroAmount = config.getBoolean("settings.modify.shears-in-dispenser-can-zero-amount", shearsInDispenserCanZeroAmount);
+ instantBlockUpdaterReintroduced = config.getBoolean("settings.modify.instant-block-updater-reintroduced", instantBlockUpdaterReintroduced);
+ redstoneDontCantOnTrapDoor = config.getBoolean("settings.modify.redstone-wire-dont-connect-if-on-trapdoor", redstoneDontCantOnTrapDoor);
+ mendingCompatibilityInfinity = config.getBoolean("settings.modify.mending-compatibility-infinity", mendingCompatibilityInfinity);
+ zeroTickPlants = config.getBoolean("settings.modify.zero-tick-plants", zeroTickPlants);
+
+ config.set("settings.modify.shears-in-dispenser-can-zero-amount", null);
+ config.set("settings.modify.instant-block-updater-reintroduced", null);
+ config.set("settings.modify.redstone-wire-dont-connect-if-on-trapdoor", null);
+ config.set("settings.modify.mending-compatibility-infinity", null);
+ config.set("settings.modify.zero-tick-plants", null);
+ }
+ }
+ }
+ }
Expand Down Expand Up @@ -340,7 +354,7 @@ index 0000000000000000000000000000000000000000..c02c51f824be1173d24b20394b5855fc
+
+ public static boolean shearsInDispenserCanZeroAmount = false;
+ private static void shearsInDispenserCanZeroAmount() {
+ shearsInDispenserCanZeroAmount = getBoolean("settings.modify.shears-in-dispenser-can-zero-amount", shearsInDispenserCanZeroAmount);
+ shearsInDispenserCanZeroAmount = getBoolean("settings.modify.minecraft-old.shears-in-dispenser-can-zero-amount", shearsInDispenserCanZeroAmount);
+ }
+
+ public static boolean redstoneShearsWrench = true;
Expand All @@ -365,10 +379,6 @@ index 0000000000000000000000000000000000000000..c02c51f824be1173d24b20394b5855fc
+
+ public static boolean noChatSign = true;
+ private static void noChatSign() {
+ if (LeavesConfig.config.contains("settings.modify.no-chat-sign")) {
+ noChatSign = LeavesConfig.config.getBoolean("settings.modify.no-chat-sign");
+ LeavesConfig.config.set("settings.modify.no-chat-sign", null);
+ }
+ noChatSign = getBoolean("settings.misc.no-chat-sign", noChatSign);
+ }
+
Expand Down Expand Up @@ -547,7 +557,7 @@ index 0000000000000000000000000000000000000000..c02c51f824be1173d24b20394b5855fc
+ private static boolean instantBlockUpdaterReintroducedLock = false;
+ private static void instantBlockUpdaterReintroduced() {
+ if (!instantBlockUpdaterReintroducedLock) {
+ instantBlockUpdaterReintroduced = getBoolean("settings.modify.instant-block-updater-reintroduced", instantBlockUpdaterReintroduced);
+ instantBlockUpdaterReintroduced = getBoolean("settings.modify.minecraft-old.instant-block-updater-reintroduced", instantBlockUpdaterReintroduced);
+ instantBlockUpdaterReintroducedLock = true;
+ }
+ }
Expand Down Expand Up @@ -692,7 +702,7 @@ index 0000000000000000000000000000000000000000..c02c51f824be1173d24b20394b5855fc
+
+ public static boolean redstoneDontCantOnTrapDoor = false;
+ private static void redstoneDontCantOnTrapDoor() {
+ redstoneDontCantOnTrapDoor = getBoolean("settings.modify.redstone-wire-dont-connect-if-on-trapdoor", redstoneDontCantOnTrapDoor);
+ redstoneDontCantOnTrapDoor = getBoolean("settings.modify.minecraft-old.redstone-wire-dont-connect-if-on-trapdoor", redstoneDontCantOnTrapDoor);
+ }
+
+ public static boolean disableCheckOutOfOrderCommand = false;
Expand Down Expand Up @@ -725,7 +735,7 @@ index 0000000000000000000000000000000000000000..c02c51f824be1173d24b20394b5855fc
+
+ public static boolean mendingCompatibilityInfinity = false;
+ private static void mendingCompatibilityInfinity() {
+ mendingCompatibilityInfinity = getBoolean("settings.modify.mending-compatibility-infinity", mendingCompatibilityInfinity);
+ mendingCompatibilityInfinity = getBoolean("settings.modify.minecraft-old.mending-compatibility-infinity", mendingCompatibilityInfinity);
+ }
+
+ public static boolean shaveSnowLayers = true;
Expand Down Expand Up @@ -912,7 +922,7 @@ index 0000000000000000000000000000000000000000..c02c51f824be1173d24b20394b5855fc
+
+ public static boolean zeroTickPlants = false;
+ private static void zeroTickPlants() {
+ zeroTickPlants = getBoolean("settings.modify.zero-tick-plants", zeroTickPlants);
+ zeroTickPlants = getBoolean("settings.modify.minecraft-old.zero-tick-plants", zeroTickPlants);
+ }
+
+ public static boolean bstatsPrivacyMode = false;
Expand Down Expand Up @@ -963,6 +973,11 @@ index 0000000000000000000000000000000000000000..c02c51f824be1173d24b20394b5855fc
+ hopperCounter = getBoolean("settings.modify.hopper-counter", hopperCounter);
+ }
+
+ public static boolean lootWorldRandom = false;
+ private static void lootWorldRandom() {
+ lootWorldRandom = getBoolean("settings.modify.minecraft-old.loot-world-random", lootWorldRandom);
+ }
+
+ public static final class WorldConfig {
+
+ public final String worldName;
Expand Down
4 changes: 2 additions & 2 deletions patches/server/0019-Multithreaded-Tracker.patch
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ Subject: [PATCH] Multithreaded Tracker
This patch is Powered by Pufferfish(https://github.com/pufferfish-gg/Pufferfish)

diff --git a/src/main/java/top/leavesmc/leaves/LeavesConfig.java b/src/main/java/top/leavesmc/leaves/LeavesConfig.java
index 8b19b4c7d3d14d57a2eb3674b63ff352b0fe83bd..1db1d2ac599c561d86716de0ce58712a63658fe3 100644
index 904d1fe0bf325c09b67e43bdaa81c902d57b8e26..f9ef4451b43d6e37d91edfcbeb5d1fbf564e596c 100644
--- a/src/main/java/top/leavesmc/leaves/LeavesConfig.java
+++ b/src/main/java/top/leavesmc/leaves/LeavesConfig.java
@@ -259,7 +259,7 @@ public final class LeavesConfig {
@@ -269,7 +269,7 @@ public final class LeavesConfig {
dontSendUselessEntityPackets = getBoolean("settings.performance.dont-send-useless-entity-packets", dontSendUselessEntityPackets);
}

Expand Down
4 changes: 2 additions & 2 deletions patches/server/0037-Async-Pathfinding.patch
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ This patch is Powered by Pufferfish(https://github.com/pufferfish-gg/Pufferfish)
But Pufferfish patch was ported downstream from the Petal fork

diff --git a/src/main/java/top/leavesmc/leaves/LeavesConfig.java b/src/main/java/top/leavesmc/leaves/LeavesConfig.java
index 1db1d2ac599c561d86716de0ce58712a63658fe3..4a7ac6933e98528db90763426d87682c76b9f50c 100644
index f9ef4451b43d6e37d91edfcbeb5d1fbf564e596c..cb84db4e1160c8cfdb41ff3196f7e13e1533f1b6 100644
--- a/src/main/java/top/leavesmc/leaves/LeavesConfig.java
+++ b/src/main/java/top/leavesmc/leaves/LeavesConfig.java
@@ -360,7 +360,7 @@ public final class LeavesConfig {
@@ -370,7 +370,7 @@ public final class LeavesConfig {
// only config now
public static boolean asyncPathfinding = false;
private static boolean asyncPathfindingLock = false;
Expand Down
4 changes: 2 additions & 2 deletions patches/server/0052-MC-Technical-Survival-Mode.patch
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ index 9af07ebff3a510a4e3fc71ab4d08897db02b7299..81eaa7ead4821929f20e4c5fcb822504
entity.spawnReason == org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.CHUNK_GEN)) {
continue;
diff --git a/src/main/java/top/leavesmc/leaves/LeavesConfig.java b/src/main/java/top/leavesmc/leaves/LeavesConfig.java
index 4a7ac6933e98528db90763426d87682c76b9f50c..abd00fd34486e9c347773c7d0122cbdd5170c87a 100644
index cb84db4e1160c8cfdb41ff3196f7e13e1533f1b6..120bb8cfefe64ae806d23c885fd3c4765f35214d 100644
--- a/src/main/java/top/leavesmc/leaves/LeavesConfig.java
+++ b/src/main/java/top/leavesmc/leaves/LeavesConfig.java
@@ -2,6 +2,7 @@ package top.leavesmc.leaves;
Expand All @@ -120,7 +120,7 @@ index 4a7ac6933e98528db90763426d87682c76b9f50c..abd00fd34486e9c347773c7d0122cbdd
import net.minecraft.server.MinecraftServer;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
@@ -480,6 +481,14 @@ public final class LeavesConfig {
@@ -490,6 +491,14 @@ public final class LeavesConfig {

public static void doMcTechnicalMode() {
if (mcTechnicalMode) {
Expand Down
4 changes: 2 additions & 2 deletions patches/server/0056-Leaves-Extra-Yggdrasil-Service.patch
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ index c748b29bf2d4382215bffd41854f70fd15f9411e..43638595413bbcc5dcaf04daa8c1df05
public final Thread serverThread;
private long nextTickTime;
diff --git a/src/main/java/top/leavesmc/leaves/LeavesConfig.java b/src/main/java/top/leavesmc/leaves/LeavesConfig.java
index abd00fd34486e9c347773c7d0122cbdd5170c87a..8d7022e12387ffc8f06c0d3ed24a46a87970a8f4 100644
index 120bb8cfefe64ae806d23c885fd3c4765f35214d..c5a4d1439d8df12fa2fe5157fcac92c74d1ddad9 100644
--- a/src/main/java/top/leavesmc/leaves/LeavesConfig.java
+++ b/src/main/java/top/leavesmc/leaves/LeavesConfig.java
@@ -11,6 +11,7 @@ import org.bukkit.configuration.file.YamlConfiguration;
Expand All @@ -55,7 +55,7 @@ index abd00fd34486e9c347773c7d0122cbdd5170c87a..8d7022e12387ffc8f06c0d3ed24a46a8
import top.leavesmc.leaves.util.MathUtils;

import java.io.File;
@@ -517,6 +518,9 @@ public final class LeavesConfig {
@@ -527,6 +528,9 @@ public final class LeavesConfig {
extraYggdrasilLoginProtect = getBoolean("settings.misc.extra-yggdrasil-service.login-protect", extraYggdrasilLoginProtect);
extraYggdrasilServiceList = getList("settings.misc.extra-yggdrasil-service.urls", extraYggdrasilServiceList);
if (extraYggdrasilService) {
Expand Down
4 changes: 2 additions & 2 deletions patches/server/0060-Syncmatica-Protocol.patch
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ index bb0e97bd0f4332a2da1b9f077d61b6f81fbeaaad..b2be14056502a902f8fd2caaacaffc5d
ServerGamePacketListenerImpl.LOGGER.error("Couldn\'t dispatch custom payload", ex);
this.disconnect("Invalid custom payload!", org.bukkit.event.player.PlayerKickEvent.Cause.INVALID_PAYLOAD);
diff --git a/src/main/java/top/leavesmc/leaves/LeavesConfig.java b/src/main/java/top/leavesmc/leaves/LeavesConfig.java
index 8d7022e12387ffc8f06c0d3ed24a46a87970a8f4..18156eaee7e7523db74a01d0870269ce0cd0a3a4 100644
index c5a4d1439d8df12fa2fe5157fcac92c74d1ddad9..b5f69089f91d842f0e3a1224b26fb17e162d796d 100644
--- a/src/main/java/top/leavesmc/leaves/LeavesConfig.java
+++ b/src/main/java/top/leavesmc/leaves/LeavesConfig.java
@@ -12,6 +12,7 @@ import top.leavesmc.leaves.command.LeavesCommand;
Expand All @@ -65,7 +65,7 @@ index 8d7022e12387ffc8f06c0d3ed24a46a87970a8f4..18156eaee7e7523db74a01d0870269ce
import top.leavesmc.leaves.util.MathUtils;

import java.io.File;
@@ -555,6 +556,7 @@ public final class LeavesConfig {
@@ -565,6 +566,7 @@ public final class LeavesConfig {
syncmaticaQuota = getBoolean("settings.protocol.syncmatica.quota", syncmaticaQuota);
syncmaticaQuotaLimit = getInt("settings.protocol.syncmatica.quota-limit", syncmaticaQuotaLimit);
if (syncmaticaProtocol) {
Expand Down
4 changes: 2 additions & 2 deletions patches/server/0070-Creative-fly-no-clip.patch
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,10 @@ index 1ec80f9c901dff1c9f29befa5a8e3c3f6f37aaf7..f26e5626c0823c041eeb388cbcd78e52

public boolean isSpawning() {
diff --git a/src/main/java/top/leavesmc/leaves/LeavesConfig.java b/src/main/java/top/leavesmc/leaves/LeavesConfig.java
index 23854dc256ff28adece0b6b4438fb1038b138244..14f1ec1ac00b9ca461edc27902def45cd34b585f 100644
index 3616400f69d41d3c7bf46f490f24e65af541c336..279dd789dc4ef7e6824a171b652c07a730391a2b 100644
--- a/src/main/java/top/leavesmc/leaves/LeavesConfig.java
+++ b/src/main/java/top/leavesmc/leaves/LeavesConfig.java
@@ -601,6 +601,7 @@ public final class LeavesConfig {
@@ -611,6 +611,7 @@ public final class LeavesConfig {
}

public static void registerCarpetRules() {
Expand Down
4 changes: 2 additions & 2 deletions patches/server/0077-Bladeren-mspt-sync-protocol.patch
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ index 47b27712c6ed11fc5c2cd7de04482870207545e7..93054a59f14fee933a908944e93b462b

public boolean getCommandBlockOverride(String command) {
diff --git a/src/main/java/top/leavesmc/leaves/LeavesConfig.java b/src/main/java/top/leavesmc/leaves/LeavesConfig.java
index 14f1ec1ac00b9ca461edc27902def45cd34b585f..a768a49f701c4045c4729c5b8893b9aff41a275b 100644
index 279dd789dc4ef7e6824a171b652c07a730391a2b..94b946b7d2586d6db874f6e70d36800766ae9523 100644
--- a/src/main/java/top/leavesmc/leaves/LeavesConfig.java
+++ b/src/main/java/top/leavesmc/leaves/LeavesConfig.java
@@ -847,6 +847,7 @@ public final class LeavesConfig {
@@ -857,6 +857,7 @@ public final class LeavesConfig {
}

public static void registerLeavesFeatures() {
Expand Down
4 changes: 2 additions & 2 deletions patches/server/0081-Lava-riptide.patch
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ index 8078f127ff4b6e0aafb5804b9c02e237f79445b5..801f066878d6ffe5dabe01d20513db90
} else {
user.startUsingItem(hand);
diff --git a/src/main/java/top/leavesmc/leaves/LeavesConfig.java b/src/main/java/top/leavesmc/leaves/LeavesConfig.java
index 871ab6819f3c98c2f705689939115f0f53cedbc8..837c76768e6e93c5f8df7817cf644f7e0c53237a 100644
index 7db8506c5c6bca2a1cbd1abf4c0d65f93f45a52f..a95ee1dbad7dc689def803f55cb9a62ed821a789 100644
--- a/src/main/java/top/leavesmc/leaves/LeavesConfig.java
+++ b/src/main/java/top/leavesmc/leaves/LeavesConfig.java
@@ -851,6 +851,7 @@ public final class LeavesConfig {
@@ -861,6 +861,7 @@ public final class LeavesConfig {

public static void registerLeavesFeatures() {
LeavesFeatureSet.register(LeavesFeature.of("mspt_sync", msptSyncProtocol));
Expand Down
4 changes: 2 additions & 2 deletions patches/server/0110-Avoid-anvil-too-expensive.patch
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ index e0c3a4ba27e21c3692e601acd0af60873bcbb84c..b9fcf49ed88c62265d9aa8926c1228b9
}

diff --git a/src/main/java/top/leavesmc/leaves/LeavesConfig.java b/src/main/java/top/leavesmc/leaves/LeavesConfig.java
index 7c2e19d10c28eaf776bc552c9742a847fce9ab66..17731c91e6e55666fd5795dba924f6eff20755f4 100644
index 0d43652e2ac7a0680aa50c212c75ff6b9496e9f3..63ddd86a124b27e128dbf1cef60eab1b4750e251 100644
--- a/src/main/java/top/leavesmc/leaves/LeavesConfig.java
+++ b/src/main/java/top/leavesmc/leaves/LeavesConfig.java
@@ -610,6 +610,7 @@ public final class LeavesConfig {
@@ -620,6 +620,7 @@ public final class LeavesConfig {

public static void registerCarpetRules() {
CarpetRules.register(CarpetRule.of("carpet", "creativeNoClip", creativeNoClip));
Expand Down
4 changes: 2 additions & 2 deletions patches/server/0115-Add-Leaves-Auto-Update.patch
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Subject: [PATCH] Add Leaves Auto Update


diff --git a/src/main/java/top/leavesmc/leaves/LeavesConfig.java b/src/main/java/top/leavesmc/leaves/LeavesConfig.java
index 17731c91e6e55666fd5795dba924f6eff20755f4..55df063d02e33f6f115e4866fffe1fe161954e02 100644
index 63ddd86a124b27e128dbf1cef60eab1b4750e251..6fa8261ba02df4571a533c70eb83eed676169c10 100644
--- a/src/main/java/top/leavesmc/leaves/LeavesConfig.java
+++ b/src/main/java/top/leavesmc/leaves/LeavesConfig.java
@@ -14,6 +14,7 @@ import top.leavesmc.leaves.bot.agent.Actions;
Expand All @@ -16,7 +16,7 @@ index 17731c91e6e55666fd5795dba924f6eff20755f4..55df063d02e33f6f115e4866fffe1fe1
import top.leavesmc.leaves.util.MathUtils;
import top.leavesmc.leaves.protocol.CarpetServerProtocol.CarpetRule;
import top.leavesmc.leaves.protocol.CarpetServerProtocol.CarpetRules;
@@ -825,6 +826,7 @@ public final class LeavesConfig {
@@ -835,6 +836,7 @@ public final class LeavesConfig {
private static void autoUpdate() {
autoUpdate = getBoolean("settings.misc.auto-update.enable", autoUpdate);
autoUpdateTime = getList("settings.misc.auto-update.time", autoUpdateTime);
Expand Down
22 changes: 22 additions & 0 deletions patches/server/0123-Loot-world-random.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: violetc <[email protected]>
Date: Mon, 4 Sep 2023 22:09:10 +0800
Subject: [PATCH] Loot world random


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 17df8b341c65ca24fd2a18424f221918d0a7a111..d5eea5d36b9fac6001cca262e9a7c397852e4bdb 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
@@ -113,6 +113,11 @@ public class LootContext {
ServerLevel serverLevel = this.getLevel();
MinecraftServer minecraftServer = serverLevel.getServer();
RandomSource randomSource;
+ // Leaves start - world random
+ if (top.leavesmc.leaves.LeavesConfig.lootWorldRandom) {
+ return new LootContext(this.params, serverLevel.getRandom(), minecraftServer.getLootData());
+ }
+ // Leaves end - world random
if (this.random != null) {
randomSource = this.random;
} else if (randomSequenceId != null) {

0 comments on commit c922c38

Please sign in to comment.