-
-
Save z609/91a7f9ce47fbbd7b6270 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.bukkit.Location; | |
import java.lang.reflect.Field; | |
import java.lang.reflect.InvocationTargetException; | |
import java.lang.reflect.Method; | |
public class Client1_8 extends FakeWither | |
{ | |
private Object dragon; | |
private int id; | |
public Client1_8(final String name, final Location loc) { | |
super(name, loc); | |
} | |
@Override | |
public Object getSpawnPacket() { | |
final Class<?> Entity = BarAPIUtil.getCraftClass("Entity"); | |
final Class<?> EntityLiving = BarAPIUtil.getCraftClass("EntityLiving"); | |
final Class<?> EntityEnderDragon = BarAPIUtil.getCraftClass("EntityWither"); | |
Object packet = null; | |
try { | |
this.dragon = EntityEnderDragon.getConstructor(BarAPIUtil.getCraftClass("World")).newInstance(this.getWorld()); | |
final Method setLocation = BarAPIUtil.getMethod(EntityEnderDragon, "setLocation", new Class[] { Double.TYPE, Double.TYPE, Double.TYPE, Float.TYPE, Float.TYPE }); | |
setLocation.invoke(this.dragon, this.getX(), this.getY(), this.getZ(), this.getPitch(), this.getYaw()); | |
final Method setInvisible = BarAPIUtil.getMethod(EntityEnderDragon, "setInvisible", new Class[] { Boolean.TYPE }); | |
setInvisible.invoke(this.dragon, this.isVisible()); | |
final Method setCustomName = BarAPIUtil.getMethod(EntityEnderDragon, "setCustomName", new Class[] { String.class }); | |
setCustomName.invoke(this.dragon, this.name); | |
final Method setHealth = BarAPIUtil.getMethod(EntityEnderDragon, "setHealth", new Class[] { Float.TYPE }); | |
setHealth.invoke(this.dragon, this.health); | |
final Field motX = BarAPIUtil.getField(Entity, "motX"); | |
motX.set(this.dragon, this.getXvel()); | |
final Field motY = BarAPIUtil.getField(Entity, "motY"); | |
motY.set(this.dragon, this.getYvel()); | |
final Field motZ = BarAPIUtil.getField(Entity, "motZ"); | |
motZ.set(this.dragon, this.getZvel()); | |
final Method getId = BarAPIUtil.getMethod(EntityEnderDragon, "getId", new Class[0]); | |
this.id = (int)(Integer)(getId.invoke(this.dragon, new Object[0])); | |
final Class<?> PacketPlayOutSpawnEntityLiving = BarAPIUtil.getCraftClass("PacketPlayOutSpawnEntityLiving"); | |
packet = PacketPlayOutSpawnEntityLiving.getConstructor(EntityLiving).newInstance(this.dragon); | |
} | |
catch (IllegalArgumentException e) { | |
e.printStackTrace(); | |
} | |
catch (SecurityException e2) { | |
e2.printStackTrace(); | |
} | |
catch (InstantiationException e3) { | |
e3.printStackTrace(); | |
} | |
catch (IllegalAccessException e4) { | |
e4.printStackTrace(); | |
} | |
catch (InvocationTargetException e5) { | |
e5.printStackTrace(); | |
} | |
catch (NoSuchMethodException e6) { | |
e6.printStackTrace(); | |
} | |
return packet; | |
} | |
@Override | |
public Object getDestroyPacket() { | |
final Class<?> PacketPlayOutEntityDestroy = BarAPIUtil.getCraftClass("PacketPlayOutEntityDestroy"); | |
Object packet = null; | |
try { | |
packet = PacketPlayOutEntityDestroy.newInstance(); | |
final Field a = PacketPlayOutEntityDestroy.getDeclaredField("a"); | |
a.setAccessible(true); | |
a.set(packet, new int[] { this.id }); | |
} | |
catch (SecurityException e) { | |
e.printStackTrace(); | |
} | |
catch (NoSuchFieldException e2) { | |
e2.printStackTrace(); | |
} | |
catch (InstantiationException e3) { | |
e3.printStackTrace(); | |
} | |
catch (IllegalAccessException e4) { | |
e4.printStackTrace(); | |
} | |
catch (IllegalArgumentException e5) { | |
e5.printStackTrace(); | |
} | |
return packet; | |
} | |
@Override | |
public Object getMetaPacket(final Object watcher) { | |
final Class<?> DataWatcher = BarAPIUtil.getCraftClass("DataWatcher"); | |
final Class<?> PacketPlayOutEntityMetadata = BarAPIUtil.getCraftClass("PacketPlayOutEntityMetadata"); | |
Object packet = null; | |
try { | |
packet = PacketPlayOutEntityMetadata.getConstructor(Integer.TYPE, DataWatcher, Boolean.TYPE).newInstance(this.id, watcher, true); | |
} | |
catch (IllegalArgumentException e) { | |
e.printStackTrace(); | |
} | |
catch (SecurityException e2) { | |
e2.printStackTrace(); | |
} | |
catch (InstantiationException e3) { | |
e3.printStackTrace(); | |
} | |
catch (IllegalAccessException e4) { | |
e4.printStackTrace(); | |
} | |
catch (InvocationTargetException e5) { | |
e5.printStackTrace(); | |
} | |
catch (NoSuchMethodException e6) { | |
e6.printStackTrace(); | |
} | |
return packet; | |
} | |
@Override | |
public Object getTeleportPacket(final Location loc) { | |
final Class<?> PacketPlayOutEntityTeleport = BarAPIUtil.getCraftClass("PacketPlayOutEntityTeleport"); | |
Object packet = null; | |
try { | |
packet = PacketPlayOutEntityTeleport.getConstructor(Integer.TYPE, Integer.TYPE, Integer.TYPE, Integer.TYPE, Byte.TYPE, Byte.TYPE, Boolean.TYPE).newInstance(this.id, loc.getBlockX() * 32, loc.getBlockY() * 32, loc.getBlockZ() * 32, (byte)((int)loc.getYaw() * 256 / 360), (byte)((int)loc.getPitch() * 256 / 360), false); | |
} | |
catch (IllegalArgumentException e) { | |
e.printStackTrace(); | |
} | |
catch (SecurityException e2) { | |
e2.printStackTrace(); | |
} | |
catch (InstantiationException e3) { | |
e3.printStackTrace(); | |
} | |
catch (IllegalAccessException e4) { | |
e4.printStackTrace(); | |
} | |
catch (InvocationTargetException e5) { | |
e5.printStackTrace(); | |
} | |
catch (NoSuchMethodException e6) { | |
e6.printStackTrace(); | |
} | |
return packet; | |
} | |
@Override | |
public Object getWatcher() { | |
final Class<?> Entity = BarAPIUtil.getCraftClass("Entity"); | |
final Class<?> DataWatcher = BarAPIUtil.getCraftClass("DataWatcher"); | |
Object watcher = null; | |
try { | |
watcher = DataWatcher.getConstructor(Entity).newInstance(this.dragon); | |
final Method a = BarAPIUtil.getMethod(DataWatcher, "a", new Class[] { Integer.TYPE, Object.class }); | |
a.invoke(watcher, 0, (byte)32); | |
a.invoke(watcher, 5, this.isVisible() ? 0 : (this.isVisible() ? 0 : 32)); | |
a.invoke(watcher, 6, this.health); | |
a.invoke(watcher, 7, 0); | |
a.invoke(watcher, 8, (byte)0); | |
a.invoke(watcher, 10, this.name); | |
a.invoke(watcher, 11, (byte)1); | |
} | |
catch (IllegalArgumentException e) { | |
e.printStackTrace(); | |
} | |
catch (SecurityException e2) { | |
e2.printStackTrace(); | |
} | |
catch (InstantiationException e3) { | |
e3.printStackTrace(); | |
} | |
catch (IllegalAccessException e4) { | |
e4.printStackTrace(); | |
} | |
catch (InvocationTargetException e5) { | |
e5.printStackTrace(); | |
} | |
catch (NoSuchMethodException e6) { | |
e6.printStackTrace(); | |
} | |
return watcher; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.bukkit.Location; | |
public abstract class FakeWither | |
{ | |
public static final float MAX_HEALTH = 300.0f; | |
private int x; | |
private int y; | |
private int z; | |
private int pitch; | |
private int yaw; | |
private byte xvel; | |
private byte yvel; | |
private byte zvel; | |
public float health; | |
private boolean visible; | |
public String name; | |
private Object world; | |
public FakeWither(final String name, final Location loc, final int percent) { | |
this.pitch = 0; | |
this.yaw = 0; | |
this.xvel = 0; | |
this.yvel = 0; | |
this.zvel = 0; | |
this.health = 0.0f; | |
this.visible = false; | |
this.name = name; | |
this.x = loc.getBlockX(); | |
this.y = loc.getBlockY(); | |
this.z = loc.getBlockZ(); | |
this.health = percent / 100.0f * 300.0f; | |
this.world = BarAPIUtil.getHandle(loc.getWorld()); | |
} | |
public FakeWither(final String name, final Location loc) { | |
this.pitch = 0; | |
this.yaw = 0; | |
this.xvel = 0; | |
this.yvel = 0; | |
this.zvel = 0; | |
this.health = 0.0f; | |
this.visible = false; | |
this.name = name; | |
this.x = loc.getBlockX(); | |
this.y = loc.getBlockY(); | |
this.z = loc.getBlockZ(); | |
this.world = BarAPIUtil.getHandle(loc.getWorld()); | |
} | |
public float getMaxHealth() { | |
return 300.0f; | |
} | |
public void setHealth(final int percent) { | |
this.health = percent / 100.0f * 300.0f; | |
} | |
public void setName(final String name) { | |
this.name = name; | |
} | |
public int getX() { | |
return this.x; | |
} | |
public void setX(final int x) { | |
this.x = x; | |
} | |
public int getY() { | |
return this.y; | |
} | |
public void setY(final int y) { | |
this.y = y; | |
} | |
public int getZ() { | |
return this.z; | |
} | |
public void setZ(final int z) { | |
this.z = z; | |
} | |
public int getPitch() { | |
return this.pitch; | |
} | |
public void setPitch(final int pitch) { | |
this.pitch = pitch; | |
} | |
public int getYaw() { | |
return this.yaw; | |
} | |
public void setYaw(final int yaw) { | |
this.yaw = yaw; | |
} | |
public byte getXvel() { | |
return this.xvel; | |
} | |
public void setXvel(final byte xvel) { | |
this.xvel = xvel; | |
} | |
public byte getYvel() { | |
return this.yvel; | |
} | |
public void setYvel(final byte yvel) { | |
this.yvel = yvel; | |
} | |
public byte getZvel() { | |
return this.zvel; | |
} | |
public void setZvel(final byte zvel) { | |
this.zvel = zvel; | |
} | |
public boolean isVisible() { | |
return this.visible; | |
} | |
public void setVisible(final boolean visible) { | |
this.visible = visible; | |
} | |
public Object getWorld() { | |
return this.world; | |
} | |
public void setWorld(final Object world) { | |
this.world = world; | |
} | |
public abstract Object getSpawnPacket(); | |
public abstract Object getDestroyPacket(); | |
public abstract Object getMetaPacket(final Object p0); | |
public abstract Object getTeleportPacket(final Location p0); | |
public abstract Object getWatcher(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment