Fix /npc gravity for players

This commit is contained in:
fullwall 2015-10-24 15:45:57 +08:00
parent 11df61f74d
commit 5e5b2dc8c8
3 changed files with 13 additions and 5 deletions

View File

@ -236,7 +236,7 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
navigation = new PlayerNavigation(this, world);
NMS.setStepHeight(this, 1); // the default (0) breaks step climbing
setSkinFlags((byte)0xFF);
setSkinFlags((byte) 0xFF);
}
public boolean isNavigating() {

View File

@ -67,7 +67,7 @@ public class HumanController extends AbstractEntityController {
}
}
}
final String prefixCapture = prefix, suffixCapture = suffix, coloredNameCapture = coloredName;
final String prefixCapture = prefix, suffixCapture = suffix;
UUID uuid = npc.getUniqueId();
if (uuid.version() == 4) { // clear version

View File

@ -1,9 +1,11 @@
package net.citizensnpcs.trait;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
import net.citizensnpcs.api.persistence.Persist;
import net.citizensnpcs.api.trait.Trait;
import org.bukkit.util.Vector;
import net.citizensnpcs.npc.entity.EntityHumanNPC.PlayerNPC;
public class Gravity extends Trait implements Toggleable {
@Persist
@ -19,7 +21,13 @@ public class Gravity extends Trait implements Toggleable {
@Override
public void run() {
if (!npc.isSpawned() || !enabled)
if (!npc.isSpawned())
return;
if (npc.getEntity() instanceof Player) {
((PlayerNPC) npc.getEntity()).setGravityEnabled(!enabled);
return;
}
if (!enabled)
return;
Vector vector = npc.getEntity().getVelocity();
vector.setY(Math.max(0, vector.getY()));