Guest User

Untitled

a guest
Feb 18th, 2022
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.82 KB | None | 0 0
  1. ublic class CustomZombie extends EntityZombie {
  2.  
  3. public CustomZombie(org.bukkit.World world)
  4. {
  5. super(((CraftWorld)world).getHandle());
  6. }
  7.  
  8. @Override
  9. public void m() {}
  10.  
  11.  
  12. public void addPath(Location to, float speed) {
  13. goalSelector.a(4, new PathfinderGoalWalkTo(this, to, speed));
  14. }
  15.  
  16. private static Object getPrivateField(String fieldName, Class clazz, Object object)
  17. {
  18. Field field;
  19. Object o = null;
  20.  
  21. try
  22. {
  23. field = clazz.getDeclaredField(fieldName);
  24.  
  25. field.setAccessible(true);
  26.  
  27. o = field.get(object);
  28. }
  29. catch(NoSuchFieldException e)
  30. {
  31. e.printStackTrace();
  32. }
  33. catch(IllegalAccessException e)
  34. {
  35. e.printStackTrace();
  36. }
  37.  
  38. return o;
  39. }
  40.  
  41. public enum EntityTypes
  42. {
  43.  
  44. CUSTOM_ZOMBIE("Zombie", 54, CustomZombie.class);
  45.  
  46. private EntityTypes(String name, int id, Class<? extends Entity> custom)
  47. {
  48. addToMaps(custom, name, id);
  49. }
  50.  
  51. public static void spawnEntity(Entity entity, Location loc)
  52. {
  53. entity.setLocation(loc.getX(), loc.getY(), loc.getZ(), loc.getYaw(), loc.getPitch());
  54. ((CraftWorld)loc.getWorld()).getHandle().addEntity(entity);
  55. }
  56.  
  57. private static void addToMaps(Class clazz, String name, int id)
  58. {
  59.  
  60. ((Map)getPrivateField("c", net.minecraft.server.v1_8_R3.EntityTypes.class, null)).put(name, clazz);
  61. ((Map)getPrivateField("d", net.minecraft.server.v1_8_R3.EntityTypes.class, null)).put(clazz, name);
  62. ((Map)getPrivateField("f", net.minecraft.server.v1_8_R3.EntityTypes.class, null)).put(clazz, Integer.valueOf(id));
  63.  
  64. }
  65.  
  66. }
  67.  
  68.  
  69.  
  70. }
Advertisement
Add Comment
Please, Sign In to add comment