From d369c1058a00a0fd09a2cb68327b339b0bf204a4 Mon Sep 17 00:00:00 2001 From: Marcel Konrad Date: Wed, 1 Jul 2020 23:19:34 +0200 Subject: [PATCH] Fix NoSuchMethodError in reobf --- .../builder/component/impl/EntityNBT.java | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/main/java/exopandora/worldhandler/builder/component/impl/EntityNBT.java b/src/main/java/exopandora/worldhandler/builder/component/impl/EntityNBT.java index 162a5ac..ef65ac0 100644 --- a/src/main/java/exopandora/worldhandler/builder/component/impl/EntityNBT.java +++ b/src/main/java/exopandora/worldhandler/builder/component/impl/EntityNBT.java @@ -1,5 +1,6 @@ package exopandora.worldhandler.builder.component.impl; +import java.lang.reflect.Array; import java.util.ArrayList; import java.util.List; import java.util.Set; @@ -7,8 +8,6 @@ import java.util.Set; import javax.annotation.Nonnull; import javax.annotation.Nullable; -import org.apache.commons.lang3.ArrayUtils; - import exopandora.worldhandler.builder.component.IBuilderComponent; import exopandora.worldhandler.builder.impl.EnumAttributes; import exopandora.worldhandler.builder.impl.EnumAttributes.Applyable; @@ -174,7 +173,7 @@ public class EntityNBT implements IBuilderComponent public void setArmorItem(int index, ResourceLocation location) { - if(ArrayUtils.isArrayIndexValid(this.armorItems, index) && location != null) + if(EntityNBT.isArrayIndexValid(this.armorItems, index) && location != null) { this.armorItems[index] = location; } @@ -188,7 +187,7 @@ public class EntityNBT implements IBuilderComponent @Nonnull public ResourceLocation getArmorItem(int slot) { - if(ArrayUtils.isArrayIndexValid(this.armorItems, slot)) + if(EntityNBT.isArrayIndexValid(this.armorItems, slot)) { return this.armorItems[slot]; } @@ -208,7 +207,7 @@ public class EntityNBT implements IBuilderComponent public void setHandItem(int index, ResourceLocation location) { - if(ArrayUtils.isArrayIndexValid(this.handItems, index) && location != null) + if(EntityNBT.isArrayIndexValid(this.handItems, index) && location != null) { this.handItems[index] = location; } @@ -217,7 +216,7 @@ public class EntityNBT implements IBuilderComponent @Nonnull public ResourceLocation getHandItem(int slot) { - if(ArrayUtils.isArrayIndexValid(this.handItems, slot)) + if(EntityNBT.isArrayIndexValid(this.handItems, slot)) { return this.handItems[slot]; } @@ -428,4 +427,14 @@ public class EntityNBT implements IBuilderComponent { return null; } + + private static boolean isArrayIndexValid(Object[] array, int index) + { + if(array != null && (Array.getLength(array) == 0 || array.length <= index)) + { + return false; + } + + return index >= 0; + } }