mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-11-22 10:36:10 +01:00
Updated controllable for 1.21.3
This commit is contained in:
parent
0b978f6322
commit
1579aa0e9e
@ -13,6 +13,7 @@ import org.bukkit.event.EventHandler;
|
|||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.entity.EntityDeathEvent;
|
import org.bukkit.event.entity.EntityDeathEvent;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.inventory.PlayerInventory;
|
||||||
|
|
||||||
import com.comphenix.protocol.PacketType;
|
import com.comphenix.protocol.PacketType;
|
||||||
import com.comphenix.protocol.PacketType.Play.Server;
|
import com.comphenix.protocol.PacketType.Play.Server;
|
||||||
@ -36,6 +37,7 @@ import com.comphenix.protocol.wrappers.WrappedGameProfile;
|
|||||||
import com.comphenix.protocol.wrappers.WrappedSignedProperty;
|
import com.comphenix.protocol.wrappers.WrappedSignedProperty;
|
||||||
import com.comphenix.protocol.wrappers.WrappedWatchableObject;
|
import com.comphenix.protocol.wrappers.WrappedWatchableObject;
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
import com.mojang.authlib.GameProfile;
|
import com.mojang.authlib.GameProfile;
|
||||||
import com.mojang.authlib.properties.Property;
|
import com.mojang.authlib.properties.Property;
|
||||||
@ -59,9 +61,9 @@ import net.citizensnpcs.util.SkinProperty;
|
|||||||
import net.citizensnpcs.util.Util;
|
import net.citizensnpcs.util.Util;
|
||||||
|
|
||||||
public class ProtocolLibListener implements Listener {
|
public class ProtocolLibListener implements Listener {
|
||||||
private ProtocolManager manager;
|
private final ProtocolManager manager;
|
||||||
private final Map<UUID, MirrorTrait> mirrorTraits = Maps.newConcurrentMap();
|
private final Map<UUID, MirrorTrait> mirrorTraits = Maps.newConcurrentMap();
|
||||||
private Citizens plugin;
|
private final Citizens plugin;
|
||||||
private final Map<Integer, RotationTrait> rotationTraits = Maps.newConcurrentMap();
|
private final Map<Integer, RotationTrait> rotationTraits = Maps.newConcurrentMap();
|
||||||
|
|
||||||
public ProtocolLibListener(Citizens plugin) {
|
public ProtocolLibListener(Citizens plugin) {
|
||||||
@ -93,9 +95,27 @@ public class ProtocolLibListener implements Listener {
|
|||||||
@Override
|
@Override
|
||||||
public void onPacketSending(PacketEvent event) {
|
public void onPacketSending(PacketEvent event) {
|
||||||
NPC npc = getNPCFromPacket(event);
|
NPC npc = getNPCFromPacket(event);
|
||||||
if (npc == null || !npc.hasTrait(Equipment.class))
|
if (npc == null)
|
||||||
|
return;
|
||||||
|
MirrorTrait mirror = npc.getTraitNullable(MirrorTrait.class);
|
||||||
|
if (mirror != null && mirror.isMirroringEquipment() && mirror.isMirroring(event.getPlayer())) {
|
||||||
|
StructureModifier<List<Pair<EnumWrappers.ItemSlot, ItemStack>>> modifier = event.getPacket()
|
||||||
|
.getLists(BukkitConverters.getPairConverter(EnumWrappers.getItemSlotConverter(),
|
||||||
|
BukkitConverters.getItemStackConverter()));
|
||||||
|
List<Pair<EnumWrappers.ItemSlot, ItemStack>> equipment = Lists.newArrayList();
|
||||||
|
PlayerInventory pi = event.getPlayer().getInventory();
|
||||||
|
equipment.add(new Pair<>(ItemSlot.CHEST, pi.getChestplate()));
|
||||||
|
equipment.add(new Pair<>(ItemSlot.FEET, pi.getBoots()));
|
||||||
|
equipment.add(new Pair<>(ItemSlot.HEAD, pi.getHelmet()));
|
||||||
|
equipment.add(new Pair<>(ItemSlot.LEGS, pi.getLeggings()));
|
||||||
|
equipment.add(new Pair<>(ItemSlot.MAINHAND, pi.getItemInHand()));
|
||||||
|
equipment.add(new Pair<>(ItemSlot.OFFHAND, pi.getItemInOffHand()));
|
||||||
|
modifier.write(0, equipment);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Equipment trait = npc.getTraitNullable(Equipment.class);
|
||||||
|
if (trait == null)
|
||||||
return;
|
return;
|
||||||
Equipment trait = npc.getOrAddTrait(Equipment.class);
|
|
||||||
PacketContainer packet = event.getPacket();
|
PacketContainer packet = event.getPacket();
|
||||||
StructureModifier<List<Pair<EnumWrappers.ItemSlot, ItemStack>>> modifier = packet
|
StructureModifier<List<Pair<EnumWrappers.ItemSlot, ItemStack>>> modifier = packet
|
||||||
.getLists(BukkitConverters.getPairConverter(EnumWrappers.getItemSlotConverter(),
|
.getLists(BukkitConverters.getPairConverter(EnumWrappers.getItemSlotConverter(),
|
||||||
@ -120,6 +140,7 @@ public class ProtocolLibListener implements Listener {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
manager.addPacketListener(new PacketAdapter(plugin, ListenerPriority.HIGHEST, Server.ENTITY_METADATA) {
|
manager.addPacketListener(new PacketAdapter(plugin, ListenerPriority.HIGHEST, Server.ENTITY_METADATA) {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPacketSending(PacketEvent event) {
|
public void onPacketSending(PacketEvent event) {
|
||||||
NPC npc = getNPCFromPacket(event);
|
NPC npc = getNPCFromPacket(event);
|
||||||
|
@ -1934,20 +1934,21 @@ public class NPCCommands {
|
|||||||
@Command(
|
@Command(
|
||||||
aliases = { "npc" },
|
aliases = { "npc" },
|
||||||
modifiers = { "mirror" },
|
modifiers = { "mirror" },
|
||||||
usage = "mirror --name [true|false]",
|
usage = "mirror --name [true|false] --equipment [true|false]",
|
||||||
desc = "",
|
desc = "",
|
||||||
min = 1,
|
min = 1,
|
||||||
max = 1,
|
max = 1,
|
||||||
permission = "citizens.npc.mirror")
|
permission = "citizens.npc.mirror")
|
||||||
@Requirements(selected = true, ownership = true)
|
@Requirements(selected = true, ownership = true)
|
||||||
public void mirror(CommandContext args, CommandSender sender, NPC npc, @Flag("name") Boolean name)
|
public void mirror(CommandContext args, CommandSender sender, NPC npc, @Flag("name") Boolean name,
|
||||||
throws CommandException {
|
@Flag("equipment") Boolean equipment) throws CommandException {
|
||||||
if (((Citizens) CitizensAPI.getPlugin()).getProtocolLibListener() == null)
|
if (((Citizens) CitizensAPI.getPlugin()).getProtocolLibListener() == null)
|
||||||
throw new CommandException("ProtocolLib must be enabled to use this feature");
|
throw new CommandException("ProtocolLib must be enabled to use this feature");
|
||||||
|
|
||||||
MirrorTrait trait = npc.getOrAddTrait(MirrorTrait.class);
|
MirrorTrait trait = npc.getOrAddTrait(MirrorTrait.class);
|
||||||
if (name != null) {
|
if (name != null) {
|
||||||
trait.setEnabled(true);
|
trait.setEnabled(true);
|
||||||
|
trait.setMirrorEquipment(equipment);
|
||||||
trait.setMirrorName(name);
|
trait.setMirrorName(name);
|
||||||
Messaging.sendTr(sender, name ? Messages.MIRROR_NAME_SET : Messages.MIRROR_NAME_UNSET, npc.getName());
|
Messaging.sendTr(sender, name ? Messages.MIRROR_NAME_SET : Messages.MIRROR_NAME_UNSET, npc.getName());
|
||||||
} else {
|
} else {
|
||||||
@ -2852,8 +2853,9 @@ public class NPCCommands {
|
|||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
aliases = { "npc" },
|
aliases = { "npc" },
|
||||||
usage = "setequipment [slot] [item]",
|
usage = "setequipment (-c(osmetic)) [slot] [item]",
|
||||||
desc = "",
|
desc = "",
|
||||||
|
flags = "c",
|
||||||
modifiers = { "setequipment" },
|
modifiers = { "setequipment" },
|
||||||
min = 2,
|
min = 2,
|
||||||
max = 3,
|
max = 3,
|
||||||
@ -2868,9 +2870,14 @@ public class NPCCommands {
|
|||||||
throw new ServerCommandException();
|
throw new ServerCommandException();
|
||||||
item = ((Player) sender).getItemInHand().clone();
|
item = ((Player) sender).getItemInHand().clone();
|
||||||
}
|
}
|
||||||
|
if (args.hasFlag('c')) {
|
||||||
|
npc.getOrAddTrait(Equipment.class).setCosmetic(slot, item);
|
||||||
|
Messaging.sendTr(sender, Messages.COSMETIC_EQUIPMENT_SET, slot, item);
|
||||||
|
} else {
|
||||||
npc.getOrAddTrait(Equipment.class).set(slot, item);
|
npc.getOrAddTrait(Equipment.class).set(slot, item);
|
||||||
Messaging.sendTr(sender, Messages.EQUIPMENT_SET, slot, item);
|
Messaging.sendTr(sender, Messages.EQUIPMENT_SET, slot, item);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
aliases = { "npc" },
|
aliases = { "npc" },
|
||||||
|
@ -38,6 +38,7 @@ public class Controllable extends Trait {
|
|||||||
private BuiltInControls controls;
|
private BuiltInControls controls;
|
||||||
@Persist
|
@Persist
|
||||||
private boolean enabled = true;
|
private boolean enabled = true;
|
||||||
|
private ControllableInput input;
|
||||||
@Persist("owner_required")
|
@Persist("owner_required")
|
||||||
private boolean ownerRequired;
|
private boolean ownerRequired;
|
||||||
|
|
||||||
@ -128,9 +129,24 @@ public class Controllable extends Trait {
|
|||||||
if (!enabled || !npc.isSpawned())
|
if (!enabled || !npc.isSpawned())
|
||||||
return;
|
return;
|
||||||
List<Entity> passengers = NMS.getPassengers(npc.getEntity());
|
List<Entity> passengers = NMS.getPassengers(npc.getEntity());
|
||||||
if (passengers.size() == 0 || !(passengers.get(0) instanceof Player) || npc.getNavigator().isNavigating())
|
if (npc.getNavigator().isNavigating() || passengers.size() == 0 || !(passengers.get(0) instanceof Player))
|
||||||
return;
|
return;
|
||||||
controller.run((Player) passengers.get(0));
|
Player player = (Player) passengers.get(0);
|
||||||
|
input = new ControllableInput();
|
||||||
|
if (SUPPORTS_PLAYER_INPUT_EVENT) {
|
||||||
|
input.forward = player.getCurrentInput().isForward() ? 1 : player.getCurrentInput().isBackward() ? -1 : 0;
|
||||||
|
input.horizontal = player.getCurrentInput().isLeft() ? 1 : player.getCurrentInput().isRight() ? -1 : 0;
|
||||||
|
input.jump = player.getCurrentInput().isJump();
|
||||||
|
input.sneak = player.getCurrentInput().isSneak();
|
||||||
|
input.sprint = player.getCurrentInput().isSprint();
|
||||||
|
} else {
|
||||||
|
input.forward = NMS.getForwardBackwardMovement(player);
|
||||||
|
input.horizontal = NMS.getXZMovement(player);
|
||||||
|
input.jump = NMS.shouldJump(player);
|
||||||
|
input.sneak = NMS.isSneaking(player);
|
||||||
|
input.sprint = player.isSprinting();
|
||||||
|
}
|
||||||
|
controller.run(player, input);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setControls(BuiltInControls controls) {
|
public void setControls(BuiltInControls controls) {
|
||||||
@ -173,6 +189,14 @@ public class Controllable extends Trait {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static class ControllableInput {
|
||||||
|
double forward;
|
||||||
|
double horizontal;
|
||||||
|
boolean jump;
|
||||||
|
boolean sneak;
|
||||||
|
boolean sprint;
|
||||||
|
}
|
||||||
|
|
||||||
public static class GroundController implements MovementController {
|
public static class GroundController implements MovementController {
|
||||||
private int jumpTicks = 0;
|
private int jumpTicks = 0;
|
||||||
private final NPC npc;
|
private final NPC npc;
|
||||||
@ -196,15 +220,15 @@ public class Controllable extends Trait {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run(Player rider) {
|
public void run(Player rider, ControllableInput input) {
|
||||||
boolean onGround = NMS.isOnGround(npc.getEntity());
|
boolean onGround = NMS.isOnGround(npc.getEntity());
|
||||||
float impulse = npc.getNavigator().getDefaultParameters()
|
float speedMod = npc.getNavigator().getDefaultParameters()
|
||||||
.modifiedSpeed(onGround ? GROUND_SPEED : AIR_SPEED);
|
.modifiedSpeed(onGround ? GROUND_SPEED : AIR_SPEED);
|
||||||
if (!Util.isHorse(npc.getEntity().getType())) {
|
if (!Util.isHorse(npc.getEntity().getType())) {
|
||||||
speed = updateHorizontalSpeed(npc.getEntity(), rider, speed, impulse,
|
speed = updateSpeed(npc.getEntity(), NMS.getYaw(rider), input, speed, speedMod,
|
||||||
Setting.MAX_CONTROLLABLE_GROUND_SPEED.asDouble());
|
Setting.MAX_CONTROLLABLE_GROUND_SPEED.asDouble());
|
||||||
}
|
}
|
||||||
if (onGround && jumpTicks <= 0 && NMS.shouldJump(rider)) {
|
if (onGround && jumpTicks <= 0 && input.jump) {
|
||||||
npc.getEntity().setVelocity(npc.getEntity().getVelocity().setY(JUMP_VELOCITY));
|
npc.getEntity().setVelocity(npc.getEntity().getVelocity().setY(JUMP_VELOCITY));
|
||||||
jumpTicks = 10;
|
jumpTicks = 10;
|
||||||
}
|
}
|
||||||
@ -239,12 +263,12 @@ public class Controllable extends Trait {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run(Player rider) {
|
public void run(Player rider, ControllableInput input) {
|
||||||
boolean onGround = NMS.isOnGround(npc.getEntity());
|
boolean onGround = NMS.isOnGround(npc.getEntity());
|
||||||
float impulse = npc.getNavigator().getDefaultParameters()
|
float speedMod = npc.getNavigator().getDefaultParameters()
|
||||||
.modifiedSpeed(onGround ? GROUND_SPEED : AIR_SPEED);
|
.modifiedSpeed(onGround ? GROUND_SPEED : AIR_SPEED);
|
||||||
if (!Util.isHorse(npc.getEntity().getType())) {
|
if (!Util.isHorse(npc.getEntity().getType())) {
|
||||||
speed = updateHorizontalSpeed(npc.getEntity(), rider, speed, impulse,
|
speed = updateSpeed(npc.getEntity(), NMS.getYaw(rider), input, speed, speedMod,
|
||||||
Setting.MAX_CONTROLLABLE_GROUND_SPEED.asDouble());
|
Setting.MAX_CONTROLLABLE_GROUND_SPEED.asDouble());
|
||||||
}
|
}
|
||||||
setMountedYaw(npc.getEntity());
|
setMountedYaw(npc.getEntity());
|
||||||
@ -278,7 +302,7 @@ public class Controllable extends Trait {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run(Player rider) {
|
public void run(Player rider, ControllableInput input) {
|
||||||
if (paused) {
|
if (paused) {
|
||||||
npc.getEntity().setVelocity(npc.getEntity().getVelocity().setY(0.001));
|
npc.getEntity().setVelocity(npc.getEntity().getVelocity().setY(0.001));
|
||||||
return;
|
return;
|
||||||
@ -297,7 +321,7 @@ public class Controllable extends Trait {
|
|||||||
|
|
||||||
void rightClickEntity(NPCRightClickEvent event);
|
void rightClickEntity(NPCRightClickEvent event);
|
||||||
|
|
||||||
void run(Player rider);
|
void run(Player rider, ControllableInput input);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class PlayerInputAirController implements MovementController {
|
public static class PlayerInputAirController implements MovementController {
|
||||||
@ -325,15 +349,14 @@ public class Controllable extends Trait {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run(Player rider) {
|
public void run(Player rider, ControllableInput input) {
|
||||||
if (paused) {
|
if (paused) {
|
||||||
npc.getEntity().setVelocity(npc.getEntity().getVelocity().setY(0.001F));
|
npc.getEntity().setVelocity(npc.getEntity().getVelocity().setY(0.001F));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
speed = updateHorizontalSpeed(npc.getEntity(), rider, speed, 1F,
|
speed = updateSpeed(npc.getEntity(), NMS.getYaw(rider), input, speed, 1F,
|
||||||
Setting.MAX_CONTROLLABLE_FLIGHT_SPEED.asDouble());
|
Setting.MAX_CONTROLLABLE_FLIGHT_SPEED.asDouble());
|
||||||
boolean shouldJump = NMS.shouldJump(rider);
|
if (input.jump) {
|
||||||
if (shouldJump) {
|
|
||||||
npc.getEntity().setVelocity(npc.getEntity().getVelocity().setY(0.25F));
|
npc.getEntity().setVelocity(npc.getEntity().getVelocity().setY(0.25F));
|
||||||
}
|
}
|
||||||
npc.getEntity().setVelocity(npc.getEntity().getVelocity().multiply(new Vector(1, 0.98, 1)));
|
npc.getEntity().setVelocity(npc.getEntity().getVelocity().multiply(new Vector(1, 0.98, 1)));
|
||||||
@ -376,25 +399,19 @@ public class Controllable extends Trait {
|
|||||||
NMS.look(entity, loc.getYaw(), loc.getPitch());
|
NMS.look(entity, loc.getYaw(), loc.getPitch());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static double updateHorizontalSpeed(Entity handle, Entity passenger, double speed, float speedMod,
|
private static double updateSpeed(Entity handle, double yaw, ControllableInput input, double speed, float speedMod,
|
||||||
double maxSpeed) {
|
double maxSpeed) {
|
||||||
|
yaw = Math.toRadians(yaw);
|
||||||
Vector vel = handle.getVelocity();
|
Vector vel = handle.getVelocity();
|
||||||
double oldSpeed = Math.sqrt(vel.getX() * vel.getX() + vel.getZ() * vel.getZ());
|
double oldSpeed = Math.sqrt(vel.getX() * vel.getX() + vel.getZ() * vel.getZ());
|
||||||
double horizontal = NMS.getHorizontalMovement(passenger);
|
double nxsin = -Math.sin(yaw);
|
||||||
if (Math.abs(Math.abs(horizontal) - 0.98) > 0.02)
|
double xcos = Math.cos(yaw);
|
||||||
return speed;
|
if (input.forward > 0) {
|
||||||
double yaw = passenger.getLocation().getYaw();
|
vel = vel.setX(nxsin * speed * speedMod).setZ(xcos * speed * speedMod);
|
||||||
if (horizontal > 0.0D) {
|
|
||||||
double dXcos = -Math.sin(yaw * Math.PI / 180.0F);
|
|
||||||
double dXsin = Math.cos(yaw * Math.PI / 180.0F);
|
|
||||||
|
|
||||||
vel = vel.setX(dXcos * speed * speedMod).setZ(dXsin * speed * speedMod);
|
|
||||||
}
|
}
|
||||||
vel = vel.add(new Vector(
|
vel.add(new Vector(Math.sin(yaw + Math.PI / 2), 0D, -Math.cos(yaw + Math.PI / 2))
|
||||||
passenger.getVelocity().getX() * speedMod * Setting.CONTROLLABLE_GROUND_DIRECTION_MODIFIER.asDouble(),
|
.multiply(speedMod * Setting.CONTROLLABLE_GROUND_DIRECTION_MODIFIER.asDouble() * input.horizontal));
|
||||||
0D,
|
vel.multiply(0.98);
|
||||||
passenger.getVelocity().getZ() * speedMod * Setting.CONTROLLABLE_GROUND_DIRECTION_MODIFIER.asDouble()))
|
|
||||||
.multiply(0.98);
|
|
||||||
|
|
||||||
double newSpeed = Math.sqrt(vel.getX() * vel.getX() + vel.getZ() * vel.getZ());
|
double newSpeed = Math.sqrt(vel.getX() * vel.getX() + vel.getZ() * vel.getZ());
|
||||||
if (newSpeed > maxSpeed) {
|
if (newSpeed > maxSpeed) {
|
||||||
@ -409,4 +426,14 @@ public class Controllable extends Trait {
|
|||||||
return (float) Math.max(0, speed - speed / 50.0D);
|
return (float) Math.max(0, speed - speed / 50.0D);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static boolean SUPPORTS_PLAYER_INPUT_EVENT = true;
|
||||||
|
|
||||||
|
static {
|
||||||
|
try {
|
||||||
|
Class.forName("org.bukkit.event.player.PlayerInputEvent");
|
||||||
|
} catch (ClassNotFoundException e) {
|
||||||
|
SUPPORTS_PLAYER_INPUT_EVENT = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,8 @@ public class MirrorTrait extends Trait {
|
|||||||
@Persist
|
@Persist
|
||||||
private volatile boolean enabled;
|
private volatile boolean enabled;
|
||||||
@Persist
|
@Persist
|
||||||
|
private volatile boolean mirrorEquipment;
|
||||||
|
@Persist
|
||||||
private volatile boolean mirrorName;
|
private volatile boolean mirrorName;
|
||||||
|
|
||||||
public MirrorTrait() {
|
public MirrorTrait() {
|
||||||
@ -27,6 +29,10 @@ public class MirrorTrait extends Trait {
|
|||||||
return enabled;
|
return enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isMirroringEquipment() {
|
||||||
|
return mirrorEquipment;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean mirrorName() {
|
public boolean mirrorName() {
|
||||||
return mirrorName;
|
return mirrorName;
|
||||||
}
|
}
|
||||||
@ -39,6 +45,10 @@ public class MirrorTrait extends Trait {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setMirrorEquipment(boolean mirrorEquipment) {
|
||||||
|
this.mirrorEquipment = mirrorEquipment;
|
||||||
|
}
|
||||||
|
|
||||||
public void setMirrorName(boolean mirror) {
|
public void setMirrorName(boolean mirror) {
|
||||||
mirrorName = mirror;
|
mirrorName = mirror;
|
||||||
}
|
}
|
||||||
|
@ -528,8 +528,8 @@ public class NMS {
|
|||||||
return BRIDGE.getHeadYaw(entity);
|
return BRIDGE.getHeadYaw(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static float getHorizontalMovement(org.bukkit.entity.Entity bukkitEntity) {
|
public static float getForwardBackwardMovement(org.bukkit.entity.Entity bukkitEntity) {
|
||||||
return BRIDGE.getHorizontalMovement(bukkitEntity);
|
return BRIDGE.getForwardBackwardMovement(bukkitEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static float getJumpPower(NPC npc, float original) {
|
public static float getJumpPower(NPC npc, float original) {
|
||||||
@ -674,8 +674,8 @@ public class NMS {
|
|||||||
return BRIDGE.getVehicle(entity);
|
return BRIDGE.getVehicle(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static float getVerticalMovement(org.bukkit.entity.Entity bukkitEntity) {
|
public static float getXZMovement(org.bukkit.entity.Entity bukkitEntity) {
|
||||||
return BRIDGE.getVerticalMovement(bukkitEntity);
|
return BRIDGE.getXZMovement(bukkitEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Collection<Player> getViewingPlayers(org.bukkit.entity.Entity entity) {
|
public static Collection<Player> getViewingPlayers(org.bukkit.entity.Entity entity) {
|
||||||
|
@ -99,7 +99,7 @@ public interface NMSBridge {
|
|||||||
|
|
||||||
public float getHeadYaw(Entity entity);
|
public float getHeadYaw(Entity entity);
|
||||||
|
|
||||||
public float getHorizontalMovement(Entity entity);
|
public float getForwardBackwardMovement(Entity entity);
|
||||||
|
|
||||||
public EntityPacketTracker getPacketTracker(Entity entity);
|
public EntityPacketTracker getPacketTracker(Entity entity);
|
||||||
|
|
||||||
@ -129,7 +129,7 @@ public interface NMSBridge {
|
|||||||
|
|
||||||
public Entity getVehicle(Entity entity);
|
public Entity getVehicle(Entity entity);
|
||||||
|
|
||||||
public float getVerticalMovement(Entity entity);
|
public float getXZMovement(Entity entity);
|
||||||
|
|
||||||
public default Collection<Player> getViewingPlayers(Entity entity) {
|
public default Collection<Player> getViewingPlayers(Entity entity) {
|
||||||
return entity.getTrackedBy();
|
return entity.getTrackedBy();
|
||||||
@ -150,6 +150,10 @@ public interface NMSBridge {
|
|||||||
|
|
||||||
public boolean isSolid(Block in);
|
public boolean isSolid(Block in);
|
||||||
|
|
||||||
|
public default boolean isSprinting(Entity entity) {
|
||||||
|
return entity instanceof Player ? ((Player) entity).isSprinting() : false;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isValid(Entity entity);
|
public boolean isValid(Entity entity);
|
||||||
|
|
||||||
public void load(CommandManager commands);
|
public void load(CommandManager commands);
|
||||||
|
@ -492,6 +492,7 @@
|
|||||||
"citizens.commands.npc.select.already-selected" : "You already have that NPC selected. ",
|
"citizens.commands.npc.select.already-selected" : "You already have that NPC selected. ",
|
||||||
"citizens.commands.npc.select.description" : "Select a NPC with the given ID or name",
|
"citizens.commands.npc.select.description" : "Select a NPC with the given ID or name",
|
||||||
"citizens.commands.npc.select.help" : "",
|
"citizens.commands.npc.select.help" : "",
|
||||||
|
"citizens.commands.npc.setequipment.cosmetic-set" : "Set [[{0}]] (cosmetic) to [[{1}]].",
|
||||||
"citizens.commands.npc.setequipment.description" : "Sets equipment via commands",
|
"citizens.commands.npc.setequipment.description" : "Sets equipment via commands",
|
||||||
"citizens.commands.npc.setequipment.help" : "",
|
"citizens.commands.npc.setequipment.help" : "",
|
||||||
"citizens.commands.npc.setequipment.set" : "Set [[{0}]] to [[{1}]].",
|
"citizens.commands.npc.setequipment.set" : "Set [[{0}]] to [[{1}]].",
|
||||||
|
@ -482,7 +482,7 @@ public class NMSImpl implements NMSBridge {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float getHorizontalMovement(org.bukkit.entity.Entity entity) {
|
public float getForwardBackwardMovement(org.bukkit.entity.Entity entity) {
|
||||||
if (!entity.getType().isAlive())
|
if (!entity.getType().isAlive())
|
||||||
return Float.NaN;
|
return Float.NaN;
|
||||||
EntityLiving handle = NMSImpl.getHandle((LivingEntity) entity);
|
EntityLiving handle = NMSImpl.getHandle((LivingEntity) entity);
|
||||||
@ -681,7 +681,7 @@ public class NMSImpl implements NMSBridge {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float getVerticalMovement(org.bukkit.entity.Entity entity) {
|
public float getXZMovement(org.bukkit.entity.Entity entity) {
|
||||||
if (!entity.getType().isAlive())
|
if (!entity.getType().isAlive())
|
||||||
return Float.NaN;
|
return Float.NaN;
|
||||||
EntityLiving handle = NMSImpl.getHandle((LivingEntity) entity);
|
EntityLiving handle = NMSImpl.getHandle((LivingEntity) entity);
|
||||||
|
@ -502,7 +502,7 @@ public class NMSImpl implements NMSBridge {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float getHorizontalMovement(org.bukkit.entity.Entity entity) {
|
public float getForwardBackwardMovement(org.bukkit.entity.Entity entity) {
|
||||||
if (!entity.getType().isAlive())
|
if (!entity.getType().isAlive())
|
||||||
return Float.NaN;
|
return Float.NaN;
|
||||||
EntityLiving handle = NMSImpl.getHandle((LivingEntity) entity);
|
EntityLiving handle = NMSImpl.getHandle((LivingEntity) entity);
|
||||||
@ -717,7 +717,7 @@ public class NMSImpl implements NMSBridge {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float getVerticalMovement(org.bukkit.entity.Entity entity) {
|
public float getXZMovement(org.bukkit.entity.Entity entity) {
|
||||||
if (!entity.getType().isAlive())
|
if (!entity.getType().isAlive())
|
||||||
return Float.NaN;
|
return Float.NaN;
|
||||||
EntityLiving handle = NMSImpl.getHandle((LivingEntity) entity);
|
EntityLiving handle = NMSImpl.getHandle((LivingEntity) entity);
|
||||||
|
@ -503,7 +503,7 @@ public class NMSImpl implements NMSBridge {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float getHorizontalMovement(org.bukkit.entity.Entity entity) {
|
public float getForwardBackwardMovement(org.bukkit.entity.Entity entity) {
|
||||||
if (!entity.getType().isAlive())
|
if (!entity.getType().isAlive())
|
||||||
return Float.NaN;
|
return Float.NaN;
|
||||||
EntityLiving handle = NMSImpl.getHandle((LivingEntity) entity);
|
EntityLiving handle = NMSImpl.getHandle((LivingEntity) entity);
|
||||||
@ -719,7 +719,7 @@ public class NMSImpl implements NMSBridge {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float getVerticalMovement(org.bukkit.entity.Entity entity) {
|
public float getXZMovement(org.bukkit.entity.Entity entity) {
|
||||||
if (!entity.getType().isAlive())
|
if (!entity.getType().isAlive())
|
||||||
return Float.NaN;
|
return Float.NaN;
|
||||||
EntityLiving handle = NMSImpl.getHandle((LivingEntity) entity);
|
EntityLiving handle = NMSImpl.getHandle((LivingEntity) entity);
|
||||||
|
@ -532,7 +532,7 @@ public class NMSImpl implements NMSBridge {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float getHorizontalMovement(org.bukkit.entity.Entity entity) {
|
public float getForwardBackwardMovement(org.bukkit.entity.Entity entity) {
|
||||||
if (!entity.getType().isAlive())
|
if (!entity.getType().isAlive())
|
||||||
return Float.NaN;
|
return Float.NaN;
|
||||||
EntityLiving handle = NMSImpl.getHandle((LivingEntity) entity);
|
EntityLiving handle = NMSImpl.getHandle((LivingEntity) entity);
|
||||||
@ -748,7 +748,7 @@ public class NMSImpl implements NMSBridge {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float getVerticalMovement(org.bukkit.entity.Entity entity) {
|
public float getXZMovement(org.bukkit.entity.Entity entity) {
|
||||||
if (!entity.getType().isAlive())
|
if (!entity.getType().isAlive())
|
||||||
return Float.NaN;
|
return Float.NaN;
|
||||||
EntityLiving handle = NMSImpl.getHandle((LivingEntity) entity);
|
EntityLiving handle = NMSImpl.getHandle((LivingEntity) entity);
|
||||||
|
@ -574,7 +574,7 @@ public class NMSImpl implements NMSBridge {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float getHorizontalMovement(org.bukkit.entity.Entity entity) {
|
public float getForwardBackwardMovement(org.bukkit.entity.Entity entity) {
|
||||||
if (!entity.getType().isAlive())
|
if (!entity.getType().isAlive())
|
||||||
return Float.NaN;
|
return Float.NaN;
|
||||||
EntityLiving handle = NMSImpl.getHandle((LivingEntity) entity);
|
EntityLiving handle = NMSImpl.getHandle((LivingEntity) entity);
|
||||||
@ -799,7 +799,7 @@ public class NMSImpl implements NMSBridge {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float getVerticalMovement(org.bukkit.entity.Entity entity) {
|
public float getXZMovement(org.bukkit.entity.Entity entity) {
|
||||||
if (!entity.getType().isAlive())
|
if (!entity.getType().isAlive())
|
||||||
return Float.NaN;
|
return Float.NaN;
|
||||||
EntityLiving handle = NMSImpl.getHandle((LivingEntity) entity);
|
EntityLiving handle = NMSImpl.getHandle((LivingEntity) entity);
|
||||||
|
@ -589,7 +589,7 @@ public class NMSImpl implements NMSBridge {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float getHorizontalMovement(org.bukkit.entity.Entity entity) {
|
public float getForwardBackwardMovement(org.bukkit.entity.Entity entity) {
|
||||||
if (!entity.getType().isAlive())
|
if (!entity.getType().isAlive())
|
||||||
return Float.NaN;
|
return Float.NaN;
|
||||||
EntityLiving handle = NMSImpl.getHandle((LivingEntity) entity);
|
EntityLiving handle = NMSImpl.getHandle((LivingEntity) entity);
|
||||||
@ -814,7 +814,7 @@ public class NMSImpl implements NMSBridge {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float getVerticalMovement(org.bukkit.entity.Entity entity) {
|
public float getXZMovement(org.bukkit.entity.Entity entity) {
|
||||||
if (!entity.getType().isAlive())
|
if (!entity.getType().isAlive())
|
||||||
return Float.NaN;
|
return Float.NaN;
|
||||||
EntityLiving handle = NMSImpl.getHandle((LivingEntity) entity);
|
EntityLiving handle = NMSImpl.getHandle((LivingEntity) entity);
|
||||||
|
@ -604,7 +604,7 @@ public class NMSImpl implements NMSBridge {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float getHorizontalMovement(org.bukkit.entity.Entity entity) {
|
public float getForwardBackwardMovement(org.bukkit.entity.Entity entity) {
|
||||||
if (!entity.getType().isAlive())
|
if (!entity.getType().isAlive())
|
||||||
return Float.NaN;
|
return Float.NaN;
|
||||||
EntityLiving handle = NMSImpl.getHandle((LivingEntity) entity);
|
EntityLiving handle = NMSImpl.getHandle((LivingEntity) entity);
|
||||||
@ -837,7 +837,7 @@ public class NMSImpl implements NMSBridge {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float getVerticalMovement(org.bukkit.entity.Entity entity) {
|
public float getXZMovement(org.bukkit.entity.Entity entity) {
|
||||||
if (!entity.getType().isAlive())
|
if (!entity.getType().isAlive())
|
||||||
return Float.NaN;
|
return Float.NaN;
|
||||||
EntityLiving handle = NMSImpl.getHandle((LivingEntity) entity);
|
EntityLiving handle = NMSImpl.getHandle((LivingEntity) entity);
|
||||||
|
@ -615,7 +615,7 @@ public class NMSImpl implements NMSBridge {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float getHorizontalMovement(org.bukkit.entity.Entity entity) {
|
public float getForwardBackwardMovement(org.bukkit.entity.Entity entity) {
|
||||||
if (!entity.getType().isAlive())
|
if (!entity.getType().isAlive())
|
||||||
return Float.NaN;
|
return Float.NaN;
|
||||||
LivingEntity handle = NMSImpl.getHandle((org.bukkit.entity.LivingEntity) entity);
|
LivingEntity handle = NMSImpl.getHandle((org.bukkit.entity.LivingEntity) entity);
|
||||||
@ -839,7 +839,7 @@ public class NMSImpl implements NMSBridge {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float getVerticalMovement(org.bukkit.entity.Entity entity) {
|
public float getXZMovement(org.bukkit.entity.Entity entity) {
|
||||||
if (!entity.getType().isAlive())
|
if (!entity.getType().isAlive())
|
||||||
return Float.NaN;
|
return Float.NaN;
|
||||||
LivingEntity handle = NMSImpl.getHandle((org.bukkit.entity.LivingEntity) entity);
|
LivingEntity handle = NMSImpl.getHandle((org.bukkit.entity.LivingEntity) entity);
|
||||||
|
@ -621,7 +621,7 @@ public class NMSImpl implements NMSBridge {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float getHorizontalMovement(org.bukkit.entity.Entity entity) {
|
public float getForwardBackwardMovement(org.bukkit.entity.Entity entity) {
|
||||||
if (!entity.getType().isAlive())
|
if (!entity.getType().isAlive())
|
||||||
return Float.NaN;
|
return Float.NaN;
|
||||||
LivingEntity handle = NMSImpl.getHandle((org.bukkit.entity.LivingEntity) entity);
|
LivingEntity handle = NMSImpl.getHandle((org.bukkit.entity.LivingEntity) entity);
|
||||||
@ -846,7 +846,7 @@ public class NMSImpl implements NMSBridge {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float getVerticalMovement(org.bukkit.entity.Entity entity) {
|
public float getXZMovement(org.bukkit.entity.Entity entity) {
|
||||||
if (!entity.getType().isAlive())
|
if (!entity.getType().isAlive())
|
||||||
return Float.NaN;
|
return Float.NaN;
|
||||||
LivingEntity handle = NMSImpl.getHandle((org.bukkit.entity.LivingEntity) entity);
|
LivingEntity handle = NMSImpl.getHandle((org.bukkit.entity.LivingEntity) entity);
|
||||||
|
@ -665,7 +665,7 @@ public class NMSImpl implements NMSBridge {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float getHorizontalMovement(org.bukkit.entity.Entity entity) {
|
public float getForwardBackwardMovement(org.bukkit.entity.Entity entity) {
|
||||||
if (!entity.getType().isAlive())
|
if (!entity.getType().isAlive())
|
||||||
return Float.NaN;
|
return Float.NaN;
|
||||||
LivingEntity handle = getHandle((org.bukkit.entity.LivingEntity) entity);
|
LivingEntity handle = getHandle((org.bukkit.entity.LivingEntity) entity);
|
||||||
@ -895,7 +895,7 @@ public class NMSImpl implements NMSBridge {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float getVerticalMovement(org.bukkit.entity.Entity entity) {
|
public float getXZMovement(org.bukkit.entity.Entity entity) {
|
||||||
if (!entity.getType().isAlive())
|
if (!entity.getType().isAlive())
|
||||||
return Float.NaN;
|
return Float.NaN;
|
||||||
LivingEntity handle = getHandle((org.bukkit.entity.LivingEntity) entity);
|
LivingEntity handle = getHandle((org.bukkit.entity.LivingEntity) entity);
|
||||||
|
@ -693,7 +693,7 @@ public class NMSImpl implements NMSBridge {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float getHorizontalMovement(org.bukkit.entity.Entity entity) {
|
public float getForwardBackwardMovement(org.bukkit.entity.Entity entity) {
|
||||||
if (!entity.getType().isAlive())
|
if (!entity.getType().isAlive())
|
||||||
return Float.NaN;
|
return Float.NaN;
|
||||||
LivingEntity handle = getHandle((org.bukkit.entity.LivingEntity) entity);
|
LivingEntity handle = getHandle((org.bukkit.entity.LivingEntity) entity);
|
||||||
@ -924,7 +924,7 @@ public class NMSImpl implements NMSBridge {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float getVerticalMovement(org.bukkit.entity.Entity entity) {
|
public float getXZMovement(org.bukkit.entity.Entity entity) {
|
||||||
if (!entity.getType().isAlive())
|
if (!entity.getType().isAlive())
|
||||||
return Float.NaN;
|
return Float.NaN;
|
||||||
LivingEntity handle = getHandle((org.bukkit.entity.LivingEntity) entity);
|
LivingEntity handle = getHandle((org.bukkit.entity.LivingEntity) entity);
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
<artifactId>citizens-v1_21_R2</artifactId>
|
<artifactId>citizens-v1_21_R2</artifactId>
|
||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<craftbukkit.version>1.21.2-R0.1-SNAPSHOT</craftbukkit.version>
|
<craftbukkit.version>1.21.3-R0.1-SNAPSHOT</craftbukkit.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
@ -681,7 +681,7 @@ public class NMSImpl implements NMSBridge {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float getHorizontalMovement(org.bukkit.entity.Entity entity) {
|
public float getForwardBackwardMovement(org.bukkit.entity.Entity entity) {
|
||||||
if (!entity.getType().isAlive())
|
if (!entity.getType().isAlive())
|
||||||
return Float.NaN;
|
return Float.NaN;
|
||||||
LivingEntity handle = getHandle((org.bukkit.entity.LivingEntity) entity);
|
LivingEntity handle = getHandle((org.bukkit.entity.LivingEntity) entity);
|
||||||
@ -912,7 +912,7 @@ public class NMSImpl implements NMSBridge {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float getVerticalMovement(org.bukkit.entity.Entity entity) {
|
public float getXZMovement(org.bukkit.entity.Entity entity) {
|
||||||
if (!entity.getType().isAlive())
|
if (!entity.getType().isAlive())
|
||||||
return Float.NaN;
|
return Float.NaN;
|
||||||
LivingEntity handle = getHandle((org.bukkit.entity.LivingEntity) entity);
|
LivingEntity handle = getHandle((org.bukkit.entity.LivingEntity) entity);
|
||||||
|
@ -436,7 +436,7 @@ public class NMSImpl implements NMSBridge {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float getHorizontalMovement(org.bukkit.entity.Entity entity) {
|
public float getForwardBackwardMovement(org.bukkit.entity.Entity entity) {
|
||||||
if (!entity.getType().isAlive())
|
if (!entity.getType().isAlive())
|
||||||
return Float.NaN;
|
return Float.NaN;
|
||||||
EntityLiving handle = NMSImpl.getHandle((LivingEntity) entity);
|
EntityLiving handle = NMSImpl.getHandle((LivingEntity) entity);
|
||||||
@ -625,7 +625,7 @@ public class NMSImpl implements NMSBridge {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float getVerticalMovement(org.bukkit.entity.Entity entity) {
|
public float getXZMovement(org.bukkit.entity.Entity entity) {
|
||||||
if (!entity.getType().isAlive())
|
if (!entity.getType().isAlive())
|
||||||
return Float.NaN;
|
return Float.NaN;
|
||||||
EntityLiving handle = NMSImpl.getHandle((LivingEntity) entity);
|
EntityLiving handle = NMSImpl.getHandle((LivingEntity) entity);
|
||||||
|
Loading…
Reference in New Issue
Block a user