mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-09-29 15:47:40 +02:00
Fix Enderman, Horse and Wither not moving properly, fix Player NPCs not jumping properly
This commit is contained in:
parent
fdadd1df8b
commit
d030909524
@ -171,8 +171,9 @@ public class CitizensNavigator implements Navigator, Runnable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void stopNavigating() {
|
private void stopNavigating() {
|
||||||
if (executing != null)
|
if (executing != null) {
|
||||||
executing.stop();
|
executing.stop();
|
||||||
|
}
|
||||||
executing = null;
|
executing = null;
|
||||||
localParams = defaultParams;
|
localParams = defaultParams;
|
||||||
stationaryTicks = 0;
|
stationaryTicks = 0;
|
||||||
@ -209,9 +210,10 @@ public class CitizensNavigator implements Navigator, Runnable {
|
|||||||
NavigationCancelEvent event = new NavigationCancelEvent(this, reason);
|
NavigationCancelEvent event = new NavigationCancelEvent(this, reason);
|
||||||
PathStrategy old = executing;
|
PathStrategy old = executing;
|
||||||
Bukkit.getPluginManager().callEvent(event);
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
if (old == executing)
|
if (old == executing) {
|
||||||
stopNavigating();
|
stopNavigating();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void switchStrategyTo(PathStrategy newStrategy) {
|
private void switchStrategyTo(PathStrategy newStrategy) {
|
||||||
if (Messaging.isDebugging())
|
if (Messaging.isDebugging())
|
||||||
|
@ -42,6 +42,7 @@ public class EndermanController extends MobEntityController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static class EntityEndermanNPC extends EntityEnderman implements NPCHolder {
|
public static class EntityEndermanNPC extends EntityEnderman implements NPCHolder {
|
||||||
|
private int jumpTicks;
|
||||||
private final CitizensNPC npc;
|
private final CitizensNPC npc;
|
||||||
|
|
||||||
public EntityEndermanNPC(World world) {
|
public EntityEndermanNPC(World world) {
|
||||||
@ -91,7 +92,7 @@ public class EndermanController extends MobEntityController {
|
|||||||
if (npc == null)
|
if (npc == null)
|
||||||
super.c();
|
super.c();
|
||||||
else {
|
else {
|
||||||
NMS.updateAI(this);
|
updateAIWithMovement();
|
||||||
npc.update();
|
npc.update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -138,5 +139,38 @@ public class EndermanController extends MobEntityController {
|
|||||||
public NPC getNPC() {
|
public NPC getNPC() {
|
||||||
return npc;
|
return npc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean j(double d1, double d2, double d3) {
|
||||||
|
if (npc == null) {
|
||||||
|
return super.j(d1, d2, d3);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateAIWithMovement() {
|
||||||
|
NMS.updateAI(this);
|
||||||
|
// taken from EntityLiving update method
|
||||||
|
if (bd) {
|
||||||
|
/* boolean inLiquid = G() || I();
|
||||||
|
if (inLiquid) {
|
||||||
|
motY += 0.04;
|
||||||
|
} else //(handled elsewhere)*/
|
||||||
|
if (onGround && jumpTicks == 0) {
|
||||||
|
bd();
|
||||||
|
jumpTicks = 10;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
jumpTicks = 0;
|
||||||
|
}
|
||||||
|
be *= 0.98F;
|
||||||
|
bf *= 0.98F;
|
||||||
|
bg *= 0.9F;
|
||||||
|
e(be, bf); // movement method
|
||||||
|
NMS.setHeadYaw(this, yaw);
|
||||||
|
if (jumpTicks > 0) {
|
||||||
|
jumpTicks--;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -204,7 +204,7 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder {
|
|||||||
motY += 0.04;
|
motY += 0.04;
|
||||||
} else //(handled elsewhere)*/
|
} else //(handled elsewhere)*/
|
||||||
if (onGround && jumpTicks == 0) {
|
if (onGround && jumpTicks == 0) {
|
||||||
ba();
|
bd();
|
||||||
jumpTicks = 10;
|
jumpTicks = 10;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -216,6 +216,9 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder {
|
|||||||
|
|
||||||
e(be, bf); // movement method
|
e(be, bf); // movement method
|
||||||
NMS.setHeadYaw(this, yaw);
|
NMS.setHeadYaw(this, yaw);
|
||||||
|
if (jumpTicks > 0) {
|
||||||
|
jumpTicks--;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMoveDestination(double x, double y, double z, float speed) {
|
public void setMoveDestination(double x, double y, double z, float speed) {
|
||||||
|
@ -28,6 +28,8 @@ public class HorseController extends MobEntityController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static class EntityHorseNPC extends EntityHorse implements NPCHolder {
|
public static class EntityHorseNPC extends EntityHorse implements NPCHolder {
|
||||||
|
private int jumpTicks;
|
||||||
|
|
||||||
private final CitizensNPC npc;
|
private final CitizensNPC npc;
|
||||||
|
|
||||||
public EntityHorseNPC(World world) {
|
public EntityHorseNPC(World world) {
|
||||||
@ -60,18 +62,21 @@ public class HorseController extends MobEntityController {
|
|||||||
public void c() {
|
public void c() {
|
||||||
if (npc == null) {
|
if (npc == null) {
|
||||||
super.c();
|
super.c();
|
||||||
} else
|
} else {
|
||||||
|
updateAIWithMovement();
|
||||||
npc.update();
|
npc.update();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void collide(net.minecraft.server.v1_6_R2.Entity entity) {
|
public void collide(net.minecraft.server.v1_6_R2.Entity entity) {
|
||||||
// this method is called by both the entities involved - cancelling
|
// this method is called by both the entities involved - cancelling
|
||||||
// it will not stop the NPC from moving.
|
// it will not stop the NPC from moving.
|
||||||
super.collide(entity);
|
super.collide(entity);
|
||||||
if (npc != null)
|
if (npc != null) {
|
||||||
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void g(double x, double y, double z) {
|
public void g(double x, double y, double z) {
|
||||||
@ -106,6 +111,32 @@ public class HorseController extends MobEntityController {
|
|||||||
public NPC getNPC() {
|
public NPC getNPC() {
|
||||||
return npc;
|
return npc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void updateAIWithMovement() {
|
||||||
|
NMS.updateAI(this);
|
||||||
|
// taken from EntityLiving update method
|
||||||
|
if (bd) {
|
||||||
|
/* boolean inLiquid = G() || I();
|
||||||
|
if (inLiquid) {
|
||||||
|
motY += 0.04;
|
||||||
|
} else //(handled elsewhere)*/
|
||||||
|
if (onGround && jumpTicks == 0) {
|
||||||
|
bd();
|
||||||
|
jumpTicks = 10;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
jumpTicks = 0;
|
||||||
|
}
|
||||||
|
be *= 0.98F;
|
||||||
|
bf *= 0.98F;
|
||||||
|
bg *= 0.9F;
|
||||||
|
|
||||||
|
e(be, bf); // movement method
|
||||||
|
NMS.setHeadYaw(this, yaw);
|
||||||
|
if (jumpTicks > 0) {
|
||||||
|
jumpTicks--;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class HorseNPC extends CraftHorse implements NPCHolder {
|
public static class HorseNPC extends CraftHorse implements NPCHolder {
|
||||||
|
@ -28,6 +28,7 @@ public class WitherController extends MobEntityController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static class EntityWitherNPC extends EntityWither implements NPCHolder {
|
public static class EntityWitherNPC extends EntityWither implements NPCHolder {
|
||||||
|
private int jumpTicks;
|
||||||
private final CitizensNPC npc;
|
private final CitizensNPC npc;
|
||||||
|
|
||||||
public EntityWitherNPC(World world) {
|
public EntityWitherNPC(World world) {
|
||||||
@ -67,6 +68,8 @@ public class WitherController extends MobEntityController {
|
|||||||
public void c() {
|
public void c() {
|
||||||
if (npc == null) {
|
if (npc == null) {
|
||||||
super.c();
|
super.c();
|
||||||
|
} else {
|
||||||
|
updateAIWithMovement();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -112,6 +115,32 @@ public class WitherController extends MobEntityController {
|
|||||||
public NPC getNPC() {
|
public NPC getNPC() {
|
||||||
return npc;
|
return npc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void updateAIWithMovement() {
|
||||||
|
NMS.updateAI(this);
|
||||||
|
// taken from EntityLiving update method
|
||||||
|
if (bd) {
|
||||||
|
/* boolean inLiquid = G() || I();
|
||||||
|
if (inLiquid) {
|
||||||
|
motY += 0.04;
|
||||||
|
} else //(handled elsewhere)*/
|
||||||
|
if (onGround && jumpTicks == 0) {
|
||||||
|
bd();
|
||||||
|
jumpTicks = 10;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
jumpTicks = 0;
|
||||||
|
}
|
||||||
|
be *= 0.98F;
|
||||||
|
bf *= 0.98F;
|
||||||
|
bg *= 0.9F;
|
||||||
|
|
||||||
|
e(be, bf); // movement method
|
||||||
|
NMS.setHeadYaw(this, yaw);
|
||||||
|
if (jumpTicks > 0) {
|
||||||
|
jumpTicks--;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class WitherNPC extends CraftWither implements NPCHolder {
|
public static class WitherNPC extends CraftWither implements NPCHolder {
|
||||||
|
@ -326,9 +326,10 @@ public class LinearWaypointProvider implements WaypointProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void onWaypointsModified() {
|
private void onWaypointsModified() {
|
||||||
if (currentGoal != null)
|
if (currentGoal != null) {
|
||||||
currentGoal.onProviderChanged();
|
currentGoal.onProviderChanged();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void removeWaypointMarker(Waypoint waypoint) {
|
private void removeWaypointMarker(Waypoint waypoint) {
|
||||||
Entity entity = waypointMarkers.remove(waypoint);
|
Entity entity = waypointMarkers.remove(waypoint);
|
||||||
@ -387,8 +388,13 @@ public class LinearWaypointProvider implements WaypointProvider {
|
|||||||
public void onProviderChanged() {
|
public void onProviderChanged() {
|
||||||
itr = waypoints.iterator();
|
itr = waypoints.iterator();
|
||||||
if (currentDestination != null) {
|
if (currentDestination != null) {
|
||||||
|
if (selector != null) {
|
||||||
selector.finish();
|
selector.finish();
|
||||||
}
|
}
|
||||||
|
if (npc != null && npc.getNavigator().isNavigating()) {
|
||||||
|
npc.getNavigator().cancelNavigation();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user