Paper/patches/server/0431-Extend-block-drop-capture-to-capture-all-items-added.patch
Owen 89d51d5f29
Allow enabling sand duping (#10191)
Because this exploit has been widely known for years and has not been fixed by Mojang, we decided that it was worth allowing people to toggle it on/off due to how easy it is to make it configurable.

It should be noted that this decision does not promise all future exploits will be configurable.
2024-03-03 17:05:34 -05:00

44 lines
3.0 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Shane Freeder <theboyetronic@gmail.com>
Date: Thu, 17 Sep 2020 00:36:05 +0100
Subject: [PATCH] Extend block drop capture to capture all items added to the
world
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
index 2e42e09d3fa19e5a16374ee6ac1677dd2b2004f1..283f686364691f54d9e9e925b33238526de74219 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -1224,6 +1224,12 @@ public class ServerLevel extends Level implements WorldGenLevel {
// WorldServer.LOGGER.warn("Tried to add entity {} but it was marked as removed already", EntityTypes.getKey(entity.getType())); // CraftBukkit
return false;
} else {
+ // Paper start - capture all item additions to the world
+ if (captureDrops != null && entity instanceof net.minecraft.world.entity.item.ItemEntity) {
+ captureDrops.add((net.minecraft.world.entity.item.ItemEntity) entity);
+ return true;
+ }
+ // Paper end - capture all item additions to the world
// SPIGOT-6415: Don't call spawn event when reason is null. For example when an entity teleports to a new world.
if (spawnReason != null && !CraftEventFactory.doEntityAddEventCalling(this, entity, spawnReason)) {
return false;
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java b/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java
index c3eb4b6372eed0b7eb636f495ce494b676767b6e..a03d1a85019afdc42de2b8449fc38384c4dac51e 100644
--- a/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java
+++ b/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java
@@ -429,10 +429,12 @@ public class ServerPlayerGameMode {
// return true; // CraftBukkit
}
// CraftBukkit start
+ java.util.List<net.minecraft.world.entity.item.ItemEntity> itemsToDrop = this.level.captureDrops; // Paper - capture all item additions to the world
+ this.level.captureDrops = null; // Paper - capture all item additions to the world; Remove this earlier so that we can actually drop stuff
if (event.isDropItems()) {
- org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockDropItemEvent(bblock, state, this.player, this.level.captureDrops);
+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockDropItemEvent(bblock, state, this.player, itemsToDrop); // Paper - capture all item additions to the world
}
- this.level.captureDrops = null;
+ //this.level.captureDrops = null; // Paper - capture all item additions to the world; move up
// Drop event experience
if (flag && event != null) {