mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-11-22 18:45:29 +01:00
Implement metadata on examiner side, relax distance margin for minecraft movement
This commit is contained in:
parent
23c4779404
commit
c702e19828
@ -1,10 +1,13 @@
|
||||
package net.citizensnpcs.npc.ai;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import net.citizensnpcs.api.astar.pathfinder.BlockSource;
|
||||
import net.citizensnpcs.api.astar.pathfinder.MinecraftBlockExaminer;
|
||||
import net.citizensnpcs.api.astar.pathfinder.NeighbourGeneratorBlockExaminer;
|
||||
@ -12,6 +15,7 @@ import net.citizensnpcs.api.astar.pathfinder.PathPoint;
|
||||
import net.citizensnpcs.api.astar.pathfinder.VectorNode;
|
||||
|
||||
public class FallingExaminer implements NeighbourGeneratorBlockExaminer {
|
||||
private final Map<PathPoint, Integer> fallen = Maps.newHashMap();
|
||||
private final int maxFallDistance;
|
||||
|
||||
public FallingExaminer(int maxFallDistance) {
|
||||
@ -34,24 +38,23 @@ public class FallingExaminer implements NeighbourGeneratorBlockExaminer {
|
||||
Material below = source.getMaterialAt(pos.getBlockX(), pos.getBlockY() - 1, pos.getBlockZ());
|
||||
Material in = source.getMaterialAt(pos);
|
||||
if (!MinecraftBlockExaminer.canStandOn(below) && MinecraftBlockExaminer.canStandIn(above, in)) {
|
||||
if (!point.data().has("fallen")) {
|
||||
Integer dist = fallen.get(point);
|
||||
if (dist == null) {
|
||||
neighbours.add(point);
|
||||
point.data().set("fallen", 0);
|
||||
} else if (point.data().<Integer> get("fallen") < maxFallDistance) {
|
||||
point.data().set("fallen", point.data().get("fallen", 0) + 1);
|
||||
neighbours.add(point.createAtOffset(new Vector(0, -1, 0)));
|
||||
fallen.put(point, dist = 0);
|
||||
} else if (dist < maxFallDistance) {
|
||||
fallen.put(point, dist + 1);
|
||||
neighbours.add(point.createAtOffset(new Vector(pos.getBlockX(), pos.getBlockY() - 1, pos.getBlockZ())));
|
||||
}
|
||||
} else {
|
||||
if (point.data().has("fallen")) {
|
||||
point.data().remove("fallen");
|
||||
}
|
||||
fallen.remove(point);
|
||||
}
|
||||
return neighbours;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PassableState isPassable(BlockSource source, PathPoint point) {
|
||||
if (point.data().has("fallen")) {
|
||||
if (fallen.containsKey(point)) {
|
||||
return PassableState.PASSABLE;
|
||||
}
|
||||
return PassableState.IGNORE;
|
||||
|
@ -196,8 +196,9 @@ public class EntityHumanNPC extends ServerPlayer implements NPCHolder, Skinnable
|
||||
this.onGround = false;
|
||||
}
|
||||
|
||||
if (this.hurtTime > 0)
|
||||
if (this.hurtTime > 0) {
|
||||
this.hurtTime--;
|
||||
}
|
||||
|
||||
if (isDeadOrDying()) {
|
||||
tickDeath();
|
||||
@ -208,6 +209,7 @@ public class EntityHumanNPC extends ServerPlayer implements NPCHolder, Skinnable
|
||||
} else {
|
||||
this.lastHurtByPlayer = null;
|
||||
}
|
||||
|
||||
if (this.lastHurtByMob != null) {
|
||||
if (!this.lastHurtByMob.isAlive()) {
|
||||
setLastHurtByMob((LivingEntity) null);
|
||||
@ -215,6 +217,7 @@ public class EntityHumanNPC extends ServerPlayer implements NPCHolder, Skinnable
|
||||
setLastHurtByMob((LivingEntity) null);
|
||||
}
|
||||
}
|
||||
|
||||
tickEffects();
|
||||
this.animStepO = this.animStep;
|
||||
this.yBodyRotO = this.yBodyRot;
|
||||
|
@ -111,8 +111,8 @@ public class PlayerMoveControl extends MoveControl {
|
||||
double dZ = this.tz - this.entity.getZ();
|
||||
double dY = this.ty - this.entity.getY();
|
||||
double dXZ = dX * dX + dZ * dZ;
|
||||
if (dY * dY < 1.0 && dXZ < 0.0075) {
|
||||
this.entity.zza = 0.0F;
|
||||
if (dY * dY < 1.0 && dXZ < 0.01) {
|
||||
// this.entity.zza = 0.0F;
|
||||
return;
|
||||
}
|
||||
float f = (float) (Mth.atan2(dZ, dX) * 57.2957763671875D) - 90.0F;
|
||||
|
Loading…
Reference in New Issue
Block a user