Search in sources :

Example 6 with PlayerConnection

use of net.minecraft.server.v1_13_R2.PlayerConnection in project WLib by WizardlyBump17.

the class EntityAdapter method sendPacket.

@Override
public void sendPacket(Object... packets) {
    if (!(entity instanceof Player))
        return;
    EntityPlayer player = ((CraftPlayer) entity).getHandle();
    PlayerConnection connection = player.playerConnection;
    for (Object packet : packets) {
        if (!(packet instanceof Packet))
            continue;
        connection.sendPacket(((Packet<?>) packet));
    }
}
Also used : Packet(net.minecraft.server.v1_12_R1.Packet) Player(org.bukkit.entity.Player) EntityPlayer(net.minecraft.server.v1_12_R1.EntityPlayer) CraftPlayer(org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer) EntityPlayer(net.minecraft.server.v1_12_R1.EntityPlayer) CraftPlayer(org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer) PlayerConnection(net.minecraft.server.v1_12_R1.PlayerConnection)

Example 7 with PlayerConnection

use of net.minecraft.server.v1_13_R2.PlayerConnection in project WLib by WizardlyBump17.

the class EntityAdapter method sendPacket.

@Override
public void sendPacket(Object... packets) {
    if (!(entity instanceof Player))
        return;
    EntityPlayer player = ((CraftPlayer) entity).getHandle();
    PlayerConnection connection = player.playerConnection;
    for (Object packet : packets) {
        if (!(packet instanceof Packet))
            continue;
        connection.sendPacket(((Packet<?>) packet));
    }
}
Also used : Packet(net.minecraft.server.v1_15_R1.Packet) Player(org.bukkit.entity.Player) CraftPlayer(org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer) EntityPlayer(net.minecraft.server.v1_15_R1.EntityPlayer) EntityPlayer(net.minecraft.server.v1_15_R1.EntityPlayer) CraftPlayer(org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer) PlayerConnection(net.minecraft.server.v1_15_R1.PlayerConnection)

Example 8 with PlayerConnection

use of net.minecraft.server.v1_13_R2.PlayerConnection in project Citizens2 by CitizensDev.

the class EntityHumanNPC method initialise.

private void initialise(MinecraftServer minecraftServer) {
    Socket socket = new EmptySocket();
    NetworkManager conn = null;
    try {
        conn = new EmptyNetworkManager(EnumProtocolDirection.CLIENTBOUND);
        playerConnection = new EmptyNetHandler(minecraftServer, conn, this);
        conn.setPacketListener(playerConnection);
        socket.close();
    } catch (IOException e) {
    // swallow
    }
    AttributeInstance range = getAttributeInstance(GenericAttributes.FOLLOW_RANGE);
    if (range == null) {
        range = getAttributeMap().b(GenericAttributes.FOLLOW_RANGE);
    }
    range.setValue(Setting.DEFAULT_PATHFINDING_RANGE.asDouble());
    controllerJump = new PlayerControllerJump(this);
    controllerLook = new PlayerControllerLook(this);
    controllerMove = new PlayerControllerMove(this);
    navigation = new PlayerNavigation(this, world);
    invulnerableTicks = 0;
    // the default (0) breaks step climbing
    NMS.setStepHeight(getBukkitEntity(), 1);
    setSkinFlags((byte) 0xFF);
    EmptyAdvancementDataPlayer.clear(this.getAdvancementData());
    try {
        ADVANCEMENT_DATA_PLAYER.invoke(this, new EmptyAdvancementDataPlayer(minecraftServer, CitizensAPI.getDataFolder().getParentFile(), this));
    } catch (Throwable e) {
        e.printStackTrace();
    }
}
Also used : EmptyNetworkManager(net.citizensnpcs.nms.v1_13_R2.network.EmptyNetworkManager) PlayerControllerLook(net.citizensnpcs.nms.v1_13_R2.util.PlayerControllerLook) EmptySocket(net.citizensnpcs.nms.v1_13_R2.network.EmptySocket) IOException(java.io.IOException) EmptyNetHandler(net.citizensnpcs.nms.v1_13_R2.network.EmptyNetHandler) PlayerControllerMove(net.citizensnpcs.nms.v1_13_R2.util.PlayerControllerMove) PlayerNavigation(net.citizensnpcs.nms.v1_13_R2.util.PlayerNavigation) AttributeInstance(net.minecraft.server.v1_13_R2.AttributeInstance) PlayerControllerJump(net.citizensnpcs.nms.v1_13_R2.util.PlayerControllerJump) EmptyAdvancementDataPlayer(net.citizensnpcs.nms.v1_13_R2.util.EmptyAdvancementDataPlayer) NetworkManager(net.minecraft.server.v1_13_R2.NetworkManager) EmptyNetworkManager(net.citizensnpcs.nms.v1_13_R2.network.EmptyNetworkManager) Socket(java.net.Socket) EmptySocket(net.citizensnpcs.nms.v1_13_R2.network.EmptySocket)

