/** * Modifies location information of the given Spawn Packet. * * @param entitySpawnPacket SquidSpawn or GuardianSpawn packet for the entity. * @param location location the entity should be spawned at. * @return beam packet used to spawn for players. */ public static WrappedBeamPacket modifyPacketEntitySpawn( WrappedBeamPacket entitySpawnPacket, Location location) { PacketContainer container = entitySpawnPacket.getHandle(); container.getIntegers().write(2, (int) Math.floor(location.getX() * 32.0)); container.getIntegers().write(3, (int) Math.floor(location.getY() * 32.0)); container.getIntegers().write(4, (int) Math.floor(location.getZ() * 32.0)); container.getBytes().write(0, (byte) (location.getYaw() * 256.0F / 360.0F)); container.getBytes().write(1, (byte) (location.getPitch() * 256.0F / 360.0F)); return entitySpawnPacket; }
/** * Creates a packet to spawn a squid at the location. * * @param location location to spawn the squid. * @return beam packet used to spawn for players. */ public static WrappedBeamPacket createPacketSquidSpawn(Location location) { PacketContainer container = new PacketContainer(SPAWN_ENTITY_LIVING); container.getIntegers().write(0, EIDGen.generateEID()); container.getIntegers().write(1, 94); container.getIntegers().write(2, (int) Math.floor(location.getX() * 32.0)); container.getIntegers().write(3, (int) Math.floor(location.getY() * 32.0)); container.getIntegers().write(4, (int) Math.floor(location.getZ() * 32.0)); container.getBytes().write(0, (byte) (location.getYaw() * 256.0F / 360.0F)); container.getBytes().write(1, (byte) (location.getPitch() * 256.0F / 360.0F)); WrappedDataWatcher watcher = new WrappedDataWatcher(); watcher.setObject(0, (byte) 32); container.getDataWatcherModifier().write(0, watcher); return new WrappedBeamPacket(container); }