From c76552e4a5f02e7f74ef594cf081fc5d7238acdb Mon Sep 17 00:00:00 2001 From: Thinkofdeath Date: Sat, 27 Dec 2014 14:03:18 +0000 Subject: Fix crashes when beacons have invalid effects --- nms-patches/TileEntityBeacon.patch | 40 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) (limited to 'nms-patches') diff --git a/nms-patches/TileEntityBeacon.patch b/nms-patches/TileEntityBeacon.patch index 55874cea..6a881eb8 100644 --- a/nms-patches/TileEntityBeacon.patch +++ b/nms-patches/TileEntityBeacon.patch @@ -1,5 +1,5 @@ ---- ../work/decompile-8eb82bde//net/minecraft/server/TileEntityBeacon.java 2014-11-28 17:43:43.389707429 +0000 -+++ src/main/java/net/minecraft/server/TileEntityBeacon.java 2014-11-28 17:38:23.000000000 +0000 +--- ../work/decompile-8eb82bde//net/minecraft/server/TileEntityBeacon.java 2014-12-27 14:03:08.349290689 +0000 ++++ src/main/java/net/minecraft/server/TileEntityBeacon.java 2014-12-27 14:03:08.349290689 +0000 @@ -5,6 +5,11 @@ import java.util.Iterator; import java.util.List; @@ -43,6 +43,17 @@ public TileEntityBeacon() {} +@@ -169,8 +198,8 @@ + + public void a(NBTTagCompound nbttagcompound) { + super.a(nbttagcompound); +- this.k = nbttagcompound.getInt("Primary"); +- this.l = nbttagcompound.getInt("Secondary"); ++ this.k = validateEffect(nbttagcompound.getInt("Primary")); // CraftBukkit ++ this.l = validateEffect(nbttagcompound.getInt("Secondary")); // CraftBukkit + this.j = nbttagcompound.getInt("Levels"); + } + @@ -182,7 +211,7 @@ } @@ -52,3 +63,28 @@ } public ItemStack getItem(int i) { +@@ -282,11 +311,11 @@ + break; + + case 1: +- this.k = j; ++ this.k = validateEffect(j); // CraftBukkit + break; + + case 2: +- this.l = j; ++ this.l = validateEffect(j); // CraftBukkit + } + + } +@@ -307,4 +336,10 @@ + return super.c(i, j); + } + } ++ ++ // CraftBukkit start ++ public int validateEffect(int i) { ++ return i < 0 || i >= MobEffectList.byId.length || MobEffectList.byId[i] == null ? 0 : i; ++ } ++ // CraftBukkit end + } -- cgit v1.2.3