Add quotes around commands

This commit is contained in:
fullwall 2024-07-06 22:13:27 +08:00
parent 71eed123b2
commit 4ba83dd520
32 changed files with 58 additions and 66 deletions

View File

@ -117,7 +117,7 @@ public class Settings {
DEFAULT_LOOK_CLOSE("Enable look close by default", "npc.default.look-close.enabled", false), DEFAULT_LOOK_CLOSE("Enable look close by default", "npc.default.look-close.enabled", false),
DEFAULT_LOOK_CLOSE_RANGE("Default look close range in blocks", "npc.default.look-close.range", 10), DEFAULT_LOOK_CLOSE_RANGE("Default look close range in blocks", "npc.default.look-close.range", 10),
DEFAULT_NAME_HOLOGRAM_RENDERER( DEFAULT_NAME_HOLOGRAM_RENDERER(
"The default renderer for name holograms, must be one of the following:<br>interaction - matches inbuilt nametags most closely<br>display - allows for different colored backgrounds<br>display_vehicle - allows for different colored backgrounds<br>armorstand - the most stable option, very very small hit to client FPS compared to other options", "The default renderer for name holograms, must be one of the following:<br>interaction - matches inbuilt nametags most closely<br>display - allows for different colored backgrounds<br>display_vehicle - allows for different colored backgrounds<br>armorstand - the most stable option, very very small hit to client FPS compared to other options<br>armorstand_vehicle - the most stable option, very very small hit to client FPS compared to other options",
"npc.hologram.default-name-renderer", ""), "npc.hologram.default-name-renderer", ""),
DEFAULT_NPC_HOLOGRAM_LINE_HEIGHT("Default distance between hologram lines", "npc.hologram.default-line-height", DEFAULT_NPC_HOLOGRAM_LINE_HEIGHT("Default distance between hologram lines", "npc.hologram.default-line-height",
0.4D), 0.4D),

View File

@ -26,7 +26,6 @@ import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.api.npc.NPCRegistry; import net.citizensnpcs.api.npc.NPCRegistry;
import net.citizensnpcs.api.util.Messaging; import net.citizensnpcs.api.util.Messaging;
import net.citizensnpcs.util.Messages; import net.citizensnpcs.util.Messages;
import net.citizensnpcs.util.Util;
public class NPCCommandSelector extends NumericPrompt { public class NPCCommandSelector extends NumericPrompt {
private final Callback callback; private final Callback callback;
@ -114,7 +113,7 @@ public class NPCCommandSelector extends NumericPrompt {
for (NPC test : npcRegistry) { for (NPC test : npcRegistry) {
if (test.getName().equalsIgnoreCase(name)) { if (test.getName().equalsIgnoreCase(name)) {
if (range > 0 && test.isSpawned() if (range > 0 && test.isSpawned()
&& !Util.locationWithinRange(args.getSenderLocation(), test.getEntity().getLocation(), range)) { && args.getSenderLocation().distance(test.getEntity().getLocation()) > range) {
continue; continue;
} }
possible.add(test); possible.add(test);

View File

@ -2347,7 +2347,7 @@ public class NPCCommands {
max = 2, max = 2,
permission = "citizens.npc.panimate") permission = "citizens.npc.panimate")
@Requirements(selected = true, ownership = true, types = EntityType.PLAYER) @Requirements(selected = true, ownership = true, types = EntityType.PLAYER)
public void playerAnimate(CommandContext args, CommandSender sender, NPC npc, @Arg(1) PlayerAnimation animation) public void playeranimate(CommandContext args, CommandSender sender, NPC npc, @Arg(1) PlayerAnimation animation)
throws CommandException { throws CommandException {
if (animation == null) { if (animation == null) {
Messaging.sendErrorTr(sender, Messages.UNKNOWN_PLAYER_ANIMATION, Messaging.sendErrorTr(sender, Messages.UNKNOWN_PLAYER_ANIMATION,

View File

@ -529,6 +529,13 @@ public class ShopTrait extends Trait {
callback = consumer; callback = consumer;
} }
private ItemStack editTitle(ItemStack item, Function<String, String> transform) {
ItemMeta meta = item.getItemMeta();
meta.setDisplayName(transform.apply(meta.hasDisplayName() ? meta.getDisplayName() : ""));
item.setItemMeta(meta);
return item;
}
@Override @Override
public void initialise(MenuContext ctx) { public void initialise(MenuContext ctx) {
this.ctx = ctx; this.ctx = ctx;
@ -595,13 +602,13 @@ public class ShopTrait extends Trait {
NPCShopAction oldCost = modified.cost.stream().filter(template::manages).findFirst().orElse(null); NPCShopAction oldCost = modified.cost.stream().filter(template::manages).findFirst().orElse(null);
costItems.getSlots().get(pos) costItems.getSlots().get(pos)
.setItemStack(Util.editTitle(template.createMenuItem(oldCost), title -> title + " Cost")); .setItemStack(editTitle(template.createMenuItem(oldCost), title -> title + " Cost"));
costItems.getSlots().get(pos).setClickHandler(event -> ctx.getMenu().transition( costItems.getSlots().get(pos).setClickHandler(event -> ctx.getMenu().transition(
template.createEditor(oldCost, cost -> modified.changeCost(template::manages, cost)))); template.createEditor(oldCost, cost -> modified.changeCost(template::manages, cost))));
NPCShopAction oldResult = modified.result.stream().filter(template::manages).findFirst().orElse(null); NPCShopAction oldResult = modified.result.stream().filter(template::manages).findFirst().orElse(null);
actionItems.getSlots().get(pos) actionItems.getSlots().get(pos)
.setItemStack(Util.editTitle(template.createMenuItem(oldResult), title -> title + " Result")); .setItemStack(editTitle(template.createMenuItem(oldResult), title -> title + " Result"));
actionItems.getSlots().get(pos).setClickHandler(event -> ctx.getMenu().transition( actionItems.getSlots().get(pos).setClickHandler(event -> ctx.getMenu().transition(
template.createEditor(oldResult, result -> modified.changeResult(template::manages, result)))); template.createEditor(oldResult, result -> modified.changeResult(template::manages, result))));

View File

@ -625,8 +625,8 @@ public class LinearWaypointProvider implements EnumerableWaypointProvider {
} }
double margin = getNavigator().getLocalParameters().distanceMargin(); double margin = getNavigator().getLocalParameters().distanceMargin();
getNavigator().getLocalParameters().addSingleUseCallback(cancelReason -> { getNavigator().getLocalParameters().addSingleUseCallback(cancelReason -> {
if (npc.isSpawned() && currentDestination != null && Util.locationWithinRange(npc.getStoredLocation(), if (npc.isSpawned() && currentDestination != null
currentDestination.getLocation(), margin + 1)) { && npc.getStoredLocation().distance(currentDestination.getLocation()) <= margin + 1) {
currentDestination.onReach(npc); currentDestination.onReach(npc);
if (cachePaths && cancelReason == null) { if (cachePaths && cancelReason == null) {
Iterable<Vector> path = getNavigator().getPathStrategy().getPath(); Iterable<Vector> path = getNavigator().getPathStrategy().getPath();

View File

@ -12,7 +12,6 @@ import java.util.Set;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.Callable; import java.util.concurrent.Callable;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
@ -152,13 +151,6 @@ public class Util {
return stack; return stack;
} }
public static ItemStack editTitle(ItemStack item, Function<String, String> transform) {
ItemMeta meta = item.getItemMeta();
meta.setDisplayName(transform.apply(meta.hasDisplayName() ? meta.getDisplayName() : ""));
item.setItemMeta(meta);
return item;
}
public static void face(Entity entity, float yaw, float pitch) { public static void face(Entity entity, float yaw, float pitch) {
double pitchCos = Math.cos(Math.toRadians(pitch)); double pitchCos = Math.cos(Math.toRadians(pitch));
Vector vector = new Vector(Math.sin(Math.toRadians(yaw)) * -pitchCos, -Math.sin(Math.toRadians(pitch)), Vector vector = new Vector(Math.sin(Math.toRadians(yaw)) * -pitchCos, -Math.sin(Math.toRadians(pitch)),
@ -201,23 +193,6 @@ public class Util {
return center; return center;
} }
/**
* Returns the yaw to face along the given velocity (corrected for dragon yaw i.e. facing backwards)
*/
public static float getDragonYaw(Entity entity, double motX, double motZ) {
Location location = entity.getLocation();
double x = location.getX();
double z = location.getZ();
double tX = x + motX;
double tZ = z + motZ;
if (z > tZ)
return (float) -Math.toDegrees(Math.atan((x - tX) / (z - tZ)));
if (z < tZ)
return (float) -Math.toDegrees(Math.atan((x - tX) / (z - tZ))) + 180.0F;
return location.getYaw();
}
public static Scoreboard getDummyScoreboard() { public static Scoreboard getDummyScoreboard() {
return DUMMY_SCOREBOARD; return DUMMY_SCOREBOARD;
} }
@ -279,6 +254,23 @@ public class Util {
return "CIT-" + id.toString().replace("-", "").substring(0, 12); return "CIT-" + id.toString().replace("-", "").substring(0, 12);
} }
/**
* Returns the yaw to face along the given velocity (corrected for dragon yaw i.e. facing backwards)
*/
public static float getYawFromVelocity(Entity entity, double motX, double motZ) {
Location location = entity.getLocation();
double x = location.getX();
double z = location.getZ();
double tX = x + motX;
double tZ = z + motZ;
if (z > tZ)
return (float) -Math.toDegrees(Math.atan((x - tX) / (z - tZ)));
if (z < tZ)
return (float) -Math.toDegrees(Math.atan((x - tX) / (z - tZ))) + 180.0F;
return location.getYaw();
}
public static boolean inBlock(Entity entity) { public static boolean inBlock(Entity entity) {
// TODO: bounding box aware? // TODO: bounding box aware?
Location loc = entity.getLocation(); Location loc = entity.getLocation();
@ -344,12 +336,6 @@ public class Util {
return "<yellow>" + Joiner.on("<green>, <yellow>").join(values).replace('_', ' ').toLowerCase(Locale.US); return "<yellow>" + Joiner.on("<green>, <yellow>").join(values).replace('_', ' ').toLowerCase(Locale.US);
} }
public static boolean locationWithinRange(Location current, Location target, double range) {
if (current == null || target == null || (current.getWorld() != target.getWorld()))
return false;
return current.distance(target) <= range;
}
public static <T extends Enum<?>> T matchEnum(T[] values, String toMatch) { public static <T extends Enum<?>> T matchEnum(T[] values, String toMatch) {
toMatch = toMatch.replace('-', '_').replace(' ', '_'); toMatch = toMatch.replace('-', '_').replace(' ', '_');
for (T check : values) { for (T check : values) {
@ -450,7 +436,7 @@ public class Util {
String bungeeServer = split.size() == 2 && split.get(0).equalsIgnoreCase("server") ? split.get(1) : null; String bungeeServer = split.size() == 2 && split.get(0).equalsIgnoreCase("server") ? split.get(1) : null;
String cmd = command; String cmd = command;
if (command.startsWith("say")) { if (command.startsWith("say")) {
cmd = "npc speak " + command.replaceFirst("say", "").trim() + " --target <p>"; cmd = "npc speak \"" + command.replaceFirst("say", "").trim() + "\" --target <p>";
} }
if ((cmd.startsWith("npc ") || cmd.startsWith("waypoints ") || cmd.startsWith("wp ")) if ((cmd.startsWith("npc ") || cmd.startsWith("waypoints ") || cmd.startsWith("wp "))
&& !cmd.contains("--id ")) { && !cmd.contains("--id ")) {

View File

@ -201,7 +201,7 @@ public class EnderDragonController extends MobEntityController {
motY *= 0.98; motY *= 0.98;
motZ *= 0.98; motZ *= 0.98;
if (getBukkitEntity().getPassenger() == null) { if (getBukkitEntity().getPassenger() == null) {
yaw = Util.getDragonYaw(getBukkitEntity(), motX, motZ); yaw = Util.getYawFromVelocity(getBukkitEntity(), motX, motZ);
} }
setPosition(locX + motX, locY + motY, locZ + motZ); setPosition(locX + motX, locY + motY, locZ + motZ);
} }

View File

@ -830,7 +830,7 @@ public class NMSImpl implements NMSBridge {
yaw += Math.abs(180 - yaw) * 2; yaw += Math.abs(180 - yaw) * 2;
} }
if (handle instanceof EntityEnderDragon) { if (handle instanceof EntityEnderDragon) {
yaw = Util.getDragonYaw(handle.getBukkitEntity(), xDiff, zDiff); yaw = Util.getYawFromVelocity(handle.getBukkitEntity(), xDiff, zDiff);
} else { } else {
yaw = yaw - 90; yaw = yaw - 90;
} }

View File

@ -202,7 +202,7 @@ public class EnderDragonController extends MobEntityController {
motY *= 0.98; motY *= 0.98;
motZ *= 0.98; motZ *= 0.98;
if (getBukkitEntity().getPassenger() == null) { if (getBukkitEntity().getPassenger() == null) {
yaw = Util.getDragonYaw(getBukkitEntity(), motX, motZ); yaw = Util.getYawFromVelocity(getBukkitEntity(), motX, motZ);
} }
setPosition(locX + motX, locY + motY, locZ + motZ); setPosition(locX + motX, locY + motY, locZ + motZ);
} }

View File

@ -883,7 +883,7 @@ public class NMSImpl implements NMSBridge {
yaw += Math.abs(180 - yaw) * 2; yaw += Math.abs(180 - yaw) * 2;
} }
if (handle instanceof EntityEnderDragon) { if (handle instanceof EntityEnderDragon) {
yaw = Util.getDragonYaw(handle.getBukkitEntity(), xDiff, zDiff); yaw = Util.getYawFromVelocity(handle.getBukkitEntity(), xDiff, zDiff);
} else { } else {
yaw = yaw - 90; yaw = yaw - 90;
} }

View File

@ -208,7 +208,7 @@ public class EnderDragonController extends MobEntityController {
motY *= 0.98; motY *= 0.98;
motZ *= 0.98; motZ *= 0.98;
if (getBukkitEntity().getPassenger() == null) { if (getBukkitEntity().getPassenger() == null) {
yaw = Util.getDragonYaw(getBukkitEntity(), motX, motZ); yaw = Util.getYawFromVelocity(getBukkitEntity(), motX, motZ);
} }
setPosition(locX + motX, locY + motY, locZ + motZ); setPosition(locX + motX, locY + motY, locZ + motZ);
} }

View File

@ -888,7 +888,7 @@ public class NMSImpl implements NMSBridge {
yaw += Math.abs(180 - yaw) * 2; yaw += Math.abs(180 - yaw) * 2;
} }
if (handle instanceof EntityEnderDragon) { if (handle instanceof EntityEnderDragon) {
yaw = Util.getDragonYaw(handle.getBukkitEntity(), xDiff, zDiff); yaw = Util.getYawFromVelocity(handle.getBukkitEntity(), xDiff, zDiff);
} else { } else {
yaw = yaw - 90; yaw = yaw - 90;
} }

View File

@ -229,7 +229,7 @@ public class EnderDragonController extends MobEntityController {
motY *= 0.98; motY *= 0.98;
motZ *= 0.98; motZ *= 0.98;
if (getBukkitEntity().getPassenger() == null) { if (getBukkitEntity().getPassenger() == null) {
yaw = Util.getDragonYaw(getBukkitEntity(), motX, motZ); yaw = Util.getYawFromVelocity(getBukkitEntity(), motX, motZ);
} }
setPosition(locX + motX, locY + motY, locZ + motZ); setPosition(locX + motX, locY + motY, locZ + motZ);
} }

View File

@ -924,7 +924,7 @@ public class NMSImpl implements NMSBridge {
yaw += Math.abs(180 - yaw) * 2; yaw += Math.abs(180 - yaw) * 2;
} }
if (handle instanceof EntityEnderDragon) { if (handle instanceof EntityEnderDragon) {
yaw = Util.getDragonYaw(handle.getBukkitEntity(), xDiff, zDiff); yaw = Util.getYawFromVelocity(handle.getBukkitEntity(), xDiff, zDiff);
} else { } else {
yaw = yaw - 90; yaw = yaw - 90;
} }

View File

@ -222,7 +222,7 @@ public class EnderDragonController extends MobEntityController {
if (mot.getX() != 0 || mot.getY() != 0 || mot.getZ() != 0) { if (mot.getX() != 0 || mot.getY() != 0 || mot.getZ() != 0) {
mot = mot.d(0.98, 0.98, 0.98); mot = mot.d(0.98, 0.98, 0.98);
if (getRidingPassenger() == null) { if (getRidingPassenger() == null) {
yaw = Util.getDragonYaw(getBukkitEntity(), mot.x, mot.z); yaw = Util.getYawFromVelocity(getBukkitEntity(), mot.x, mot.z);
} }
setPosition(locX + mot.getX(), locY + mot.getY(), locZ + mot.getZ()); setPosition(locX + mot.getX(), locY + mot.getY(), locZ + mot.getZ());
setMot(mot); setMot(mot);

View File

@ -994,7 +994,7 @@ public class NMSImpl implements NMSBridge {
yaw += Math.abs(180 - yaw) * 2; yaw += Math.abs(180 - yaw) * 2;
} }
if (handle instanceof EntityEnderDragon) { if (handle instanceof EntityEnderDragon) {
yaw = Util.getDragonYaw(handle.getBukkitEntity(), xDiff, zDiff); yaw = Util.getYawFromVelocity(handle.getBukkitEntity(), xDiff, zDiff);
} else { } else {
yaw = yaw - 90; yaw = yaw - 90;
} }

View File

@ -217,7 +217,7 @@ public class EnderDragonController extends MobEntityController {
if (mot.getX() != 0 || mot.getY() != 0 || mot.getZ() != 0) { if (mot.getX() != 0 || mot.getY() != 0 || mot.getZ() != 0) {
mot = mot.d(0.98, 0.98, 0.98); mot = mot.d(0.98, 0.98, 0.98);
if (getRidingPassenger() == null) { if (getRidingPassenger() == null) {
yaw = Util.getDragonYaw(getBukkitEntity(), mot.x, mot.z); yaw = Util.getYawFromVelocity(getBukkitEntity(), mot.x, mot.z);
} }
setPosition(locX() + mot.getX(), locY() + mot.getY(), locZ() + mot.getZ()); setPosition(locX() + mot.getX(), locY() + mot.getY(), locZ() + mot.getZ());
setMot(mot); setMot(mot);

View File

@ -1011,7 +1011,7 @@ public class NMSImpl implements NMSBridge {
yaw += Math.abs(180 - yaw) * 2; yaw += Math.abs(180 - yaw) * 2;
} }
if (handle instanceof EntityEnderDragon) { if (handle instanceof EntityEnderDragon) {
yaw = Util.getDragonYaw(handle.getBukkitEntity(), xDiff, zDiff); yaw = Util.getYawFromVelocity(handle.getBukkitEntity(), xDiff, zDiff);
} else { } else {
yaw = yaw - 90; yaw = yaw - 90;
} }

View File

@ -217,7 +217,7 @@ public class EnderDragonController extends MobEntityController {
if (mot.getX() != 0 || mot.getY() != 0 || mot.getZ() != 0) { if (mot.getX() != 0 || mot.getY() != 0 || mot.getZ() != 0) {
mot = mot.d(0.98, 0.98, 0.98); mot = mot.d(0.98, 0.98, 0.98);
if (getRidingPassenger() == null) { if (getRidingPassenger() == null) {
yaw = Util.getDragonYaw(getBukkitEntity(), mot.x, mot.z); yaw = Util.getYawFromVelocity(getBukkitEntity(), mot.x, mot.z);
} }
setPosition(locX() + mot.getX(), locY() + mot.getY(), locZ() + mot.getZ()); setPosition(locX() + mot.getX(), locY() + mot.getY(), locZ() + mot.getZ());
setMot(mot); setMot(mot);

View File

@ -1041,7 +1041,7 @@ public class NMSImpl implements NMSBridge {
yaw += Math.abs(180 - yaw) * 2; yaw += Math.abs(180 - yaw) * 2;
} }
if (handle.getBukkitEntity().getType() == EntityType.ENDER_DRAGON) { if (handle.getBukkitEntity().getType() == EntityType.ENDER_DRAGON) {
yaw = Util.getDragonYaw(handle.getBukkitEntity(), xDiff, zDiff); yaw = Util.getYawFromVelocity(handle.getBukkitEntity(), xDiff, zDiff);
} else { } else {
yaw = yaw - 90; yaw = yaw - 90;
} }

View File

@ -104,7 +104,7 @@ public class EnderDragonController extends MobEntityController {
if (mot.x != 0 || mot.y != 0 || mot.z != 0) { if (mot.x != 0 || mot.y != 0 || mot.z != 0) {
mot = mot.multiply(0.98, 0.98, 0.98); mot = mot.multiply(0.98, 0.98, 0.98);
if (getFirstPassenger() == null) { if (getFirstPassenger() == null) {
setYRot(Util.getDragonYaw(getBukkitEntity(), mot.x, mot.z)); setYRot(Util.getYawFromVelocity(getBukkitEntity(), mot.x, mot.z));
} }
setPos(getX() + mot.x, getY() + mot.y, getZ() + mot.z); setPos(getX() + mot.x, getY() + mot.y, getZ() + mot.z);
setDeltaMovement(mot); setDeltaMovement(mot);

View File

@ -1049,7 +1049,7 @@ public class NMSImpl implements NMSBridge {
yaw += Math.abs(180 - yaw) * 2; yaw += Math.abs(180 - yaw) * 2;
} }
if (handle.getBukkitEntity().getType() == EntityType.ENDER_DRAGON) { if (handle.getBukkitEntity().getType() == EntityType.ENDER_DRAGON) {
yaw = Util.getDragonYaw(handle.getBukkitEntity(), xDiff, zDiff); yaw = Util.getYawFromVelocity(handle.getBukkitEntity(), xDiff, zDiff);
} else { } else {
yaw = yaw - 90; yaw = yaw - 90;
} }

View File

@ -106,7 +106,7 @@ public class EnderDragonController extends MobEntityController {
if (mot.x != 0 || mot.y != 0 || mot.z != 0) { if (mot.x != 0 || mot.y != 0 || mot.z != 0) {
mot = mot.multiply(0.98, 0.98, 0.98); mot = mot.multiply(0.98, 0.98, 0.98);
if (getFirstPassenger() == null) { if (getFirstPassenger() == null) {
setYRot(Util.getDragonYaw(getBukkitEntity(), mot.x, mot.z)); setYRot(Util.getYawFromVelocity(getBukkitEntity(), mot.x, mot.z));
} }
setPos(getX() + mot.x, getY() + mot.y, getZ() + mot.z); setPos(getX() + mot.x, getY() + mot.y, getZ() + mot.z);
setDeltaMovement(mot); setDeltaMovement(mot);

View File

@ -1058,7 +1058,7 @@ public class NMSImpl implements NMSBridge {
yaw += Math.abs(180 - yaw) * 2; yaw += Math.abs(180 - yaw) * 2;
} }
if (handle.getBukkitEntity().getType() == EntityType.ENDER_DRAGON) { if (handle.getBukkitEntity().getType() == EntityType.ENDER_DRAGON) {
yaw = Util.getDragonYaw(handle.getBukkitEntity(), xDiff, zDiff); yaw = Util.getYawFromVelocity(handle.getBukkitEntity(), xDiff, zDiff);
} else { } else {
yaw = yaw - 90; yaw = yaw - 90;
} }

View File

@ -107,7 +107,7 @@ public class EnderDragonController extends MobEntityController {
if (mot.x != 0 || mot.y != 0 || mot.z != 0) { if (mot.x != 0 || mot.y != 0 || mot.z != 0) {
mot = mot.multiply(0.98, 0.91, 0.98); mot = mot.multiply(0.98, 0.91, 0.98);
if (getFirstPassenger() == null) { if (getFirstPassenger() == null) {
setYRot(Util.getDragonYaw(getBukkitEntity(), mot.x, mot.z)); setYRot(Util.getYawFromVelocity(getBukkitEntity(), mot.x, mot.z));
} }
setPos(getX() + mot.x, getY() + mot.y, getZ() + mot.z); setPos(getX() + mot.x, getY() + mot.y, getZ() + mot.z);
setDeltaMovement(mot); setDeltaMovement(mot);

View File

@ -1138,7 +1138,7 @@ public class NMSImpl implements NMSBridge {
yaw += Math.abs(180 - yaw) * 2; yaw += Math.abs(180 - yaw) * 2;
} }
if (handle.getBukkitEntity().getType() == EntityType.ENDER_DRAGON) { if (handle.getBukkitEntity().getType() == EntityType.ENDER_DRAGON) {
yaw = Util.getDragonYaw(handle.getBukkitEntity(), xDiff, zDiff); yaw = Util.getYawFromVelocity(handle.getBukkitEntity(), xDiff, zDiff);
} else { } else {
yaw = yaw - 90; yaw = yaw - 90;
} }

View File

@ -102,7 +102,7 @@ public class EnderDragonController extends MobEntityController {
if (mot.x != 0 || mot.y != 0 || mot.z != 0) { if (mot.x != 0 || mot.y != 0 || mot.z != 0) {
mot = mot.multiply(0.98, 0.91, 0.98); mot = mot.multiply(0.98, 0.91, 0.98);
if (getFirstPassenger() == null) { if (getFirstPassenger() == null) {
setYRot(Util.getDragonYaw(getBukkitEntity(), mot.x, mot.z)); setYRot(Util.getYawFromVelocity(getBukkitEntity(), mot.x, mot.z));
} }
setPos(getX() + mot.x, getY() + mot.y, getZ() + mot.z); setPos(getX() + mot.x, getY() + mot.y, getZ() + mot.z);
setDeltaMovement(mot); setDeltaMovement(mot);

View File

@ -1124,7 +1124,7 @@ public class NMSImpl implements NMSBridge {
yaw += Math.abs(180 - yaw) * 2; yaw += Math.abs(180 - yaw) * 2;
} }
if (handle.getBukkitEntity().getType() == EntityType.ENDER_DRAGON) { if (handle.getBukkitEntity().getType() == EntityType.ENDER_DRAGON) {
yaw = Util.getDragonYaw(handle.getBukkitEntity(), xDiff, zDiff); yaw = Util.getYawFromVelocity(handle.getBukkitEntity(), xDiff, zDiff);
} else { } else {
yaw = yaw - 90; yaw = yaw - 90;
} }

View File

@ -102,7 +102,7 @@ public class EnderDragonController extends MobEntityController {
if (mot.x != 0 || mot.y != 0 || mot.z != 0) { if (mot.x != 0 || mot.y != 0 || mot.z != 0) {
mot = mot.multiply(0.98, 0.91, 0.98); mot = mot.multiply(0.98, 0.91, 0.98);
if (getFirstPassenger() == null) { if (getFirstPassenger() == null) {
setYRot(Util.getDragonYaw(getBukkitEntity(), mot.x, mot.z)); setYRot(Util.getYawFromVelocity(getBukkitEntity(), mot.x, mot.z));
} }
setPos(getX() + mot.x, getY() + mot.y, getZ() + mot.z); setPos(getX() + mot.x, getY() + mot.y, getZ() + mot.z);
setDeltaMovement(mot); setDeltaMovement(mot);

View File

@ -1102,7 +1102,7 @@ public class NMSImpl implements NMSBridge {
yaw += Math.abs(180 - yaw) * 2; yaw += Math.abs(180 - yaw) * 2;
} }
if (handle.getBukkitEntity().getType() == EntityType.ENDER_DRAGON) { if (handle.getBukkitEntity().getType() == EntityType.ENDER_DRAGON) {
yaw = Util.getDragonYaw(handle.getBukkitEntity(), xDiff, zDiff); yaw = Util.getYawFromVelocity(handle.getBukkitEntity(), xDiff, zDiff);
} else { } else {
yaw = yaw - 90; yaw = yaw - 90;
} }

View File

@ -188,7 +188,7 @@ public class EnderDragonController extends MobEntityController {
motY *= 0.98; motY *= 0.98;
motZ *= 0.98; motZ *= 0.98;
if (getBukkitEntity().getPassenger() == null) { if (getBukkitEntity().getPassenger() == null) {
yaw = Util.getDragonYaw(getBukkitEntity(), motX, motZ); yaw = Util.getYawFromVelocity(getBukkitEntity(), motX, motZ);
} }
setPosition(locX + motX, locY + motY, locZ + motZ); setPosition(locX + motX, locY + motY, locZ + motZ);
} }

View File

@ -768,7 +768,7 @@ public class NMSImpl implements NMSBridge {
yaw += Math.abs(180 - yaw) * 2; yaw += Math.abs(180 - yaw) * 2;
} }
if (handle instanceof EntityEnderDragon) { if (handle instanceof EntityEnderDragon) {
yaw = Util.getDragonYaw(handle.getBukkitEntity(), xDiff, zDiff); yaw = Util.getYawFromVelocity(handle.getBukkitEntity(), xDiff, zDiff);
} else { } else {
yaw = yaw - 90; yaw = yaw - 90;
} }