@Override public void setup() throws Exception { registerCustomEntity(EntityNMSArmorStand.class, "ArmorStand", 30); registerCustomEntity(EntityNMSItem.class, "Item", 1); registerCustomEntity(EntityNMSSlime.class, "Slime", 55); if (!VersionUtils.isMCPCOrCauldron()) { validateEntityMethod = World.class.getDeclaredMethod("a", Entity.class); validateEntityMethod.setAccessible(true); } }
@SuppressWarnings("rawtypes") public void registerCustomEntity(Class entityClass, String name, int id) throws Exception { if (VersionUtils.isMCPCOrCauldron()) { // MCPC+ / Cauldron entity registration. Class<?> entityTypesClass = Class.forName("net.minecraft.server.v1_8_R3.EntityTypes"); ReflectionUtils.putInPrivateStaticMap(entityTypesClass, "field_75626_c", entityClass, name); ReflectionUtils.putInPrivateStaticMap( entityTypesClass, "field_75624_e", entityClass, Integer.valueOf(id)); } else { // Normal entity registration. ReflectionUtils.putInPrivateStaticMap(EntityTypes.class, "d", entityClass, name); ReflectionUtils.putInPrivateStaticMap( EntityTypes.class, "f", entityClass, Integer.valueOf(id)); } }