aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0877-Prevent-empty-items-from-being-added-to-world.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patches/server/0877-Prevent-empty-items-from-being-added-to-world.patch')
-rw-r--r--patches/server/0877-Prevent-empty-items-from-being-added-to-world.patch33
1 files changed, 33 insertions, 0 deletions
diff --git a/patches/server/0877-Prevent-empty-items-from-being-added-to-world.patch b/patches/server/0877-Prevent-empty-items-from-being-added-to-world.patch
new file mode 100644
index 0000000000..6d09d8f5e3
--- /dev/null
+++ b/patches/server/0877-Prevent-empty-items-from-being-added-to-world.patch
@@ -0,0 +1,33 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Owen1212055 <[email protected]>
+Date: Wed, 15 Jun 2022 21:52:57 -0400
+Subject: [PATCH] Prevent empty items from being added to world
+
+The previous solution caused a bunch of bandaid fixes inorder to resolve edge cases where minecraft/the api might spawn items that are air.
+Just simply prevent them from being added to the world instead.
+
+diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
+index 87b59687f8b484f08c43a10d42460e827eb9a62a..d3767b4db89b9f067c02b412e75b5944b9c353da 100644
+--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
++++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
+@@ -1464,6 +1464,7 @@ 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 {
++ if (entity instanceof net.minecraft.world.entity.item.ItemEntity itemEntity && itemEntity.getItem().isEmpty()) return false; // Paper - Prevent empty items from being added
+ // 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);
+diff --git a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
+index 30c417c3169c1df43662fd77ac6816db64a42802..4c78c04ed031ec2e04642ebe5d79527e848d95f6 100644
+--- a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
++++ b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
+@@ -507,7 +507,7 @@ public class ItemEntity extends Entity {
+ }
+
+ public void setItem(ItemStack stack) {
+- com.google.common.base.Preconditions.checkArgument(!stack.isEmpty(), "Cannot drop air"); // CraftBukkit
++ // com.google.common.base.Preconditions.checkArgument(!stack.isEmpty(), "Cannot drop air"); // CraftBukkit // Paper - Remove check
+ this.getEntityData().set(ItemEntity.DATA_ITEM, stack);
+ this.getEntityData().markDirty(ItemEntity.DATA_ITEM); // CraftBukkit - SPIGOT-4591, must mark dirty
+ this.despawnRate = level.paperConfig().entities.spawning.altItemDespawnRate.enabled ? level.paperConfig().entities.spawning.altItemDespawnRate.items.getOrDefault(stack.getItem(), level.spigotConfig.itemDespawnRate) : level.spigotConfig.itemDespawnRate; // Paper