@@ -20,6 +20,21 @@ public class ReflectionUtils
2020{
2121 private static Reflections currentReflections ;
2222
23+ public static <T extends Entity > T createEntity (World world , Location location , Class <? extends Entity > clazz , T fallback )
24+ {
25+ try
26+ {
27+ Object obj = world .getClass ().getMethod ("createEntity" , Location .class , Class .class ).invoke (world , location , clazz );
28+ return (T )obj .getClass ().getMethod ("getBukkitEntity" ).invoke (obj );
29+ }
30+ catch (Exception exception )
31+ {
32+ exception .printStackTrace ();
33+ }
34+
35+ return fallback ;
36+ }
37+
2338 public static void setArmorStandInvisible (ArmorStand stand )
2439 {
2540 currentReflections .setArmorStandInvisible (stand );
@@ -35,11 +50,6 @@ public static void setItemAge(Item item, int age)
3550 currentReflections .setItemAge (item , age );
3651 }
3752
38- public static <T extends Entity > T createEntity (World world , Location location , Class <? extends Entity > clazz , T fallback )
39- {
40- return currentReflections .createEntity (world , location , clazz , fallback );
41- }
42-
4353 public static ItemStack parseItemStack (JsonObject json )
4454 {
4555 return currentReflections .parseItemStack (json );
@@ -127,9 +137,11 @@ public static void setReflections(Versions v)
127137 case V_1_19_R3 :
128138 currentReflections = new Reflections_1_19 ((byte )2 );
129139 return ;
130- case OTHER :
131140 case V_1_20_R1 :
132- currentReflections = new Reflections_1_20 ();
141+ currentReflections = new Reflections_1_20 (false );
142+ case OTHER :
143+ case V_1_20_R2 :
144+ currentReflections = new Reflections_1_20 (true );
133145 }
134146 }
135147}
0 commit comments