Example 9 with PlayerConnection

use of net.minecraft.server.v1_13_R2.PlayerConnection in project MechanicsMain by WeaponMechanics.

the class FakeEntity_1_13_R2 method show.

@Override
public void show(@NotNull Player player) {
    PlayerConnection connection = ((CraftPlayer) player).getHandle().playerConnection;
    if (connections.contains(connection))
        throw new IllegalArgumentException();
    connection.sendPacket(type.isAlive() ? new PacketPlayOutSpawnEntityLiving((EntityLiving) entity) : new PacketPlayOutSpawnEntity(entity, type == EntityType.FALLING_BLOCK ? Block.getCombinedId(block) : 0));
    connection.sendPacket(new PacketPlayOutEntityMetadata(cache, entity.getDataWatcher(), true));
    connection.sendPacket(new PacketPlayOutEntityLook(cache, convertYaw(getYaw()), convertPitch(getPitch()), false));
    connection.sendPacket(new PacketPlayOutEntityVelocity(cache, motion.getX(), motion.getY(), motion.getZ()));
    connection.sendPacket(new PacketPlayOutEntityHeadRotation(entity, convertYaw(getYaw())));
    PacketPlayOutEntityEquipment[] equipment = getEquipmentPacket();
    if (equipment != null) {
        for (PacketPlayOutEntityEquipment packet : equipment) {
            connection.sendPacket(packet);
        }
    }
    // Inject the player's packet connection into this listener, so we can
    // show the player position/velocity/rotation changes
    connections.add(connection);
}
Also used : PacketPlayOutEntityLook(net.minecraft.server.v1_13_R2.PacketPlayOutEntity.PacketPlayOutEntityLook)

Example 10 with PlayerConnection

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;
}
Also used : ParallelWorld(thpmc.engine.api.world.parallel.ParallelWorld) ParallelUniverse(thpmc.engine.api.world.parallel.ParallelUniverse) EntityPlayer(net.minecraft.server.v1_16_R3.EntityPlayer) CraftPlayer(org.bukkit.craftbukkit.v1_16_R3.entity.CraftPlayer) World(org.bukkit.World) ParallelWorld(thpmc.engine.api.world.parallel.ParallelWorld) PlayerConnection(net.minecraft.server.v1_16_R3.PlayerConnection)

Aggregations

Player (org.bukkit.entity.Player)6 EntityPlayer (net.minecraft.server.v1_16_R3.EntityPlayer)3 PlayerConnection (net.minecraft.server.v1_16_R3.PlayerConnection)3 CraftPlayer (org.bukkit.craftbukkit.v1_16_R3.entity.CraftPlayer)3 GameProfile (com.mojang.authlib.GameProfile)2 PacketPlayOutEntityLook (net.minecraft.server.v1_13_R2.PacketPlayOutEntity.PacketPlayOutEntityLook)2 EntityPlayer (net.minecraft.server.v1_15_R1.EntityPlayer)2 PlayerConnection (net.minecraft.server.v1_15_R1.PlayerConnection)2 PlayerConnection (net.minecraft.server.v1_8_R3.PlayerConnection)2 World (org.bukkit.World)2 CraftPlayer (org.bukkit.craftbukkit.v1_13_R2.entity.CraftPlayer)2 CraftPlayer (org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer)2 CraftPlayer (org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer)2 ParallelUniverse (thpmc.engine.api.world.parallel.ParallelUniverse)2 ParallelWorld (thpmc.engine.api.world.parallel.ParallelWorld)2 Property (com.mojang.authlib.properties.Property)1 IOException (java.io.IOException)1 Socket (java.net.Socket)1 EmptyNetHandler (net.citizensnpcs.nms.v1_13_R2.network.EmptyNetHandler)1 EmptyNetworkManager (net.citizensnpcs.nms.v1_13_R2.network.EmptyNetworkManager)1