aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0763-Prevent-empty-items-from-being-added-to-world.patch
blob: a3cccb274cb62ac1a713e7d57a7af105783dbe2b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Owen1212055 <23108066+Owen1212055@users.noreply.github.com>
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 196c776fdb20aac5a9ad5692c47f61c979e4ace0..de822b99df2de08371f3a7a29bf8f3275650887c 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -1231,6 +1231,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);