Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix NPE related to BlockDispenseEntityEvent #142

Merged
merged 1 commit into from
Jul 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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