-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix NPE related to BlockDispenseEntityEvent (#142)
Signed-off-by: Christopher White <[email protected]>
- Loading branch information
1 parent
9e59d7a
commit 1465194
Showing
1 changed file
with
26 additions
and
0 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
patches/server/0226-Readd-NPE-prevention-for-BlockDispenseEntityEvent.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
From e0c046f68018df323312eecb0a711587eb0bb029 Mon Sep 17 00:00:00 2001 | ||
From: Christopher White <[email protected]> | ||
Date: Sat, 20 Jul 2024 11:28:20 -0700 | ||
Subject: [PATCH] Readd NPE prevention for BlockDispenseEntityEvent | ||
|
||
Signed-off-by: Christopher White <[email protected]> | ||
|
||
diff --git a/src/main/java/net/minecraft/server/DispenserRegistry.java b/src/main/java/net/minecraft/server/DispenserRegistry.java | ||
index 9577483d..5c5ceed7 100644 | ||
--- a/src/main/java/net/minecraft/server/DispenserRegistry.java | ||
+++ b/src/main/java/net/minecraft/server/DispenserRegistry.java | ||
@@ -89,6 +89,11 @@ public class DispenserRegistry { | ||
CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1); | ||
|
||
Entity entity = ItemMonsterEgg.spawnCreature(isourceblock.getWorld(), itemstack.getData(), d0, d1, d2, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.DISPENSE_EGG); | ||
+ if (entity == null) { | ||
+ // This happens if the spawn event is cancelled | ||
+ itemstack.count++; | ||
+ return itemstack; | ||
+ } | ||
|
||
BlockDispenseEntityEvent event = new BlockDispenseEntityEvent(block, craftItem.clone(), new org.bukkit.util.Vector(d0, d1, d2), entity.getBukkitEntity()); | ||
if (!BlockDispenser.eventFired) { | ||
-- | ||
2.45.2 | ||
|