mirror of
https://github.com/LeavesMC/Leaves.git
synced 2025-12-24 01:19:19 +00:00
48 lines
2.5 KiB
Diff
48 lines
2.5 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: violetc <58360096+s-yh-china@users.noreply.github.com>
|
|
Date: Mon, 15 Aug 2022 17:17:24 +0800
|
|
Subject: [PATCH] Skip cloning loot parameters
|
|
|
|
This patch is Powered by Pufferfish(https://github.com/pufferfish-gg/Pufferfish)
|
|
|
|
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..c666e7f401b0ed453e03e8bad9c2aca10b367bda 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
|
|
@@ -28,6 +28,19 @@ public class LootContext {
|
|
LootContext(LootParams parameters, RandomSource random, LootDataResolver dataLookup) {
|
|
this.params = parameters;
|
|
this.random = random;
|
|
+ this.luck = luck;
|
|
+ this.level = world;
|
|
+ this.lootTables = tableGetter;
|
|
+ this.conditions = conditionGetter;
|
|
+ // Leaves start - use unmodifiable maps instead of immutable ones to skip the copy
|
|
+ if (top.leavesmc.leaves.LeavesConfig.skipCloneLootParameters) {
|
|
+ this.params = java.util.Collections.unmodifiableMap(parameters);
|
|
+ this.dynamicDrops = java.util.Collections.unmodifiableMap(drops);
|
|
+ } else {
|
|
+ this.params = ImmutableMap.copyOf(parameters);
|
|
+ this.dynamicDrops = ImmutableMap.copyOf(drops);
|
|
+ }
|
|
+ // Leaves end - use unmodifiable maps instead of immutable ones to skip the copy
|
|
this.lootDataResolver = dataLookup;
|
|
}
|
|
|
|
diff --git a/src/main/java/top/leavesmc/leaves/LeavesConfig.java b/src/main/java/top/leavesmc/leaves/LeavesConfig.java
|
|
index 53ccd141c53faa3fa53127f546ba0faeb685d731..1335959fc27da3e53ea845dff83fcac0b3a1e873 100644
|
|
--- a/src/main/java/top/leavesmc/leaves/LeavesConfig.java
|
|
+++ b/src/main/java/top/leavesmc/leaves/LeavesConfig.java
|
|
@@ -321,6 +321,11 @@ public final class LeavesConfig {
|
|
throttleInactiveGoalSelectorTick = getBoolean("settings.performance.inactive-goal-selector-disable", throttleInactiveGoalSelectorTick);
|
|
}
|
|
|
|
+ public static boolean skipCloneLootParameters = true;
|
|
+ private static void skipCloneLootParameters() {
|
|
+ skipCloneLootParameters = getBoolean("settings.performance.skip-clone-loot-parameters", skipCloneLootParameters);
|
|
+ }
|
|
+
|
|
public static final class WorldConfig {
|
|
|
|
public final String worldName;
|