@Override public PacketBlockBreakAnimation setEntityId(Player player) { Object nmsPlayer = ReflectionAPI.invokeMethod(player, ReflectionAPI.getMethod(player, "getHandle")); return this.setEntityId( (int) ReflectionAPI.invokeMethod(nmsPlayer, ReflectionAPI.getMethod(nmsPlayer, "getId"))); }
public CraftPacketBlockBreakAnimation(Player player, Location blockLocation, byte destroyStage) { Object nmsPlayer = ReflectionAPI.invokeMethod(player, ReflectionAPI.getMethod(player, "getHandle")); this.entityId = (int) ReflectionAPI.invokeMethod(nmsPlayer, ReflectionAPI.getMethod(nmsPlayer, "getId")); this.blockLocation = blockLocation; this.destroyStage = destroyStage; }
@Override public void send(Player player) { // Get packet class Class<?> packetClass = ReflectionAPI.getNmsClass("PacketPlayOutBlockBreakAnimation"); // Create packet Object packet = ReflectionAPI.newInstance( ReflectionAPI.getConstructor( packetClass, Integer.class, ReflectionAPI.getNmsClass("BlockPosition"), Integer.class), this.entityId, BlockPositionWrapper.fromLocation(this.blockLocation), this.destroyStage); // Send the packet. ReflectionAPI.NmsClass.sendPacket(player, packet); }