From cd24514ec687db8dd3f6eef6f8d85b66da44c800 Mon Sep 17 00:00:00 2001 From: Andrew Date: Wed, 6 Nov 2013 19:46:09 +1300 Subject: [PATCH] Fixed a error when setting up a itemstack watcher before it spawns in --- .../disguise/disguisetypes/Disguise.java | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/me/libraryaddict/disguise/disguisetypes/Disguise.java b/src/me/libraryaddict/disguise/disguisetypes/Disguise.java index 773f765e..166e70fe 100644 --- a/src/me/libraryaddict/disguise/disguisetypes/Disguise.java +++ b/src/me/libraryaddict/disguise/disguisetypes/Disguise.java @@ -419,12 +419,21 @@ public abstract class Disguise { // Start from 2 as they ALL share 0 and 1 for (int dataNo = 2; dataNo <= 31; dataNo++) { // If the watcher already set a metadata on this - if (getWatcher().getValue(dataNo, null) != null) { + if (getWatcher().hasValue(dataNo)) { // Better check that the value is stable. - if (disguiseValues.containsKey(dataNo) - && getWatcher().getValue(dataNo, null).getClass() == disguiseValues.get(dataNo).getClass()) { - // The classes are the same. The client "shouldn't" crash. - continue; + // To check this, I'm going to check if there exists a default value + // Then I'm going to check if the watcher value is the same as the default value. + if (disguiseValues.containsKey(dataNo)) { + // Now check if they are the same class, or both null. + if (disguiseValues.get(dataNo) == null || getWatcher().getValue(dataNo, null) == null) { + if (disguiseValues.get(dataNo) == null && getWatcher().getValue(dataNo, null) == null) { + // They are both null. Idk what this means really. + continue; + } + } else if (getWatcher().getValue(dataNo, null).getClass() == disguiseValues.get(dataNo).getClass()) { + // The classes are the same. The client "shouldn't" crash. + continue; + } } } // If neither of them touch it