mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-30 16:19:03 +01:00
Preserve overstacked loot (#5943)
This commit is contained in:
parent
7f7961ea23
commit
88b2f00a03
1 changed files with 72 additions and 0 deletions
72
patches/server/Preserve-overstacked-loot.patch
Normal file
72
patches/server/Preserve-overstacked-loot.patch
Normal file
|
@ -0,0 +1,72 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: lexikiq <noellekiq@gmail.com>
|
||||
Date: Mon, 21 Jun 2021 23:21:58 -0400
|
||||
Subject: [PATCH] Preserve overstacked loot
|
||||
|
||||
Preserves overstacked items in loot tables, such as shulker box drops, to prevent the items
|
||||
from being deleted (as they'd overflow past the bounds of the container)-- or worse, causing
|
||||
chunk bans via the large amount of NBT created by unstacking the items.
|
||||
|
||||
Fixes GH-5140 and GH-4748.
|
||||
|
||||
diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
||||
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
||||
@@ -0,0 +0,0 @@ public class PaperWorldConfig {
|
||||
allowPlayerCrammingDamage = getBoolean("allow-player-cramming-damage", allowPlayerCrammingDamage);
|
||||
}
|
||||
|
||||
+ public boolean splitOverstackedLoot = true;
|
||||
+ private void splitOverstackedLoot() {
|
||||
+ splitOverstackedLoot = getBoolean("split-overstacked-loot", splitOverstackedLoot);
|
||||
+ }
|
||||
+
|
||||
private Table<String, String, Integer> sensorTickRates;
|
||||
private Table<String, String, Integer> behaviorTickRates;
|
||||
private void tickRates() {
|
||||
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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 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
|
||||
@@ -0,0 +0,0 @@ public class LootTable {
|
||||
this.compositeFunction = LootItemFunctions.compose(functions);
|
||||
}
|
||||
|
||||
+ @Deprecated // Paper - preserve overstacked items
|
||||
public static Consumer<ItemStack> createStackSplitter(Consumer<ItemStack> lootConsumer) {
|
||||
+ // Paper start - preserve overstacked items
|
||||
+ return createStackSplitter(lootConsumer, null);
|
||||
+ }
|
||||
+
|
||||
+ public static Consumer<ItemStack> createStackSplitter(Consumer<ItemStack> lootConsumer, @org.jetbrains.annotations.Nullable net.minecraft.server.level.ServerLevel world) {
|
||||
+ boolean skipSplitter = world != null && !world.paperConfig.splitOverstackedLoot;
|
||||
+ // Paper end
|
||||
return (itemstack) -> {
|
||||
- if (itemstack.getCount() < itemstack.getMaxStackSize()) {
|
||||
+ if (skipSplitter || itemstack.getCount() < itemstack.getMaxStackSize()) { // Paper - preserve overstacked items
|
||||
lootConsumer.accept(itemstack);
|
||||
} else {
|
||||
int i = itemstack.getCount();
|
||||
@@ -0,0 +0,0 @@ public class LootTable {
|
||||
}
|
||||
|
||||
public void getRandomItems(LootContext context, Consumer<ItemStack> lootConsumer) {
|
||||
- this.getRandomItemsRaw(context, LootTable.createStackSplitter(lootConsumer));
|
||||
+ this.getRandomItemsRaw(context, LootTable.createStackSplitter(lootConsumer, context.getLevel())); // Paper - preserve overstacked items
|
||||
}
|
||||
|
||||
public List<ItemStack> getRandomItems(LootContext context) {
|
||||
diff --git a/src/main/java/net/minecraft/world/level/storage/loot/functions/SetContainerContents.java b/src/main/java/net/minecraft/world/level/storage/loot/functions/SetContainerContents.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/storage/loot/functions/SetContainerContents.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/storage/loot/functions/SetContainerContents.java
|
||||
@@ -0,0 +0,0 @@ public class SetContainerContents extends LootItemConditionalFunction {
|
||||
NonNullList<ItemStack> nonNullList = NonNullList.create();
|
||||
this.entries.forEach((entry) -> {
|
||||
entry.expand(context, (choice) -> {
|
||||
- choice.createItemStack(LootTable.createStackSplitter(nonNullList::add), context);
|
||||
+ choice.createItemStack(LootTable.createStackSplitter(nonNullList::add, context.getLevel()), context); // Paper - preserve overstacked items
|
||||
});
|
||||
});
|
||||
CompoundTag compoundTag = new CompoundTag();
|
Loading…
Reference in a new issue