add hand swinging
This commit is contained in:
parent
828a8a3465
commit
5213476d15
5 changed files with 22 additions and 0 deletions
|
@ -124,4 +124,10 @@ public interface Npc extends PropertyHolder {
|
||||||
* @return The set of players that can currently see this npc
|
* @return The set of players that can currently see this npc
|
||||||
*/
|
*/
|
||||||
Set<Player> getViewers();
|
Set<Player> getViewers();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Swings the entity's hand
|
||||||
|
* @param offHand Should the hand be the offhand
|
||||||
|
*/
|
||||||
|
void swingHand(boolean offHand);
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,6 +73,10 @@ public class PacketEntity implements PropertyHolder {
|
||||||
packetFactory.sendAllMetadata(player, this, properties);
|
packetFactory.sendAllMetadata(player, this, properties);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void swingHand(Player player, boolean offhand) {
|
||||||
|
packetFactory.sendHandSwing(player, this, offhand);
|
||||||
|
}
|
||||||
|
|
||||||
private static int reserveEntityID() {
|
private static int reserveEntityID() {
|
||||||
if (PacketEvents.getAPI().getServerManager().getVersion().isNewerThanOrEquals(ServerVersion.V_1_14)) {
|
if (PacketEvents.getAPI().getServerManager().getVersion().isNewerThanOrEquals(ServerVersion.V_1_14)) {
|
||||||
return Reflections.ATOMIC_ENTITY_ID_FIELD.get().incrementAndGet();
|
return Reflections.ATOMIC_ENTITY_ID_FIELD.get().incrementAndGet();
|
||||||
|
|
|
@ -214,4 +214,8 @@ public class NpcImpl extends Viewable implements Npc {
|
||||||
delete();
|
delete();
|
||||||
this.worldName = world.getName();
|
this.worldName = world.getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void swingHand(boolean offHand) {
|
||||||
|
for (Player viewer : getViewers()) entity.swingHand(viewer, offHand);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,4 +23,5 @@ public interface PacketFactory {
|
||||||
void sendEquipment(Player player, PacketEntity entity, Equipment equipment);
|
void sendEquipment(Player player, PacketEntity entity, Equipment equipment);
|
||||||
void sendMetadata(Player player, PacketEntity entity, List<EntityData> data);
|
void sendMetadata(Player player, PacketEntity entity, List<EntityData> data);
|
||||||
void sendHeadRotation(Player player, PacketEntity entity, float yaw, float pitch);
|
void sendHeadRotation(Player player, PacketEntity entity, float yaw, float pitch);
|
||||||
|
void sendHandSwing(Player player, PacketEntity entity, boolean offHand);
|
||||||
}
|
}
|
||||||
|
|
|
@ -175,4 +175,11 @@ public class V1_8PacketFactory implements PacketFactory {
|
||||||
protected void add(Map<Integer, EntityData> map, EntityData data) {
|
protected void add(Map<Integer, EntityData> map, EntityData data) {
|
||||||
map.put(data.getIndex(), data);
|
map.put(data.getIndex(), data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void sendHandSwing(Player player, PacketEntity entity, boolean offHand) {
|
||||||
|
sendPacket(player, new WrapperPlayServerEntityAnimation(entity.getEntityId(), offHand ?
|
||||||
|
WrapperPlayServerEntityAnimation.EntityAnimationType.SWING_OFF_HAND :
|
||||||
|
WrapperPlayServerEntityAnimation.EntityAnimationType.SWING_MAIN_ARM));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue