Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package me.the_red_freak.zombietest.entities;
- import java.lang.reflect.InvocationTargetException;
- import java.lang.reflect.Method;
- import org.bukkit.Location;
- import org.bukkit.craftbukkit.v1_11_R1.CraftWorld;
- import net.minecraft.server.v1_11_R1.Entity;
- import net.minecraft.server.v1_11_R1.EntityInsentient;
- import net.minecraft.server.v1_11_R1.WorldServer;
- public enum EntityTypes {
- // NAME("Entity name", Entity ID, yourcustomclass.class);
- CZombie("CZombie", 54, Zombie.class); // You can
- // add as
- // many as
- // you want.
- private EntityTypes(String name, int id, Class<? extends EntityInsentient> custom) {
- // addToMaps(custom, name, id);
- try {
- Method f = net.minecraft.server.v1_11_R1.EntityTypes.class.getDeclaredMethod("a", Integer.class,
- String.class, Class.class, String.class);
- f.setAccessible(true);
- f.invoke(id, name, custom, name);
- } catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException
- | InvocationTargetException e) {
- e.printStackTrace();
- }
- }
- /**
- * That one here is outdated!
- */
- // private static void addToMaps(Class clazz, String name, int id) {
- // ((Map) Util.getPrivateField("c",
- // net.minecraft.server.v1_11_R1.EntityTypes.class, null)).put(name, clazz);
- // ((Map) Util.getPrivateField("d",
- // net.minecraft.server.v1_11_R1.EntityTypes.class, null)).put(clazz, name);
- // ((Map) Util.getPrivateField("f",
- // net.minecraft.server.v1_11_R1.EntityTypes.class, null)).put(clazz,
- // Integer.valueOf(id));
- // }
- /**
- * So i tried to set up my own one
- *
- * @see EntityTypes#EntityTypes(String, int, Class)
- */
- public static void spawnEntity(Entity entity, Location loc) {
- WorldServer s = ((CraftWorld) loc.getWorld()).getHandle();
- s.addEntity(entity);
- entity.setPosition(loc.getX(), loc.getY(), loc.getZ());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement