private void register() { try { customentity = Class.forName("temp.CustomEntityBat"); } catch (Exception e1) { try { cp.insertClassPath(new ClassClassPath(new CustomEntityBatHelper().getClass())); CtClass ces = cp.getAndRename( "me.dablakbandit.customentitiesapi.entities.CustomEntityBatHelper", "temp.CustomEntityBatHelper"); ces.setSuperclass(cp.get("temp.CustomEntityAmbientHelper")); ces.toClass(); CtClass EntityBat = cp.getCtClass("net.minecraft.server." + NMSUtils.getVersion() + "EntityBat"); cp.importPackage("net.minecraft.server." + NMSUtils.getVersion() + "EntityBat"); cp.importPackage("net.minecraft.server." + NMSUtils.getVersion() + "EntityAmbient"); for (CtField f : fields) { ctClass.addField(f); } fields.clear(); ctClass.setSuperclass(EntityBat); for (String m : methods) { ctClass.addMethod(CtNewMethod.make(m, ctClass)); } methods.clear(); customentity = ctClass.toClass(); } catch (Exception e2) { e2.printStackTrace(); } } if (customentity != null) CustomEntitiesAPI.getInstance().registerEntity("EntityBat", 65, customentity); }
public CustomEntitySilverfish(Entity e) { this(); a(); try { entity = customentity.cast(NMSUtils.getHandle(e)); } catch (Exception e1) { } }
private void register() { try { customentity = Class.forName("temp.CustomEntitySilverfish"); } catch (Exception e1) { try { cp.insertClassPath(new ClassClassPath(new CustomEntitySilverfishHelper().getClass())); CtClass ces = cp.getAndRename( "me.dablakbandit.customentitiesapi.entities.CustomEntitySilverfishHelper", "temp.CustomEntitySilverfishHelper"); ces.setSuperclass(cp.get("temp.CustomEntityMonsterHelper")); ces.toClass(); CtClass EntitySilverfish = cp.getCtClass("net.minecraft.server." + NMSUtils.getVersion() + "EntitySilverfish"); cp.importPackage("net.minecraft.server." + NMSUtils.getVersion() + "EntitySilverfish"); cp.importPackage("net.minecraft.server." + NMSUtils.getVersion() + "EntityMonster"); for (CtField f : fields) { ctClass.addField(f); } fields.clear(); ctClass.setSuperclass(EntitySilverfish); methods.add( "public void setUnableToMove(){" + "CustomEntitySilverfishHelper.setUnableToMove(this);" + "}"); methods.add( "public void setAbleToMove(){" + "CustomEntitySilverfishHelper.setAbleToMove(this);" + "}"); methods.add( "public void setAbleToMove(double d){" + "CustomEntitySilverfishHelper.setAbleToMove(this, d);" + "}"); for (String m : methods) { ctClass.addMethod(CtNewMethod.make(m, ctClass)); } methods.clear(); customentity = ctClass.toClass(); } catch (Exception e2) { e2.printStackTrace(); } } if (customentity != null) CustomEntitiesAPI.getInstance().registerEntity("EntitySilverfish", 60, customentity); }