Cancel current move destination when navigator paused

This commit is contained in:
fullwall 2022-02-02 21:40:19 +08:00
parent 5c3878d2f8
commit bef0f16f3b
13 changed files with 181 additions and 3 deletions

View File

@ -235,6 +235,9 @@ public class CitizensNavigator implements Navigator, Runnable {
@Override
public void setPaused(boolean paused) {
if (paused && isNavigating()) {
NMS.cancelMoveDestination(npc.getEntity());
}
this.paused = paused;
}

View File

@ -57,6 +57,10 @@ public class NMS {
BRIDGE.attack(attacker, bukkitTarget);
}
public static void cancelMoveDestination(Entity entity) {
BRIDGE.cancelMoveDestination(entity);
}
/*
* Yggdrasil's default implementation of this method silently fails instead of throwing
* an Exception like it should.

View File

@ -41,6 +41,8 @@ public interface NMSBridge {
public void attack(LivingEntity attacker, LivingEntity target);
public void cancelMoveDestination(Entity entity);
public GameProfile fillProfileProperties(GameProfile profile, boolean requireSecure) throws Throwable;
public BlockBreaker getBlockBreaker(Entity entity, Block targetBlock, BlockBreakerConfiguration config);

View File

@ -160,6 +160,7 @@ import net.minecraft.server.v1_10_R1.Block;
import net.minecraft.server.v1_10_R1.BlockPosition;
import net.minecraft.server.v1_10_R1.BossBattleServer;
import net.minecraft.server.v1_10_R1.ControllerJump;
import net.minecraft.server.v1_10_R1.ControllerMove;
import net.minecraft.server.v1_10_R1.CrashReport;
import net.minecraft.server.v1_10_R1.CrashReportSystemDetails;
import net.minecraft.server.v1_10_R1.DamageSource;
@ -267,6 +268,20 @@ public class NMSImpl implements NMSBridge {
}
}
@Override
public void cancelMoveDestination(org.bukkit.entity.Entity entity) {
Entity handle = getHandle(entity);
if (handle instanceof EntityInsentient) {
try {
MOVE_CONTROLLER_MOVING.invoke(((EntityInsentient) handle).getControllerMove(), null);
} catch (Throwable t) {
t.printStackTrace();
}
} else if (handle instanceof EntityHumanNPC) {
((EntityHumanNPC) handle).getControllerMove().f = false;
}
}
@Override
public GameProfile fillProfileProperties(GameProfile profile, boolean requireSecure) throws Exception {
if (Bukkit.isPrimaryThread())
@ -1562,6 +1577,7 @@ public class NMSImpl implements NMSBridge {
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.HORSE, EntityType.GHAST);
private static final Field CRAFT_BOSSBAR_HANDLE_FIELD = NMS.getField(CraftBossBar.class, "handle");
private static final float DEFAULT_SPEED = 1F;
private static final Field ENDERDRAGON_BATTLE_BAR_FIELD = NMS.getField(EnderDragonBattle.class, "c");
@ -1573,6 +1589,7 @@ public class NMSImpl implements NMSBridge {
public static Field GOAL_FIELD = NMS.getField(PathfinderGoalSelector.class, "b");
private static final Field JUMP_FIELD = NMS.getField(EntityLiving.class, "be");
private static Method MAKE_REQUEST;
private static MethodHandle MOVE_CONTROLLER_MOVING = NMS.getSetter(ControllerMove.class, "h");
private static Field NAVIGATION_WORLD_FIELD = NMS.getField(NavigationAbstract.class, "b");
public static Field NETWORK_ADDRESS = NMS.getField(NetworkManager.class, "l");
public static final Location PACKET_CACHE_LOCATION = new Location(null, 0, 0, 0);

View File

@ -175,6 +175,7 @@ import net.minecraft.server.v1_11_R1.Block;
import net.minecraft.server.v1_11_R1.BlockPosition;
import net.minecraft.server.v1_11_R1.BossBattleServer;
import net.minecraft.server.v1_11_R1.ControllerJump;
import net.minecraft.server.v1_11_R1.ControllerMove;
import net.minecraft.server.v1_11_R1.CrashReport;
import net.minecraft.server.v1_11_R1.CrashReportSystemDetails;
import net.minecraft.server.v1_11_R1.DamageSource;
@ -286,6 +287,20 @@ public class NMSImpl implements NMSBridge {
}
}
@Override
public void cancelMoveDestination(org.bukkit.entity.Entity entity) {
Entity handle = getHandle(entity);
if (handle instanceof EntityInsentient) {
try {
MOVE_CONTROLLER_MOVING.invoke(((EntityInsentient) handle).getControllerMove(), null);
} catch (Throwable t) {
t.printStackTrace();
}
} else if (handle instanceof EntityHumanNPC) {
((EntityHumanNPC) handle).getControllerMove().f = false;
}
}
@Override
public GameProfile fillProfileProperties(GameProfile profile, boolean requireSecure) throws Exception {
if (Bukkit.isPrimaryThread())
@ -1625,6 +1640,7 @@ public class NMSImpl implements NMSBridge {
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.HORSE, EntityType.GHAST);
private static final Field CRAFT_BOSSBAR_HANDLE_FIELD = NMS.getField(CraftBossBar.class, "handle");
private static final float DEFAULT_SPEED = 1F;
private static final Field ENDERDRAGON_BATTLE_BAR_FIELD = NMS.getField(EnderDragonBattle.class, "c");
@ -1635,6 +1651,7 @@ public class NMSImpl implements NMSBridge {
public static Field GOAL_FIELD = NMS.getField(PathfinderGoalSelector.class, "b");
private static final Field JUMP_FIELD = NMS.getField(EntityLiving.class, "bd");
private static Method MAKE_REQUEST;
private static MethodHandle MOVE_CONTROLLER_MOVING = NMS.getSetter(ControllerMove.class, "h");
private static Field NAVIGATION_WORLD_FIELD = NMS.getField(NavigationAbstract.class, "b");
public static Field NETWORK_ADDRESS = NMS.getField(NetworkManager.class, "l");
public static final Location PACKET_CACHE_LOCATION = new Location(null, 0, 0, 0);

View File

@ -178,6 +178,7 @@ import net.minecraft.server.v1_12_R1.Block;
import net.minecraft.server.v1_12_R1.BlockPosition;
import net.minecraft.server.v1_12_R1.BossBattleServer;
import net.minecraft.server.v1_12_R1.ControllerJump;
import net.minecraft.server.v1_12_R1.ControllerMove;
import net.minecraft.server.v1_12_R1.CrashReport;
import net.minecraft.server.v1_12_R1.CrashReportSystemDetails;
import net.minecraft.server.v1_12_R1.DamageSource;
@ -291,6 +292,20 @@ public class NMSImpl implements NMSBridge {
}
}
@Override
public void cancelMoveDestination(org.bukkit.entity.Entity entity) {
Entity handle = getHandle(entity);
if (handle instanceof EntityInsentient) {
try {
MOVE_CONTROLLER_MOVING.invoke(((EntityInsentient) handle).getControllerMove(), null);
} catch (Throwable t) {
t.printStackTrace();
}
} else if (handle instanceof EntityHumanNPC) {
((EntityHumanNPC) handle).getControllerMove().f = false;
}
}
@Override
public GameProfile fillProfileProperties(GameProfile profile, boolean requireSecure) throws Exception {
if (Bukkit.isPrimaryThread())
@ -1607,11 +1622,11 @@ public class NMSImpl implements NMSBridge {
if ((entity.width > f2) && (!justCreated) && (!entity.world.isClientSide))
entity.move(EnumMoveType.SELF, (f2 - entity.width) / 2, 0.0D, (f2 - entity.width) / 2);
}
};
}
public static void stopNavigation(NavigationAbstract navigation) {
navigation.p();
}
};
public static void updateAI(EntityLiving entity) {
if (entity instanceof EntityInsentient) {
@ -1631,6 +1646,7 @@ public class NMSImpl implements NMSBridge {
}
private static MethodHandle ADVANCEMENT_PLAYER_FIELD = NMS.getFinalSetter(EntityPlayer.class, "bY");
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.MAGMA_CUBE, EntityType.HORSE, EntityType.GHAST);
@ -1644,6 +1660,7 @@ public class NMSImpl implements NMSBridge {
public static Field GOAL_FIELD = NMS.getField(PathfinderGoalSelector.class, "b");
private static final Field JUMP_FIELD = NMS.getField(EntityLiving.class, "bd");
private static Method MAKE_REQUEST;
private static MethodHandle MOVE_CONTROLLER_MOVING = NMS.getSetter(ControllerMove.class, "h");
private static Field NAVIGATION_WORLD_FIELD = NMS.getField(NavigationAbstract.class, "b");
public static Field NETWORK_ADDRESS = NMS.getField(NetworkManager.class, "l");
public static final Location PACKET_CACHE_LOCATION = new Location(null, 0, 0, 0);

View File

@ -192,6 +192,7 @@ import net.minecraft.server.v1_13_R2.Block;
import net.minecraft.server.v1_13_R2.BlockPosition;
import net.minecraft.server.v1_13_R2.BossBattleServer;
import net.minecraft.server.v1_13_R2.ControllerJump;
import net.minecraft.server.v1_13_R2.ControllerMove;
import net.minecraft.server.v1_13_R2.CrashReport;
import net.minecraft.server.v1_13_R2.CrashReportSystemDetails;
import net.minecraft.server.v1_13_R2.DamageSource;
@ -309,6 +310,20 @@ public class NMSImpl implements NMSBridge {
}
}
@Override
public void cancelMoveDestination(org.bukkit.entity.Entity entity) {
Entity handle = getHandle(entity);
if (handle instanceof EntityInsentient) {
try {
MOVE_CONTROLLER_MOVING.invoke(((EntityInsentient) handle).getControllerMove(), null);
} catch (Throwable t) {
t.printStackTrace();
}
} else if (handle instanceof EntityHumanNPC) {
((EntityHumanNPC) handle).getControllerMove().f = false;
}
}
@Override
public GameProfile fillProfileProperties(GameProfile profile, boolean requireSecure) throws Exception {
if (Bukkit.isPrimaryThread())
@ -1744,6 +1759,7 @@ public class NMSImpl implements NMSBridge {
EntityType.SHULKER, EntityType.ENDERMITE, EntityType.ENDER_DRAGON, EntityType.BAT, EntityType.SLIME,
EntityType.DOLPHIN, EntityType.MAGMA_CUBE, EntityType.HORSE, EntityType.GHAST, EntityType.SHULKER,
EntityType.PHANTOM);
private static final Method BLOCK_POSITION_B_D = NMS.getMethod(BlockPosition.PooledBlockPosition.class, "e", false,
double.class, double.class, double.class);
private static final Field CRAFT_BOSSBAR_HANDLE_FIELD = NMS.getField(CraftBossBar.class, "handle");
@ -1758,6 +1774,7 @@ public class NMSImpl implements NMSBridge {
public static Field GOAL_FIELD = NMS.getField(PathfinderGoalSelector.class, "b");
private static final Field JUMP_FIELD = NMS.getField(EntityLiving.class, "bg");
private static Method MAKE_REQUEST;
private static MethodHandle MOVE_CONTROLLER_MOVING = NMS.getSetter(ControllerMove.class, "h");
private static Field NAVIGATION_WORLD_FIELD = NMS.getField(NavigationAbstract.class, "b");
public static Field NETWORK_ADDRESS = NMS.getField(NetworkManager.class, "l", false);
public static final Location PACKET_CACHE_LOCATION = new Location(null, 0, 0, 0);

View File

@ -208,6 +208,7 @@ import net.minecraft.server.v1_14_R1.BlockPosition;
import net.minecraft.server.v1_14_R1.BossBattleServer;
import net.minecraft.server.v1_14_R1.ChunkProviderServer;
import net.minecraft.server.v1_14_R1.ControllerJump;
import net.minecraft.server.v1_14_R1.ControllerMove;
import net.minecraft.server.v1_14_R1.CrashReport;
import net.minecraft.server.v1_14_R1.CrashReportSystemDetails;
import net.minecraft.server.v1_14_R1.DamageSource;
@ -354,6 +355,20 @@ public class NMSImpl implements NMSBridge {
}
}
@Override
public void cancelMoveDestination(org.bukkit.entity.Entity entity) {
Entity handle = getHandle(entity);
if (handle instanceof EntityInsentient) {
try {
MOVE_CONTROLLER_MOVING.invoke(((EntityInsentient) handle).getControllerMove(), null);
} catch (Throwable t) {
t.printStackTrace();
}
} else if (handle instanceof EntityHumanNPC) {
((EntityHumanNPC) handle).getControllerMove().f = false;
}
}
@Override
public GameProfile fillProfileProperties(GameProfile profile, boolean requireSecure) throws Throwable {
if (Bukkit.isPrimaryThread())
@ -1843,6 +1858,7 @@ public class NMSImpl implements NMSBridge {
EntityType.PHANTOM);
private static final MethodHandle BEHAVIOR_MAP = NMS.getGetter(BehaviorController.class, "c");
private static final MethodHandle BLOCK_POSITION_B_D = NMS.getMethodHandle(BlockPosition.PooledBlockPosition.class,
"c", false, double.class, double.class, double.class);
private static final MethodHandle BUKKITENTITY_FIELD_SETTER = NMS.getSetter(Entity.class, "bukkitEntity");
@ -1870,6 +1886,7 @@ public class NMSImpl implements NMSBridge {
private static final MethodHandle JUMP_FIELD = NMS.getGetter(EntityLiving.class, "jumping");
private static final MethodHandle MAKE_REQUEST = NMS.getMethodHandle(YggdrasilAuthenticationService.class,
"makeRequest", true, URL.class, Object.class, Class.class);
private static MethodHandle MOVE_CONTROLLER_MOVING = NMS.getSetter(ControllerMove.class, "h");
private static final MethodHandle NAVIGATION_WORLD_FIELD = NMS.getSetter(NavigationAbstract.class, "b");
public static final Location PACKET_CACHE_LOCATION = new Location(null, 0, 0, 0);
private static final MethodHandle PATHFINDING_RANGE = NMS.getGetter(NavigationAbstract.class, "p");

View File

@ -210,6 +210,7 @@ import net.minecraft.server.v1_15_R1.BlockPosition;
import net.minecraft.server.v1_15_R1.BossBattleServer;
import net.minecraft.server.v1_15_R1.ChunkProviderServer;
import net.minecraft.server.v1_15_R1.ControllerJump;
import net.minecraft.server.v1_15_R1.ControllerMove;
import net.minecraft.server.v1_15_R1.CrashReport;
import net.minecraft.server.v1_15_R1.CrashReportSystemDetails;
import net.minecraft.server.v1_15_R1.DamageSource;
@ -362,6 +363,20 @@ public class NMSImpl implements NMSBridge {
}
}
@Override
public void cancelMoveDestination(org.bukkit.entity.Entity entity) {
Entity handle = getHandle(entity);
if (handle instanceof EntityInsentient) {
try {
MOVE_CONTROLLER_MOVING.invoke(((EntityInsentient) handle).getControllerMove(), null);
} catch (Throwable t) {
t.printStackTrace();
}
} else if (handle instanceof EntityHumanNPC) {
((EntityHumanNPC) handle).getControllerMove().f = false;
}
}
@Override
public GameProfile fillProfileProperties(GameProfile profile, boolean requireSecure) throws Throwable {
if (Bukkit.isPrimaryThread())
@ -1897,6 +1912,7 @@ public class NMSImpl implements NMSBridge {
EntityType.SHULKER, EntityType.PHANTOM);
private static final MethodHandle BEHAVIOR_MAP = NMS.getGetter(BehaviorController.class, "c");
private static final MethodHandle BUKKITENTITY_FIELD_SETTER = NMS.getSetter(Entity.class, "bukkitEntity");
private static final MethodHandle CHUNKMAP_UPDATE_PLAYER_STATUS = NMS.getMethodHandle(PlayerChunkMap.class, "a",
true, EntityPlayer.class, boolean.class);
@ -1922,6 +1938,7 @@ public class NMSImpl implements NMSBridge {
private static final MethodHandle JUMP_FIELD = NMS.getGetter(EntityLiving.class, "jumping");
private static final MethodHandle MAKE_REQUEST = NMS.getMethodHandle(YggdrasilAuthenticationService.class,
"makeRequest", true, URL.class, Object.class, Class.class);
private static MethodHandle MOVE_CONTROLLER_MOVING = NMS.getSetter(ControllerMove.class, "h");
private static final MethodHandle NAVIGATION_WORLD_FIELD = NMS.getSetter(NavigationAbstract.class, "b");
public static final Location PACKET_CACHE_LOCATION = new Location(null, 0, 0, 0);
private static final MethodHandle PATHFINDING_RANGE = NMS.getGetter(NavigationAbstract.class, "p");

View File

@ -215,6 +215,7 @@ import net.minecraft.server.v1_16_R3.BlockPosition;
import net.minecraft.server.v1_16_R3.BossBattleServer;
import net.minecraft.server.v1_16_R3.ChunkProviderServer;
import net.minecraft.server.v1_16_R3.ControllerJump;
import net.minecraft.server.v1_16_R3.ControllerMove;
import net.minecraft.server.v1_16_R3.CrashReport;
import net.minecraft.server.v1_16_R3.CrashReportSystemDetails;
import net.minecraft.server.v1_16_R3.DamageSource;
@ -368,6 +369,20 @@ public class NMSImpl implements NMSBridge {
}
}
@Override
public void cancelMoveDestination(org.bukkit.entity.Entity entity) {
Entity handle = getHandle(entity);
if (handle instanceof EntityInsentient) {
try {
MOVE_CONTROLLER_MOVING.invoke(((EntityInsentient) handle).getControllerMove(), null);
} catch (Throwable t) {
t.printStackTrace();
}
} else if (handle instanceof EntityHumanNPC) {
((EntityHumanNPC) handle).getControllerMove().f = false;
}
}
@Override
public GameProfile fillProfileProperties(GameProfile profile, boolean requireSecure) throws Throwable {
if (Bukkit.isPrimaryThread())
@ -1871,7 +1886,9 @@ public class NMSImpl implements NMSBridge {
EntityType.SILVERFISH, EntityType.SHULKER, EntityType.ENDERMITE, EntityType.ENDER_DRAGON, EntityType.BAT,
EntityType.SLIME, EntityType.DOLPHIN, EntityType.MAGMA_CUBE, EntityType.HORSE, EntityType.GHAST,
EntityType.SHULKER, EntityType.PHANTOM);
private static final MethodHandle BEHAVIOR_MAP = NMS.getGetter(BehaviorController.class, "e");
private static final MethodHandle BUKKITENTITY_FIELD_SETTER = NMS.getSetter(Entity.class, "bukkitEntity");
private static final MethodHandle CHUNKMAP_UPDATE_PLAYER_STATUS = NMS.getMethodHandle(PlayerChunkMap.class, "a",
true, EntityPlayer.class, boolean.class);
@ -1896,6 +1913,7 @@ public class NMSImpl implements NMSBridge {
private static final MethodHandle JUMP_FIELD = NMS.getGetter(EntityLiving.class, "jumping");
private static final MethodHandle MAKE_REQUEST = NMS.getMethodHandle(YggdrasilAuthenticationService.class,
"makeRequest", true, URL.class, Object.class, Class.class);
private static MethodHandle MOVE_CONTROLLER_MOVING = NMS.getSetter(ControllerMove.class, "h");
private static final MethodHandle NAVIGATION_A = NMS.getMethodHandle(NavigationAbstract.class, "a", true,
int.class);
private static final MethodHandle NAVIGATION_S = NMS.getFinalSetter(NavigationAbstract.class, "s");

View File

@ -246,6 +246,7 @@ import net.minecraft.world.entity.ai.Brain;
import net.minecraft.world.entity.ai.attributes.AttributeInstance;
import net.minecraft.world.entity.ai.attributes.Attributes;
import net.minecraft.world.entity.ai.control.JumpControl;
import net.minecraft.world.entity.ai.control.MoveControl;
import net.minecraft.world.entity.ai.goal.GoalSelector;
import net.minecraft.world.entity.ai.navigation.PathNavigation;
import net.minecraft.world.entity.animal.AbstractFish;
@ -383,6 +384,20 @@ public class NMSImpl implements NMSBridge {
EnchantmentHelper.doPostDamageEffects(target, handle);
}
@Override
public void cancelMoveDestination(org.bukkit.entity.Entity entity) {
Entity handle = getHandle(entity);
if (handle instanceof Mob) {
try {
MOVE_CONTROLLER_MOVING.invoke(((Mob) handle).getMoveControl(), null);
} catch (Throwable t) {
t.printStackTrace();
}
} else if (handle instanceof EntityHumanNPC) {
((EntityHumanNPC) handle).getMoveControl().moving = false;
}
}
@Override
public GameProfile fillProfileProperties(GameProfile profile, boolean requireSecure) throws Throwable {
if (Bukkit.isPrimaryThread())
@ -1880,6 +1895,7 @@ public class NMSImpl implements NMSBridge {
EntityType.SILVERFISH, EntityType.SHULKER, EntityType.ENDERMITE, EntityType.ENDER_DRAGON, EntityType.BAT,
EntityType.SLIME, EntityType.DOLPHIN, EntityType.MAGMA_CUBE, EntityType.HORSE, EntityType.GHAST,
EntityType.SHULKER, EntityType.PHANTOM);
private static final MethodHandle BEHAVIOR_MAP = NMS.getGetter(Brain.class, "f");
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,
@ -1902,6 +1918,7 @@ public class NMSImpl implements NMSBridge {
private static final MethodHandle JUMP_FIELD = NMS.getGetter(LivingEntity.class, "bn");
private static final MethodHandle MAKE_REQUEST = NMS.getMethodHandle(YggdrasilAuthenticationService.class,
"makeRequest", true, URL.class, Object.class, Class.class);
private static MethodHandle MOVE_CONTROLLER_MOVING = NMS.getSetter(MoveControl.class, "k");
private static final MethodHandle NAVIGATION_CREATE_PATHFINDER = NMS.getMethodHandle(PathNavigation.class, "a",
true, int.class);
private static MethodHandle NAVIGATION_PATH = NMS.getGetter(PathNavigation.class, "c");

View File

@ -248,6 +248,7 @@ import net.minecraft.world.entity.ai.Brain;
import net.minecraft.world.entity.ai.attributes.AttributeInstance;
import net.minecraft.world.entity.ai.attributes.Attributes;
import net.minecraft.world.entity.ai.control.JumpControl;
import net.minecraft.world.entity.ai.control.MoveControl;
import net.minecraft.world.entity.ai.goal.GoalSelector;
import net.minecraft.world.entity.ai.navigation.PathNavigation;
import net.minecraft.world.entity.animal.AbstractFish;
@ -387,6 +388,20 @@ public class NMSImpl implements NMSBridge {
EnchantmentHelper.doPostDamageEffects(target, handle);
}
@Override
public void cancelMoveDestination(org.bukkit.entity.Entity entity) {
Entity handle = getHandle(entity);
if (handle instanceof Mob) {
try {
MOVE_CONTROLLER_MOVING.invoke(((Mob) handle).getMoveControl(), null);
} catch (Throwable t) {
t.printStackTrace();
}
} else if (handle instanceof EntityHumanNPC) {
((EntityHumanNPC) handle).getMoveControl().moving = false;
}
}
@Override
public GameProfile fillProfileProperties(GameProfile profile, boolean requireSecure) throws Throwable {
if (Bukkit.isPrimaryThread())
@ -1936,6 +1951,7 @@ public class NMSImpl implements NMSBridge {
private static final MethodHandle JUMP_FIELD = NMS.getGetter(LivingEntity.class, "bo");
private static final MethodHandle MAKE_REQUEST = NMS.getMethodHandle(YggdrasilAuthenticationService.class,
"makeRequest", true, URL.class, Object.class, Class.class);
private static MethodHandle MOVE_CONTROLLER_MOVING = NMS.getSetter(MoveControl.class, "k");
private static final MethodHandle NAVIGATION_CREATE_PATHFINDER = NMS
.getFirstMethodHandleWithReturnType(PathNavigation.class, true, PathFinder.class, int.class);
private static MethodHandle NAVIGATION_PATH = NMS.getFirstGetter(PathNavigation.class, Path.class);

View File

@ -141,6 +141,7 @@ import net.minecraft.server.v1_8_R3.AxisAlignedBB;
import net.minecraft.server.v1_8_R3.Block;
import net.minecraft.server.v1_8_R3.BlockPosition;
import net.minecraft.server.v1_8_R3.ControllerJump;
import net.minecraft.server.v1_8_R3.ControllerMove;
import net.minecraft.server.v1_8_R3.CrashReport;
import net.minecraft.server.v1_8_R3.CrashReportSystemDetails;
import net.minecraft.server.v1_8_R3.DamageSource;
@ -239,6 +240,20 @@ public class NMSImpl implements NMSBridge {
}
}
@Override
public void cancelMoveDestination(org.bukkit.entity.Entity entity) {
Entity handle = getHandle(entity);
if (handle instanceof EntityInsentient) {
try {
MOVE_CONTROLLER_MOVING.set(((EntityInsentient) handle).getControllerMove(), false);
} catch (Throwable t) {
t.printStackTrace();
}
} else if (handle instanceof EntityHumanNPC) {
((EntityHumanNPC) handle).getControllerMove().f = false;
}
}
@Override
public GameProfile fillProfileProperties(GameProfile profile, boolean requireSecure) throws Exception {
if (Bukkit.isPrimaryThread())
@ -1434,6 +1449,7 @@ public class NMSImpl implements NMSBridge {
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.GHAST);
private static final float DEFAULT_SPEED = 1F;
private static Map<Class<?>, Integer> ENTITY_CLASS_TO_INT;
private static Map<Class<?>, String> ENTITY_CLASS_TO_NAME;
@ -1442,6 +1458,7 @@ public class NMSImpl implements NMSBridge {
public static Field GOAL_FIELD = NMS.getField(PathfinderGoalSelector.class, "b");
private static final Field JUMP_FIELD = NMS.getField(EntityLiving.class, "aY");
private static Method MAKE_REQUEST;
private static Field MOVE_CONTROLLER_MOVING = NMS.getField(ControllerMove.class, "f");
private static Field NAVIGATION_WORLD_FIELD = NMS.getField(NavigationAbstract.class, "c");
public static Field NETWORK_ADDRESS = NMS.getField(NetworkManager.class, "l");
public static final Location PACKET_CACHE_LOCATION = new Location(null, 0, 0, 0);
@ -1450,7 +1467,6 @@ public class NMSImpl implements NMSBridge {
private static Field SKULL_PROFILE_FIELD;
private static Field TEAM_FIELD;
private static Field TRACKED_ENTITY_SET = NMS.getField(EntityTracker.class, "c");
static {
try {
Field field = NMS.getField(EntityTypes.class, "f");