Add food ticking for players if /npc ai is enabled, update player pose and xp ticks
This commit is contained in:
parent
b6e6a66eb3
commit
4bfededf7a
|
@ -278,7 +278,13 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
||||||
}
|
}
|
||||||
updateAI();
|
updateAI();
|
||||||
cs();
|
cs();
|
||||||
|
if (npc.useMinecraftAI()) {
|
||||||
|
foodData.a(this);
|
||||||
|
}
|
||||||
if (npc.data().get(NPC.Metadata.PICKUP_ITEMS, false)) {
|
if (npc.data().get(NPC.Metadata.PICKUP_ITEMS, false)) {
|
||||||
|
if (this.bA > 0) {
|
||||||
|
--this.bA;
|
||||||
|
}
|
||||||
AxisAlignedBB axisalignedbb;
|
AxisAlignedBB axisalignedbb;
|
||||||
if (this.isPassenger() && !this.getVehicle().dead) {
|
if (this.isPassenger() && !this.getVehicle().dead) {
|
||||||
axisalignedbb = this.getBoundingBox().a(this.getVehicle().getBoundingBox()).grow(1.0, 0.0, 1.0);
|
axisalignedbb = this.getBoundingBox().a(this.getVehicle().getBoundingBox()).grow(1.0, 0.0, 1.0);
|
||||||
|
@ -291,6 +297,7 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
cJ();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -63,7 +63,6 @@ import net.minecraft.server.v1_11_R1.SoundEffect;
|
||||||
import net.minecraft.server.v1_11_R1.WorldServer;
|
import net.minecraft.server.v1_11_R1.WorldServer;
|
||||||
|
|
||||||
public class EntityHumanNPC extends EntityPlayer implements NPCHolder, SkinnableEntity {
|
public class EntityHumanNPC extends EntityPlayer implements NPCHolder, SkinnableEntity {
|
||||||
private final Map<PathType, Float> bz = Maps.newEnumMap(PathType.class);
|
|
||||||
private PlayerControllerJump controllerJump;
|
private PlayerControllerJump controllerJump;
|
||||||
private PlayerControllerMove controllerMove;
|
private PlayerControllerMove controllerMove;
|
||||||
private final Map<EnumItemSlot, ItemStack> equipmentCache = Maps.newEnumMap(EnumItemSlot.class);
|
private final Map<EnumItemSlot, ItemStack> equipmentCache = Maps.newEnumMap(EnumItemSlot.class);
|
||||||
|
@ -72,6 +71,7 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
||||||
private PlayerNavigation navigation;
|
private PlayerNavigation navigation;
|
||||||
private final CitizensNPC npc;
|
private final CitizensNPC npc;
|
||||||
private final Location packetLocationCache = new Location(null, 0, 0, 0);
|
private final Location packetLocationCache = new Location(null, 0, 0, 0);
|
||||||
|
private final Map<PathType, Float> pathtypes = Maps.newEnumMap(PathType.class);
|
||||||
private final SkinPacketTracker skinTracker;
|
private final SkinPacketTracker skinTracker;
|
||||||
|
|
||||||
public EntityHumanNPC(MinecraftServer minecraftServer, WorldServer world, GameProfile gameProfile,
|
public EntityHumanNPC(MinecraftServer minecraftServer, WorldServer world, GameProfile gameProfile,
|
||||||
|
@ -103,11 +103,11 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
||||||
}
|
}
|
||||||
|
|
||||||
public float a(PathType pathtype) {
|
public float a(PathType pathtype) {
|
||||||
return this.bz.containsKey(pathtype) ? this.bz.get(pathtype) : pathtype.a();
|
return this.pathtypes.containsKey(pathtype) ? this.pathtypes.get(pathtype) : pathtype.a();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void a(PathType pathtype, float f) {
|
public void a(PathType pathtype, float f) {
|
||||||
this.bz.put(pathtype, f);
|
this.pathtypes.put(pathtype, f);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -340,7 +340,13 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
||||||
}
|
}
|
||||||
updateAI();
|
updateAI();
|
||||||
ct();
|
ct();
|
||||||
|
if (npc.useMinecraftAI()) {
|
||||||
|
foodData.a(this);
|
||||||
|
}
|
||||||
if (npc.data().get(NPC.Metadata.PICKUP_ITEMS, false)) {
|
if (npc.data().get(NPC.Metadata.PICKUP_ITEMS, false)) {
|
||||||
|
if (this.bz > 0) {
|
||||||
|
--this.bz;
|
||||||
|
}
|
||||||
AxisAlignedBB axisalignedbb;
|
AxisAlignedBB axisalignedbb;
|
||||||
if (this.isPassenger() && !this.getVehicle().dead) {
|
if (this.isPassenger() && !this.getVehicle().dead) {
|
||||||
axisalignedbb = this.getBoundingBox().b(this.getVehicle().getBoundingBox()).grow(1.0, 0.0, 1.0);
|
axisalignedbb = this.getBoundingBox().b(this.getVehicle().getBoundingBox()).grow(1.0, 0.0, 1.0);
|
||||||
|
@ -353,6 +359,7 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
cL();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMoveDestination(double x, double y, double z, double speed) {
|
public void setMoveDestination(double x, double y, double z, double speed) {
|
||||||
|
|
|
@ -357,7 +357,13 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
||||||
}
|
}
|
||||||
updateAI();
|
updateAI();
|
||||||
cB();
|
cB();
|
||||||
|
if (npc.useMinecraftAI()) {
|
||||||
|
foodData.a(this);
|
||||||
|
}
|
||||||
if (npc.data().get(NPC.Metadata.PICKUP_ITEMS, false)) {
|
if (npc.data().get(NPC.Metadata.PICKUP_ITEMS, false)) {
|
||||||
|
if (this.bD > 0) {
|
||||||
|
--this.bD;
|
||||||
|
}
|
||||||
AxisAlignedBB axisalignedbb;
|
AxisAlignedBB axisalignedbb;
|
||||||
if (this.isPassenger() && !this.getVehicle().dead) {
|
if (this.isPassenger() && !this.getVehicle().dead) {
|
||||||
axisalignedbb = this.getBoundingBox().b(this.getVehicle().getBoundingBox()).grow(1.0, 0.0, 1.0);
|
axisalignedbb = this.getBoundingBox().b(this.getVehicle().getBoundingBox()).grow(1.0, 0.0, 1.0);
|
||||||
|
@ -370,6 +376,7 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
cT();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMoveDestination(double x, double y, double z, double speed) {
|
public void setMoveDestination(double x, double y, double z, double speed) {
|
||||||
|
|
|
@ -333,7 +333,13 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
||||||
}
|
}
|
||||||
updateAI();
|
updateAI();
|
||||||
cN();
|
cN();
|
||||||
|
if (npc.useMinecraftAI()) {
|
||||||
|
foodData.a(this);
|
||||||
|
}
|
||||||
if (npc.data().get(NPC.Metadata.PICKUP_ITEMS, false)) {
|
if (npc.data().get(NPC.Metadata.PICKUP_ITEMS, false)) {
|
||||||
|
if (this.bJ > 0) {
|
||||||
|
--this.bJ;
|
||||||
|
}
|
||||||
AxisAlignedBB axisalignedbb;
|
AxisAlignedBB axisalignedbb;
|
||||||
if (this.isPassenger() && !this.getVehicle().dead) {
|
if (this.isPassenger() && !this.getVehicle().dead) {
|
||||||
axisalignedbb = this.getBoundingBox().b(this.getVehicle().getBoundingBox()).grow(1.0, 0.0, 1.0);
|
axisalignedbb = this.getBoundingBox().b(this.getVehicle().getBoundingBox()).grow(1.0, 0.0, 1.0);
|
||||||
|
@ -346,6 +352,7 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
dh();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMoveDestination(double x, double y, double z, double speed) {
|
public void setMoveDestination(double x, double y, double z, double speed) {
|
||||||
|
|
|
@ -338,7 +338,13 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
||||||
}
|
}
|
||||||
updateAI();
|
updateAI();
|
||||||
collideNearby();
|
collideNearby();
|
||||||
|
if (npc.useMinecraftAI()) {
|
||||||
|
foodData.a(this);
|
||||||
|
}
|
||||||
if (npc.data().get(NPC.Metadata.PICKUP_ITEMS, false)) {
|
if (npc.data().get(NPC.Metadata.PICKUP_ITEMS, false)) {
|
||||||
|
if (this.bF > 0) {
|
||||||
|
--this.bF;
|
||||||
|
}
|
||||||
AxisAlignedBB axisalignedbb;
|
AxisAlignedBB axisalignedbb;
|
||||||
if (this.isPassenger() && !this.getVehicle().dead) {
|
if (this.isPassenger() && !this.getVehicle().dead) {
|
||||||
axisalignedbb = this.getBoundingBox().b(this.getVehicle().getBoundingBox()).grow(1.0, 0.0, 1.0);
|
axisalignedbb = this.getBoundingBox().b(this.getVehicle().getBoundingBox()).grow(1.0, 0.0, 1.0);
|
||||||
|
@ -351,6 +357,7 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
dB();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMoveDestination(double x, double y, double z, double speed) {
|
public void setMoveDestination(double x, double y, double z, double speed) {
|
||||||
|
|
|
@ -384,8 +384,13 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
||||||
boolean navigating = npc.getNavigator().isNavigating();
|
boolean navigating = npc.getNavigator().isNavigating();
|
||||||
updatePackets(navigating);
|
updatePackets(navigating);
|
||||||
npc.update();
|
npc.update();
|
||||||
|
if (npc.useMinecraftAI()) {
|
||||||
|
foodData.a(this);
|
||||||
|
}
|
||||||
if (npc.data().get(NPC.Metadata.PICKUP_ITEMS, false)) {
|
if (npc.data().get(NPC.Metadata.PICKUP_ITEMS, false)) {
|
||||||
|
if (this.bC > 0) {
|
||||||
|
--this.bC;
|
||||||
|
}
|
||||||
AxisAlignedBB axisalignedbb;
|
AxisAlignedBB axisalignedbb;
|
||||||
if (this.isPassenger() && !this.getVehicle().dead) {
|
if (this.isPassenger() && !this.getVehicle().dead) {
|
||||||
axisalignedbb = this.getBoundingBox().b(this.getVehicle().getBoundingBox()).grow(1.0, 0.0, 1.0);
|
axisalignedbb = this.getBoundingBox().b(this.getVehicle().getBoundingBox()).grow(1.0, 0.0, 1.0);
|
||||||
|
@ -398,6 +403,7 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
dX();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateAI() {
|
public void updateAI() {
|
||||||
|
|
|
@ -349,7 +349,13 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
||||||
boolean navigating = npc.getNavigator().isNavigating();
|
boolean navigating = npc.getNavigator().isNavigating();
|
||||||
updatePackets(navigating);
|
updatePackets(navigating);
|
||||||
npc.update();
|
npc.update();
|
||||||
|
if (npc.useMinecraftAI()) {
|
||||||
|
foodData.a(this);
|
||||||
|
}
|
||||||
if (npc.data().get(NPC.Metadata.PICKUP_ITEMS, false)) {
|
if (npc.data().get(NPC.Metadata.PICKUP_ITEMS, false)) {
|
||||||
|
if (this.bu > 0) {
|
||||||
|
--this.bu;
|
||||||
|
}
|
||||||
AxisAlignedBB axisalignedbb;
|
AxisAlignedBB axisalignedbb;
|
||||||
if (this.isPassenger() && !this.getVehicle().dead) {
|
if (this.isPassenger() && !this.getVehicle().dead) {
|
||||||
axisalignedbb = this.getBoundingBox().b(this.getVehicle().getBoundingBox()).grow(1.0, 0.0, 1.0);
|
axisalignedbb = this.getBoundingBox().b(this.getVehicle().getBoundingBox()).grow(1.0, 0.0, 1.0);
|
||||||
|
@ -362,16 +368,7 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
eu();
|
||||||
double diff = this.yaw - this.aK;
|
|
||||||
if (diff != 40 && diff != -40) {
|
|
||||||
++this.yawUpdateRequiredTicks;
|
|
||||||
}
|
|
||||||
if (this.yawUpdateRequiredTicks > 5) {
|
|
||||||
this.yaw = (diff > -40 && diff < 0) || (diff > 0 && diff > 40) ? this.aK - 40 : this.aK + 40;
|
|
||||||
this.yawUpdateRequiredTicks = 0;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updatePackets(boolean navigating) {
|
private void updatePackets(boolean navigating) {
|
||||||
|
|
|
@ -144,8 +144,13 @@ public class EntityHumanNPC extends ServerPlayer implements NPCHolder, Skinnable
|
||||||
this.onGround = false;
|
this.onGround = false;
|
||||||
}
|
}
|
||||||
pushEntities();
|
pushEntities();
|
||||||
|
if (npc.useMinecraftAI()) {
|
||||||
|
foodData.tick(this);
|
||||||
|
}
|
||||||
if (npc.data().get(NPC.Metadata.PICKUP_ITEMS, false)) {
|
if (npc.data().get(NPC.Metadata.PICKUP_ITEMS, false)) {
|
||||||
|
if (this.takeXpDelay > 0) {
|
||||||
|
--this.takeXpDelay;
|
||||||
|
}
|
||||||
AABB axisalignedbb;
|
AABB axisalignedbb;
|
||||||
if (this.isPassenger() && !this.getVehicle().isRemoved()) {
|
if (this.isPassenger() && !this.getVehicle().isRemoved()) {
|
||||||
axisalignedbb = this.getBoundingBox().minmax(this.getVehicle().getBoundingBox()).inflate(1.0, 0.0, 1.0);
|
axisalignedbb = this.getBoundingBox().minmax(this.getVehicle().getBoundingBox()).inflate(1.0, 0.0, 1.0);
|
||||||
|
@ -156,6 +161,7 @@ public class EntityHumanNPC extends ServerPlayer implements NPCHolder, Skinnable
|
||||||
entity.playerTouch(this);
|
entity.playerTouch(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
updatePlayerPose();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -145,8 +145,13 @@ public class EntityHumanNPC extends ServerPlayer implements NPCHolder, Skinnable
|
||||||
this.onGround = false;
|
this.onGround = false;
|
||||||
}
|
}
|
||||||
pushEntities();
|
pushEntities();
|
||||||
|
if (npc.useMinecraftAI()) {
|
||||||
|
foodData.tick(this);
|
||||||
|
}
|
||||||
if (npc.data().get(NPC.Metadata.PICKUP_ITEMS, false)) {
|
if (npc.data().get(NPC.Metadata.PICKUP_ITEMS, false)) {
|
||||||
|
if (this.takeXpDelay > 0) {
|
||||||
|
--this.takeXpDelay;
|
||||||
|
}
|
||||||
AABB axisalignedbb;
|
AABB axisalignedbb;
|
||||||
if (this.isPassenger() && !this.getVehicle().isRemoved()) {
|
if (this.isPassenger() && !this.getVehicle().isRemoved()) {
|
||||||
axisalignedbb = this.getBoundingBox().minmax(this.getVehicle().getBoundingBox()).inflate(1.0, 0.0, 1.0);
|
axisalignedbb = this.getBoundingBox().minmax(this.getVehicle().getBoundingBox()).inflate(1.0, 0.0, 1.0);
|
||||||
|
@ -157,6 +162,7 @@ public class EntityHumanNPC extends ServerPlayer implements NPCHolder, Skinnable
|
||||||
entity.playerTouch(this);
|
entity.playerTouch(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
updatePlayerPose();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -138,8 +138,13 @@ public class EntityHumanNPC extends ServerPlayer implements NPCHolder, Skinnable
|
||||||
this.onGround = false;
|
this.onGround = false;
|
||||||
}
|
}
|
||||||
pushEntities();
|
pushEntities();
|
||||||
|
if (npc.useMinecraftAI()) {
|
||||||
|
foodData.tick(this);
|
||||||
|
}
|
||||||
if (npc.data().get(NPC.Metadata.PICKUP_ITEMS, false)) {
|
if (npc.data().get(NPC.Metadata.PICKUP_ITEMS, false)) {
|
||||||
|
if (this.takeXpDelay > 0) {
|
||||||
|
--this.takeXpDelay;
|
||||||
|
}
|
||||||
AABB axisalignedbb;
|
AABB axisalignedbb;
|
||||||
if (this.isPassenger() && !this.getVehicle().isRemoved()) {
|
if (this.isPassenger() && !this.getVehicle().isRemoved()) {
|
||||||
axisalignedbb = this.getBoundingBox().minmax(this.getVehicle().getBoundingBox()).inflate(1.0, 0.0, 1.0);
|
axisalignedbb = this.getBoundingBox().minmax(this.getVehicle().getBoundingBox()).inflate(1.0, 0.0, 1.0);
|
||||||
|
@ -150,6 +155,7 @@ public class EntityHumanNPC extends ServerPlayer implements NPCHolder, Skinnable
|
||||||
entity.playerTouch(this);
|
entity.playerTouch(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
updatePlayerPose();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -141,8 +141,13 @@ public class EntityHumanNPC extends ServerPlayer implements NPCHolder, Skinnable
|
||||||
this.onGround = false;
|
this.onGround = false;
|
||||||
}
|
}
|
||||||
pushEntities();
|
pushEntities();
|
||||||
|
if (npc.useMinecraftAI()) {
|
||||||
|
foodData.tick(this);
|
||||||
|
}
|
||||||
if (npc.data().get(NPC.Metadata.PICKUP_ITEMS, false)) {
|
if (npc.data().get(NPC.Metadata.PICKUP_ITEMS, false)) {
|
||||||
|
if (this.takeXpDelay > 0) {
|
||||||
|
--this.takeXpDelay;
|
||||||
|
}
|
||||||
AABB axisalignedbb;
|
AABB axisalignedbb;
|
||||||
if (this.isPassenger() && !this.getVehicle().isRemoved()) {
|
if (this.isPassenger() && !this.getVehicle().isRemoved()) {
|
||||||
axisalignedbb = this.getBoundingBox().minmax(this.getVehicle().getBoundingBox()).inflate(1.0, 0.0, 1.0);
|
axisalignedbb = this.getBoundingBox().minmax(this.getVehicle().getBoundingBox()).inflate(1.0, 0.0, 1.0);
|
||||||
|
@ -153,6 +158,7 @@ public class EntityHumanNPC extends ServerPlayer implements NPCHolder, Skinnable
|
||||||
entity.playerTouch(this);
|
entity.playerTouch(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
updatePlayerPose();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -280,7 +280,13 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
||||||
}
|
}
|
||||||
updateAI();
|
updateAI();
|
||||||
bL();
|
bL();
|
||||||
|
if (npc.useMinecraftAI()) {
|
||||||
|
foodData.a(this);
|
||||||
|
}
|
||||||
if (npc.data().get(NPC.Metadata.PICKUP_ITEMS, false)) {
|
if (npc.data().get(NPC.Metadata.PICKUP_ITEMS, false)) {
|
||||||
|
if (this.bp > 0) {
|
||||||
|
--this.bp;
|
||||||
|
}
|
||||||
AxisAlignedBB axisalignedbb = null;
|
AxisAlignedBB axisalignedbb = null;
|
||||||
if (this.vehicle != null && !this.vehicle.dead) {
|
if (this.vehicle != null && !this.vehicle.dead) {
|
||||||
axisalignedbb = this.getBoundingBox().a(this.vehicle.getBoundingBox()).grow(1.0, 0.0, 1.0);
|
axisalignedbb = this.getBoundingBox().a(this.vehicle.getBoundingBox()).grow(1.0, 0.0, 1.0);
|
||||||
|
|
Loading…
Reference in New Issue