2021-06-11 14:02:28 +02:00
|
|
|
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
|
2023-12-05 18:20:55 +01:00
|
|
|
index d3f0cb141ce0942e55e395bfd2e7c3e2c2e48952..dd5ac4b4c30afab7b376947548722050fb3af106 100644
|
2021-06-11 14:02:28 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
2023-09-22 22:13:57 +02:00
|
|
|
@@ -1509,6 +1509,12 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
2021-11-24 17:39:04 +01:00
|
|
|
// WorldServer.LOGGER.warn("Tried to add entity {} but it was marked as removed already", EntityTypes.getKey(entity.getType())); // CraftBukkit
|
2021-06-11 14:02:28 +02:00
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
+ // Paper start - capture all item additions to the world
|
2021-06-14 16:41:34 +02:00
|
|
|
+ if (captureDrops != null && entity instanceof net.minecraft.world.entity.item.ItemEntity) {
|
|
|
|
+ captureDrops.add((net.minecraft.world.entity.item.ItemEntity) entity);
|
2021-06-11 14:02:28 +02:00
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+ // Paper end
|
2022-03-13 08:47:54 +01:00
|
|
|
// 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)) {
|
2021-06-11 14:02:28 +02:00
|
|
|
return false;
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java b/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java
|
2023-12-05 18:20:55 +01:00
|
|
|
index 1685dd08ef6331e133d752cd9ce3874c9eda5a05..49828aa38e06d7a2f0c7c5b7c4be374996ef4524 100644
|
2021-06-11 14:02:28 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java
|
2023-12-03 04:41:35 +01:00
|
|
|
@@ -431,10 +431,12 @@ public class ServerPlayerGameMode {
|
2021-06-11 14:02:28 +02:00
|
|
|
// return true; // CraftBukkit
|
|
|
|
}
|
|
|
|
// CraftBukkit start
|
2023-10-27 01:34:58 +02:00
|
|
|
+ java.util.List<net.minecraft.world.entity.item.ItemEntity> itemsToDrop = this.level.captureDrops; // Paper - store current list
|
|
|
|
+ this.level.captureDrops = null; // Paper - Remove this earlier so that we can actually drop stuff
|
2021-06-11 14:02:28 +02:00
|
|
|
if (event.isDropItems()) {
|
2023-10-27 01:34:58 +02:00
|
|
|
- org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockDropItemEvent(bblock, state, this.player, this.level.captureDrops);
|
2021-06-11 14:02:28 +02:00
|
|
|
+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockDropItemEvent(bblock, state, this.player, itemsToDrop); // Paper - use stored ref
|
|
|
|
}
|
2023-10-27 01:34:58 +02:00
|
|
|
- this.level.captureDrops = null;
|
|
|
|
+ //this.level.captureDrops = null; // Paper - move up
|
2021-06-11 14:02:28 +02:00
|
|
|
|
|
|
|
// Drop event experience
|
|
|
|
if (flag && event != null) {
|