commit
e909f28193
|
@ -8,7 +8,7 @@
|
|||
<parent>
|
||||
<artifactId>npclib</artifactId>
|
||||
<groupId>net.jitse</groupId>
|
||||
<version>2.8-SNAPSHOT</version>
|
||||
<version>2.9-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>npclib-api</artifactId>
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
package net.jitse.npclib.api;
|
||||
|
||||
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.api.state.NPCState;
|
||||
import org.bukkit.Location;
|
||||
|
@ -103,6 +104,13 @@ public interface NPC {
|
|||
*/
|
||||
NPC toggleState(NPCState state);
|
||||
|
||||
/**
|
||||
* Plays an animation as the the NPC.
|
||||
*
|
||||
* @param animation The animation to play.
|
||||
*/
|
||||
void playAnimation(NPCAnimation animation);
|
||||
|
||||
/**
|
||||
* Get state of NPC.
|
||||
*
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
package net.jitse.npclib.api.state;
|
||||
|
||||
public enum NPCAnimation {
|
||||
|
||||
SWING_MAINHAND(0),
|
||||
TAKE_DAMAGE(1),
|
||||
SWING_OFFHAND(3),
|
||||
CRITICAL_DAMAGE(4),
|
||||
MAGICAL_DAMAGE(5);
|
||||
|
||||
private int id;
|
||||
|
||||
NPCAnimation(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
}
|
|
@ -11,6 +11,7 @@ import net.jitse.npclib.api.NPC;
|
|||
import net.jitse.npclib.api.events.NPCHideEvent;
|
||||
import net.jitse.npclib.api.events.NPCShowEvent;
|
||||
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.api.state.NPCState;
|
||||
import net.jitse.npclib.hologram.Hologram;
|
||||
|
@ -268,6 +269,16 @@ public abstract class NPCBase implements NPC, NPCPacketHandler {
|
|||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playAnimation(NPCAnimation animation) {
|
||||
for (UUID shownUuid : shown) {
|
||||
Player player = Bukkit.getPlayer(shownUuid);
|
||||
if (player != null && isShown(player)) {
|
||||
sendAnimationPacket(player, animation);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItem(NPCSlot slot) {
|
||||
Objects.requireNonNull(slot, "Slot cannot be null");
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
package net.jitse.npclib.internal;
|
||||
|
||||
import net.jitse.npclib.api.state.NPCAnimation;
|
||||
import net.jitse.npclib.api.state.NPCSlot;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
@ -22,6 +23,8 @@ interface NPCPacketHandler {
|
|||
|
||||
void sendEquipmentPacket(Player player, NPCSlot slot, boolean auto);
|
||||
|
||||
void sendAnimationPacket(Player player, NPCAnimation animation);
|
||||
|
||||
default void sendEquipmentPackets(Player player) {
|
||||
for (NPCSlot slot : NPCSlot.values())
|
||||
sendEquipmentPacket(player, slot, true);
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
<parent>
|
||||
<groupId>net.jitse</groupId>
|
||||
<artifactId>npclib</artifactId>
|
||||
<version>2.8-SNAPSHOT</version>
|
||||
<version>2.9-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>npclib-nms</artifactId>
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
<parent>
|
||||
<groupId>net.jitse</groupId>
|
||||
<artifactId>npclib-nms</artifactId>
|
||||
<version>2.8-SNAPSHOT</version>
|
||||
<version>2.9-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>npclib-nms-v1_10_R1</artifactId>
|
||||
|
|
|
@ -8,6 +8,7 @@ import com.mojang.authlib.GameProfile;
|
|||
import com.mojang.authlib.properties.Property;
|
||||
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;
|
||||
|
@ -109,6 +110,14 @@ public class NPC_v1_10_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);
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
package net.jitse.npclib.nms.v1_10_R1.packets;
|
||||
|
||||
import com.comphenix.tinyprotocol.Reflection;
|
||||
import net.jitse.npclib.api.state.NPCAnimation;
|
||||
import net.minecraft.server.v1_10_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;
|
||||
}
|
||||
|
||||
}
|
|
@ -8,7 +8,7 @@
|
|||
<parent>
|
||||
<groupId>net.jitse</groupId>
|
||||
<artifactId>npclib-nms</artifactId>
|
||||
<version>2.8-SNAPSHOT</version>
|
||||
<version>2.9-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>npclib-nms-v1_11_R1</artifactId>
|
||||
|
|
|
@ -8,6 +8,7 @@ import com.mojang.authlib.GameProfile;
|
|||
import com.mojang.authlib.properties.Property;
|
||||
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;
|
||||
|
@ -109,6 +110,14 @@ public class NPC_v1_11_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);
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
package net.jitse.npclib.nms.v1_11_R1.packets;
|
||||
|
||||
import com.comphenix.tinyprotocol.Reflection;
|
||||
import net.jitse.npclib.api.state.NPCAnimation;
|
||||
import net.minecraft.server.v1_11_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;
|
||||
}
|
||||
|
||||
}
|
|
@ -8,7 +8,7 @@
|
|||
<parent>
|
||||
<groupId>net.jitse</groupId>
|
||||
<artifactId>npclib-nms</artifactId>
|
||||
<version>2.8-SNAPSHOT</version>
|
||||
<version>2.9-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>npclib-nms-v1_12_R1</artifactId>
|
||||
|
|
|
@ -8,6 +8,7 @@ import com.mojang.authlib.GameProfile;
|
|||
import com.mojang.authlib.properties.Property;
|
||||
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;
|
||||
|
@ -109,6 +110,14 @@ public class NPC_v1_12_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);
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
package net.jitse.npclib.nms.v1_12_R1.packets;
|
||||
|
||||
import com.comphenix.tinyprotocol.Reflection;
|
||||
import net.jitse.npclib.api.state.NPCAnimation;
|
||||
import net.minecraft.server.v1_12_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;
|
||||
}
|
||||
|
||||
}
|
|
@ -8,7 +8,7 @@
|
|||
<parent>
|
||||
<groupId>net.jitse</groupId>
|
||||
<artifactId>npclib-nms</artifactId>
|
||||
<version>2.8-SNAPSHOT</version>
|
||||
<version>2.9-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>npclib-nms-v1_13_R1</artifactId>
|
||||
|
|
|
@ -8,6 +8,7 @@ import com.mojang.authlib.GameProfile;
|
|||
import com.mojang.authlib.properties.Property;
|
||||
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;
|
||||
|
@ -109,6 +110,14 @@ public class NPC_v1_13_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);
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
package net.jitse.npclib.nms.v1_13_R1.packets;
|
||||
|
||||
import com.comphenix.tinyprotocol.Reflection;
|
||||
import net.jitse.npclib.api.state.NPCAnimation;
|
||||
import net.minecraft.server.v1_13_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;
|
||||
}
|
||||
|
||||
}
|
|
@ -8,7 +8,7 @@
|
|||
<parent>
|
||||
<groupId>net.jitse</groupId>
|
||||
<artifactId>npclib-nms</artifactId>
|
||||
<version>2.8-SNAPSHOT</version>
|
||||
<version>2.9-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>npclib-nms-v1_13_R2</artifactId>
|
||||
|
|
|
@ -8,6 +8,7 @@ import com.mojang.authlib.GameProfile;
|
|||
import com.mojang.authlib.properties.Property;
|
||||
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;
|
||||
|
@ -109,6 +110,14 @@ public class NPC_v1_13_R2 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);
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
package net.jitse.npclib.nms.v1_13_R2.packets;
|
||||
|
||||
import com.comphenix.tinyprotocol.Reflection;
|
||||
import net.jitse.npclib.api.state.NPCAnimation;
|
||||
import net.minecraft.server.v1_13_R2.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;
|
||||
}
|
||||
|
||||
}
|
|
@ -8,7 +8,7 @@
|
|||
<parent>
|
||||
<groupId>net.jitse</groupId>
|
||||
<artifactId>npclib-nms</artifactId>
|
||||
<version>2.8-SNAPSHOT</version>
|
||||
<version>2.9-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>npclib-nms-v1_14_R1</artifactId>
|
||||
|
|
|
@ -4,6 +4,7 @@ import com.mojang.authlib.GameProfile;
|
|||
import com.mojang.authlib.properties.Property;
|
||||
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;
|
||||
|
@ -105,6 +106,14 @@ public class NPC_v1_14_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);
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
package net.jitse.npclib.nms.v1_14_R1.packets;
|
||||
|
||||
import com.comphenix.tinyprotocol.Reflection;
|
||||
import net.jitse.npclib.api.state.NPCAnimation;
|
||||
import net.minecraft.server.v1_14_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;
|
||||
}
|
||||
|
||||
}
|
|
@ -8,7 +8,7 @@
|
|||
<parent>
|
||||
<groupId>net.jitse</groupId>
|
||||
<artifactId>npclib-nms</artifactId>
|
||||
<version>2.8-SNAPSHOT</version>
|
||||
<version>2.9-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>npclib-nms-v1_15_R1</artifactId>
|
||||
|
|
|
@ -4,6 +4,7 @@ import com.mojang.authlib.GameProfile;
|
|||
import com.mojang.authlib.properties.Property;
|
||||
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;
|
||||
|
@ -106,6 +107,14 @@ public class NPC_v1_15_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);
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
package net.jitse.npclib.nms.v1_15_R1.packets;
|
||||
|
||||
import com.comphenix.tinyprotocol.Reflection;
|
||||
import net.jitse.npclib.api.state.NPCAnimation;
|
||||
import net.minecraft.server.v1_15_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;
|
||||
}
|
||||
|
||||
}
|
|
@ -8,7 +8,7 @@
|
|||
<parent>
|
||||
<groupId>net.jitse</groupId>
|
||||
<artifactId>npclib-nms</artifactId>
|
||||
<version>2.8-SNAPSHOT</version>
|
||||
<version>2.9-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>npclib-nms-v1_16_R1</artifactId>
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
|
@ -8,7 +8,7 @@
|
|||
<parent>
|
||||
<groupId>net.jitse</groupId>
|
||||
<artifactId>npclib-nms</artifactId>
|
||||
<version>2.8-SNAPSHOT</version>
|
||||
<version>2.9-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>npclib-nms-v1_8_R2</artifactId>
|
||||
|
|
|
@ -8,6 +8,7 @@ import com.mojang.authlib.GameProfile;
|
|||
import com.mojang.authlib.properties.Property;
|
||||
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;
|
||||
|
@ -114,6 +115,18 @@ public class NPC_v1_8_R2 extends NPCBase {
|
|||
playerConnection.sendPacket(packet);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendAnimationPacket(Player player, NPCAnimation animation) {
|
||||
if(animation == NPCAnimation.SWING_OFFHAND) {
|
||||
throw new IllegalArgumentException("Offhand Swing Animations are only available on 1.9 and up.");
|
||||
}
|
||||
|
||||
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);
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
package net.jitse.npclib.nms.v1_8_R2.packets;
|
||||
|
||||
import com.comphenix.tinyprotocol.Reflection;
|
||||
import net.jitse.npclib.api.state.NPCAnimation;
|
||||
import net.minecraft.server.v1_8_R2.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;
|
||||
}
|
||||
|
||||
}
|
|
@ -8,7 +8,7 @@
|
|||
<parent>
|
||||
<groupId>net.jitse</groupId>
|
||||
<artifactId>npclib-nms</artifactId>
|
||||
<version>2.8-SNAPSHOT</version>
|
||||
<version>2.9-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>npclib-nms-v1_8_R3</artifactId>
|
||||
|
|
|
@ -8,6 +8,7 @@ import com.mojang.authlib.GameProfile;
|
|||
import com.mojang.authlib.properties.Property;
|
||||
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;
|
||||
|
@ -115,6 +116,18 @@ public class NPC_v1_8_R3 extends NPCBase {
|
|||
playerConnection.sendPacket(packet);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendAnimationPacket(Player player, NPCAnimation animation) {
|
||||
if(animation == NPCAnimation.SWING_OFFHAND) {
|
||||
throw new IllegalArgumentException("Offhand Swing Animations are only available on 1.9 and up.");
|
||||
}
|
||||
|
||||
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);
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
package net.jitse.npclib.nms.v1_8_R3.packets;
|
||||
|
||||
import com.comphenix.tinyprotocol.Reflection;
|
||||
import net.jitse.npclib.api.state.NPCAnimation;
|
||||
import net.minecraft.server.v1_8_R3.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;
|
||||
}
|
||||
|
||||
}
|
|
@ -8,7 +8,7 @@
|
|||
<parent>
|
||||
<groupId>net.jitse</groupId>
|
||||
<artifactId>npclib-nms</artifactId>
|
||||
<version>2.8-SNAPSHOT</version>
|
||||
<version>2.9-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>npclib-nms-v1_9_R1</artifactId>
|
||||
|
|
|
@ -8,6 +8,7 @@ import com.mojang.authlib.GameProfile;
|
|||
import com.mojang.authlib.properties.Property;
|
||||
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;
|
||||
|
@ -109,6 +110,14 @@ public class NPC_v1_9_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);
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
package net.jitse.npclib.nms.v1_9_R1.packets;
|
||||
|
||||
import com.comphenix.tinyprotocol.Reflection;
|
||||
import net.jitse.npclib.api.state.NPCAnimation;
|
||||
import net.minecraft.server.v1_9_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;
|
||||
}
|
||||
|
||||
}
|
|
@ -8,7 +8,7 @@
|
|||
<parent>
|
||||
<groupId>net.jitse</groupId>
|
||||
<artifactId>npclib-nms</artifactId>
|
||||
<version>2.8-SNAPSHOT</version>
|
||||
<version>2.9-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>npclib-nms-v1_9_R2</artifactId>
|
||||
|
|
|
@ -8,6 +8,7 @@ import com.mojang.authlib.GameProfile;
|
|||
import com.mojang.authlib.properties.Property;
|
||||
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;
|
||||
|
@ -109,6 +110,14 @@ public class NPC_v1_9_R2 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);
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
package net.jitse.npclib.nms.v1_9_R2.packets;
|
||||
|
||||
import com.comphenix.tinyprotocol.Reflection;
|
||||
import net.jitse.npclib.api.state.NPCAnimation;
|
||||
import net.minecraft.server.v1_9_R2.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;
|
||||
}
|
||||
|
||||
}
|
|
@ -8,7 +8,7 @@
|
|||
<parent>
|
||||
<groupId>net.jitse</groupId>
|
||||
<artifactId>npclib</artifactId>
|
||||
<version>2.8-SNAPSHOT</version>
|
||||
<version>2.9-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>npclib-plugin</artifactId>
|
||||
|
|
Loading…
Reference in New Issue