Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ublic class CustomZombie extends EntityZombie {
- public CustomZombie(org.bukkit.World world)
- {
- super(((CraftWorld)world).getHandle());
- }
- @Override
- public void m() {}
- public void addPath(Location to, float speed) {
- goalSelector.a(4, new PathfinderGoalWalkTo(this, to, speed));
- }
- private static Object getPrivateField(String fieldName, Class clazz, Object object)
- {
- Field field;
- Object o = null;
- try
- {
- field = clazz.getDeclaredField(fieldName);
- field.setAccessible(true);
- o = field.get(object);
- }
- catch(NoSuchFieldException e)
- {
- e.printStackTrace();
- }
- catch(IllegalAccessException e)
- {
- e.printStackTrace();
- }
- return o;
- }
- public enum EntityTypes
- {
- CUSTOM_ZOMBIE("Zombie", 54, CustomZombie.class);
- private EntityTypes(String name, int id, Class<? extends Entity> custom)
- {
- addToMaps(custom, name, id);
- }
- public static void spawnEntity(Entity entity, Location loc)
- {
- entity.setLocation(loc.getX(), loc.getY(), loc.getZ(), loc.getYaw(), loc.getPitch());
- ((CraftWorld)loc.getWorld()).getHandle().addEntity(entity);
- }
- private static void addToMaps(Class clazz, String name, int id)
- {
- ((Map)getPrivateField("c", net.minecraft.server.v1_8_R3.EntityTypes.class, null)).put(name, clazz);
- ((Map)getPrivateField("d", net.minecraft.server.v1_8_R3.EntityTypes.class, null)).put(clazz, name);
- ((Map)getPrivateField("f", net.minecraft.server.v1_8_R3.EntityTypes.class, null)).put(clazz, Integer.valueOf(id));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment