geforkt von Mirrors/Paper
34 Zeilen
2.6 KiB
Diff
34 Zeilen
2.6 KiB
Diff
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 491e285de9ab6c0c09aa879d1e5f3219bce9dc9e..cefe6fdcb6ef975b49a2417f5354775578391933 100644
|
|
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
|
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
|
@@ -1296,6 +1296,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 b8db8750125315b15cc3d3e76ee629a60c4546a1..6b3a17e6717b8c03c5bd674771b29e4becd42c71 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
|
|
@@ -520,7 +520,7 @@ public class ItemEntity extends Entity implements TraceableEntity {
|
|
}
|
|
|
|
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.despawnRate = this.level().paperConfig().entities.spawning.altItemDespawnRate.enabled ? this.level().paperConfig().entities.spawning.altItemDespawnRate.items.getOrDefault(stack.getItem(), this.level().spigotConfig.itemDespawnRate) : this.level().spigotConfig.itemDespawnRate; // Paper
|
|
}
|