From 0b21e88f0d7b48995bdff7e23d5ae8be88cf67f5 Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Mon, 3 Sep 2018 15:23:08 +1200 Subject: [PATCH] Modify way nms Particle is fetched --- .../disguise/utilities/ReflectionManager.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/main/java/me/libraryaddict/disguise/utilities/ReflectionManager.java b/src/main/java/me/libraryaddict/disguise/utilities/ReflectionManager.java index 84210686..a26b8f67 100644 --- a/src/main/java/me/libraryaddict/disguise/utilities/ReflectionManager.java +++ b/src/main/java/me/libraryaddict/disguise/utilities/ReflectionManager.java @@ -842,7 +842,16 @@ public class ReflectionManager { private static Object getParticleType(Particle particle) { try { - return getCraftClass("CraftParticle").getMethod("toNMS", Particle.class).invoke(null, particle); + Class craftParticle = getCraftClass("CraftParticle"); + Field mcKeyField = craftParticle.getDeclaredField("minecraftKey"); + mcKeyField.setAccessible(true); + Object mcKey = mcKeyField.get(Enum.valueOf(craftParticle, particle.name())); + + Class typesClass = getNmsClass("IRegistry"); + + Object registry = typesClass.getField("PARTICLE_TYPE").get(null); + + return registry.getClass().getMethod("get", mcKey.getClass()).invoke(registry, mcKey); } catch (Exception e) { e.printStackTrace(); @@ -928,9 +937,10 @@ public class ReflectionManager { } public static Object createMinecraftKey(String name) { - try{ + try { return getNmsClass("MinecraftKey").getConstructor(String.class).newInstance(name); - }catch(Exception ex) { + } + catch (Exception ex) { ex.printStackTrace(); }