mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-11-27 21:29:14 +01:00
Fix walking over slabs
This commit is contained in:
parent
f1f5b74f6b
commit
b4373ccaa9
@ -142,7 +142,7 @@ public class CitizensHumanNPC extends CitizensNPC implements Equipable {
|
||||
if (isSpawned() && getBukkitEntity().getLocation().getChunk().isLoaded()) {
|
||||
if (NMS.inWater(mcEntity)) {
|
||||
mcEntity.motY += 0.08F;
|
||||
} else
|
||||
} else if (!getNavigator().isNavigating())
|
||||
mcEntity.move(0, -0.2, 0);
|
||||
// gravity! also works around an entity.onGround not updating issue
|
||||
// (onGround is normally updated by the client)
|
||||
|
@ -11,6 +11,7 @@ import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.npc.network.EmptyNetHandler;
|
||||
import net.citizensnpcs.npc.network.EmptyNetworkManager;
|
||||
import net.citizensnpcs.npc.network.EmptySocket;
|
||||
import net.citizensnpcs.util.NMS;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.EntityPlayer;
|
||||
import net.minecraft.server.EnumGamemode;
|
||||
@ -100,7 +101,6 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder {
|
||||
// swallow
|
||||
}
|
||||
|
||||
W = STEP_HEIGHT; // fix moving up slabs and steps
|
||||
getNavigation().e(true);
|
||||
|
||||
try {
|
||||
@ -115,6 +115,7 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder {
|
||||
super.j_();
|
||||
if (npc == null)
|
||||
return;
|
||||
|
||||
Navigation navigation = getNavigation();
|
||||
if (Math.abs(motX) < EPSILON && Math.abs(motY) < EPSILON && Math.abs(motZ) < EPSILON)
|
||||
motX = motY = motZ = 0;
|
||||
@ -156,10 +157,10 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder {
|
||||
bF *= 0.9F;
|
||||
|
||||
float prev = aM;
|
||||
aM *= bs() * npc.getNavigator().getDefaultParameters().speed();
|
||||
aM *= by() * npc.getNavigator().getDefaultParameters().speed();
|
||||
e(bD, bE); // movement method
|
||||
aM = prev;
|
||||
ay = yaw; // update head yaw to match entity yaw
|
||||
NMS.setHeadYaw(this, yaw);
|
||||
}
|
||||
|
||||
public static class PlayerNPC extends CraftPlayer implements NPCHolder {
|
||||
@ -197,5 +198,4 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder {
|
||||
}
|
||||
|
||||
private static final float EPSILON = 0.005F;
|
||||
private static final float STEP_HEIGHT = 1F;
|
||||
}
|
@ -19,12 +19,15 @@ public class TriggerAddPrompt extends StringPrompt {
|
||||
@Override
|
||||
public Prompt acceptInput(ConversationContext context, String input) {
|
||||
input = input.toLowerCase().trim();
|
||||
if (input.equalsIgnoreCase("back"))
|
||||
if (input.equalsIgnoreCase("back")) {
|
||||
context.setSessionData("said", false);
|
||||
return (Prompt) context.getSessionData("previous");
|
||||
}
|
||||
Prompt prompt = WaypointTriggerRegistry.getTriggerPromptFrom(input);
|
||||
if (prompt == null) {
|
||||
Messaging.sendErrorTr((CommandSender) context.getForWhom(),
|
||||
Messages.WAYPOINT_TRIGGER_EDITOR_INVALID_TRIGGER, input);
|
||||
context.setSessionData("said", false);
|
||||
return this;
|
||||
}
|
||||
return prompt;
|
||||
@ -44,6 +47,9 @@ public class TriggerAddPrompt extends StringPrompt {
|
||||
Messaging.sendErrorTr((CommandSender) context.getForWhom(),
|
||||
Messages.WAYPOINT_TRIGGER_EDITOR_INACTIVE);
|
||||
}
|
||||
if (context.getSessionData("said") == Boolean.TRUE)
|
||||
return "";
|
||||
context.setSessionData("said", true);
|
||||
context.setSessionData(WaypointTriggerPrompt.RETURN_PROMPT_KEY, this);
|
||||
return Messaging.tr(Messages.WAYPOINT_TRIGGER_ADD_PROMPT,
|
||||
WaypointTriggerRegistry.describeValidTriggerNames());
|
||||
|
@ -24,16 +24,23 @@ public class TriggerEditPrompt extends StringPrompt {
|
||||
@Override
|
||||
public Prompt acceptInput(ConversationContext context, String input) {
|
||||
input = input.toLowerCase().trim();
|
||||
if (input.contains("add"))
|
||||
if (input.contains("add")) {
|
||||
context.setSessionData("said", false);
|
||||
return new TriggerAddPrompt(editor);
|
||||
if (input.contains("remove"))
|
||||
}
|
||||
if (input.contains("remove")) {
|
||||
context.setSessionData("said", false);
|
||||
return new TriggerRemovePrompt(editor);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPromptText(ConversationContext context) {
|
||||
context.setSessionData("previous", this);
|
||||
if (context.getSessionData("said") == Boolean.TRUE)
|
||||
return "";
|
||||
context.setSessionData("said", true);
|
||||
String base = Messaging.tr(Messages.WAYPOINT_TRIGGER_EDITOR_PROMPT);
|
||||
if (editor.getCurrentWaypoint() != null) {
|
||||
Waypoint waypoint = editor.getCurrentWaypoint();
|
||||
|
@ -20,8 +20,10 @@ public class TriggerRemovePrompt extends StringPrompt {
|
||||
|
||||
@Override
|
||||
public Prompt acceptInput(ConversationContext context, String input) {
|
||||
if (input.equalsIgnoreCase("back"))
|
||||
if (input.equalsIgnoreCase("back")) {
|
||||
context.setSessionData("said", false);
|
||||
return (Prompt) context.getSessionData("previous");
|
||||
}
|
||||
if (editor.getCurrentWaypoint() == null) {
|
||||
Messaging.sendErrorTr((CommandSender) context.getForWhom(),
|
||||
Messages.WAYPOINT_TRIGGER_EDITOR_INACTIVE);
|
||||
@ -54,6 +56,9 @@ public class TriggerRemovePrompt extends StringPrompt {
|
||||
Messages.WAYPOINT_TRIGGER_EDITOR_INACTIVE);
|
||||
return "";
|
||||
}
|
||||
if (context.getSessionData("said") == Boolean.TRUE)
|
||||
return "";
|
||||
context.setSessionData("said", true);
|
||||
String root = Messaging.tr(Messages.WAYPOINT_TRIGGER_REMOVE_PROMPT);
|
||||
int i = 1;
|
||||
for (WaypointTrigger trigger : editor.getCurrentWaypoint().getTriggers()) {
|
||||
|
@ -256,6 +256,7 @@ public class NMS {
|
||||
MOVEMENT_SPEEDS.put(EntityType.SHEEP, 0.25F);
|
||||
MOVEMENT_SPEEDS.put(EntityType.SNOWMAN, 0.25F);
|
||||
MOVEMENT_SPEEDS.put(EntityType.PIG, 0.27F);
|
||||
MOVEMENT_SPEEDS.put(EntityType.PLAYER, 1F);
|
||||
MOVEMENT_SPEEDS.put(EntityType.VILLAGER, 0.3F);
|
||||
|
||||
LAND_SPEED_MODIFIER_FIELD = getField(EntityLiving.class, "bQ");
|
||||
|
Loading…
Reference in New Issue
Block a user