use of net.minecraft.server.v1_13_R2.PlayerConnection in project DragonsOnline by UniverseCraft.
the class PlayerNPC116R3 method spawn.
public void spawn() {
registry.unregister(this);
uuid = UUID.randomUUID();
this.isDestroyed = false;
DedicatedServer server = ((CraftServer) Bukkit.getServer()).getServer();
WorldServer world = ((CraftWorld) location.getWorld()).getHandle();
// displayName);
GameProfile gameProfile = new GameProfile(uuid, "");
gameProfile.getProperties().clear();
gameProfile.getProperties().put("textures", new Property("textures", texture, signature));
this.handle = new EntityPlayer(server, world, gameProfile, new PlayerInteractManager(world));
handle.persist = true;
handle.collides = false;
handle.setCustomNameVisible(false);
handle.setInvulnerable(npc.isImmortal());
handle.playerConnection = new PlayerConnection(((CraftServer) Bukkit.getServer()).getServer(), new NetworkManager(EnumProtocolDirection.SERVERBOUND), handle);
((CraftWorld) location.getWorld()).addEntity(handle, CreatureSpawnEvent.SpawnReason.CUSTOM);
handle.setLocation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
registry.register(this);
for (Entity e : getEntity().getNearbyEntities(SPAWN_RADIUS, SPAWN_RADIUS, SPAWN_RADIUS)) {
if (e instanceof Player) {
registry.updateSpawns((Player) e, true);
}
}
}
use of net.minecraft.server.v1_13_R2.PlayerConnection in project THP-Engine by TheHollowPlanetMC.
the class FlyPacketHandler method rewrite.
@Override
public Object rewrite(Object packet, EnginePlayer EnginePlayer, boolean cacheSetting) {
ParallelUniverse universe = EnginePlayer.getUniverse();
if (universe == null)
return packet;
World world = EnginePlayer.getBukkitPlayer().getWorld();
String worldName = world.getName();
ParallelWorld parallelWorld = universe.getWorld(worldName);
EntityPlayer entityPlayer = ((CraftPlayer) EnginePlayer.getBukkitPlayer()).getHandle();
int x = NumberConversions.floor(entityPlayer.locX());
int y = NumberConversions.floor(entityPlayer.locY());
int z = NumberConversions.floor(entityPlayer.locZ());
int downY = y - 1;
downY = Math.max(0, downY);
if (parallelWorld.hasBlockData(x, y, z) || parallelWorld.hasBlockData(x, downY, z)) {
try {
PlayerConnection playerConnection = entityPlayer.playerConnection;
C.set(playerConnection, 0);
E.set(playerConnection, 0);
} catch (Exception e) {
e.printStackTrace();
}
}
return packet;
}
use of net.minecraft.server.v1_13_R2.PlayerConnection in project MechanicsMain by WeaponMechanics.
the class FakeEntity_1_13_R2 method show.
public void show() {
// Construct the packets out of the loop to save resources, they will
// be the same for each Player.
Packet<?> spawn = type.isAlive() ? new PacketPlayOutSpawnEntityLiving((EntityLiving) entity) : new PacketPlayOutSpawnEntity(entity, type == EntityType.FALLING_BLOCK ? Block.getCombinedId(block) : 0);
PacketPlayOutEntityMetadata meta = new PacketPlayOutEntityMetadata(cache, entity.getDataWatcher(), true);
PacketPlayOutEntityHeadRotation head = new PacketPlayOutEntityHeadRotation(entity, convertYaw(getYaw()));
PacketPlayOutEntityLook look = new PacketPlayOutEntityLook(cache, convertYaw(getYaw()), convertPitch(getPitch()), false);
PacketPlayOutEntityVelocity velocity = new PacketPlayOutEntityVelocity(cache, motion.getX(), motion.getY(), motion.getZ());
for (Player temp : DistanceUtil.getPlayersInRange(location)) {
PlayerConnection connection = ((CraftPlayer) temp).getHandle().playerConnection;
if (connections.contains(connection)) {
continue;
}
connection.sendPacket(spawn);
connection.sendPacket(meta);
connection.sendPacket(head);
connection.sendPacket(velocity);
connection.sendPacket(look);
PacketPlayOutEntityEquipment[] equipment = getEquipmentPacket();
if (equipment != null) {
for (PacketPlayOutEntityEquipment packet : equipment) {
connection.sendPacket(packet);
}
}
connections.add(connection);
}
}
use of net.minecraft.server.v1_13_R2.PlayerConnection in project HitW-plugin by Blackoutburst.
the class GameUtils method sendTitle.
public static void sendTitle(Player player, String title, String subtitle, int fadeIn, int stay, int fadeOut) {
CraftPlayer craftplayer = (CraftPlayer) player;
PlayerConnection connection = craftplayer.getHandle().playerConnection;
IChatBaseComponent titleJSON = ChatSerializer.a("{'text': '" + title + "'}");
IChatBaseComponent subtitleJSON = ChatSerializer.a("{'text': '" + subtitle + "'}");
PacketPlayOutTitle timePacket = new PacketPlayOutTitle(fadeIn, stay, fadeOut);
PacketPlayOutTitle titlePacket = new PacketPlayOutTitle(EnumTitleAction.TITLE, titleJSON);
PacketPlayOutTitle subtitlePacket = new PacketPlayOutTitle(EnumTitleAction.SUBTITLE, subtitleJSON);
connection.sendPacket(timePacket);
connection.sendPacket(titlePacket);
connection.sendPacket(subtitlePacket);
}
use of net.minecraft.server.v1_13_R2.PlayerConnection in project SkinChangerAPI by gabrielmercier.
the class SkinChangerAPI method change.
/**
* Change the player skin.
*
* @param player The targeted player.
* @param skinProperty The property of the new player's skin.
*/
public static void change(Player player, Property skinProperty) {
// Init the player's connection
GameProfile profile = ((CraftPlayer) player).getHandle().getProfile();
PlayerConnection connection = ((CraftPlayer) player).getHandle().playerConnection;
// Send the packets
connection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, ((CraftPlayer) player).getHandle()));
profile.getProperties().removeAll("textures");
profile.getProperties().put("textures", skinProperty);
connection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, ((CraftPlayer) player).getHandle()));
}
Aggregations