Set step height to 1 for all living NPCs

This commit is contained in:
fullwall 2014-02-20 11:44:59 +08:00
parent f897ab728d
commit 5b2e5323c3
4 changed files with 10 additions and 4 deletions

View File

@ -203,6 +203,9 @@ public class CitizensNPC extends AbstractNPC {
LivingEntity entity = (LivingEntity) getEntity();
entity.setRemoveWhenFarAway(false);
entity.setCustomName(getFullName());
if (NMS.getStepHeight(entity) < 1) {
NMS.setStepHeight(NMS.getHandle(entity), 1);
}
}
return true;
}

View File

@ -30,8 +30,9 @@ public abstract class MobEntityController extends AbstractEntityController {
// entity.onGround isn't updated right away - we approximate here so
// that things like pathfinding still work *immediately* after spawn.
org.bukkit.Material beneath = at.getBlock().getRelative(BlockFace.DOWN).getType();
if (beneath.isBlock())
if (beneath.isBlock()) {
entity.onGround = true;
}
return entity.getBukkitEntity();
}

View File

@ -83,7 +83,6 @@ public class WolfController extends MobEntityController {
public void bn() {
super.bn();
if (npc != null) {
NMS.setStepHeight(this, 1);
npc.update();
}
}

View File

@ -177,7 +177,7 @@ public class NMS {
}
private static Constructor<?> getCustomEntityConstructor(Class<?> clazz, EntityType type) throws SecurityException,
NoSuchMethodException {
NoSuchMethodException {
Constructor<?> constructor = ENTITY_CONSTRUCTOR_CACHE.get(clazz);
if (constructor == null) {
constructor = clazz.getConstructor(World.class);
@ -238,6 +238,10 @@ public class NMS {
// return DEFAULT_SPEED;
}
public static float getStepHeight(LivingEntity entity) {
return NMS.getHandle(entity).X;
}
public static void initNetworkManager(NetworkManager network) {
if (NETWORK_CHANNEL == null || NETWORK_ADDRESS == null)
return;
@ -542,7 +546,6 @@ public class NMS {
private static Field NETWORK_CHANNEL = getField(NetworkManager.class, "k");
private static final Location PACKET_CACHE_LOCATION = new Location(null, 0, 0, 0);
private static Field PATHFINDING_RANGE = getField(Navigation.class, "e");
private static final Random RANDOM = Util.getFastRandom();
// true field above false and three synchronised lists