Fix paper's problems, fixes #524
This commit is contained in:
parent
7e2c04a331
commit
8fbeb2a4f7
@ -74,7 +74,8 @@ public class ReflectionManager {
|
|||||||
private static Enum[] enumGamemode;
|
private static Enum[] enumGamemode;
|
||||||
private static Method getNmsEntityMethod;
|
private static Method getNmsEntityMethod;
|
||||||
private static Enum[] enumItemSlots;
|
private static Enum[] enumItemSlots;
|
||||||
private static Method soundGetMethod;
|
private static Enum[] craftSounds;
|
||||||
|
private static Field craftSound;
|
||||||
private static Constructor vector3FConstructor;
|
private static Constructor vector3FConstructor;
|
||||||
private static Method enumDirectionFrom;
|
private static Method enumDirectionFrom;
|
||||||
private static Constructor villagerDataConstructor;
|
private static Constructor villagerDataConstructor;
|
||||||
@ -137,7 +138,9 @@ public class ReflectionManager {
|
|||||||
enumGamemode = (Enum[]) getNmsClass("EnumGamemode").getEnumConstants();
|
enumGamemode = (Enum[]) getNmsClass("EnumGamemode").getEnumConstants();
|
||||||
getNmsEntityMethod = getCraftMethod("entity.CraftEntity", "getHandle");
|
getNmsEntityMethod = getCraftMethod("entity.CraftEntity", "getHandle");
|
||||||
enumItemSlots = (Enum[]) getNmsClass("EnumItemSlot").getEnumConstants();
|
enumItemSlots = (Enum[]) getNmsClass("EnumItemSlot").getEnumConstants();
|
||||||
soundGetMethod = getCraftMethod("CraftSound", "getSound", Sound.class);
|
craftSounds = (Enum[]) getCraftClass("CraftSound").getEnumConstants();
|
||||||
|
craftSound = getCraftClass("CraftSound").getDeclaredField("minecraftKey");
|
||||||
|
craftSound.setAccessible(true);
|
||||||
vector3FConstructor = getNmsConstructor("Vector3f", float.class, float.class, float.class);
|
vector3FConstructor = getNmsConstructor("Vector3f", float.class, float.class, float.class);
|
||||||
enumDirectionFrom = getNmsMethod("EnumDirection", "fromType1", int.class);
|
enumDirectionFrom = getNmsMethod("EnumDirection", "fromType1", int.class);
|
||||||
getBlockData = getNmsMethod(getNmsClass("Block"), "getBlockData");
|
getBlockData = getNmsMethod(getNmsClass("Block"), "getBlockData");
|
||||||
@ -1057,9 +1060,15 @@ public class ReflectionManager {
|
|||||||
|
|
||||||
public static Object getSoundString(Sound sound) {
|
public static Object getSoundString(Sound sound) {
|
||||||
try {
|
try {
|
||||||
return soundGetMethod.invoke(null, sound);
|
for (Enum e : craftSounds) {
|
||||||
} catch (IllegalAccessException | InvocationTargetException e) {
|
if (!e.name().equals(sound.name())) {
|
||||||
e.printStackTrace();
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
return craftSound.get(e);
|
||||||
|
}
|
||||||
|
} catch (IllegalAccessException illegalAccessException) {
|
||||||
|
illegalAccessException.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
Loading…
Reference in New Issue
Block a user