Fix NPE in AnvilDamageEvent - Closes #1331

This commit is contained in:
Aikar 2018-08-13 22:39:50 -04:00
parent d285e05dd8
commit 49aa3c4e2d
No known key found for this signature in database
GPG Key ID: 401ADFC9891FAAFE
1 changed files with 3 additions and 3 deletions

View File

@ -1,11 +1,11 @@
From 259073abd3c6dd5d4a3434c920db539e73f956cc Mon Sep 17 00:00:00 2001
From aba330fc2adbe136ffb43bd42ba13a203279a0ea Mon Sep 17 00:00:00 2001
From: BillyGalbreath <Blake.Galbreath@GMail.com>
Date: Fri, 20 Jul 2018 23:37:03 -0500
Subject: [PATCH] AnvilDamageEvent
diff --git a/src/main/java/net/minecraft/server/ContainerAnvil.java b/src/main/java/net/minecraft/server/ContainerAnvil.java
index fb3413d81e..9f20348d0c 100644
index fb3413d81e..3b23ef9863 100644
--- a/src/main/java/net/minecraft/server/ContainerAnvil.java
+++ b/src/main/java/net/minecraft/server/ContainerAnvil.java
@@ -73,6 +73,16 @@ public class ContainerAnvil extends Container {
@ -13,7 +13,7 @@ index fb3413d81e..9f20348d0c 100644
if (!entityhuman.abilities.canInstantlyBuild && iblockdata.a(TagsBlock.y) && entityhuman.getRandom().nextFloat() < 0.12F) {
IBlockData iblockdata1 = BlockAnvil.a_(iblockdata);
+ // Paper start
+ com.destroystokyo.paper.event.block.AnvilDamagedEvent event = new com.destroystokyo.paper.event.block.AnvilDamagedEvent(getBukkitView(), org.bukkit.craftbukkit.block.data.CraftBlockData.fromData(iblockdata1));
+ com.destroystokyo.paper.event.block.AnvilDamagedEvent event = new com.destroystokyo.paper.event.block.AnvilDamagedEvent(getBukkitView(), iblockdata1 != null ? org.bukkit.craftbukkit.block.data.CraftBlockData.fromData(iblockdata1) : null);
+ if (!event.callEvent()) {
+ return itemstack;
+ } else if (event.getDamageState() == com.destroystokyo.paper.event.block.AnvilDamagedEvent.DamageState.BROKEN) {