mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-11-22 10:36:10 +01:00
Move movement code into playerTick to avoid inter-world crashes
This commit is contained in:
parent
5bfe08ecfb
commit
2a8f54f2d6
@ -1,8 +1,11 @@
|
||||
package net.citizensnpcs.commands;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.scoreboard.Scoreboard;
|
||||
import org.bukkit.scoreboard.Team;
|
||||
|
||||
import net.citizensnpcs.Citizens;
|
||||
import net.citizensnpcs.Settings.Setting;
|
||||
import net.citizensnpcs.api.command.Command;
|
||||
import net.citizensnpcs.api.command.CommandContext;
|
||||
import net.citizensnpcs.api.command.Requirements;
|
||||
@ -12,6 +15,7 @@ import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.api.util.Messaging;
|
||||
import net.citizensnpcs.util.Messages;
|
||||
import net.citizensnpcs.util.StringHelper;
|
||||
import net.citizensnpcs.util.Util;
|
||||
|
||||
@Requirements
|
||||
public class AdminCommands {
|
||||
@ -27,7 +31,7 @@ public class AdminCommands {
|
||||
Messaging.send(sender, " <7>-- <c>Author: fullwall");
|
||||
Messaging.send(sender, " <7>-- <c>Source Code: http://github.com/CitizensDev");
|
||||
Messaging.send(sender, " <7>-- <c>Website: " + plugin.getDescription().getWebsite());
|
||||
Messaging.send(sender, " <7>-- <c>Report an issue: http://github.com/CitizensDev/Citizens2/issues");
|
||||
Messaging.send(sender, " <7>-- <c>Report an issue: http://github.com/CitizensDev/Citizens2/issues");
|
||||
}
|
||||
|
||||
@Command(
|
||||
|
@ -311,13 +311,10 @@ public class CitizensNPC extends AbstractNPC {
|
||||
}
|
||||
if (getEntity() instanceof Player) {
|
||||
NMS.replaceTrackerEntry((Player) getEntity());
|
||||
PlayerUpdateTask.registerPlayer(getEntity());
|
||||
}
|
||||
}
|
||||
|
||||
if (getEntity() instanceof Player) {
|
||||
PlayerUpdateTask.registerPlayer(getEntity());
|
||||
}
|
||||
|
||||
if (requiresNameHologram() && !hasTrait(HologramTrait.class)) {
|
||||
addTrait(HologramTrait.class);
|
||||
}
|
||||
|
@ -285,6 +285,22 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
||||
super.k_();
|
||||
return;
|
||||
}
|
||||
boolean navigating = npc.getNavigator().isNavigating();
|
||||
if (!navigating && getBukkitEntity() != null
|
||||
&& (npc.hasTrait(Gravity.class) && npc.getTrait(Gravity.class).hasGravity())
|
||||
&& Util.isLoaded(getBukkitEntity().getLocation(LOADED_LOCATION))) {
|
||||
g(0, 0);
|
||||
}
|
||||
if (Math.abs(motX) < EPSILON && Math.abs(motY) < EPSILON && Math.abs(motZ) < EPSILON) {
|
||||
motX = motY = motZ = 0;
|
||||
}
|
||||
if (navigating) {
|
||||
if (!NMSImpl.isNavigationFinished(navigation)) {
|
||||
NMSImpl.updateNavigation(navigation);
|
||||
}
|
||||
moveOnCurrentHeading();
|
||||
}
|
||||
NMSImpl.updateAI(this);
|
||||
this.aD = this.aE;
|
||||
this.aK = this.aL;
|
||||
if (this.hurtTicks > 0) {
|
||||
@ -311,20 +327,6 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
||||
|
||||
boolean navigating = npc.getNavigator().isNavigating();
|
||||
updatePackets(navigating);
|
||||
if (!navigating && getBukkitEntity() != null && npc.getTrait(Gravity.class).hasGravity()
|
||||
&& Util.isLoaded(getBukkitEntity().getLocation(LOADED_LOCATION))) {
|
||||
g(0, 0);
|
||||
}
|
||||
if (Math.abs(motX) < EPSILON && Math.abs(motY) < EPSILON && Math.abs(motZ) < EPSILON) {
|
||||
motX = motY = motZ = 0;
|
||||
}
|
||||
if (navigating) {
|
||||
if (!NMSImpl.isNavigationFinished(navigation)) {
|
||||
NMSImpl.updateNavigation(navigation);
|
||||
}
|
||||
moveOnCurrentHeading();
|
||||
}
|
||||
NMSImpl.updateAI(this);
|
||||
|
||||
if (noDamageTicks > 0) {
|
||||
--noDamageTicks;
|
||||
|
@ -125,20 +125,6 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
||||
|
||||
boolean navigating = npc.getNavigator().isNavigating();
|
||||
updatePackets(navigating);
|
||||
if (!navigating && getBukkitEntity() != null && npc.getTrait(Gravity.class).hasGravity()
|
||||
&& Util.isLoaded(getBukkitEntity().getLocation(LOADED_LOCATION))) {
|
||||
g(0, 0);
|
||||
}
|
||||
if (Math.abs(motX) < EPSILON && Math.abs(motY) < EPSILON && Math.abs(motZ) < EPSILON) {
|
||||
motX = motY = motZ = 0;
|
||||
}
|
||||
if (navigating) {
|
||||
if (!NMSImpl.isNavigationFinished(navigation)) {
|
||||
NMSImpl.updateNavigation(navigation);
|
||||
}
|
||||
moveOnCurrentHeading();
|
||||
}
|
||||
NMSImpl.updateAI(this);
|
||||
|
||||
if (noDamageTicks > 0) {
|
||||
--noDamageTicks;
|
||||
@ -359,6 +345,22 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
||||
return;
|
||||
}
|
||||
cA();
|
||||
boolean navigating = npc.getNavigator().isNavigating();
|
||||
if (!navigating && getBukkitEntity() != null
|
||||
&& (npc.hasTrait(Gravity.class) && npc.getTrait(Gravity.class).hasGravity())
|
||||
&& Util.isLoaded(getBukkitEntity().getLocation(LOADED_LOCATION))) {
|
||||
g(0, 0);
|
||||
}
|
||||
if (Math.abs(motX) < EPSILON && Math.abs(motY) < EPSILON && Math.abs(motZ) < EPSILON) {
|
||||
motX = motY = motZ = 0;
|
||||
}
|
||||
if (navigating) {
|
||||
if (!NMSImpl.isNavigationFinished(navigation)) {
|
||||
NMSImpl.updateNavigation(navigation);
|
||||
}
|
||||
moveOnCurrentHeading();
|
||||
}
|
||||
NMSImpl.updateAI(this);
|
||||
this.aC = this.aD;
|
||||
this.aJ = this.aK;
|
||||
if (this.hurtTicks > 0) {
|
||||
|
@ -138,20 +138,6 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
||||
|
||||
boolean navigating = npc.getNavigator().isNavigating();
|
||||
updatePackets(navigating);
|
||||
if (!navigating && getBukkitEntity() != null && npc.getTrait(Gravity.class).hasGravity()
|
||||
&& Util.isLoaded(getBukkitEntity().getLocation(LOADED_LOCATION))) {
|
||||
a(0, 0, 0);
|
||||
}
|
||||
if (Math.abs(motX) < EPSILON && Math.abs(motY) < EPSILON && Math.abs(motZ) < EPSILON) {
|
||||
motX = motY = motZ = 0;
|
||||
}
|
||||
if (navigating) {
|
||||
if (!NMSImpl.isNavigationFinished(navigation)) {
|
||||
NMSImpl.updateNavigation(navigation);
|
||||
}
|
||||
moveOnCurrentHeading();
|
||||
}
|
||||
NMSImpl.updateAI(this);
|
||||
|
||||
if (noDamageTicks > 0) {
|
||||
--noDamageTicks;
|
||||
@ -386,6 +372,22 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
||||
return;
|
||||
}
|
||||
Y();
|
||||
boolean navigating = npc.getNavigator().isNavigating();
|
||||
if (!navigating && getBukkitEntity() != null
|
||||
&& (npc.hasTrait(Gravity.class) && npc.getTrait(Gravity.class).hasGravity())
|
||||
&& Util.isLoaded(getBukkitEntity().getLocation(LOADED_LOCATION))) {
|
||||
a(0, 0, 0);
|
||||
}
|
||||
if (Math.abs(motX) < EPSILON && Math.abs(motY) < EPSILON && Math.abs(motZ) < EPSILON) {
|
||||
motX = motY = motZ = 0;
|
||||
}
|
||||
if (navigating) {
|
||||
if (!NMSImpl.isNavigationFinished(navigation)) {
|
||||
NMSImpl.updateNavigation(navigation);
|
||||
}
|
||||
moveOnCurrentHeading();
|
||||
}
|
||||
NMSImpl.updateAI(this);
|
||||
this.aC = this.aD;
|
||||
this.aJ = this.aK;
|
||||
if (this.hurtTicks > 0) {
|
||||
|
@ -342,6 +342,22 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
||||
return;
|
||||
}
|
||||
W();
|
||||
boolean navigating = npc.getNavigator().isNavigating();
|
||||
if (!navigating && getBukkitEntity() != null
|
||||
&& (npc.hasTrait(Gravity.class) && npc.getTrait(Gravity.class).hasGravity())
|
||||
&& Util.isLoaded(getBukkitEntity().getLocation(LOADED_LOCATION))) {
|
||||
a(0, 0, 0);
|
||||
}
|
||||
if (Math.abs(motX) < EPSILON && Math.abs(motY) < EPSILON && Math.abs(motZ) < EPSILON) {
|
||||
motX = motY = motZ = 0;
|
||||
}
|
||||
if (navigating) {
|
||||
if (!NMSImpl.isNavigationFinished(navigation)) {
|
||||
NMSImpl.updateNavigation(navigation);
|
||||
}
|
||||
moveOnCurrentHeading();
|
||||
}
|
||||
NMSImpl.updateAI(this);
|
||||
this.aF = this.aG;
|
||||
this.aM = this.aN;
|
||||
if (this.hurtTicks > 0) {
|
||||
@ -409,20 +425,6 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
||||
|
||||
boolean navigating = npc.getNavigator().isNavigating();
|
||||
updatePackets(navigating);
|
||||
if (!navigating && getBukkitEntity() != null && npc.getTrait(Gravity.class).hasGravity()
|
||||
&& Util.isLoaded(getBukkitEntity().getLocation(LOADED_LOCATION))) {
|
||||
a(0, 0, 0);
|
||||
}
|
||||
if (Math.abs(motX) < EPSILON && Math.abs(motY) < EPSILON && Math.abs(motZ) < EPSILON) {
|
||||
motX = motY = motZ = 0;
|
||||
}
|
||||
if (navigating) {
|
||||
if (!NMSImpl.isNavigationFinished(navigation)) {
|
||||
NMSImpl.updateNavigation(navigation);
|
||||
}
|
||||
moveOnCurrentHeading();
|
||||
}
|
||||
NMSImpl.updateAI(this);
|
||||
|
||||
if (noDamageTicks > 0) {
|
||||
--noDamageTicks;
|
||||
|
@ -346,6 +346,23 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
||||
return;
|
||||
}
|
||||
entityBaseTick();
|
||||
boolean navigating = npc.getNavigator().isNavigating();
|
||||
if (!navigating && getBukkitEntity() != null
|
||||
&& (npc.hasTrait(Gravity.class) && npc.getTrait(Gravity.class).hasGravity())
|
||||
&& Util.isLoaded(getBukkitEntity().getLocation(LOADED_LOCATION))) {
|
||||
e(new Vec3D(0, 0, 0));
|
||||
}
|
||||
Vec3D mot = getMot();
|
||||
if (Math.abs(mot.getX()) < EPSILON && Math.abs(mot.getY()) < EPSILON && Math.abs(mot.getZ()) < EPSILON) {
|
||||
setMot(new Vec3D(0, 0, 0));
|
||||
}
|
||||
if (navigating) {
|
||||
if (!NMSImpl.isNavigationFinished(navigation)) {
|
||||
NMSImpl.updateNavigation(navigation);
|
||||
}
|
||||
moveOnCurrentHeading();
|
||||
}
|
||||
NMSImpl.updateAI(this);
|
||||
this.aB = this.aC;
|
||||
if (this.hurtTicks > 0) {
|
||||
this.hurtTicks -= 1;
|
||||
@ -412,21 +429,6 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
||||
|
||||
boolean navigating = npc.getNavigator().isNavigating();
|
||||
updatePackets(navigating);
|
||||
if (!navigating && getBukkitEntity() != null && npc.getTrait(Gravity.class).hasGravity()
|
||||
&& Util.isLoaded(getBukkitEntity().getLocation(LOADED_LOCATION))) {
|
||||
e(new Vec3D(0, 0, 0));
|
||||
}
|
||||
Vec3D mot = getMot();
|
||||
if (Math.abs(mot.getX()) < EPSILON && Math.abs(mot.getY()) < EPSILON && Math.abs(mot.getZ()) < EPSILON) {
|
||||
setMot(new Vec3D(0, 0, 0));
|
||||
}
|
||||
if (navigating) {
|
||||
if (!NMSImpl.isNavigationFinished(navigation)) {
|
||||
NMSImpl.updateNavigation(navigation);
|
||||
}
|
||||
moveOnCurrentHeading();
|
||||
}
|
||||
NMSImpl.updateAI(this);
|
||||
|
||||
if (noDamageTicks > 0) {
|
||||
--noDamageTicks;
|
||||
|
@ -346,6 +346,23 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
||||
return;
|
||||
}
|
||||
entityBaseTick();
|
||||
boolean navigating = npc.getNavigator().isNavigating();
|
||||
if (!navigating && getBukkitEntity() != null
|
||||
&& (npc.hasTrait(Gravity.class) && npc.getTrait(Gravity.class).hasGravity())
|
||||
&& Util.isLoaded(getBukkitEntity().getLocation(LOADED_LOCATION))) {
|
||||
e(new Vec3D(0, 0, 0));
|
||||
}
|
||||
Vec3D mot = getMot();
|
||||
if (Math.abs(mot.getX()) < EPSILON && Math.abs(mot.getY()) < EPSILON && Math.abs(mot.getZ()) < EPSILON) {
|
||||
setMot(new Vec3D(0, 0, 0));
|
||||
}
|
||||
if (navigating) {
|
||||
if (!NMSImpl.isNavigationFinished(navigation)) {
|
||||
NMSImpl.updateNavigation(navigation);
|
||||
}
|
||||
moveOnCurrentHeading();
|
||||
}
|
||||
NMSImpl.updateAI(this);
|
||||
|
||||
this.az = this.aA;
|
||||
if (this.hurtTicks > 0) {
|
||||
@ -413,21 +430,6 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
||||
|
||||
boolean navigating = npc.getNavigator().isNavigating();
|
||||
updatePackets(navigating);
|
||||
if (!navigating && getBukkitEntity() != null && npc.getTrait(Gravity.class).hasGravity()
|
||||
&& Util.isLoaded(getBukkitEntity().getLocation(LOADED_LOCATION))) {
|
||||
e(new Vec3D(0, 0, 0));
|
||||
}
|
||||
Vec3D mot = getMot();
|
||||
if (Math.abs(mot.getX()) < EPSILON && Math.abs(mot.getY()) < EPSILON && Math.abs(mot.getZ()) < EPSILON) {
|
||||
setMot(new Vec3D(0, 0, 0));
|
||||
}
|
||||
if (navigating) {
|
||||
if (!NMSImpl.isNavigationFinished(navigation)) {
|
||||
NMSImpl.updateNavigation(navigation);
|
||||
}
|
||||
moveOnCurrentHeading();
|
||||
}
|
||||
NMSImpl.updateAI(this);
|
||||
|
||||
if (noDamageTicks > 0) {
|
||||
--noDamageTicks;
|
||||
|
@ -377,6 +377,23 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
||||
return;
|
||||
}
|
||||
entityBaseTick();
|
||||
boolean navigating = npc.getNavigator().isNavigating();
|
||||
if (!navigating && getBukkitEntity() != null
|
||||
&& (npc.hasTrait(Gravity.class) && npc.getTrait(Gravity.class).hasGravity())
|
||||
&& Util.isLoaded(getBukkitEntity().getLocation(LOADED_LOCATION))) {
|
||||
f(new Vec3D(0, 0, 0));
|
||||
}
|
||||
Vec3D mot = getMot();
|
||||
if (Math.abs(mot.getX()) < EPSILON && Math.abs(mot.getY()) < EPSILON && Math.abs(mot.getZ()) < EPSILON) {
|
||||
setMot(new Vec3D(0, 0, 0));
|
||||
}
|
||||
if (navigating) {
|
||||
if (!NMSImpl.isNavigationFinished(navigation)) {
|
||||
NMSImpl.updateNavigation(navigation);
|
||||
}
|
||||
moveOnCurrentHeading();
|
||||
}
|
||||
NMSImpl.updateAI(this);
|
||||
|
||||
this.ay = this.az;
|
||||
if (this.hurtTicks > 0) {
|
||||
@ -444,21 +461,6 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
||||
|
||||
boolean navigating = npc.getNavigator().isNavigating();
|
||||
updatePackets(navigating);
|
||||
if (!navigating && getBukkitEntity() != null && npc.getTrait(Gravity.class).hasGravity()
|
||||
&& Util.isLoaded(getBukkitEntity().getLocation(LOADED_LOCATION))) {
|
||||
f(new Vec3D(0, 0, 0));
|
||||
}
|
||||
Vec3D mot = getMot();
|
||||
if (Math.abs(mot.getX()) < EPSILON && Math.abs(mot.getY()) < EPSILON && Math.abs(mot.getZ()) < EPSILON) {
|
||||
setMot(new Vec3D(0, 0, 0));
|
||||
}
|
||||
if (navigating) {
|
||||
if (!NMSImpl.isNavigationFinished(navigation)) {
|
||||
NMSImpl.updateNavigation(navigation);
|
||||
}
|
||||
moveOnCurrentHeading();
|
||||
}
|
||||
NMSImpl.updateAI(this);
|
||||
|
||||
if (noDamageTicks > 0) {
|
||||
--noDamageTicks;
|
||||
|
@ -881,7 +881,7 @@ public class NMSImpl implements NMSBridge {
|
||||
- (handle.getBukkitEntity().getType() == EntityType.PHANTOM ? 45 : 90);
|
||||
if (zDiff < 0.0)
|
||||
yaw += Math.abs(180 - yaw) * 2;
|
||||
if (handle instanceof EntityEnderDragon) {
|
||||
if (handle.getBukkitEntity().getType() == EntityType.ENDER_DRAGON) {
|
||||
yaw = getDragonYaw(handle, to.getX(), to.getZ());
|
||||
} else {
|
||||
yaw = yaw - 90;
|
||||
|
@ -290,6 +290,22 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
||||
super.l();
|
||||
return;
|
||||
}
|
||||
boolean navigating = npc.getNavigator().isNavigating();
|
||||
if (!navigating && getBukkitEntity() != null
|
||||
&& (npc.hasTrait(Gravity.class) && npc.getTrait(Gravity.class).hasGravity())
|
||||
&& Util.isLoaded(getBukkitEntity().getLocation(LOADED_LOCATION))) {
|
||||
g(0, 0);
|
||||
}
|
||||
if (Math.abs(motX) < EPSILON && Math.abs(motY) < EPSILON && Math.abs(motZ) < EPSILON) {
|
||||
motX = motY = motZ = 0;
|
||||
}
|
||||
if (navigating) {
|
||||
if (!NMSImpl.isNavigationFinished(navigation)) {
|
||||
NMSImpl.updateNavigation(navigation);
|
||||
}
|
||||
moveOnCurrentHeading();
|
||||
}
|
||||
NMSImpl.updateAI(this);
|
||||
if (!this.world.isClientSide) {
|
||||
b(0, this.fireTicks > 0);
|
||||
}
|
||||
@ -379,20 +395,6 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
||||
|
||||
boolean navigating = npc.getNavigator().isNavigating();
|
||||
updatePackets(navigating);
|
||||
if (!navigating && getBukkitEntity() != null && npc.getTrait(Gravity.class).hasGravity()
|
||||
&& Util.isLoaded(getBukkitEntity().getLocation(LOADED_LOCATION))) {
|
||||
g(0, 0);
|
||||
}
|
||||
if (Math.abs(motX) < EPSILON && Math.abs(motY) < EPSILON && Math.abs(motZ) < EPSILON) {
|
||||
motX = motY = motZ = 0;
|
||||
}
|
||||
if (navigating) {
|
||||
if (!NMSImpl.isNavigationFinished(navigation)) {
|
||||
NMSImpl.updateNavigation(navigation);
|
||||
}
|
||||
moveOnCurrentHeading();
|
||||
}
|
||||
NMSImpl.updateAI(this);
|
||||
|
||||
if (noDamageTicks > 0) {
|
||||
--noDamageTicks;
|
||||
|
Loading…
Reference in New Issue
Block a user