Skip to content

Instantly share code, notes, and snippets.

@Avery246813579
Created January 11, 2015 06:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Avery246813579/8ae3d994c4a0f0434de4 to your computer and use it in GitHub Desktop.
Save Avery246813579/8ae3d994c4a0f0434de4 to your computer and use it in GitHub Desktop.
Bar Api Packet
public Object getSpawnPacket() {
Class<?> Entity = getCraftClass("Entity");
Class<?> EntityLiving = getCraftClass("EntityLiving");
Class<?> EntityEnderDragon = getCraftClass("EntityWither");
Object packet = null;
try {
NBTTagCompound compound = new NBTTagCompound();
compound.setInt("Invul", 0);
this.dragon = EntityEnderDragon.getConstructor(new Class[] { getCraftClass("World") }).newInstance(new Object[] { getWorld() });
//Method invul = getMethod(EntityEnderDragon, "a", new Class[] { NBTTagCompound.class });
//invul.invoke(this.dragon, new Object[] { compound });
Method setLocation = getMethod(EntityEnderDragon, "setLocation", new Class[] { Double.TYPE, Double.TYPE, Double.TYPE, Float.TYPE, Float.TYPE });
setLocation.invoke(this.dragon, new Object[] { Integer.valueOf(getX()), Integer.valueOf(getY()), Integer.valueOf(getZ()), Integer.valueOf(getPitch()), Integer.valueOf(getYaw()) });
Method setInvisible = getMethod(EntityEnderDragon, "setInvisible", new Class[] { Boolean.TYPE });
setInvisible.invoke(this.dragon, new Object[] { Boolean.valueOf(!isVisible()) });
Method setCustomName = getMethod(EntityEnderDragon, "setCustomName", new Class[] { String.class });
setCustomName.invoke(this.dragon, new Object[] { this.name });
Field motX = getField(Entity, "motX");
motX.set(this.dragon, Byte.valueOf(getXvel()));
Field motY = getField(Entity, "motY");
motY.set(this.dragon, Byte.valueOf(getYvel()));
Field motZ = getField(Entity, "motZ");
motZ.set(this.dragon, Byte.valueOf(getZvel()));
Method getId = getMethod(EntityEnderDragon, "getId", new Class[0]);
this.id = ((Integer) getId.invoke(this.dragon, new Object[0])).intValue();
Class<?> PacketPlayOutSpawnEntityLiving = getCraftClass("PacketPlayOutSpawnEntityLiving");
Method setHealth = getMethod(EntityEnderDragon, "setHealth", new Class[] { Float.TYPE });
setHealth.invoke(this.dragon, new Object[] { Float.valueOf(this.health) });
Method invul = getMethod(EntityEnderDragon, "a", new Class[] { NBTTagCompound.class });
invul.invoke(this.dragon, new Object[] { compound });
packet = PacketPlayOutSpawnEntityLiving.getConstructor(new Class[] { EntityLiving }).newInstance(new Object[] { this.dragon });
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (SecurityException e) {
e.printStackTrace();
} catch (InstantiationException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
}
return packet;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment