mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-11-23 19:16:34 +01:00
Fix speed on mob NPCs
This commit is contained in:
parent
3808d7188a
commit
8ad3b1d674
@ -289,12 +289,12 @@ public class NPCCommands {
|
|||||||
permission = "citizens.npc.create")
|
permission = "citizens.npc.create")
|
||||||
@Requirements
|
@Requirements
|
||||||
public void create(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
public void create(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
String name = Colorizer.parseColors(args.getJoinedStrings(1));
|
String name = Colorizer.parseColors(args.getJoinedStrings(1).trim());
|
||||||
if (name.length() > 16) {
|
if (name.length() > 16) {
|
||||||
Messaging.sendErrorTr(sender, Messages.NPC_NAME_TOO_LONG);
|
Messaging.sendErrorTr(sender, Messages.NPC_NAME_TOO_LONG);
|
||||||
name = name.substring(0, 16);
|
name = name.substring(0, 16);
|
||||||
}
|
}
|
||||||
if (name.length() <= 0)
|
if (name.length() == 0)
|
||||||
throw new CommandException();
|
throw new CommandException();
|
||||||
|
|
||||||
EntityType type = EntityType.PLAYER;
|
EntityType type = EntityType.PLAYER;
|
||||||
|
@ -110,7 +110,6 @@ public class CitizensNavigator implements Navigator, Runnable {
|
|||||||
if (defaultParams.baseSpeed() == UNINITIALISED_SPEED) {
|
if (defaultParams.baseSpeed() == UNINITIALISED_SPEED) {
|
||||||
defaultParams.baseSpeed(NMS.getSpeedFor(npc));
|
defaultParams.baseSpeed(NMS.getSpeedFor(npc));
|
||||||
}
|
}
|
||||||
NMS.setSpeed(npc.getEntity(), defaultParams.speedModifier());
|
|
||||||
updatePathfindingRange();
|
updatePathfindingRange();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -213,12 +213,12 @@ public class NMS {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static float getSpeedFor(NPC npc) {
|
public static float getSpeedFor(NPC npc) {
|
||||||
if (!npc.isSpawned())
|
if (!npc.isSpawned() || !(npc instanceof LivingEntity))
|
||||||
return DEFAULT_SPEED;
|
return DEFAULT_SPEED;
|
||||||
// this is correct, but too slow. TODO: investigate
|
// this is correct, but too slow. TODO: investigate
|
||||||
// return (float)
|
return (float) ((EntityLiving) NMS.getHandle(npc.getEntity())).getAttributeInstance(GenericAttributes.d)
|
||||||
// NMS.getHandle(npc.getBukkitEntity()).getAttributeInstance(GenericAttributes.d).getValue();
|
.getValue();
|
||||||
return DEFAULT_SPEED;
|
// return DEFAULT_SPEED;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void initNetworkManager(NetworkManager network) {
|
public static void initNetworkManager(NetworkManager network) {
|
||||||
@ -381,13 +381,6 @@ public class NMS {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setSpeed(org.bukkit.entity.Entity entity, float speedModifier) {
|
|
||||||
if (!(entity instanceof LivingEntity))
|
|
||||||
return;
|
|
||||||
EntityLiving handle = NMS.getHandle((LivingEntity) entity);
|
|
||||||
handle.getAttributeInstance(GenericAttributes.d).setValue(speedModifier);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void setStepHeight(EntityLiving entity, float height) {
|
public static void setStepHeight(EntityLiving entity, float height) {
|
||||||
entity.X = height;
|
entity.X = height;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user