mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-11-29 06:05:17 +01:00
Trial removing arm swing in favour of manual position packets
This commit is contained in:
parent
d69f17cd06
commit
406bea7b53
@ -1422,7 +1422,7 @@ public class NPCCommands {
|
|||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
aliases = { "npc" },
|
aliases = { "npc" },
|
||||||
usage = "lookclose --range [range] -r[ealistic looking] --randomlook [true|false] --randomswitchtargets [true|false] --randompitchrange [min,max] --randomyawrange [min,max] --disablewhennavigating [true|false] --targetnpcs [true|false]",
|
usage = "lookclose --range [range] -r[ealistic looking] --randomlook [true|false] --perplayer [true|false] --randomswitchtargets [true|false] --randompitchrange [min,max] --randomyawrange [min,max] --disablewhennavigating [true|false] --targetnpcs [true|false]",
|
||||||
desc = "Toggle whether a NPC will look when a player is near",
|
desc = "Toggle whether a NPC will look when a player is near",
|
||||||
modifiers = { "lookclose", "look" },
|
modifiers = { "lookclose", "look" },
|
||||||
min = 1,
|
min = 1,
|
||||||
@ -2448,7 +2448,7 @@ public class NPCCommands {
|
|||||||
if (yaw != null) {
|
if (yaw != null) {
|
||||||
NMS.setBodyYaw(npc.getEntity(), yaw);
|
NMS.setBodyYaw(npc.getEntity(), yaw);
|
||||||
if (npc.getEntity().getType() == EntityType.PLAYER) {
|
if (npc.getEntity().getType() == EntityType.PLAYER) {
|
||||||
PlayerAnimation.ARM_SWING.play((Player) npc.getEntity());
|
NMS.sendPositionUpdate(npc.getEntity(), false, yaw, npc.getStoredLocation().getPitch(), null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (pitch != null) {
|
if (pitch != null) {
|
||||||
|
@ -139,6 +139,9 @@ public class RotationTrait extends Trait {
|
|||||||
NMS.setBodyYaw(entity, bodyYaw);
|
NMS.setBodyYaw(entity, bodyYaw);
|
||||||
NMS.setHeadYaw(entity, headYaw);
|
NMS.setHeadYaw(entity, headYaw);
|
||||||
NMS.setPitch(entity, pitch);
|
NMS.setPitch(entity, pitch);
|
||||||
|
if (entity instanceof Player) {
|
||||||
|
NMS.sendPositionUpdate(entity, true, bodyYaw, pitch, headYaw);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -209,7 +212,7 @@ public class RotationTrait extends Trait {
|
|||||||
@Override
|
@Override
|
||||||
public void apply() {
|
public void apply() {
|
||||||
if (Math.abs(lastBodyYaw - bodyYaw) + Math.abs(lastHeadYaw - headYaw) + Math.abs(pitch - lastPitch) > 1) {
|
if (Math.abs(lastBodyYaw - bodyYaw) + Math.abs(lastHeadYaw - headYaw) + Math.abs(pitch - lastPitch) > 1) {
|
||||||
NMS.sendRotationNearby(entity, bodyYaw, headYaw, pitch);
|
NMS.sendPositionUpdate(entity, true, bodyYaw, pitch, headYaw);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -645,12 +645,8 @@ public class NMS {
|
|||||||
BRIDGE.replaceTrackerEntry(entity);
|
BRIDGE.replaceTrackerEntry(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void sendPositionUpdate(Player excluding, org.bukkit.entity.Entity from, Location location) {
|
public static void sendPositionUpdate(Entity from, boolean position, Float bodyYaw, Float pitch, Float headYaw) {
|
||||||
BRIDGE.sendPositionUpdate(excluding, from, location);
|
BRIDGE.sendPositionUpdate(from, position, bodyYaw, pitch, headYaw);
|
||||||
}
|
|
||||||
|
|
||||||
public static void sendRotationNearby(Entity entity, float bodyYaw, float headYaw, float pitch) {
|
|
||||||
BRIDGE.sendRotationNearby(entity, bodyYaw, headYaw, pitch);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean sendTabListAdd(Player recipient, Player listPlayer) {
|
public static boolean sendTabListAdd(Player recipient, Player listPlayer) {
|
||||||
|
@ -156,9 +156,7 @@ public interface NMSBridge {
|
|||||||
|
|
||||||
public void replaceTrackerEntry(Entity entity);
|
public void replaceTrackerEntry(Entity entity);
|
||||||
|
|
||||||
public void sendPositionUpdate(Player excluding, Entity from, Location location);
|
public void sendPositionUpdate(Entity from, boolean position, Float bodyYaw, Float pitch, Float headYaw);
|
||||||
|
|
||||||
public void sendRotationNearby(Entity from, float bodyYaw, float headYaw, float pitch);
|
|
||||||
|
|
||||||
public boolean sendTabListAdd(Player recipient, Player listPlayer);
|
public boolean sendTabListAdd(Player recipient, Player listPlayer);
|
||||||
|
|
||||||
|
@ -234,6 +234,8 @@ import net.minecraft.server.v1_10_R1.NetworkManager;
|
|||||||
import net.minecraft.server.v1_10_R1.Packet;
|
import net.minecraft.server.v1_10_R1.Packet;
|
||||||
import net.minecraft.server.v1_10_R1.PacketPlayOutAnimation;
|
import net.minecraft.server.v1_10_R1.PacketPlayOutAnimation;
|
||||||
import net.minecraft.server.v1_10_R1.PacketPlayOutBed;
|
import net.minecraft.server.v1_10_R1.PacketPlayOutBed;
|
||||||
|
import net.minecraft.server.v1_10_R1.PacketPlayOutEntity.PacketPlayOutEntityLook;
|
||||||
|
import net.minecraft.server.v1_10_R1.PacketPlayOutEntity.PacketPlayOutRelEntityMoveLook;
|
||||||
import net.minecraft.server.v1_10_R1.PacketPlayOutEntityEquipment;
|
import net.minecraft.server.v1_10_R1.PacketPlayOutEntityEquipment;
|
||||||
import net.minecraft.server.v1_10_R1.PacketPlayOutEntityHeadRotation;
|
import net.minecraft.server.v1_10_R1.PacketPlayOutEntityHeadRotation;
|
||||||
import net.minecraft.server.v1_10_R1.PacketPlayOutEntityTeleport;
|
import net.minecraft.server.v1_10_R1.PacketPlayOutEntityTeleport;
|
||||||
@ -1094,22 +1096,37 @@ public class NMSImpl implements NMSBridge {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendPositionUpdate(Player excluding, org.bukkit.entity.Entity from, Location storedLocation) {
|
public void sendPositionUpdate(org.bukkit.entity.Entity from, boolean position, Float bodyYaw, Float pitch,
|
||||||
sendPacketNearby(excluding, storedLocation, new PacketPlayOutEntityTeleport(getHandle(from)));
|
Float headYaw) {
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void sendRotationNearby(org.bukkit.entity.Entity from, float bodyYaw, float headYaw, float pitch) {
|
|
||||||
Entity handle = getHandle(from);
|
Entity handle = getHandle(from);
|
||||||
float oldBody = handle.yaw;
|
if (bodyYaw == null) {
|
||||||
float oldPitch = handle.pitch;
|
bodyYaw = handle.yaw;
|
||||||
handle.yaw = bodyYaw;
|
}
|
||||||
handle.pitch = pitch;
|
if (pitch == null) {
|
||||||
Packet<?>[] packets = new Packet[] { new PacketPlayOutEntityTeleport(handle),
|
pitch = handle.pitch;
|
||||||
new PacketPlayOutEntityHeadRotation(handle, (byte) (headYaw * 256.0F / 360.0F)) };
|
}
|
||||||
sendPacketsNearby(null, from.getLocation(), packets);
|
List<Packet<?>> toSend = Lists.newArrayList();
|
||||||
handle.yaw = oldBody;
|
if (position) {
|
||||||
handle.pitch = oldPitch;
|
EntityTrackerEntry entry = ((WorldServer) handle.world).getTracker().trackedEntities.get(handle.getId());
|
||||||
|
long dx, dy, dz;
|
||||||
|
try {
|
||||||
|
dx = EntityTracker.a(handle.locX) - (long) ENTITY_TRACKER_ENTRY_X.invoke(entry);
|
||||||
|
dy = EntityTracker.a(handle.locY) - (long) ENTITY_TRACKER_ENTRY_Y.invoke(entry);
|
||||||
|
dz = EntityTracker.a(handle.locY) - (long) ENTITY_TRACKER_ENTRY_Z.invoke(entry);
|
||||||
|
} catch (Throwable e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
toSend.add(new PacketPlayOutRelEntityMoveLook(handle.getId(), (short) dx, (short) dy, (short) dz,
|
||||||
|
(byte) (bodyYaw * 256.0F / 360.0F), (byte) (pitch * 256.0F / 360.0F), handle.onGround));
|
||||||
|
} else {
|
||||||
|
toSend.add(new PacketPlayOutEntityLook(handle.getId(), (byte) (bodyYaw * 256.0F / 360.0F),
|
||||||
|
(byte) (pitch * 256.0F / 360.0F), handle.onGround));
|
||||||
|
}
|
||||||
|
if (headYaw != null) {
|
||||||
|
toSend.add(new PacketPlayOutEntityHeadRotation(handle, (byte) (headYaw * 256.0F / 360.0F)));
|
||||||
|
}
|
||||||
|
sendPacketsNearby(null, from.getLocation(), toSend, 64);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -1940,14 +1957,20 @@ public class NMSImpl implements NMSBridge {
|
|||||||
EntityType.HORSE, EntityType.GHAST);
|
EntityType.HORSE, EntityType.GHAST);
|
||||||
|
|
||||||
private static final Field CRAFT_BOSSBAR_HANDLE_FIELD = NMS.getField(CraftBossBar.class, "handle");
|
private static final Field CRAFT_BOSSBAR_HANDLE_FIELD = NMS.getField(CraftBossBar.class, "handle");
|
||||||
|
|
||||||
private static final float DEFAULT_SPEED = 1F;
|
private static final float DEFAULT_SPEED = 1F;
|
||||||
|
|
||||||
private static final Field ENDERDRAGON_BATTLE_BAR_FIELD = NMS.getField(EnderDragonBattle.class, "c");
|
private static final Field ENDERDRAGON_BATTLE_BAR_FIELD = NMS.getField(EnderDragonBattle.class, "c");
|
||||||
|
|
||||||
private static final Field ENDERDRAGON_BATTLE_FIELD = NMS.getField(EntityEnderDragon.class, "bK");
|
private static final Field ENDERDRAGON_BATTLE_FIELD = NMS.getField(EntityEnderDragon.class, "bK");
|
||||||
public static MethodHandle ENDERDRAGON_CHECK_WALLS = NMS.getFirstMethodHandleWithReturnType(EntityEnderDragon.class,
|
public static MethodHandle ENDERDRAGON_CHECK_WALLS = NMS.getFirstMethodHandleWithReturnType(EntityEnderDragon.class,
|
||||||
true, boolean.class, AxisAlignedBB.class);
|
true, boolean.class, AxisAlignedBB.class);
|
||||||
private static DataWatcherObject<Boolean> ENDERMAN_ANGRY;
|
private static DataWatcherObject<Boolean> ENDERMAN_ANGRY;
|
||||||
private static Map<Class<?>, Integer> ENTITY_CLASS_TO_INT;
|
private static Map<Class<?>, Integer> ENTITY_CLASS_TO_INT;
|
||||||
private static Map<Class<?>, String> ENTITY_CLASS_TO_NAME;
|
private static Map<Class<?>, String> ENTITY_CLASS_TO_NAME;
|
||||||
|
private static final MethodHandle ENTITY_TRACKER_ENTRY_X = NMS.getGetter(EntityTrackerEntry.class, "xLoc");
|
||||||
|
private static final MethodHandle ENTITY_TRACKER_ENTRY_Y = NMS.getGetter(EntityTrackerEntry.class, "yLoc");
|
||||||
|
private static final MethodHandle ENTITY_TRACKER_ENTRY_Z = NMS.getGetter(EntityTrackerEntry.class, "zLoc");
|
||||||
private static final Location FROM_LOCATION = new Location(null, 0, 0, 0);
|
private static final Location FROM_LOCATION = new Location(null, 0, 0, 0);
|
||||||
public static Field GOAL_FIELD = NMS.getField(PathfinderGoalSelector.class, "b");
|
public static Field GOAL_FIELD = NMS.getField(PathfinderGoalSelector.class, "b");
|
||||||
private static final Field JUMP_FIELD = NMS.getField(EntityLiving.class, "be");
|
private static final Field JUMP_FIELD = NMS.getField(EntityLiving.class, "be");
|
||||||
|
@ -254,6 +254,8 @@ import net.minecraft.server.v1_11_R1.NetworkManager;
|
|||||||
import net.minecraft.server.v1_11_R1.Packet;
|
import net.minecraft.server.v1_11_R1.Packet;
|
||||||
import net.minecraft.server.v1_11_R1.PacketPlayOutAnimation;
|
import net.minecraft.server.v1_11_R1.PacketPlayOutAnimation;
|
||||||
import net.minecraft.server.v1_11_R1.PacketPlayOutBed;
|
import net.minecraft.server.v1_11_R1.PacketPlayOutBed;
|
||||||
|
import net.minecraft.server.v1_11_R1.PacketPlayOutEntity.PacketPlayOutEntityLook;
|
||||||
|
import net.minecraft.server.v1_11_R1.PacketPlayOutEntity.PacketPlayOutRelEntityMoveLook;
|
||||||
import net.minecraft.server.v1_11_R1.PacketPlayOutEntityEquipment;
|
import net.minecraft.server.v1_11_R1.PacketPlayOutEntityEquipment;
|
||||||
import net.minecraft.server.v1_11_R1.PacketPlayOutEntityHeadRotation;
|
import net.minecraft.server.v1_11_R1.PacketPlayOutEntityHeadRotation;
|
||||||
import net.minecraft.server.v1_11_R1.PacketPlayOutEntityTeleport;
|
import net.minecraft.server.v1_11_R1.PacketPlayOutEntityTeleport;
|
||||||
@ -1147,22 +1149,37 @@ public class NMSImpl implements NMSBridge {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendPositionUpdate(Player excluding, org.bukkit.entity.Entity from, Location storedLocation) {
|
public void sendPositionUpdate(org.bukkit.entity.Entity from, boolean position, Float bodyYaw, Float pitch,
|
||||||
sendPacketNearby(excluding, storedLocation, new PacketPlayOutEntityTeleport(getHandle(from)));
|
Float headYaw) {
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void sendRotationNearby(org.bukkit.entity.Entity from, float bodyYaw, float headYaw, float pitch) {
|
|
||||||
Entity handle = getHandle(from);
|
Entity handle = getHandle(from);
|
||||||
float oldBody = handle.yaw;
|
if (bodyYaw == null) {
|
||||||
float oldPitch = handle.pitch;
|
bodyYaw = handle.yaw;
|
||||||
handle.yaw = bodyYaw;
|
}
|
||||||
handle.pitch = pitch;
|
if (pitch == null) {
|
||||||
Packet<?>[] packets = new Packet[] { new PacketPlayOutEntityTeleport(handle),
|
pitch = handle.pitch;
|
||||||
new PacketPlayOutEntityHeadRotation(handle, (byte) (headYaw * 256.0F / 360.0F)) };
|
}
|
||||||
sendPacketsNearby(null, from.getLocation(), packets);
|
List<Packet<?>> toSend = Lists.newArrayList();
|
||||||
handle.yaw = oldBody;
|
if (position) {
|
||||||
handle.pitch = oldPitch;
|
EntityTrackerEntry entry = ((WorldServer) handle.world).getTracker().trackedEntities.get(handle.getId());
|
||||||
|
long dx, dy, dz;
|
||||||
|
try {
|
||||||
|
dx = EntityTracker.a(handle.locX) - (long) ENTITY_TRACKER_ENTRY_X.invoke(entry);
|
||||||
|
dy = EntityTracker.a(handle.locY) - (long) ENTITY_TRACKER_ENTRY_Y.invoke(entry);
|
||||||
|
dz = EntityTracker.a(handle.locY) - (long) ENTITY_TRACKER_ENTRY_Z.invoke(entry);
|
||||||
|
} catch (Throwable e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
toSend.add(new PacketPlayOutRelEntityMoveLook(handle.getId(), (short) dx, (short) dy, (short) dz,
|
||||||
|
(byte) (bodyYaw * 256.0F / 360.0F), (byte) (pitch * 256.0F / 360.0F), handle.onGround));
|
||||||
|
} else {
|
||||||
|
toSend.add(new PacketPlayOutEntityLook(handle.getId(), (byte) (bodyYaw * 256.0F / 360.0F),
|
||||||
|
(byte) (pitch * 256.0F / 360.0F), handle.onGround));
|
||||||
|
}
|
||||||
|
if (headYaw != null) {
|
||||||
|
toSend.add(new PacketPlayOutEntityHeadRotation(handle, (byte) (headYaw * 256.0F / 360.0F)));
|
||||||
|
}
|
||||||
|
sendPacketsNearby(null, from.getLocation(), toSend, 64);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -1998,14 +2015,20 @@ public class NMSImpl implements NMSBridge {
|
|||||||
private static final Set<EntityType> BAD_CONTROLLER_LOOK = EnumSet.of(EntityType.POLAR_BEAR, EntityType.SILVERFISH,
|
private static final Set<EntityType> BAD_CONTROLLER_LOOK = EnumSet.of(EntityType.POLAR_BEAR, EntityType.SILVERFISH,
|
||||||
EntityType.ENDERMITE, EntityType.ENDER_DRAGON, EntityType.BAT, EntityType.SLIME, EntityType.MAGMA_CUBE,
|
EntityType.ENDERMITE, EntityType.ENDER_DRAGON, EntityType.BAT, EntityType.SLIME, EntityType.MAGMA_CUBE,
|
||||||
EntityType.HORSE, EntityType.GHAST);
|
EntityType.HORSE, EntityType.GHAST);
|
||||||
|
|
||||||
private static final Field CRAFT_BOSSBAR_HANDLE_FIELD = NMS.getField(CraftBossBar.class, "handle");
|
private static final Field CRAFT_BOSSBAR_HANDLE_FIELD = NMS.getField(CraftBossBar.class, "handle");
|
||||||
|
|
||||||
private static final float DEFAULT_SPEED = 1F;
|
private static final float DEFAULT_SPEED = 1F;
|
||||||
|
|
||||||
private static final Field ENDERDRAGON_BATTLE_BAR_FIELD = NMS.getField(EnderDragonBattle.class, "c");
|
private static final Field ENDERDRAGON_BATTLE_BAR_FIELD = NMS.getField(EnderDragonBattle.class, "c");
|
||||||
private static final Field ENDERDRAGON_BATTLE_FIELD = NMS.getField(EntityEnderDragon.class, "bJ");
|
private static final Field ENDERDRAGON_BATTLE_FIELD = NMS.getField(EntityEnderDragon.class, "bJ");
|
||||||
public static MethodHandle ENDERDRAGON_CHECK_WALLS = NMS.getFirstMethodHandleWithReturnType(EntityEnderDragon.class,
|
public static MethodHandle ENDERDRAGON_CHECK_WALLS = NMS.getFirstMethodHandleWithReturnType(EntityEnderDragon.class,
|
||||||
true, boolean.class, AxisAlignedBB.class);
|
true, boolean.class, AxisAlignedBB.class);
|
||||||
private static DataWatcherObject<Boolean> ENDERMAN_ANGRY;
|
private static DataWatcherObject<Boolean> ENDERMAN_ANGRY;
|
||||||
private static CustomEntityRegistry ENTITY_REGISTRY;
|
private static CustomEntityRegistry ENTITY_REGISTRY;
|
||||||
|
private static final MethodHandle ENTITY_TRACKER_ENTRY_X = NMS.getGetter(EntityTrackerEntry.class, "xLoc");
|
||||||
|
private static final MethodHandle ENTITY_TRACKER_ENTRY_Y = NMS.getGetter(EntityTrackerEntry.class, "yLoc");
|
||||||
|
private static final MethodHandle ENTITY_TRACKER_ENTRY_Z = NMS.getGetter(EntityTrackerEntry.class, "zLoc");
|
||||||
private static final Location FROM_LOCATION = new Location(null, 0, 0, 0);
|
private static final Location FROM_LOCATION = new Location(null, 0, 0, 0);
|
||||||
public static Field GOAL_FIELD = NMS.getField(PathfinderGoalSelector.class, "b");
|
public static Field GOAL_FIELD = NMS.getField(PathfinderGoalSelector.class, "b");
|
||||||
private static final Field JUMP_FIELD = NMS.getField(EntityLiving.class, "bd");
|
private static final Field JUMP_FIELD = NMS.getField(EntityLiving.class, "bd");
|
||||||
|
@ -258,6 +258,8 @@ import net.minecraft.server.v1_12_R1.NetworkManager;
|
|||||||
import net.minecraft.server.v1_12_R1.Packet;
|
import net.minecraft.server.v1_12_R1.Packet;
|
||||||
import net.minecraft.server.v1_12_R1.PacketPlayOutAnimation;
|
import net.minecraft.server.v1_12_R1.PacketPlayOutAnimation;
|
||||||
import net.minecraft.server.v1_12_R1.PacketPlayOutBed;
|
import net.minecraft.server.v1_12_R1.PacketPlayOutBed;
|
||||||
|
import net.minecraft.server.v1_12_R1.PacketPlayOutEntity.PacketPlayOutEntityLook;
|
||||||
|
import net.minecraft.server.v1_12_R1.PacketPlayOutEntity.PacketPlayOutRelEntityMoveLook;
|
||||||
import net.minecraft.server.v1_12_R1.PacketPlayOutEntityEquipment;
|
import net.minecraft.server.v1_12_R1.PacketPlayOutEntityEquipment;
|
||||||
import net.minecraft.server.v1_12_R1.PacketPlayOutEntityHeadRotation;
|
import net.minecraft.server.v1_12_R1.PacketPlayOutEntityHeadRotation;
|
||||||
import net.minecraft.server.v1_12_R1.PacketPlayOutEntityTeleport;
|
import net.minecraft.server.v1_12_R1.PacketPlayOutEntityTeleport;
|
||||||
@ -1154,22 +1156,37 @@ public class NMSImpl implements NMSBridge {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendPositionUpdate(Player excluding, org.bukkit.entity.Entity from, Location storedLocation) {
|
public void sendPositionUpdate(org.bukkit.entity.Entity from, boolean position, Float bodyYaw, Float pitch,
|
||||||
sendPacketNearby(excluding, storedLocation, new PacketPlayOutEntityTeleport(getHandle(from)));
|
Float headYaw) {
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void sendRotationNearby(org.bukkit.entity.Entity from, float bodyYaw, float headYaw, float pitch) {
|
|
||||||
Entity handle = getHandle(from);
|
Entity handle = getHandle(from);
|
||||||
float oldBody = handle.yaw;
|
if (bodyYaw == null) {
|
||||||
float oldPitch = handle.pitch;
|
bodyYaw = handle.yaw;
|
||||||
handle.yaw = bodyYaw;
|
}
|
||||||
handle.pitch = pitch;
|
if (pitch == null) {
|
||||||
Packet<?>[] packets = new Packet[] { new PacketPlayOutEntityTeleport(handle),
|
pitch = handle.pitch;
|
||||||
new PacketPlayOutEntityHeadRotation(handle, (byte) (headYaw * 256.0F / 360.0F)) };
|
}
|
||||||
sendPacketsNearby(null, from.getLocation(), packets);
|
List<Packet<?>> toSend = Lists.newArrayList();
|
||||||
handle.yaw = oldBody;
|
if (position) {
|
||||||
handle.pitch = oldPitch;
|
EntityTrackerEntry entry = ((WorldServer) handle.world).getTracker().trackedEntities.get(handle.getId());
|
||||||
|
long dx, dy, dz;
|
||||||
|
try {
|
||||||
|
dx = EntityTracker.a(handle.locX) - (long) ENTITY_TRACKER_ENTRY_X.invoke(entry);
|
||||||
|
dy = EntityTracker.a(handle.locY) - (long) ENTITY_TRACKER_ENTRY_Y.invoke(entry);
|
||||||
|
dz = EntityTracker.a(handle.locY) - (long) ENTITY_TRACKER_ENTRY_Z.invoke(entry);
|
||||||
|
} catch (Throwable e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
toSend.add(new PacketPlayOutRelEntityMoveLook(handle.getId(), (short) dx, (short) dy, (short) dz,
|
||||||
|
(byte) (bodyYaw * 256.0F / 360.0F), (byte) (pitch * 256.0F / 360.0F), handle.onGround));
|
||||||
|
} else {
|
||||||
|
toSend.add(new PacketPlayOutEntityLook(handle.getId(), (byte) (bodyYaw * 256.0F / 360.0F),
|
||||||
|
(byte) (pitch * 256.0F / 360.0F), handle.onGround));
|
||||||
|
}
|
||||||
|
if (headYaw != null) {
|
||||||
|
toSend.add(new PacketPlayOutEntityHeadRotation(handle, (byte) (headYaw * 256.0F / 360.0F)));
|
||||||
|
}
|
||||||
|
sendPacketsNearby(null, from.getLocation(), toSend, 64);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -2005,14 +2022,20 @@ public class NMSImpl implements NMSBridge {
|
|||||||
private static final Set<EntityType> BAD_CONTROLLER_LOOK = EnumSet.of(EntityType.POLAR_BEAR, EntityType.SILVERFISH,
|
private static final Set<EntityType> BAD_CONTROLLER_LOOK = EnumSet.of(EntityType.POLAR_BEAR, EntityType.SILVERFISH,
|
||||||
EntityType.SHULKER, EntityType.ENDERMITE, EntityType.ENDER_DRAGON, EntityType.BAT, EntityType.SLIME,
|
EntityType.SHULKER, EntityType.ENDERMITE, EntityType.ENDER_DRAGON, EntityType.BAT, EntityType.SLIME,
|
||||||
EntityType.MAGMA_CUBE, EntityType.HORSE, EntityType.GHAST);
|
EntityType.MAGMA_CUBE, EntityType.HORSE, EntityType.GHAST);
|
||||||
|
|
||||||
private static final Field CRAFT_BOSSBAR_HANDLE_FIELD = NMS.getField(CraftBossBar.class, "handle");
|
private static final Field CRAFT_BOSSBAR_HANDLE_FIELD = NMS.getField(CraftBossBar.class, "handle");
|
||||||
|
|
||||||
private static final float DEFAULT_SPEED = 1F;
|
private static final float DEFAULT_SPEED = 1F;
|
||||||
|
|
||||||
private static final Field ENDERDRAGON_BATTLE_BAR_FIELD = NMS.getField(EnderDragonBattle.class, "c");
|
private static final Field ENDERDRAGON_BATTLE_BAR_FIELD = NMS.getField(EnderDragonBattle.class, "c");
|
||||||
private static final Field ENDERDRAGON_BATTLE_FIELD = NMS.getField(EntityEnderDragon.class, "bK");
|
private static final Field ENDERDRAGON_BATTLE_FIELD = NMS.getField(EntityEnderDragon.class, "bK");
|
||||||
public static MethodHandle ENDERDRAGON_CHECK_WALLS = NMS.getFirstMethodHandleWithReturnType(EntityEnderDragon.class,
|
public static MethodHandle ENDERDRAGON_CHECK_WALLS = NMS.getFirstMethodHandleWithReturnType(EntityEnderDragon.class,
|
||||||
true, boolean.class, AxisAlignedBB.class);
|
true, boolean.class, AxisAlignedBB.class);
|
||||||
private static DataWatcherObject<Boolean> ENDERMAN_ANGRY;
|
private static DataWatcherObject<Boolean> ENDERMAN_ANGRY;
|
||||||
private static CustomEntityRegistry ENTITY_REGISTRY;
|
private static CustomEntityRegistry ENTITY_REGISTRY;
|
||||||
|
private static final MethodHandle ENTITY_TRACKER_ENTRY_X = NMS.getGetter(EntityTrackerEntry.class, "xLoc");
|
||||||
|
private static final MethodHandle ENTITY_TRACKER_ENTRY_Y = NMS.getGetter(EntityTrackerEntry.class, "yLoc");
|
||||||
|
private static final MethodHandle ENTITY_TRACKER_ENTRY_Z = NMS.getGetter(EntityTrackerEntry.class, "zLoc");
|
||||||
private static final Location FROM_LOCATION = new Location(null, 0, 0, 0);
|
private static final Location FROM_LOCATION = new Location(null, 0, 0, 0);
|
||||||
public static Field GOAL_FIELD = NMS.getField(PathfinderGoalSelector.class, "b");
|
public static Field GOAL_FIELD = NMS.getField(PathfinderGoalSelector.class, "b");
|
||||||
private static final Field JUMP_FIELD = NMS.getField(EntityLiving.class, "bd");
|
private static final Field JUMP_FIELD = NMS.getField(EntityLiving.class, "bd");
|
||||||
|
@ -45,12 +45,9 @@ public class PlayerlistTrackerEntry extends EntityTrackerEntry {
|
|||||||
lastUpdatedPlayer = null;
|
lastUpdatedPlayer = null;
|
||||||
if (!Setting.DISABLE_TABLIST.asBoolean())
|
if (!Setting.DISABLE_TABLIST.asBoolean())
|
||||||
return;
|
return;
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(CitizensAPI.getPlugin(), new Runnable() {
|
Bukkit.getScheduler().scheduleSyncDelayedTask(CitizensAPI.getPlugin(),
|
||||||
@Override
|
() -> NMS.sendTabListRemove(entityplayer.getBukkitEntity(), (Player) tracker.getBukkitEntity()),
|
||||||
public void run() {
|
Setting.TABLIST_REMOVE_PACKET_DELAY.asTicks());
|
||||||
NMS.sendTabListRemove(entityplayer.getBukkitEntity(), (Player) tracker.getBukkitEntity());
|
|
||||||
}
|
|
||||||
}, Setting.TABLIST_REMOVE_PACKET_DELAY.asTicks());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -277,6 +277,7 @@ import net.minecraft.server.v1_13_R2.Packet;
|
|||||||
import net.minecraft.server.v1_13_R2.PacketPlayOutAnimation;
|
import net.minecraft.server.v1_13_R2.PacketPlayOutAnimation;
|
||||||
import net.minecraft.server.v1_13_R2.PacketPlayOutBed;
|
import net.minecraft.server.v1_13_R2.PacketPlayOutBed;
|
||||||
import net.minecraft.server.v1_13_R2.PacketPlayOutEntity.PacketPlayOutEntityLook;
|
import net.minecraft.server.v1_13_R2.PacketPlayOutEntity.PacketPlayOutEntityLook;
|
||||||
|
import net.minecraft.server.v1_13_R2.PacketPlayOutEntity.PacketPlayOutRelEntityMoveLook;
|
||||||
import net.minecraft.server.v1_13_R2.PacketPlayOutEntityEquipment;
|
import net.minecraft.server.v1_13_R2.PacketPlayOutEntityEquipment;
|
||||||
import net.minecraft.server.v1_13_R2.PacketPlayOutEntityHeadRotation;
|
import net.minecraft.server.v1_13_R2.PacketPlayOutEntityHeadRotation;
|
||||||
import net.minecraft.server.v1_13_R2.PacketPlayOutEntityTeleport;
|
import net.minecraft.server.v1_13_R2.PacketPlayOutEntityTeleport;
|
||||||
@ -1197,18 +1198,37 @@ public class NMSImpl implements NMSBridge {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendPositionUpdate(Player excluding, org.bukkit.entity.Entity from, Location storedLocation) {
|
public void sendPositionUpdate(org.bukkit.entity.Entity from, boolean position, Float bodyYaw, Float pitch,
|
||||||
sendPacketNearby(excluding, storedLocation, new PacketPlayOutEntityTeleport(getHandle(from)));
|
Float headYaw) {
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void sendRotationNearby(org.bukkit.entity.Entity from, float bodyYaw, float headYaw, float pitch) {
|
|
||||||
Entity handle = getHandle(from);
|
Entity handle = getHandle(from);
|
||||||
Packet<?>[] packets = new Packet[] {
|
if (bodyYaw == null) {
|
||||||
new PacketPlayOutEntityLook(handle.getId(), (byte) (bodyYaw * 256.0F / 360.0F),
|
bodyYaw = handle.yaw;
|
||||||
(byte) (pitch * 256.0F / 360.0F), isOnGround(from)),
|
}
|
||||||
new PacketPlayOutEntityHeadRotation(handle, (byte) (headYaw * 256.0F / 360.0F)) };
|
if (pitch == null) {
|
||||||
sendPacketsNearby(null, from.getLocation(), packets);
|
pitch = handle.pitch;
|
||||||
|
}
|
||||||
|
List<Packet<?>> toSend = Lists.newArrayList();
|
||||||
|
if (position) {
|
||||||
|
EntityTrackerEntry entry = ((WorldServer) handle.world).getTracker().trackedEntities.get(handle.getId());
|
||||||
|
long dx, dy, dz;
|
||||||
|
try {
|
||||||
|
dx = EntityTracker.a(handle.locX) - (long) ENTITY_TRACKER_ENTRY_X.invoke(entry);
|
||||||
|
dy = EntityTracker.a(handle.locY) - (long) ENTITY_TRACKER_ENTRY_Y.invoke(entry);
|
||||||
|
dz = EntityTracker.a(handle.locY) - (long) ENTITY_TRACKER_ENTRY_Z.invoke(entry);
|
||||||
|
} catch (Throwable e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
toSend.add(new PacketPlayOutRelEntityMoveLook(handle.getId(), (short) dx, (short) dy, (short) dz,
|
||||||
|
(byte) (bodyYaw * 256.0F / 360.0F), (byte) (pitch * 256.0F / 360.0F), handle.onGround));
|
||||||
|
} else {
|
||||||
|
toSend.add(new PacketPlayOutEntityLook(handle.getId(), (byte) (bodyYaw * 256.0F / 360.0F),
|
||||||
|
(byte) (pitch * 256.0F / 360.0F), handle.onGround));
|
||||||
|
}
|
||||||
|
if (headYaw != null) {
|
||||||
|
toSend.add(new PacketPlayOutEntityHeadRotation(handle, (byte) (headYaw * 256.0F / 360.0F)));
|
||||||
|
}
|
||||||
|
sendPacketsNearby(null, from.getLocation(), toSend, 64);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -2149,13 +2169,17 @@ public class NMSImpl implements NMSBridge {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static MethodHandle ADVANCEMENT_PLAYER_FIELD = NMS.getFinalSetter(EntityPlayer.class, "cf");
|
private static MethodHandle ADVANCEMENT_PLAYER_FIELD = NMS.getFinalSetter(EntityPlayer.class, "cf");
|
||||||
|
|
||||||
private static final Set<EntityType> BAD_CONTROLLER_LOOK = EnumSet.of(EntityType.POLAR_BEAR, EntityType.SILVERFISH,
|
private static final Set<EntityType> BAD_CONTROLLER_LOOK = EnumSet.of(EntityType.POLAR_BEAR, EntityType.SILVERFISH,
|
||||||
EntityType.SHULKER, EntityType.ENDERMITE, EntityType.ENDER_DRAGON, EntityType.BAT, EntityType.SLIME,
|
EntityType.SHULKER, EntityType.ENDERMITE, EntityType.ENDER_DRAGON, EntityType.BAT, EntityType.SLIME,
|
||||||
EntityType.DOLPHIN, EntityType.MAGMA_CUBE, EntityType.HORSE, EntityType.GHAST, EntityType.SHULKER,
|
EntityType.DOLPHIN, EntityType.MAGMA_CUBE, EntityType.HORSE, EntityType.GHAST, EntityType.SHULKER,
|
||||||
EntityType.PHANTOM);
|
EntityType.PHANTOM);
|
||||||
|
|
||||||
private static final Method BLOCK_POSITION_B_D = NMS.getMethod(BlockPosition.PooledBlockPosition.class, "e", false,
|
private static final Method BLOCK_POSITION_B_D = NMS.getMethod(BlockPosition.PooledBlockPosition.class, "e", false,
|
||||||
double.class, double.class, double.class);
|
double.class, double.class, double.class);
|
||||||
|
|
||||||
private static final Field CRAFT_BOSSBAR_HANDLE_FIELD = NMS.getField(CraftBossBar.class, "handle");
|
private static final Field CRAFT_BOSSBAR_HANDLE_FIELD = NMS.getField(CraftBossBar.class, "handle");
|
||||||
|
|
||||||
private static final float DEFAULT_SPEED = 1F;
|
private static final float DEFAULT_SPEED = 1F;
|
||||||
private static final Field ENDERDRAGON_BATTLE_BAR_FIELD = NMS.getField(EnderDragonBattle.class, "c", false);
|
private static final Field ENDERDRAGON_BATTLE_BAR_FIELD = NMS.getField(EnderDragonBattle.class, "c", false);
|
||||||
private static final Field ENDERDRAGON_BATTLE_FIELD = NMS.getField(EntityEnderDragon.class, "bR");
|
private static final Field ENDERDRAGON_BATTLE_FIELD = NMS.getField(EntityEnderDragon.class, "bR");
|
||||||
@ -2165,6 +2189,9 @@ public class NMSImpl implements NMSBridge {
|
|||||||
private static Method ENTITY_FISH_METHOD = NMS.getMethod(EntityFish.class, "t", false, boolean.class);
|
private static Method ENTITY_FISH_METHOD = NMS.getMethod(EntityFish.class, "t", false, boolean.class);
|
||||||
private static Field ENTITY_FISH_NUM_IN_SCHOOL;
|
private static Field ENTITY_FISH_NUM_IN_SCHOOL;
|
||||||
private static CustomEntityRegistry ENTITY_REGISTRY;
|
private static CustomEntityRegistry ENTITY_REGISTRY;
|
||||||
|
private static final MethodHandle ENTITY_TRACKER_ENTRY_X = NMS.getGetter(EntityTrackerEntry.class, "xLoc");
|
||||||
|
private static final MethodHandle ENTITY_TRACKER_ENTRY_Y = NMS.getGetter(EntityTrackerEntry.class, "yLoc");
|
||||||
|
private static final MethodHandle ENTITY_TRACKER_ENTRY_Z = NMS.getGetter(EntityTrackerEntry.class, "zLoc");
|
||||||
private static final Location FROM_LOCATION = new Location(null, 0, 0, 0);
|
private static final Location FROM_LOCATION = new Location(null, 0, 0, 0);
|
||||||
public static Field GOAL_FIELD = NMS.getField(PathfinderGoalSelector.class, "b");
|
public static Field GOAL_FIELD = NMS.getField(PathfinderGoalSelector.class, "b");
|
||||||
private static final Field JUMP_FIELD = NMS.getField(EntityLiving.class, "bg");
|
private static final Field JUMP_FIELD = NMS.getField(EntityLiving.class, "bg");
|
||||||
|
@ -44,12 +44,9 @@ public class PlayerlistTrackerEntry extends EntityTrackerEntry {
|
|||||||
lastUpdatedPlayer = null;
|
lastUpdatedPlayer = null;
|
||||||
if (!Setting.DISABLE_TABLIST.asBoolean())
|
if (!Setting.DISABLE_TABLIST.asBoolean())
|
||||||
return;
|
return;
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(CitizensAPI.getPlugin(), new Runnable() {
|
Bukkit.getScheduler().scheduleSyncDelayedTask(CitizensAPI.getPlugin(),
|
||||||
@Override
|
() -> NMS.sendTabListRemove(entityplayer.getBukkitEntity(), (Player) tracker.getBukkitEntity()),
|
||||||
public void run() {
|
Setting.TABLIST_REMOVE_PACKET_DELAY.asTicks());
|
||||||
NMS.sendTabListRemove(entityplayer.getBukkitEntity(), (Player) tracker.getBukkitEntity());
|
|
||||||
}
|
|
||||||
}, Setting.TABLIST_REMOVE_PACKET_DELAY.asTicks());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -291,9 +291,10 @@ import net.minecraft.server.v1_14_R1.MobEffects;
|
|||||||
import net.minecraft.server.v1_14_R1.NavigationAbstract;
|
import net.minecraft.server.v1_14_R1.NavigationAbstract;
|
||||||
import net.minecraft.server.v1_14_R1.NetworkManager;
|
import net.minecraft.server.v1_14_R1.NetworkManager;
|
||||||
import net.minecraft.server.v1_14_R1.Packet;
|
import net.minecraft.server.v1_14_R1.Packet;
|
||||||
|
import net.minecraft.server.v1_14_R1.PacketPlayOutEntity.PacketPlayOutEntityLook;
|
||||||
|
import net.minecraft.server.v1_14_R1.PacketPlayOutEntity.PacketPlayOutRelEntityMoveLook;
|
||||||
import net.minecraft.server.v1_14_R1.PacketPlayOutEntityEquipment;
|
import net.minecraft.server.v1_14_R1.PacketPlayOutEntityEquipment;
|
||||||
import net.minecraft.server.v1_14_R1.PacketPlayOutEntityHeadRotation;
|
import net.minecraft.server.v1_14_R1.PacketPlayOutEntityHeadRotation;
|
||||||
import net.minecraft.server.v1_14_R1.PacketPlayOutEntityTeleport;
|
|
||||||
import net.minecraft.server.v1_14_R1.PacketPlayOutOpenWindow;
|
import net.minecraft.server.v1_14_R1.PacketPlayOutOpenWindow;
|
||||||
import net.minecraft.server.v1_14_R1.PacketPlayOutPlayerInfo;
|
import net.minecraft.server.v1_14_R1.PacketPlayOutPlayerInfo;
|
||||||
import net.minecraft.server.v1_14_R1.PacketPlayOutScoreboardTeam;
|
import net.minecraft.server.v1_14_R1.PacketPlayOutScoreboardTeam;
|
||||||
@ -1213,22 +1214,37 @@ public class NMSImpl implements NMSBridge {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendPositionUpdate(Player excluding, org.bukkit.entity.Entity from, Location storedLocation) {
|
public void sendPositionUpdate(org.bukkit.entity.Entity from, boolean position, Float bodyYaw, Float pitch,
|
||||||
sendPacketNearby(excluding, storedLocation, new PacketPlayOutEntityTeleport(getHandle(from)));
|
Float headYaw) {
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void sendRotationNearby(org.bukkit.entity.Entity from, float bodyYaw, float headYaw, float pitch) {
|
|
||||||
Entity handle = getHandle(from);
|
Entity handle = getHandle(from);
|
||||||
float oldBody = handle.yaw;
|
if (bodyYaw == null) {
|
||||||
float oldPitch = handle.pitch;
|
bodyYaw = handle.yaw;
|
||||||
handle.yaw = bodyYaw;
|
}
|
||||||
handle.pitch = pitch;
|
if (pitch == null) {
|
||||||
Packet<?>[] packets = new Packet[] { new PacketPlayOutEntityTeleport(handle),
|
pitch = handle.pitch;
|
||||||
new PacketPlayOutEntityHeadRotation(handle, (byte) (headYaw * 256.0F / 360.0F)) };
|
}
|
||||||
sendPacketsNearby(null, from.getLocation(), packets);
|
List<Packet<?>> toSend = Lists.newArrayList();
|
||||||
handle.yaw = oldBody;
|
if (position) {
|
||||||
handle.pitch = oldPitch;
|
EntityTracker entry = ((WorldServer) handle.world).getChunkProvider().playerChunkMap.trackedEntities
|
||||||
|
.get(handle.getId());
|
||||||
|
EntityTrackerEntry ete = null;
|
||||||
|
try {
|
||||||
|
ete = (EntityTrackerEntry) ENTITY_TRACKER_ENTRY_GETTER.invoke(entry);
|
||||||
|
} catch (Throwable e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Vec3D pos = handle.getPositionVector().d(ete.b());
|
||||||
|
toSend.add(new PacketPlayOutRelEntityMoveLook(handle.getId(), (short) pos.x, (short) pos.y, (short) pos.z,
|
||||||
|
(byte) (bodyYaw * 256.0F / 360.0F), (byte) (pitch * 256.0F / 360.0F), handle.onGround));
|
||||||
|
} else {
|
||||||
|
toSend.add(new PacketPlayOutEntityLook(handle.getId(), (byte) (bodyYaw * 256.0F / 360.0F),
|
||||||
|
(byte) (pitch * 256.0F / 360.0F), handle.onGround));
|
||||||
|
}
|
||||||
|
if (headYaw != null) {
|
||||||
|
toSend.add(new PacketPlayOutEntityHeadRotation(handle, (byte) (headYaw * 256.0F / 360.0F)));
|
||||||
|
}
|
||||||
|
sendPacketsNearby(null, from.getLocation(), toSend, 64);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -2224,6 +2240,7 @@ public class NMSImpl implements NMSBridge {
|
|||||||
|
|
||||||
private static final MethodHandle ADVANCEMENT_PLAYER_FIELD = NMS.getFinalSetter(EntityPlayer.class,
|
private static final MethodHandle ADVANCEMENT_PLAYER_FIELD = NMS.getFinalSetter(EntityPlayer.class,
|
||||||
"advancementDataPlayer");
|
"advancementDataPlayer");
|
||||||
|
|
||||||
private static final Set<EntityType> BAD_CONTROLLER_LOOK = EnumSet.of(EntityType.POLAR_BEAR, EntityType.SILVERFISH,
|
private static final Set<EntityType> BAD_CONTROLLER_LOOK = EnumSet.of(EntityType.POLAR_BEAR, EntityType.SILVERFISH,
|
||||||
EntityType.SHULKER, EntityType.ENDERMITE, EntityType.ENDER_DRAGON, EntityType.BAT, EntityType.SLIME,
|
EntityType.SHULKER, EntityType.ENDERMITE, EntityType.ENDER_DRAGON, EntityType.BAT, EntityType.SLIME,
|
||||||
EntityType.DOLPHIN, EntityType.MAGMA_CUBE, EntityType.HORSE, EntityType.GHAST, EntityType.SHULKER,
|
EntityType.DOLPHIN, EntityType.MAGMA_CUBE, EntityType.HORSE, EntityType.GHAST, EntityType.SHULKER,
|
||||||
@ -2250,6 +2267,8 @@ public class NMSImpl implements NMSBridge {
|
|||||||
EntityPose.class);
|
EntityPose.class);
|
||||||
private static final MethodHandle ENTITY_SETPOSE_METHOD = NMS.getMethodHandle(Entity.class, "setPose", true,
|
private static final MethodHandle ENTITY_SETPOSE_METHOD = NMS.getMethodHandle(Entity.class, "setPose", true,
|
||||||
EntityPose.class);
|
EntityPose.class);
|
||||||
|
private static final MethodHandle ENTITY_TRACKER_ENTRY_GETTER = NMS.getFirstGetter(EntityTracker.class,
|
||||||
|
EntityTrackerEntry.class);
|
||||||
private static final Location FROM_LOCATION = new Location(null, 0, 0, 0);
|
private static final Location FROM_LOCATION = new Location(null, 0, 0, 0);
|
||||||
private static final MethodHandle GOAL_FIELD = NMS.getGetter(PathfinderGoalSelector.class, "d");
|
private static final MethodHandle GOAL_FIELD = NMS.getGetter(PathfinderGoalSelector.class, "d");
|
||||||
private static final MethodHandle HEAD_HEIGHT = NMS.getSetter(Entity.class, "headHeight");
|
private static final MethodHandle HEAD_HEIGHT = NMS.getSetter(Entity.class, "headHeight");
|
||||||
|
@ -39,12 +39,9 @@ public class PlayerlistTracker extends PlayerChunkMap.EntityTracker {
|
|||||||
NMS.sendTabListAdd(entityplayer.getBukkitEntity(), (Player) tracker.getBukkitEntity());
|
NMS.sendTabListAdd(entityplayer.getBukkitEntity(), (Player) tracker.getBukkitEntity());
|
||||||
if (!Setting.DISABLE_TABLIST.asBoolean())
|
if (!Setting.DISABLE_TABLIST.asBoolean())
|
||||||
return;
|
return;
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(CitizensAPI.getPlugin(), new Runnable() {
|
Bukkit.getScheduler().scheduleSyncDelayedTask(CitizensAPI.getPlugin(),
|
||||||
@Override
|
() -> NMS.sendTabListRemove(entityplayer.getBukkitEntity(), (Player) tracker.getBukkitEntity()),
|
||||||
public void run() {
|
Setting.TABLIST_REMOVE_PACKET_DELAY.asTicks());
|
||||||
NMS.sendTabListRemove(entityplayer.getBukkitEntity(), (Player) tracker.getBukkitEntity());
|
|
||||||
}
|
|
||||||
}, Setting.TABLIST_REMOVE_PACKET_DELAY.asTicks());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -296,9 +296,10 @@ import net.minecraft.server.v1_15_R1.MobEffects;
|
|||||||
import net.minecraft.server.v1_15_R1.NavigationAbstract;
|
import net.minecraft.server.v1_15_R1.NavigationAbstract;
|
||||||
import net.minecraft.server.v1_15_R1.NetworkManager;
|
import net.minecraft.server.v1_15_R1.NetworkManager;
|
||||||
import net.minecraft.server.v1_15_R1.Packet;
|
import net.minecraft.server.v1_15_R1.Packet;
|
||||||
|
import net.minecraft.server.v1_15_R1.PacketPlayOutEntity.PacketPlayOutEntityLook;
|
||||||
|
import net.minecraft.server.v1_15_R1.PacketPlayOutEntity.PacketPlayOutRelEntityMoveLook;
|
||||||
import net.minecraft.server.v1_15_R1.PacketPlayOutEntityEquipment;
|
import net.minecraft.server.v1_15_R1.PacketPlayOutEntityEquipment;
|
||||||
import net.minecraft.server.v1_15_R1.PacketPlayOutEntityHeadRotation;
|
import net.minecraft.server.v1_15_R1.PacketPlayOutEntityHeadRotation;
|
||||||
import net.minecraft.server.v1_15_R1.PacketPlayOutEntityTeleport;
|
|
||||||
import net.minecraft.server.v1_15_R1.PacketPlayOutOpenWindow;
|
import net.minecraft.server.v1_15_R1.PacketPlayOutOpenWindow;
|
||||||
import net.minecraft.server.v1_15_R1.PacketPlayOutPlayerInfo;
|
import net.minecraft.server.v1_15_R1.PacketPlayOutPlayerInfo;
|
||||||
import net.minecraft.server.v1_15_R1.PacketPlayOutScoreboardTeam;
|
import net.minecraft.server.v1_15_R1.PacketPlayOutScoreboardTeam;
|
||||||
@ -1230,22 +1231,37 @@ public class NMSImpl implements NMSBridge {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendPositionUpdate(Player excluding, org.bukkit.entity.Entity from, Location storedLocation) {
|
public void sendPositionUpdate(org.bukkit.entity.Entity from, boolean position, Float bodyYaw, Float pitch,
|
||||||
sendPacketNearby(excluding, storedLocation, new PacketPlayOutEntityTeleport(getHandle(from)));
|
Float headYaw) {
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void sendRotationNearby(org.bukkit.entity.Entity from, float bodyYaw, float headYaw, float pitch) {
|
|
||||||
Entity handle = getHandle(from);
|
Entity handle = getHandle(from);
|
||||||
float oldBody = handle.yaw;
|
if (bodyYaw == null) {
|
||||||
float oldPitch = handle.pitch;
|
bodyYaw = handle.yaw;
|
||||||
handle.yaw = bodyYaw;
|
}
|
||||||
handle.pitch = pitch;
|
if (pitch == null) {
|
||||||
Packet<?>[] packets = new Packet[] { new PacketPlayOutEntityTeleport(handle),
|
pitch = handle.pitch;
|
||||||
new PacketPlayOutEntityHeadRotation(handle, (byte) (headYaw * 256.0F / 360.0F)) };
|
}
|
||||||
sendPacketsNearby(null, from.getLocation(), packets);
|
List<Packet<?>> toSend = Lists.newArrayList();
|
||||||
handle.yaw = oldBody;
|
if (position) {
|
||||||
handle.pitch = oldPitch;
|
EntityTracker entry = ((WorldServer) handle.world).getChunkProvider().playerChunkMap.trackedEntities
|
||||||
|
.get(handle.getId());
|
||||||
|
EntityTrackerEntry ete = null;
|
||||||
|
try {
|
||||||
|
ete = (EntityTrackerEntry) ENTITY_TRACKER_ENTRY_GETTER.invoke(entry);
|
||||||
|
} catch (Throwable e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Vec3D pos = handle.getPositionVector().d(ete.b());
|
||||||
|
toSend.add(new PacketPlayOutRelEntityMoveLook(handle.getId(), (short) pos.x, (short) pos.y, (short) pos.z,
|
||||||
|
(byte) (bodyYaw * 256.0F / 360.0F), (byte) (pitch * 256.0F / 360.0F), handle.onGround));
|
||||||
|
} else {
|
||||||
|
toSend.add(new PacketPlayOutEntityLook(handle.getId(), (byte) (bodyYaw * 256.0F / 360.0F),
|
||||||
|
(byte) (pitch * 256.0F / 360.0F), handle.onGround));
|
||||||
|
}
|
||||||
|
if (headYaw != null) {
|
||||||
|
toSend.add(new PacketPlayOutEntityHeadRotation(handle, (byte) (headYaw * 256.0F / 360.0F)));
|
||||||
|
}
|
||||||
|
sendPacketsNearby(null, from.getLocation(), toSend, 64);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -2309,6 +2325,7 @@ public class NMSImpl implements NMSBridge {
|
|||||||
|
|
||||||
private static final MethodHandle ADVANCEMENT_PLAYER_FIELD = NMS.getFinalSetter(EntityPlayer.class,
|
private static final MethodHandle ADVANCEMENT_PLAYER_FIELD = NMS.getFinalSetter(EntityPlayer.class,
|
||||||
"advancementDataPlayer");
|
"advancementDataPlayer");
|
||||||
|
|
||||||
private static final Set<EntityType> BAD_CONTROLLER_LOOK = EnumSet.of(EntityType.POLAR_BEAR, EntityType.BEE,
|
private static final Set<EntityType> BAD_CONTROLLER_LOOK = EnumSet.of(EntityType.POLAR_BEAR, EntityType.BEE,
|
||||||
EntityType.SILVERFISH, EntityType.SHULKER, EntityType.ENDERMITE, EntityType.ENDER_DRAGON, EntityType.BAT,
|
EntityType.SILVERFISH, EntityType.SHULKER, EntityType.ENDERMITE, EntityType.ENDER_DRAGON, EntityType.BAT,
|
||||||
EntityType.SLIME, EntityType.DOLPHIN, EntityType.MAGMA_CUBE, EntityType.HORSE, EntityType.GHAST,
|
EntityType.SLIME, EntityType.DOLPHIN, EntityType.MAGMA_CUBE, EntityType.HORSE, EntityType.GHAST,
|
||||||
@ -2333,6 +2350,8 @@ public class NMSImpl implements NMSBridge {
|
|||||||
EntityPose.class);
|
EntityPose.class);
|
||||||
private static final MethodHandle ENTITY_SETPOSE_METHOD = NMS.getMethodHandle(Entity.class, "setPose", true,
|
private static final MethodHandle ENTITY_SETPOSE_METHOD = NMS.getMethodHandle(Entity.class, "setPose", true,
|
||||||
EntityPose.class);
|
EntityPose.class);
|
||||||
|
private static final MethodHandle ENTITY_TRACKER_ENTRY_GETTER = NMS.getFirstGetter(EntityTracker.class,
|
||||||
|
EntityTrackerEntry.class);
|
||||||
private static final MethodHandle FLYING_MOVECONTROL_FLOAT_GETTER = NMS.getFirstGetter(ControllerMoveFlying.class,
|
private static final MethodHandle FLYING_MOVECONTROL_FLOAT_GETTER = NMS.getFirstGetter(ControllerMoveFlying.class,
|
||||||
boolean.class);
|
boolean.class);
|
||||||
private static final MethodHandle FLYING_MOVECONTROL_FLOAT_SETTER = NMS.getFirstSetter(ControllerMoveFlying.class,
|
private static final MethodHandle FLYING_MOVECONTROL_FLOAT_SETTER = NMS.getFirstSetter(ControllerMoveFlying.class,
|
||||||
|
@ -39,12 +39,9 @@ public class PlayerlistTracker extends PlayerChunkMap.EntityTracker {
|
|||||||
NMS.sendTabListAdd(entityplayer.getBukkitEntity(), (Player) tracker.getBukkitEntity());
|
NMS.sendTabListAdd(entityplayer.getBukkitEntity(), (Player) tracker.getBukkitEntity());
|
||||||
if (!Setting.DISABLE_TABLIST.asBoolean())
|
if (!Setting.DISABLE_TABLIST.asBoolean())
|
||||||
return;
|
return;
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(CitizensAPI.getPlugin(), new Runnable() {
|
Bukkit.getScheduler().scheduleSyncDelayedTask(CitizensAPI.getPlugin(),
|
||||||
@Override
|
() -> NMS.sendTabListRemove(entityplayer.getBukkitEntity(), (Player) tracker.getBukkitEntity()),
|
||||||
public void run() {
|
Setting.TABLIST_REMOVE_PACKET_DELAY.asTicks());
|
||||||
NMS.sendTabListRemove(entityplayer.getBukkitEntity(), (Player) tracker.getBukkitEntity());
|
|
||||||
}
|
|
||||||
}, Setting.TABLIST_REMOVE_PACKET_DELAY.asTicks());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -309,9 +309,10 @@ import net.minecraft.server.v1_16_R3.MobEffects;
|
|||||||
import net.minecraft.server.v1_16_R3.NavigationAbstract;
|
import net.minecraft.server.v1_16_R3.NavigationAbstract;
|
||||||
import net.minecraft.server.v1_16_R3.NetworkManager;
|
import net.minecraft.server.v1_16_R3.NetworkManager;
|
||||||
import net.minecraft.server.v1_16_R3.Packet;
|
import net.minecraft.server.v1_16_R3.Packet;
|
||||||
|
import net.minecraft.server.v1_16_R3.PacketPlayOutEntity.PacketPlayOutEntityLook;
|
||||||
|
import net.minecraft.server.v1_16_R3.PacketPlayOutEntity.PacketPlayOutRelEntityMoveLook;
|
||||||
import net.minecraft.server.v1_16_R3.PacketPlayOutEntityEquipment;
|
import net.minecraft.server.v1_16_R3.PacketPlayOutEntityEquipment;
|
||||||
import net.minecraft.server.v1_16_R3.PacketPlayOutEntityHeadRotation;
|
import net.minecraft.server.v1_16_R3.PacketPlayOutEntityHeadRotation;
|
||||||
import net.minecraft.server.v1_16_R3.PacketPlayOutEntityTeleport;
|
|
||||||
import net.minecraft.server.v1_16_R3.PacketPlayOutOpenWindow;
|
import net.minecraft.server.v1_16_R3.PacketPlayOutOpenWindow;
|
||||||
import net.minecraft.server.v1_16_R3.PacketPlayOutPlayerInfo;
|
import net.minecraft.server.v1_16_R3.PacketPlayOutPlayerInfo;
|
||||||
import net.minecraft.server.v1_16_R3.PacketPlayOutScoreboardTeam;
|
import net.minecraft.server.v1_16_R3.PacketPlayOutScoreboardTeam;
|
||||||
@ -1267,22 +1268,37 @@ public class NMSImpl implements NMSBridge {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendPositionUpdate(Player excluding, org.bukkit.entity.Entity from, Location storedLocation) {
|
public void sendPositionUpdate(org.bukkit.entity.Entity from, boolean position, Float bodyYaw, Float pitch,
|
||||||
sendPacketNearby(excluding, storedLocation, new PacketPlayOutEntityTeleport(getHandle(from)));
|
Float headYaw) {
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void sendRotationNearby(org.bukkit.entity.Entity from, float bodyYaw, float headYaw, float pitch) {
|
|
||||||
Entity handle = getHandle(from);
|
Entity handle = getHandle(from);
|
||||||
float oldBody = handle.yaw;
|
if (bodyYaw == null) {
|
||||||
float oldPitch = handle.pitch;
|
bodyYaw = handle.yaw;
|
||||||
handle.yaw = bodyYaw;
|
}
|
||||||
handle.pitch = pitch;
|
if (pitch == null) {
|
||||||
Packet<?>[] packets = new Packet[] { new PacketPlayOutEntityTeleport(handle),
|
pitch = handle.pitch;
|
||||||
new PacketPlayOutEntityHeadRotation(handle, (byte) (headYaw * 256.0F / 360.0F)) };
|
}
|
||||||
sendPacketsNearby(null, from.getLocation(), packets);
|
List<Packet<?>> toSend = Lists.newArrayList();
|
||||||
handle.yaw = oldBody;
|
if (position) {
|
||||||
handle.pitch = oldPitch;
|
EntityTracker entry = ((WorldServer) handle.world).getChunkProvider().playerChunkMap.trackedEntities
|
||||||
|
.get(handle.getId());
|
||||||
|
EntityTrackerEntry ete = null;
|
||||||
|
try {
|
||||||
|
ete = (EntityTrackerEntry) ENTITY_TRACKER_ENTRY_GETTER.invoke(entry);
|
||||||
|
} catch (Throwable e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Vec3D pos = handle.getPositionVector().d(ete.b());
|
||||||
|
toSend.add(new PacketPlayOutRelEntityMoveLook(handle.getId(), (short) pos.x, (short) pos.y, (short) pos.z,
|
||||||
|
(byte) (bodyYaw * 256.0F / 360.0F), (byte) (pitch * 256.0F / 360.0F), handle.isOnGround()));
|
||||||
|
} else {
|
||||||
|
toSend.add(new PacketPlayOutEntityLook(handle.getId(), (byte) (bodyYaw * 256.0F / 360.0F),
|
||||||
|
(byte) (pitch * 256.0F / 360.0F), handle.isOnGround()));
|
||||||
|
}
|
||||||
|
if (headYaw != null) {
|
||||||
|
toSend.add(new PacketPlayOutEntityHeadRotation(handle, (byte) (headYaw * 256.0F / 360.0F)));
|
||||||
|
}
|
||||||
|
sendPacketsNearby(null, from.getLocation(), toSend, 64);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -2333,6 +2349,7 @@ public class NMSImpl implements NMSBridge {
|
|||||||
|
|
||||||
private static final MethodHandle ADVANCEMENT_PLAYER_FIELD = NMS.getFinalSetter(EntityPlayer.class,
|
private static final MethodHandle ADVANCEMENT_PLAYER_FIELD = NMS.getFinalSetter(EntityPlayer.class,
|
||||||
"advancementDataPlayer");
|
"advancementDataPlayer");
|
||||||
|
|
||||||
private static final MethodHandle ATTRIBUTE_MAP = NMS.getGetter(AttributeMapBase.class, "d");
|
private static final MethodHandle ATTRIBUTE_MAP = NMS.getGetter(AttributeMapBase.class, "d");
|
||||||
private static final MethodHandle ATTRIBUTE_PROVIDER_MAP = NMS.getGetter(AttributeProvider.class, "a");
|
private static final MethodHandle ATTRIBUTE_PROVIDER_MAP = NMS.getGetter(AttributeProvider.class, "a");
|
||||||
private static final MethodHandle ATTRIBUTE_PROVIDER_MAP_SETTER = NMS.getFinalSetter(AttributeProvider.class, "a");
|
private static final MethodHandle ATTRIBUTE_PROVIDER_MAP_SETTER = NMS.getFinalSetter(AttributeProvider.class, "a");
|
||||||
@ -2359,6 +2376,8 @@ public class NMSImpl implements NMSBridge {
|
|||||||
private static CustomEntityRegistry ENTITY_REGISTRY;
|
private static CustomEntityRegistry ENTITY_REGISTRY;
|
||||||
private static final MethodHandle ENTITY_SETPOSE_METHOD = NMS.getMethodHandle(Entity.class, "setPose", true,
|
private static final MethodHandle ENTITY_SETPOSE_METHOD = NMS.getMethodHandle(Entity.class, "setPose", true,
|
||||||
EntityPose.class);
|
EntityPose.class);
|
||||||
|
private static final MethodHandle ENTITY_TRACKER_ENTRY_GETTER = NMS.getFirstGetter(EntityTracker.class,
|
||||||
|
EntityTrackerEntry.class);
|
||||||
private static final MethodHandle FISHING_HOOK_HOOKED = NMS.getGetter(EntityFishingHook.class, "hooked");
|
private static final MethodHandle FISHING_HOOK_HOOKED = NMS.getGetter(EntityFishingHook.class, "hooked");
|
||||||
private static final MethodHandle FISHING_HOOK_HOOKED_SETTER = NMS.getSetter(EntityFishingHook.class, "hooked");
|
private static final MethodHandle FISHING_HOOK_HOOKED_SETTER = NMS.getSetter(EntityFishingHook.class, "hooked");
|
||||||
private static final MethodHandle FLYING_MOVECONTROL_FLOAT_GETTER = NMS.getFirstGetter(ControllerMoveFlying.class,
|
private static final MethodHandle FLYING_MOVECONTROL_FLOAT_GETTER = NMS.getFirstGetter(ControllerMoveFlying.class,
|
||||||
|
@ -16,7 +16,6 @@ import net.citizensnpcs.util.NMS;
|
|||||||
import net.minecraft.server.v1_16_R3.Entity;
|
import net.minecraft.server.v1_16_R3.Entity;
|
||||||
import net.minecraft.server.v1_16_R3.EntityPlayer;
|
import net.minecraft.server.v1_16_R3.EntityPlayer;
|
||||||
import net.minecraft.server.v1_16_R3.EntityTrackerEntry;
|
import net.minecraft.server.v1_16_R3.EntityTrackerEntry;
|
||||||
import net.minecraft.server.v1_16_R3.PacketPlayOutAnimation;
|
|
||||||
import net.minecraft.server.v1_16_R3.PlayerChunkMap;
|
import net.minecraft.server.v1_16_R3.PlayerChunkMap;
|
||||||
import net.minecraft.server.v1_16_R3.PlayerChunkMap.EntityTracker;
|
import net.minecraft.server.v1_16_R3.PlayerChunkMap.EntityTracker;
|
||||||
|
|
||||||
@ -40,13 +39,9 @@ public class PlayerlistTracker extends PlayerChunkMap.EntityTracker {
|
|||||||
NMS.sendTabListAdd(entityplayer.getBukkitEntity(), (Player) tracker.getBukkitEntity());
|
NMS.sendTabListAdd(entityplayer.getBukkitEntity(), (Player) tracker.getBukkitEntity());
|
||||||
if (!Setting.DISABLE_TABLIST.asBoolean())
|
if (!Setting.DISABLE_TABLIST.asBoolean())
|
||||||
return;
|
return;
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(CitizensAPI.getPlugin(), new Runnable() {
|
Bukkit.getScheduler().scheduleSyncDelayedTask(CitizensAPI.getPlugin(),
|
||||||
@Override
|
() -> NMS.sendTabListRemove(entityplayer.getBukkitEntity(), (Player) tracker.getBukkitEntity()),
|
||||||
public void run() {
|
Setting.TABLIST_REMOVE_PACKET_DELAY.asTicks());
|
||||||
NMSImpl.sendPacket(entityplayer.getBukkitEntity(), new PacketPlayOutAnimation(tracker, 0));
|
|
||||||
NMS.sendTabListRemove(entityplayer.getBukkitEntity(), (Player) tracker.getBukkitEntity());
|
|
||||||
}
|
|
||||||
}, Setting.TABLIST_REMOVE_PACKET_DELAY.asTicks());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -248,12 +248,12 @@ import net.minecraft.network.Connection;
|
|||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.network.chat.TextComponent;
|
import net.minecraft.network.chat.TextComponent;
|
||||||
import net.minecraft.network.protocol.Packet;
|
import net.minecraft.network.protocol.Packet;
|
||||||
|
import net.minecraft.network.protocol.game.ClientboundMoveEntityPacket;
|
||||||
import net.minecraft.network.protocol.game.ClientboundOpenScreenPacket;
|
import net.minecraft.network.protocol.game.ClientboundOpenScreenPacket;
|
||||||
import net.minecraft.network.protocol.game.ClientboundPlayerInfoPacket;
|
import net.minecraft.network.protocol.game.ClientboundPlayerInfoPacket;
|
||||||
import net.minecraft.network.protocol.game.ClientboundRotateHeadPacket;
|
import net.minecraft.network.protocol.game.ClientboundRotateHeadPacket;
|
||||||
import net.minecraft.network.protocol.game.ClientboundSetEquipmentPacket;
|
import net.minecraft.network.protocol.game.ClientboundSetEquipmentPacket;
|
||||||
import net.minecraft.network.protocol.game.ClientboundSetPlayerTeamPacket;
|
import net.minecraft.network.protocol.game.ClientboundSetPlayerTeamPacket;
|
||||||
import net.minecraft.network.protocol.game.ClientboundTeleportEntityPacket;
|
|
||||||
import net.minecraft.network.syncher.EntityDataAccessor;
|
import net.minecraft.network.syncher.EntityDataAccessor;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
@ -1250,25 +1250,37 @@ public class NMSImpl implements NMSBridge {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendPositionUpdate(Player excluding, org.bukkit.entity.Entity from, Location storedLocation) {
|
public void sendPositionUpdate(org.bukkit.entity.Entity from, boolean position, Float bodyYaw, Float pitch,
|
||||||
sendPacketNearby(excluding, storedLocation, new ClientboundTeleportEntityPacket(getHandle(from)));
|
Float headYaw) {
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void sendRotationNearby(org.bukkit.entity.Entity from, float bodyYaw, float headYaw, float pitch) {
|
|
||||||
Entity handle = getHandle(from);
|
Entity handle = getHandle(from);
|
||||||
float oldBody = handle.getYRot();
|
if (bodyYaw == null) {
|
||||||
float oldPitch = handle.getXRot();
|
bodyYaw = handle.getYRot();
|
||||||
handle.setYBodyRot(bodyYaw);
|
}
|
||||||
handle.setXRot(pitch);
|
if (pitch == null) {
|
||||||
sendPacketsNearby(null, from.getLocation(), new ClientboundTeleportEntityPacket(handle), // new
|
pitch = handle.getXRot();
|
||||||
// ClientboundMoveEntityPacket.Rot(handle.getId(),
|
}
|
||||||
// (byte) (bodyYaw *
|
List<Packet<?>> toSend = Lists.newArrayList();
|
||||||
// 256.0F / 360.0F),
|
if (position) {
|
||||||
// (byte) (pitch * 256.0F / 360.0F), handle.onGround),
|
TrackedEntity entry = ((ServerLevel) handle.level).getChunkProvider().chunkMap.G.get(handle.getId());
|
||||||
new ClientboundRotateHeadPacket(handle, (byte) (headYaw * 256.0F / 360.0F)));
|
ServerEntity se = null;
|
||||||
handle.setYBodyRot(oldBody);
|
try {
|
||||||
handle.setXRot(oldPitch);
|
se = (ServerEntity) SERVER_ENTITY_GETTER.invoke(entry);
|
||||||
|
} catch (Throwable e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Vec3 pos = handle.position().subtract(se.sentPos());
|
||||||
|
toSend.add(
|
||||||
|
new ClientboundMoveEntityPacket.PosRot(handle.getId(), (short) pos.x, (short) pos.y, (short) pos.z,
|
||||||
|
(byte) (bodyYaw * 256.0F / 360.0F), (byte) (pitch * 256.0F / 360.0F), handle.isOnGround()));
|
||||||
|
} else {
|
||||||
|
toSend.add(new ClientboundMoveEntityPacket.Rot(handle.getId(), (byte) (bodyYaw * 256.0F / 360.0F),
|
||||||
|
(byte) (pitch * 256.0F / 360.0F), handle.isOnGround()));
|
||||||
|
}
|
||||||
|
if (headYaw != null) {
|
||||||
|
toSend.add(new ClientboundRotateHeadPacket(handle, (byte) (headYaw * 256.0F / 360.0F)));
|
||||||
|
}
|
||||||
|
sendPacketsNearby(null, from.getLocation(), toSend, 64);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -2320,6 +2332,7 @@ public class NMSImpl implements NMSBridge {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static final MethodHandle ADVANCEMENTS_PLAYER_FIELD = NMS.getFinalSetter(ServerPlayer.class, "cr");
|
private static final MethodHandle ADVANCEMENTS_PLAYER_FIELD = NMS.getFinalSetter(ServerPlayer.class, "cr");
|
||||||
|
|
||||||
private static final MethodHandle ATTRIBUTE_PROVIDER_MAP = NMS.getFirstGetter(AttributeSupplier.class, Map.class);
|
private static final MethodHandle ATTRIBUTE_PROVIDER_MAP = NMS.getFirstGetter(AttributeSupplier.class, Map.class);
|
||||||
private static final MethodHandle ATTRIBUTE_PROVIDER_MAP_SETTER = NMS.getFinalSetter(AttributeSupplier.class, "a");
|
private static final MethodHandle ATTRIBUTE_PROVIDER_MAP_SETTER = NMS.getFinalSetter(AttributeSupplier.class, "a");
|
||||||
private static final MethodHandle ATTRIBUTE_SUPPLIER = NMS.getFirstGetter(AttributeMap.class,
|
private static final MethodHandle ATTRIBUTE_SUPPLIER = NMS.getFirstGetter(AttributeMap.class,
|
||||||
@ -2370,6 +2383,8 @@ public class NMSImpl implements NMSBridge {
|
|||||||
private static final MethodHandle PUFFERFISH_D = NMS.getSetter(Pufferfish.class, "bT");
|
private static final MethodHandle PUFFERFISH_D = NMS.getSetter(Pufferfish.class, "bT");
|
||||||
private static EntityDataAccessor<Integer> RABBIT_TYPE_DATAWATCHER = null;
|
private static EntityDataAccessor<Integer> RABBIT_TYPE_DATAWATCHER = null;
|
||||||
private static final Random RANDOM = Util.getFastRandom();
|
private static final Random RANDOM = Util.getFastRandom();
|
||||||
|
private static final MethodHandle SERVER_ENTITY_GETTER = NMS.getFirstGetter(TrackedEntity.class,
|
||||||
|
ServerEntity.class);
|
||||||
private static MethodHandle SET_PROFILE_METHOD;
|
private static MethodHandle SET_PROFILE_METHOD;
|
||||||
private static final MethodHandle SIZE_FIELD_GETTER = NMS.getFirstGetter(Entity.class, EntityDimensions.class);
|
private static final MethodHandle SIZE_FIELD_GETTER = NMS.getFirstGetter(Entity.class, EntityDimensions.class);
|
||||||
private static final MethodHandle SIZE_FIELD_SETTER = NMS.getFirstSetter(Entity.class, EntityDimensions.class);
|
private static final MethodHandle SIZE_FIELD_SETTER = NMS.getFirstSetter(Entity.class, EntityDimensions.class);
|
||||||
|
@ -13,7 +13,6 @@ import net.citizensnpcs.api.npc.NPC;
|
|||||||
import net.citizensnpcs.nms.v1_17_R1.entity.EntityHumanNPC;
|
import net.citizensnpcs.nms.v1_17_R1.entity.EntityHumanNPC;
|
||||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||||
import net.citizensnpcs.util.NMS;
|
import net.citizensnpcs.util.NMS;
|
||||||
import net.minecraft.network.protocol.game.ClientboundAnimatePacket;
|
|
||||||
import net.minecraft.server.level.ChunkMap;
|
import net.minecraft.server.level.ChunkMap;
|
||||||
import net.minecraft.server.level.ChunkMap.TrackedEntity;
|
import net.minecraft.server.level.ChunkMap.TrackedEntity;
|
||||||
import net.minecraft.server.level.ServerEntity;
|
import net.minecraft.server.level.ServerEntity;
|
||||||
@ -44,7 +43,6 @@ public class PlayerlistTracker extends ChunkMap.TrackedEntity {
|
|||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(CitizensAPI.getPlugin(), new Runnable() {
|
Bukkit.getScheduler().scheduleSyncDelayedTask(CitizensAPI.getPlugin(), new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
NMSImpl.sendPacket(entityplayer.getBukkitEntity(), new ClientboundAnimatePacket(tracker, 0));
|
|
||||||
NMS.sendTabListRemove(entityplayer.getBukkitEntity(), (Player) tracker.getBukkitEntity());
|
NMS.sendTabListRemove(entityplayer.getBukkitEntity(), (Player) tracker.getBukkitEntity());
|
||||||
}
|
}
|
||||||
}, Setting.TABLIST_REMOVE_PACKET_DELAY.asTicks());
|
}, Setting.TABLIST_REMOVE_PACKET_DELAY.asTicks());
|
||||||
|
@ -249,12 +249,12 @@ import net.minecraft.network.Connection;
|
|||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.network.chat.TextComponent;
|
import net.minecraft.network.chat.TextComponent;
|
||||||
import net.minecraft.network.protocol.Packet;
|
import net.minecraft.network.protocol.Packet;
|
||||||
|
import net.minecraft.network.protocol.game.ClientboundMoveEntityPacket;
|
||||||
import net.minecraft.network.protocol.game.ClientboundOpenScreenPacket;
|
import net.minecraft.network.protocol.game.ClientboundOpenScreenPacket;
|
||||||
import net.minecraft.network.protocol.game.ClientboundPlayerInfoPacket;
|
import net.minecraft.network.protocol.game.ClientboundPlayerInfoPacket;
|
||||||
import net.minecraft.network.protocol.game.ClientboundRotateHeadPacket;
|
import net.minecraft.network.protocol.game.ClientboundRotateHeadPacket;
|
||||||
import net.minecraft.network.protocol.game.ClientboundSetEquipmentPacket;
|
import net.minecraft.network.protocol.game.ClientboundSetEquipmentPacket;
|
||||||
import net.minecraft.network.protocol.game.ClientboundSetPlayerTeamPacket;
|
import net.minecraft.network.protocol.game.ClientboundSetPlayerTeamPacket;
|
||||||
import net.minecraft.network.protocol.game.ClientboundTeleportEntityPacket;
|
|
||||||
import net.minecraft.network.syncher.EntityDataAccessor;
|
import net.minecraft.network.syncher.EntityDataAccessor;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
@ -1258,23 +1258,37 @@ public class NMSImpl implements NMSBridge {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendPositionUpdate(Player excluding, org.bukkit.entity.Entity from, Location storedLocation) {
|
public void sendPositionUpdate(org.bukkit.entity.Entity from, boolean position, Float bodyYaw, Float pitch,
|
||||||
sendPacketNearby(excluding, storedLocation, new ClientboundTeleportEntityPacket(getHandle(from)));
|
Float headYaw) {
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void sendRotationNearby(org.bukkit.entity.Entity from, float bodyYaw, float headYaw, float pitch) {
|
|
||||||
Entity handle = getHandle(from);
|
Entity handle = getHandle(from);
|
||||||
float oldBody = handle.getYRot();
|
if (bodyYaw == null) {
|
||||||
float oldPitch = handle.getXRot();
|
bodyYaw = handle.getYRot();
|
||||||
handle.setYBodyRot(bodyYaw);
|
}
|
||||||
handle.setXRot(pitch);
|
if (pitch == null) {
|
||||||
sendPacketsNearby(null, from.getLocation(), new ClientboundTeleportEntityPacket(handle),
|
pitch = handle.getXRot();
|
||||||
// newClientboundMoveEntityPacket.Rot(handle.getId(), (byte) (bodyYaw *256.0F / 360.0F), (byte) (pitch *
|
}
|
||||||
// 256.0F / 360.0F), handle.onGround),
|
List<Packet<?>> toSend = Lists.newArrayList();
|
||||||
new ClientboundRotateHeadPacket(handle, (byte) (headYaw * 256.0F / 360.0F)));
|
if (position) {
|
||||||
handle.setYBodyRot(oldBody);
|
TrackedEntity entry = ((ServerLevel) handle.level).getChunkSource().chunkMap.entityMap.get(handle.getId());
|
||||||
handle.setXRot(oldPitch);
|
ServerEntity se = null;
|
||||||
|
try {
|
||||||
|
se = (ServerEntity) SERVER_ENTITY_GETTER.invoke(entry);
|
||||||
|
} catch (Throwable e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Vec3 pos = handle.position().subtract(se.sentPos());
|
||||||
|
toSend.add(
|
||||||
|
new ClientboundMoveEntityPacket.PosRot(handle.getId(), (short) pos.x, (short) pos.y, (short) pos.z,
|
||||||
|
(byte) (bodyYaw * 256.0F / 360.0F), (byte) (pitch * 256.0F / 360.0F), handle.onGround));
|
||||||
|
} else {
|
||||||
|
toSend.add(new ClientboundMoveEntityPacket.Rot(handle.getId(), (byte) (bodyYaw * 256.0F / 360.0F),
|
||||||
|
(byte) (pitch * 256.0F / 360.0F), handle.onGround));
|
||||||
|
}
|
||||||
|
if (headYaw != null) {
|
||||||
|
toSend.add(new ClientboundRotateHeadPacket(handle, (byte) (headYaw * 256.0F / 360.0F)));
|
||||||
|
}
|
||||||
|
sendPacketsNearby(null, from.getLocation(), toSend, 64);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -2370,6 +2384,7 @@ public class NMSImpl implements NMSBridge {
|
|||||||
EntityType.SILVERFISH, EntityType.SHULKER, EntityType.ENDERMITE, EntityType.ENDER_DRAGON, EntityType.BAT,
|
EntityType.SILVERFISH, EntityType.SHULKER, EntityType.ENDERMITE, EntityType.ENDER_DRAGON, EntityType.BAT,
|
||||||
EntityType.SLIME, EntityType.DOLPHIN, EntityType.MAGMA_CUBE, EntityType.HORSE, EntityType.GHAST,
|
EntityType.SLIME, EntityType.DOLPHIN, EntityType.MAGMA_CUBE, EntityType.HORSE, EntityType.GHAST,
|
||||||
EntityType.SHULKER, EntityType.PHANTOM);
|
EntityType.SHULKER, EntityType.PHANTOM);
|
||||||
|
|
||||||
private static final MethodHandle BEHAVIOR_TREE_MAP = NMS.getGetter(Brain.class, "f");
|
private static final MethodHandle BEHAVIOR_TREE_MAP = NMS.getGetter(Brain.class, "f");
|
||||||
private static final MethodHandle BUKKITENTITY_FIELD_SETTER = NMS.getSetter(Entity.class, "bukkitEntity");
|
private static final MethodHandle BUKKITENTITY_FIELD_SETTER = NMS.getSetter(Entity.class, "bukkitEntity");
|
||||||
private static final MethodHandle CHUNKMAP_UPDATE_PLAYER_STATUS = NMS.getMethodHandle(ChunkMap.class, "a", true,
|
private static final MethodHandle CHUNKMAP_UPDATE_PLAYER_STATUS = NMS.getMethodHandle(ChunkMap.class, "a", true,
|
||||||
@ -2419,6 +2434,8 @@ public class NMSImpl implements NMSBridge {
|
|||||||
private static final MethodHandle PUFFERFISH_D = NMS.getSetter(Pufferfish.class, "bW");
|
private static final MethodHandle PUFFERFISH_D = NMS.getSetter(Pufferfish.class, "bW");
|
||||||
private static EntityDataAccessor<Integer> RABBIT_TYPE_DATAWATCHER = null;
|
private static EntityDataAccessor<Integer> RABBIT_TYPE_DATAWATCHER = null;
|
||||||
private static final Random RANDOM = Util.getFastRandom();
|
private static final Random RANDOM = Util.getFastRandom();
|
||||||
|
private static final MethodHandle SERVER_ENTITY_GETTER = NMS.getFirstGetter(TrackedEntity.class,
|
||||||
|
ServerEntity.class);
|
||||||
private static MethodHandle SET_PROFILE_METHOD;
|
private static MethodHandle SET_PROFILE_METHOD;
|
||||||
private static final MethodHandle SIZE_FIELD_GETTER = NMS.getFirstGetter(Entity.class, EntityDimensions.class);
|
private static final MethodHandle SIZE_FIELD_GETTER = NMS.getFirstGetter(Entity.class, EntityDimensions.class);
|
||||||
private static final MethodHandle SIZE_FIELD_SETTER = NMS.getFirstSetter(Entity.class, EntityDimensions.class);
|
private static final MethodHandle SIZE_FIELD_SETTER = NMS.getFirstSetter(Entity.class, EntityDimensions.class);
|
||||||
|
@ -13,7 +13,6 @@ import net.citizensnpcs.api.npc.NPC;
|
|||||||
import net.citizensnpcs.nms.v1_18_R2.entity.EntityHumanNPC;
|
import net.citizensnpcs.nms.v1_18_R2.entity.EntityHumanNPC;
|
||||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||||
import net.citizensnpcs.util.NMS;
|
import net.citizensnpcs.util.NMS;
|
||||||
import net.minecraft.network.protocol.game.ClientboundAnimatePacket;
|
|
||||||
import net.minecraft.server.level.ChunkMap;
|
import net.minecraft.server.level.ChunkMap;
|
||||||
import net.minecraft.server.level.ChunkMap.TrackedEntity;
|
import net.minecraft.server.level.ChunkMap.TrackedEntity;
|
||||||
import net.minecraft.server.level.ServerEntity;
|
import net.minecraft.server.level.ServerEntity;
|
||||||
@ -41,13 +40,9 @@ public class PlayerlistTracker extends ChunkMap.TrackedEntity {
|
|||||||
NMS.sendTabListAdd(entityplayer.getBukkitEntity(), (Player) tracker.getBukkitEntity());
|
NMS.sendTabListAdd(entityplayer.getBukkitEntity(), (Player) tracker.getBukkitEntity());
|
||||||
if (!Setting.DISABLE_TABLIST.asBoolean())
|
if (!Setting.DISABLE_TABLIST.asBoolean())
|
||||||
return;
|
return;
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(CitizensAPI.getPlugin(), new Runnable() {
|
Bukkit.getScheduler().scheduleSyncDelayedTask(CitizensAPI.getPlugin(),
|
||||||
@Override
|
() -> NMS.sendTabListRemove(entityplayer.getBukkitEntity(), (Player) tracker.getBukkitEntity()),
|
||||||
public void run() {
|
Setting.TABLIST_REMOVE_PACKET_DELAY.asTicks());
|
||||||
NMSImpl.sendPacket(entityplayer.getBukkitEntity(), new ClientboundAnimatePacket(tracker, 0));
|
|
||||||
NMS.sendTabListRemove(entityplayer.getBukkitEntity(), (Player) tracker.getBukkitEntity());
|
|
||||||
}
|
|
||||||
}, Setting.TABLIST_REMOVE_PACKET_DELAY.asTicks());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -16,7 +16,6 @@ import net.citizensnpcs.api.npc.NPC;
|
|||||||
import net.citizensnpcs.nms.v1_19_R3.entity.EntityHumanNPC;
|
import net.citizensnpcs.nms.v1_19_R3.entity.EntityHumanNPC;
|
||||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||||
import net.citizensnpcs.util.NMS;
|
import net.citizensnpcs.util.NMS;
|
||||||
import net.minecraft.network.protocol.game.ClientboundAnimatePacket;
|
|
||||||
import net.minecraft.server.level.ChunkMap;
|
import net.minecraft.server.level.ChunkMap;
|
||||||
import net.minecraft.server.level.ChunkMap.TrackedEntity;
|
import net.minecraft.server.level.ChunkMap.TrackedEntity;
|
||||||
import net.minecraft.server.level.ServerEntity;
|
import net.minecraft.server.level.ServerEntity;
|
||||||
@ -62,14 +61,10 @@ public class CitizensEntityTracker extends ChunkMap.TrackedEntity {
|
|||||||
final ServerPlayer entityplayer = lastUpdatedPlayer;
|
final ServerPlayer entityplayer = lastUpdatedPlayer;
|
||||||
boolean sendTabRemove = NMS.sendTabListAdd(entityplayer.getBukkitEntity(), (Player) tracker.getBukkitEntity());
|
boolean sendTabRemove = NMS.sendTabListAdd(entityplayer.getBukkitEntity(), (Player) tracker.getBukkitEntity());
|
||||||
if (!sendTabRemove || !Setting.DISABLE_TABLIST.asBoolean()) {
|
if (!sendTabRemove || !Setting.DISABLE_TABLIST.asBoolean()) {
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(CitizensAPI.getPlugin(),
|
|
||||||
() -> NMSImpl.sendPacket(entityplayer.getBukkitEntity(), new ClientboundAnimatePacket(tracker, 0)),
|
|
||||||
1);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(CitizensAPI.getPlugin(), () -> {
|
Bukkit.getScheduler().scheduleSyncDelayedTask(CitizensAPI.getPlugin(), () -> {
|
||||||
NMS.sendTabListRemove(entityplayer.getBukkitEntity(), (Player) tracker.getBukkitEntity());
|
NMS.sendTabListRemove(entityplayer.getBukkitEntity(), (Player) tracker.getBukkitEntity());
|
||||||
NMSImpl.sendPacket(entityplayer.getBukkitEntity(), new ClientboundAnimatePacket(tracker, 0));
|
|
||||||
}, Setting.TABLIST_REMOVE_PACKET_DELAY.asTicks());
|
}, Setting.TABLIST_REMOVE_PACKET_DELAY.asTicks());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -280,7 +280,6 @@ import net.minecraft.network.protocol.game.ClientboundPlayerInfoUpdatePacket;
|
|||||||
import net.minecraft.network.protocol.game.ClientboundRotateHeadPacket;
|
import net.minecraft.network.protocol.game.ClientboundRotateHeadPacket;
|
||||||
import net.minecraft.network.protocol.game.ClientboundSetEquipmentPacket;
|
import net.minecraft.network.protocol.game.ClientboundSetEquipmentPacket;
|
||||||
import net.minecraft.network.protocol.game.ClientboundSetPlayerTeamPacket;
|
import net.minecraft.network.protocol.game.ClientboundSetPlayerTeamPacket;
|
||||||
import net.minecraft.network.protocol.game.ClientboundTeleportEntityPacket;
|
|
||||||
import net.minecraft.network.protocol.game.VecDeltaCodec;
|
import net.minecraft.network.protocol.game.VecDeltaCodec;
|
||||||
import net.minecraft.network.syncher.EntityDataAccessor;
|
import net.minecraft.network.syncher.EntityDataAccessor;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
@ -1354,33 +1353,37 @@ public class NMSImpl implements NMSBridge {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendPositionUpdate(Player excluding, org.bukkit.entity.Entity from, Location location) {
|
public void sendPositionUpdate(org.bukkit.entity.Entity from, boolean position, Float bodyYaw, Float pitch,
|
||||||
sendPacketNearby(excluding, location, new ClientboundTeleportEntityPacket(getHandle(from)));
|
Float headYaw) {
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void sendRotationNearby(org.bukkit.entity.Entity from, float bodyYaw, float headYaw, float pitch) {
|
|
||||||
Entity handle = getHandle(from);
|
Entity handle = getHandle(from);
|
||||||
float oldBody = handle.getYRot();
|
if (bodyYaw == null) {
|
||||||
float oldPitch = handle.getXRot();
|
bodyYaw = handle.getYRot();
|
||||||
// handle.setYRot(bodyYaw);
|
|
||||||
// handle.setXRot(pitch);
|
|
||||||
TrackedEntity entry = ((ServerLevel) handle.level).getChunkSource().chunkMap.entityMap.get(handle.getId());
|
|
||||||
VecDeltaCodec vdc = null;
|
|
||||||
try {
|
|
||||||
vdc = (VecDeltaCodec) POSITION_CODEC_GETTER.invoke((ServerEntity) SERVER_ENTITY_GETTER.invoke(entry));
|
|
||||||
} catch (Throwable e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
Vec3 pos = handle.trackingPosition();
|
if (pitch == null) {
|
||||||
sendPacketsNearby(null, from.getLocation(), // new ClientboundTeleportEntityPacket(handle),
|
pitch = handle.getXRot();
|
||||||
new ClientboundMoveEntityPacket.PosRot(handle.getId(), (short) vdc.encodeX(pos),
|
}
|
||||||
(short) vdc.encodeY(pos), (short) vdc.encodeZ(pos), (byte) (bodyYaw * 256.0F / 360.0F),
|
List<Packet<?>> toSend = Lists.newArrayList();
|
||||||
(byte) (pitch * 256.0F / 360.0F), handle.onGround),
|
if (position) {
|
||||||
new ClientboundRotateHeadPacket(handle, (byte) (headYaw * 256.0F / 360.0F)));
|
TrackedEntity entry = ((ServerLevel) handle.level).getChunkSource().chunkMap.entityMap.get(handle.getId());
|
||||||
// handle.setYRot(oldBody);
|
VecDeltaCodec vdc = null;
|
||||||
// handle.setXRot(oldPitch);
|
try {
|
||||||
|
vdc = (VecDeltaCodec) POSITION_CODEC_GETTER.invoke((ServerEntity) SERVER_ENTITY_GETTER.invoke(entry));
|
||||||
|
} catch (Throwable e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Vec3 pos = handle.trackingPosition();
|
||||||
|
toSend.add(new ClientboundMoveEntityPacket.PosRot(handle.getId(), (short) vdc.encodeX(pos),
|
||||||
|
(short) vdc.encodeY(pos), (short) vdc.encodeZ(pos), (byte) (bodyYaw * 256.0F / 360.0F),
|
||||||
|
(byte) (pitch * 256.0F / 360.0F), handle.onGround));
|
||||||
|
} else {
|
||||||
|
toSend.add(new ClientboundMoveEntityPacket.Rot(handle.getId(), (byte) (bodyYaw * 256.0F / 360.0F),
|
||||||
|
(byte) (pitch * 256.0F / 360.0F), handle.onGround));
|
||||||
|
}
|
||||||
|
if (headYaw != null) {
|
||||||
|
toSend.add(new ClientboundRotateHeadPacket(handle, (byte) (headYaw * 256.0F / 360.0F)));
|
||||||
|
}
|
||||||
|
sendPacketsNearby(null, from.getLocation(), toSend, 64);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -209,6 +209,8 @@ import net.minecraft.server.v1_8_R3.NetworkManager;
|
|||||||
import net.minecraft.server.v1_8_R3.Packet;
|
import net.minecraft.server.v1_8_R3.Packet;
|
||||||
import net.minecraft.server.v1_8_R3.PacketPlayOutAnimation;
|
import net.minecraft.server.v1_8_R3.PacketPlayOutAnimation;
|
||||||
import net.minecraft.server.v1_8_R3.PacketPlayOutBed;
|
import net.minecraft.server.v1_8_R3.PacketPlayOutBed;
|
||||||
|
import net.minecraft.server.v1_8_R3.PacketPlayOutEntity.PacketPlayOutEntityLook;
|
||||||
|
import net.minecraft.server.v1_8_R3.PacketPlayOutEntity.PacketPlayOutRelEntityMoveLook;
|
||||||
import net.minecraft.server.v1_8_R3.PacketPlayOutEntityEquipment;
|
import net.minecraft.server.v1_8_R3.PacketPlayOutEntityEquipment;
|
||||||
import net.minecraft.server.v1_8_R3.PacketPlayOutEntityHeadRotation;
|
import net.minecraft.server.v1_8_R3.PacketPlayOutEntityHeadRotation;
|
||||||
import net.minecraft.server.v1_8_R3.PacketPlayOutEntityTeleport;
|
import net.minecraft.server.v1_8_R3.PacketPlayOutEntityTeleport;
|
||||||
@ -1015,22 +1017,31 @@ public class NMSImpl implements NMSBridge {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendPositionUpdate(Player excluding, org.bukkit.entity.Entity from, Location storedLocation) {
|
public void sendPositionUpdate(org.bukkit.entity.Entity from, boolean position, Float bodyYaw, Float pitch,
|
||||||
sendPacketNearby(excluding, storedLocation, new PacketPlayOutEntityTeleport(getHandle(from)));
|
Float headYaw) {
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void sendRotationNearby(org.bukkit.entity.Entity from, float bodyYaw, float headYaw, float pitch) {
|
|
||||||
Entity handle = getHandle(from);
|
Entity handle = getHandle(from);
|
||||||
float oldBody = handle.yaw;
|
if (bodyYaw == null) {
|
||||||
float oldPitch = handle.pitch;
|
bodyYaw = handle.yaw;
|
||||||
handle.yaw = bodyYaw;
|
}
|
||||||
handle.pitch = pitch;
|
if (pitch == null) {
|
||||||
Packet<?>[] packets = new Packet[] { new PacketPlayOutEntityTeleport(handle),
|
pitch = handle.pitch;
|
||||||
new PacketPlayOutEntityHeadRotation(handle, (byte) (headYaw * 256.0F / 360.0F)) };
|
}
|
||||||
sendPacketsNearby(null, from.getLocation(), packets);
|
List<Packet<?>> toSend = Lists.newArrayList();
|
||||||
handle.yaw = oldBody;
|
if (position) {
|
||||||
handle.pitch = oldPitch;
|
EntityTrackerEntry entry = ((WorldServer) handle.world).getTracker().trackedEntities.get(handle.getId());
|
||||||
|
long dx = MathHelper.floor(handle.locX * 32.0) - entry.xLoc;
|
||||||
|
long dy = MathHelper.floor(handle.locY * 32.0) - entry.yLoc;
|
||||||
|
long dz = MathHelper.floor(handle.locZ * 32.0) - entry.zLoc;
|
||||||
|
toSend.add(new PacketPlayOutRelEntityMoveLook(handle.getId(), (byte) dx, (byte) dy, (byte) dz,
|
||||||
|
(byte) (bodyYaw * 256.0F / 360.0F), (byte) (pitch * 256.0F / 360.0F), handle.onGround));
|
||||||
|
} else {
|
||||||
|
toSend.add(new PacketPlayOutEntityLook(handle.getId(), (byte) (bodyYaw * 256.0F / 360.0F),
|
||||||
|
(byte) (pitch * 256.0F / 360.0F), handle.onGround));
|
||||||
|
}
|
||||||
|
if (headYaw != null) {
|
||||||
|
toSend.add(new PacketPlayOutEntityHeadRotation(handle, (byte) (headYaw * 256.0F / 360.0F)));
|
||||||
|
}
|
||||||
|
sendPacketsNearby(null, from.getLocation(), toSend, 64);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -1800,12 +1811,18 @@ public class NMSImpl implements NMSBridge {
|
|||||||
private static final Set<EntityType> BAD_CONTROLLER_LOOK = EnumSet.of(EntityType.SILVERFISH, EntityType.ENDERMITE,
|
private static final Set<EntityType> BAD_CONTROLLER_LOOK = EnumSet.of(EntityType.SILVERFISH, EntityType.ENDERMITE,
|
||||||
EntityType.ENDER_DRAGON, EntityType.BAT, EntityType.SLIME, EntityType.MAGMA_CUBE, EntityType.HORSE,
|
EntityType.ENDER_DRAGON, EntityType.BAT, EntityType.SLIME, EntityType.MAGMA_CUBE, EntityType.HORSE,
|
||||||
EntityType.GHAST);
|
EntityType.GHAST);
|
||||||
|
|
||||||
private static final float DEFAULT_SPEED = 1F;
|
private static final float DEFAULT_SPEED = 1F;
|
||||||
|
|
||||||
public static MethodHandle ENDERDRAGON_CHECK_WALLS = NMS.getFirstMethodHandleWithReturnType(EntityEnderDragon.class,
|
public static MethodHandle ENDERDRAGON_CHECK_WALLS = NMS.getFirstMethodHandleWithReturnType(EntityEnderDragon.class,
|
||||||
true, boolean.class, AxisAlignedBB.class);
|
true, boolean.class, AxisAlignedBB.class);
|
||||||
|
|
||||||
private static Method ENTITY_ATTACK_A = NMS.getMethod(Entity.class, "a", true, EntityLiving.class, Entity.class);
|
private static Method ENTITY_ATTACK_A = NMS.getMethod(Entity.class, "a", true, EntityLiving.class, Entity.class);
|
||||||
private static Map<Class<?>, Integer> ENTITY_CLASS_TO_INT;
|
private static Map<Class<?>, Integer> ENTITY_CLASS_TO_INT;
|
||||||
private static Map<Class<?>, String> ENTITY_CLASS_TO_NAME;
|
private static Map<Class<?>, String> ENTITY_CLASS_TO_NAME;
|
||||||
|
private static final MethodHandle ENTITY_TRACKER_ENTRY_X = NMS.getGetter(EntityTrackerEntry.class, "xLoc");
|
||||||
|
private static final MethodHandle ENTITY_TRACKER_ENTRY_Y = NMS.getGetter(EntityTrackerEntry.class, "yLoc");
|
||||||
|
private static final MethodHandle ENTITY_TRACKER_ENTRY_Z = NMS.getGetter(EntityTrackerEntry.class, "zLoc");
|
||||||
private static final Location FROM_LOCATION = new Location(null, 0, 0, 0);
|
private static final Location FROM_LOCATION = new Location(null, 0, 0, 0);
|
||||||
private static Method GET_NMS_BLOCK = NMS.getMethod(CraftBlock.class, "getNMSBlock", false);
|
private static Method GET_NMS_BLOCK = NMS.getMethod(CraftBlock.class, "getNMSBlock", false);
|
||||||
private static Field GOAL_FIELD = NMS.getField(PathfinderGoalSelector.class, "b");
|
private static Field GOAL_FIELD = NMS.getField(PathfinderGoalSelector.class, "b");
|
||||||
|
Loading…
Reference in New Issue
Block a user