mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2025-03-10 22:05:09 +01:00
Handle null EntityTypes from SpawnEggs.
Fixes WORLDGUARD-3179.
This commit is contained in:
parent
41f520845a
commit
df985013eb
@ -836,7 +836,11 @@ private static <T extends Event & Cancellable> void handleBlockRightClick(T even
|
|||||||
if (item != null && item.getType() == Material.MONSTER_EGG) {
|
if (item != null && item.getType() == Material.MONSTER_EGG) {
|
||||||
MaterialData data = item.getData();
|
MaterialData data = item.getData();
|
||||||
if (data instanceof SpawnEgg) {
|
if (data instanceof SpawnEgg) {
|
||||||
Events.fireToCancel(event, new SpawnEntityEvent(event, cause, placed.getLocation().add(0.5, 0, 0.5), ((SpawnEgg) data).getSpawnedType()));
|
@Nullable EntityType type = ((SpawnEgg) data).getSpawnedType();
|
||||||
|
if (type == null) {
|
||||||
|
type = EntityType.SHEEP; // Haven't investigated why it's sometimes null
|
||||||
|
}
|
||||||
|
Events.fireToCancel(event, new SpawnEntityEvent(event, cause, placed.getLocation().add(0.5, 0, 0.5), type));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user