mirror of
https://github.com/FancyInnovations/FancyPlugins.git
synced 2025-12-06 07:43:36 +00:00
Add flag to control the arm swing when updating npc (#106)
* fancynpcs: Add overloaded update and updateForAll methods to skip swing animation. * fancynpcs: remove unnecessary changes to other calls of update(player). * Revert version change * fancynpcs: pull default update(Player) method out to NPC class, and make non-abstract. * fancynpcs: make swinging arm default update behavior.
This commit is contained in:
@@ -118,12 +118,20 @@ public abstract class Npc {
|
|||||||
|
|
||||||
public abstract void lookAt(Player player, Location location);
|
public abstract void lookAt(Player player, Location location);
|
||||||
|
|
||||||
public abstract void update(Player player);
|
public abstract void update(Player player, boolean swingArm);
|
||||||
|
|
||||||
|
public void update(Player player) {
|
||||||
|
update(player, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateForAll(boolean swingArm) {
|
||||||
|
for (Player onlinePlayer : Bukkit.getOnlinePlayers()) {
|
||||||
|
update(onlinePlayer, swingArm);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void updateForAll() {
|
public void updateForAll() {
|
||||||
for (Player onlinePlayer : Bukkit.getOnlinePlayers()) {
|
updateForAll(true);
|
||||||
update(onlinePlayer);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract void move(Player player, boolean swingArm);
|
public abstract void move(Player player, boolean swingArm);
|
||||||
|
|||||||
@@ -190,7 +190,7 @@ public class Npc_1_19_4 extends Npc {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(Player player) {
|
public void update(Player player, boolean swingArm) {
|
||||||
if (npc == null) {
|
if (npc == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -271,7 +271,7 @@ public class Npc_1_19_4 extends Npc {
|
|||||||
refreshEntityData(player);
|
refreshEntityData(player);
|
||||||
|
|
||||||
if (data.isSpawnEntity() && data.getLocation() != null) {
|
if (data.isSpawnEntity() && data.getLocation() != null) {
|
||||||
move(player, true);
|
move(player, swingArm);
|
||||||
}
|
}
|
||||||
|
|
||||||
NpcAttribute playerPoseAttr = FancyNpcsPlugin.get().getAttributeManager().getAttributeByName(org.bukkit.entity.EntityType.PLAYER, "pose");
|
NpcAttribute playerPoseAttr = FancyNpcsPlugin.get().getAttributeManager().getAttributeByName(org.bukkit.entity.EntityType.PLAYER, "pose");
|
||||||
|
|||||||
@@ -191,7 +191,7 @@ public class Npc_1_20_1 extends Npc {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(Player player) {
|
public void update(Player player, boolean swingArm) {
|
||||||
if (npc == null) {
|
if (npc == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -271,7 +271,7 @@ public class Npc_1_20_1 extends Npc {
|
|||||||
refreshEntityData(player);
|
refreshEntityData(player);
|
||||||
|
|
||||||
if (data.isSpawnEntity() && data.getLocation() != null) {
|
if (data.isSpawnEntity() && data.getLocation() != null) {
|
||||||
move(player, true);
|
move(player, swingArm);
|
||||||
}
|
}
|
||||||
|
|
||||||
NpcAttribute playerPoseAttr = FancyNpcsPlugin.get().getAttributeManager().getAttributeByName(org.bukkit.entity.EntityType.PLAYER, "pose");
|
NpcAttribute playerPoseAttr = FancyNpcsPlugin.get().getAttributeManager().getAttributeByName(org.bukkit.entity.EntityType.PLAYER, "pose");
|
||||||
|
|||||||
@@ -188,7 +188,7 @@ public class Npc_1_20_2 extends Npc {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(Player player) {
|
public void update(Player player, boolean swingArm) {
|
||||||
if (npc == null) {
|
if (npc == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -266,7 +266,7 @@ public class Npc_1_20_2 extends Npc {
|
|||||||
refreshEntityData(player);
|
refreshEntityData(player);
|
||||||
|
|
||||||
if (data.isSpawnEntity() && data.getLocation() != null) {
|
if (data.isSpawnEntity() && data.getLocation() != null) {
|
||||||
move(player, true);
|
move(player, swingArm);
|
||||||
}
|
}
|
||||||
|
|
||||||
NpcAttribute playerPoseAttr = FancyNpcsPlugin.get().getAttributeManager().getAttributeByName(org.bukkit.entity.EntityType.PLAYER, "pose");
|
NpcAttribute playerPoseAttr = FancyNpcsPlugin.get().getAttributeManager().getAttributeByName(org.bukkit.entity.EntityType.PLAYER, "pose");
|
||||||
|
|||||||
@@ -187,7 +187,7 @@ public class Npc_1_20_4 extends Npc {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(Player player) {
|
public void update(Player player, boolean swingArm) {
|
||||||
if (npc == null) {
|
if (npc == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -265,7 +265,7 @@ public class Npc_1_20_4 extends Npc {
|
|||||||
refreshEntityData(player);
|
refreshEntityData(player);
|
||||||
|
|
||||||
if (data.isSpawnEntity() && data.getLocation() != null) {
|
if (data.isSpawnEntity() && data.getLocation() != null) {
|
||||||
move(player, true);
|
move(player, swingArm);
|
||||||
}
|
}
|
||||||
|
|
||||||
NpcAttribute playerPoseAttr = FancyNpcsPlugin.get().getAttributeManager().getAttributeByName(org.bukkit.entity.EntityType.PLAYER, "pose");
|
NpcAttribute playerPoseAttr = FancyNpcsPlugin.get().getAttributeManager().getAttributeByName(org.bukkit.entity.EntityType.PLAYER, "pose");
|
||||||
|
|||||||
@@ -187,7 +187,7 @@ public class Npc_1_20_6 extends Npc {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(Player player) {
|
public void update(Player player, boolean swingArm) {
|
||||||
if (npc == null) {
|
if (npc == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -265,7 +265,7 @@ public class Npc_1_20_6 extends Npc {
|
|||||||
refreshEntityData(player);
|
refreshEntityData(player);
|
||||||
|
|
||||||
if (data.isSpawnEntity() && data.getLocation() != null) {
|
if (data.isSpawnEntity() && data.getLocation() != null) {
|
||||||
move(player, true);
|
move(player, swingArm);
|
||||||
}
|
}
|
||||||
|
|
||||||
NpcAttribute playerPoseAttr = FancyNpcsPlugin.get().getAttributeManager().getAttributeByName(org.bukkit.entity.EntityType.PLAYER, "pose");
|
NpcAttribute playerPoseAttr = FancyNpcsPlugin.get().getAttributeManager().getAttributeByName(org.bukkit.entity.EntityType.PLAYER, "pose");
|
||||||
|
|||||||
@@ -199,7 +199,7 @@ public class Npc_1_21_1 extends Npc {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(Player player) {
|
public void update(Player player, boolean swingArm) {
|
||||||
if (npc == null) {
|
if (npc == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -277,7 +277,7 @@ public class Npc_1_21_1 extends Npc {
|
|||||||
refreshEntityData(player);
|
refreshEntityData(player);
|
||||||
|
|
||||||
if (data.isSpawnEntity() && data.getLocation() != null) {
|
if (data.isSpawnEntity() && data.getLocation() != null) {
|
||||||
move(player, true);
|
move(player, swingArm);
|
||||||
}
|
}
|
||||||
|
|
||||||
NpcAttribute playerPoseAttr = FancyNpcsPlugin.get().getAttributeManager().getAttributeByName(org.bukkit.entity.EntityType.PLAYER, "pose");
|
NpcAttribute playerPoseAttr = FancyNpcsPlugin.get().getAttributeManager().getAttributeByName(org.bukkit.entity.EntityType.PLAYER, "pose");
|
||||||
|
|||||||
@@ -210,7 +210,7 @@ public class Npc_1_21_3 extends Npc {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(Player player) {
|
public void update(Player player, boolean swingArm) {
|
||||||
if (npc == null) {
|
if (npc == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -288,7 +288,7 @@ public class Npc_1_21_3 extends Npc {
|
|||||||
refreshEntityData(player);
|
refreshEntityData(player);
|
||||||
|
|
||||||
if (data.isSpawnEntity() && data.getLocation() != null) {
|
if (data.isSpawnEntity() && data.getLocation() != null) {
|
||||||
move(player, true);
|
move(player, swingArm);
|
||||||
}
|
}
|
||||||
|
|
||||||
NpcAttribute playerPoseAttr = FancyNpcsPlugin.get().getAttributeManager().getAttributeByName(org.bukkit.entity.EntityType.PLAYER, "pose");
|
NpcAttribute playerPoseAttr = FancyNpcsPlugin.get().getAttributeManager().getAttributeByName(org.bukkit.entity.EntityType.PLAYER, "pose");
|
||||||
|
|||||||
@@ -210,7 +210,7 @@ public class Npc_1_21_4 extends Npc {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(Player player) {
|
public void update(Player player, boolean swingArm) {
|
||||||
if (npc == null) {
|
if (npc == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -288,7 +288,7 @@ public class Npc_1_21_4 extends Npc {
|
|||||||
refreshEntityData(player);
|
refreshEntityData(player);
|
||||||
|
|
||||||
if (data.isSpawnEntity() && data.getLocation() != null) {
|
if (data.isSpawnEntity() && data.getLocation() != null) {
|
||||||
move(player, true);
|
move(player, swingArm);
|
||||||
}
|
}
|
||||||
|
|
||||||
NpcAttribute playerPoseAttr = FancyNpcsPlugin.get().getAttributeManager().getAttributeByName(org.bukkit.entity.EntityType.PLAYER, "pose");
|
NpcAttribute playerPoseAttr = FancyNpcsPlugin.get().getAttributeManager().getAttributeByName(org.bukkit.entity.EntityType.PLAYER, "pose");
|
||||||
|
|||||||
@@ -208,9 +208,8 @@ public class Npc_1_21_5 extends Npc {
|
|||||||
ClientboundRotateHeadPacket rotateHeadPacket = new ClientboundRotateHeadPacket(npc, (byte) (location.getYaw() * angelMultiplier));
|
ClientboundRotateHeadPacket rotateHeadPacket = new ClientboundRotateHeadPacket(npc, (byte) (location.getYaw() * angelMultiplier));
|
||||||
serverPlayer.connection.send(rotateHeadPacket);
|
serverPlayer.connection.send(rotateHeadPacket);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(Player player) {
|
public void update(Player player, boolean swingArm) {
|
||||||
if (npc == null) {
|
if (npc == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -288,7 +287,7 @@ public class Npc_1_21_5 extends Npc {
|
|||||||
refreshEntityData(player);
|
refreshEntityData(player);
|
||||||
|
|
||||||
if (data.isSpawnEntity() && data.getLocation() != null) {
|
if (data.isSpawnEntity() && data.getLocation() != null) {
|
||||||
move(player, true);
|
move(player, swingArm);
|
||||||
}
|
}
|
||||||
|
|
||||||
NpcAttribute playerPoseAttr = FancyNpcsPlugin.get().getAttributeManager().getAttributeByName(org.bukkit.entity.EntityType.PLAYER, "pose");
|
NpcAttribute playerPoseAttr = FancyNpcsPlugin.get().getAttributeManager().getAttributeByName(org.bukkit.entity.EntityType.PLAYER, "pose");
|
||||||
|
|||||||
@@ -210,7 +210,7 @@ public class Npc_1_21_6 extends Npc {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(Player player) {
|
public void update(Player player, boolean swingArm) {
|
||||||
if (npc == null) {
|
if (npc == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -298,7 +298,7 @@ public class Npc_1_21_6 extends Npc {
|
|||||||
refreshEntityData(player);
|
refreshEntityData(player);
|
||||||
|
|
||||||
if (data.isSpawnEntity() && data.getLocation() != null) {
|
if (data.isSpawnEntity() && data.getLocation() != null) {
|
||||||
move(player, true);
|
move(player, swingArm);
|
||||||
}
|
}
|
||||||
|
|
||||||
NpcAttribute playerPoseAttr = FancyNpcsPlugin.get().getAttributeManager().getAttributeByName(org.bukkit.entity.EntityType.PLAYER, "pose");
|
NpcAttribute playerPoseAttr = FancyNpcsPlugin.get().getAttributeManager().getAttributeByName(org.bukkit.entity.EntityType.PLAYER, "pose");
|
||||||
|
|||||||
Reference in New Issue
Block a user