Search in sources :

Example 1 with PacketPlayOutNamedEntitySpawn

use of net.minecraft.network.protocol.game.PacketPlayOutNamedEntitySpawn in project Nexus by ProjectEdenGG.

the class FakeNPCPacketUtils method spawnFakeNPC.

// NPCs
public static void spawnFakeNPC(HasPlayer hasPlayer, FakeNPC fakeNPC) {
    EntityPlayer entityPlayer = fakeNPC.getEntityPlayer();
    PacketPlayOutPlayerInfo playerInfoPacket = new PacketPlayOutPlayerInfo(EnumPlayerInfoAction.a, entityPlayer);
    PacketPlayOutNamedEntitySpawn spawnPacket = new PacketPlayOutNamedEntitySpawn(entityPlayer);
    PacketPlayOutEntityHeadRotation headRotationPacket = new PacketPlayOutEntityHeadRotation(entityPlayer, PacketUtils.encodeAngle(fakeNPC.getLocation().getYaw()));
    // untested
    DataWatcher dataWatcher = entityPlayer.getDataWatcher();
    dataWatcher.set(new DataWatcherObject<>(16, DataWatcherRegistry.a), (byte) 127);
    sendPacket(hasPlayer, playerInfoPacket, spawnPacket, headRotationPacket);
    spawnHologram(hasPlayer, fakeNPC);
}
Also used : PacketPlayOutNamedEntitySpawn(net.minecraft.network.protocol.game.PacketPlayOutNamedEntitySpawn) PacketPlayOutEntityHeadRotation(net.minecraft.network.protocol.game.PacketPlayOutEntityHeadRotation) EntityPlayer(net.minecraft.server.level.EntityPlayer) PacketPlayOutPlayerInfo(net.minecraft.network.protocol.game.PacketPlayOutPlayerInfo) DataWatcher(net.minecraft.network.syncher.DataWatcher)

Aggregations

PacketPlayOutEntityHeadRotation (net.minecraft.network.protocol.game.PacketPlayOutEntityHeadRotation)1 PacketPlayOutNamedEntitySpawn (net.minecraft.network.protocol.game.PacketPlayOutNamedEntitySpawn)1 PacketPlayOutPlayerInfo (net.minecraft.network.protocol.game.PacketPlayOutPlayerInfo)1 DataWatcher (net.minecraft.network.syncher.DataWatcher)1 EntityPlayer (net.minecraft.server.level.EntityPlayer)1