Added Animations
This commit is contained in:
@@ -5,6 +5,7 @@ import com.mojang.authlib.properties.Property;
|
||||
import com.mojang.datafixers.util.Pair;
|
||||
import net.jitse.npclib.NPCLib;
|
||||
import net.jitse.npclib.api.skin.Skin;
|
||||
import net.jitse.npclib.api.state.NPCAnimation;
|
||||
import net.jitse.npclib.api.state.NPCSlot;
|
||||
import net.jitse.npclib.hologram.Hologram;
|
||||
import net.jitse.npclib.internal.MinecraftVersion;
|
||||
@@ -30,6 +31,7 @@ public class NPC_v1_16_R1 extends NPCBase {
|
||||
private PacketPlayOutPlayerInfo packetPlayOutPlayerInfoAdd, packetPlayOutPlayerInfoRemove;
|
||||
private PacketPlayOutEntityHeadRotation packetPlayOutEntityHeadRotation;
|
||||
private PacketPlayOutEntityDestroy packetPlayOutEntityDestroy;
|
||||
private PacketPlayOutAnimation packetPlayOutAnimation;
|
||||
|
||||
public NPC_v1_16_R1(NPCLib instance, List<String> lines) {
|
||||
super(instance, lines);
|
||||
@@ -109,6 +111,14 @@ public class NPC_v1_16_R1 extends NPCBase {
|
||||
playerConnection.sendPacket(packet);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendAnimationPacket(Player player, NPCAnimation animation) {
|
||||
PlayerConnection playerConnection = ((CraftPlayer) player).getHandle().playerConnection;
|
||||
|
||||
PacketPlayOutAnimation packet = new PacketPlayOutAnimationWrapper().create(animation, entityId);
|
||||
playerConnection.sendPacket(packet);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSkin(Skin skin) {
|
||||
GameProfile newProfile = new GameProfile(uuid, name);
|
||||
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
package net.jitse.npclib.nms.v1_16_R1.packets;
|
||||
|
||||
import com.comphenix.tinyprotocol.Reflection;
|
||||
import net.jitse.npclib.api.state.NPCAnimation;
|
||||
import net.minecraft.server.v1_16_R1.PacketPlayOutAnimation;
|
||||
|
||||
public class PacketPlayOutAnimationWrapper {
|
||||
|
||||
public PacketPlayOutAnimation create(NPCAnimation npcAnimation, int entityId) {
|
||||
PacketPlayOutAnimation packetPlayOutAnimation = new PacketPlayOutAnimation();
|
||||
|
||||
Reflection.getField(packetPlayOutAnimation.getClass(), "a", int.class)
|
||||
.set(packetPlayOutAnimation, entityId);
|
||||
Reflection.getField(packetPlayOutAnimation.getClass(), "b", int.class)
|
||||
.set(packetPlayOutAnimation, npcAnimation.getId());
|
||||
|
||||
return packetPlayOutAnimation;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user