From 63f1013d46c92f054187435f0ce111ad20d7f6a8 Mon Sep 17 00:00:00 2001 From: fullwall Date: Thu, 23 Feb 2023 23:52:27 +0800 Subject: [PATCH] Try fix controllable / sit trait issues --- main/src/main/java/net/citizensnpcs/StoredShops.java | 1 - main/src/main/java/net/citizensnpcs/npc/CitizensNPC.java | 3 +-- .../src/main/java/net/citizensnpcs/trait/ArmorStandTrait.java | 4 ++-- main/src/main/java/net/citizensnpcs/trait/Controllable.java | 2 ++ main/src/main/java/net/citizensnpcs/trait/SitTrait.java | 4 ++-- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/main/src/main/java/net/citizensnpcs/StoredShops.java b/main/src/main/java/net/citizensnpcs/StoredShops.java index 39fb86e06..3bec9b9a8 100644 --- a/main/src/main/java/net/citizensnpcs/StoredShops.java +++ b/main/src/main/java/net/citizensnpcs/StoredShops.java @@ -25,7 +25,6 @@ public class StoredShops { public void deleteShop(NPCShop shop) { if (Messaging.isDebugging()) { Messaging.debug("Deleting shop", shop.getName()); - new Exception().printStackTrace(); } if (npcShops.values().contains(shop)) { npcShops.values().remove(shop); diff --git a/main/src/main/java/net/citizensnpcs/npc/CitizensNPC.java b/main/src/main/java/net/citizensnpcs/npc/CitizensNPC.java index 56fdfe86d..605b37654 100644 --- a/main/src/main/java/net/citizensnpcs/npc/CitizensNPC.java +++ b/main/src/main/java/net/citizensnpcs/npc/CitizensNPC.java @@ -328,8 +328,7 @@ public class CitizensNPC extends AbstractNPC { skinnable.getSkinTracker().onSpawnNPC(); } - teleport(at, TeleportCause.PLUGIN); - + NMS.setLocationDirectly(getEntity(), at); NMS.setHeadYaw(getEntity(), at.getYaw()); NMS.setBodyYaw(getEntity(), at.getYaw()); diff --git a/main/src/main/java/net/citizensnpcs/trait/ArmorStandTrait.java b/main/src/main/java/net/citizensnpcs/trait/ArmorStandTrait.java index 958975962..c2e55293a 100644 --- a/main/src/main/java/net/citizensnpcs/trait/ArmorStandTrait.java +++ b/main/src/main/java/net/citizensnpcs/trait/ArmorStandTrait.java @@ -122,12 +122,12 @@ public class ArmorStandTrait extends Trait { } public void setAsHelperEntity(NPC parent) { - npc.addTrait(new ClickRedirectTrait(npc)); + npc.addTrait(new ClickRedirectTrait(parent)); setAsPointEntity(); } public void setAsHelperEntityWithName(NPC parent) { - npc.addTrait(new ClickRedirectTrait(npc)); + npc.addTrait(new ClickRedirectTrait(parent)); setAsPointEntityWithName(); } diff --git a/main/src/main/java/net/citizensnpcs/trait/Controllable.java b/main/src/main/java/net/citizensnpcs/trait/Controllable.java index 55d9739b7..63eae8ab2 100644 --- a/main/src/main/java/net/citizensnpcs/trait/Controllable.java +++ b/main/src/main/java/net/citizensnpcs/trait/Controllable.java @@ -272,6 +272,8 @@ public class Controllable extends Trait implements Toggleable, CommandConfigurab Vector vel = handle.getVelocity(); double oldSpeed = Math.sqrt(vel.getX() * vel.getX() + vel.getZ() * vel.getZ()); double horizontal = NMS.getHorizontalMovement(passenger); + if (Math.abs(Math.abs(horizontal) - 0.98) > 0.02) + return speed; double yaw = passenger.getLocation().getYaw(); if (horizontal > 0.0D) { double dXcos = -Math.sin(yaw * Math.PI / 180.0F); diff --git a/main/src/main/java/net/citizensnpcs/trait/SitTrait.java b/main/src/main/java/net/citizensnpcs/trait/SitTrait.java index 2a0d9af73..750b8c1b6 100644 --- a/main/src/main/java/net/citizensnpcs/trait/SitTrait.java +++ b/main/src/main/java/net/citizensnpcs/trait/SitTrait.java @@ -55,7 +55,7 @@ public class SitTrait extends Trait { } chair = registry.createNPC(EntityType.ARMOR_STAND, ""); chair.getOrAddTrait(ArmorStandTrait.class).setAsHelperEntity(npc); - if (!chair.spawn(sittingAt)) { + if (!chair.spawn(sittingAt.clone())) { chair = null; return; } @@ -66,7 +66,7 @@ public class SitTrait extends Trait { } if (chair.getStoredLocation() != null && chair.getStoredLocation().distance(sittingAt) > 0.05) { - chair.teleport(sittingAt, TeleportCause.PLUGIN); + chair.teleport(sittingAt.clone(), TeleportCause.PLUGIN); } }