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