Try fix controllable / sit trait issues

This commit is contained in:
fullwall 2023-02-23 23:52:27 +08:00
parent 61fd34df0b
commit 63f1013d46
5 changed files with 7 additions and 7 deletions

View File

@ -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);

View File

@ -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());

View File

@ -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();
}

View File

@ -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);

View File

@ -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);
}
}