use of net.minecraft.server.v1_16_R2.BlockPosition in project Citizens2 by CitizensDev.
the class PlayerPathfinderNormal method a.
@Override
public PathType a(IBlockAccess paramIBlockAccess, int paramInt1, int paramInt2, int paramInt3, EntityHumanNPC paramEntityInsentient, int paramInt4, int paramInt5, int paramInt6, boolean paramBoolean1, boolean paramBoolean2) {
EnumSet<PathType> localEnumSet = EnumSet.noneOf(PathType.class);
PathType localObject1 = PathType.BLOCKED;
BlockPosition localBlockPosition = new BlockPosition(paramEntityInsentient);
for (int i = 0; i < paramInt4; i++) {
for (int k = 0; k < paramInt5; k++) {
for (int m = 0; m < paramInt6; m++) {
int n = i + paramInt1;
int i1 = k + paramInt2;
int i2 = m + paramInt3;
PathType localPathType2 = a(paramIBlockAccess, n, i1, i2);
if ((localPathType2 == PathType.DOOR_WOOD_CLOSED) && (paramBoolean1) && (paramBoolean2)) {
localPathType2 = PathType.WALKABLE;
}
if ((localPathType2 == PathType.DOOR_OPEN) && (!paramBoolean2)) {
localPathType2 = PathType.BLOCKED;
}
if ((localPathType2 == PathType.RAIL) && (!(paramIBlockAccess.getType(localBlockPosition).getBlock() instanceof BlockMinecartTrackAbstract)) && (!(paramIBlockAccess.getType(localBlockPosition.down()).getBlock() instanceof BlockMinecartTrackAbstract))) {
localPathType2 = PathType.FENCE;
}
if ((i == 0) && (k == 0) && (m == 0)) {
localObject1 = localPathType2;
}
localEnumSet.add(localPathType2);
}
}
}
if (localEnumSet.contains(PathType.FENCE)) {
return PathType.FENCE;
}
PathType localObject2 = PathType.BLOCKED;
for (PathType localPathType1 : localEnumSet) {
if (paramEntityInsentient.a(localPathType1) < 0.0F) {
return localPathType1;
}
if (paramEntityInsentient.a(localPathType1) >= paramEntityInsentient.a(localObject2)) {
localObject2 = localPathType1;
}
}
if ((localObject1 == PathType.OPEN) && (paramEntityInsentient.a(localObject2) == 0.0F)) {
return PathType.OPEN;
}
return localObject2;
}
use of net.minecraft.server.v1_16_R2.BlockPosition in project Citizens2 by CitizensDev.
the class PlayerPathfinderNormal method a.
private PathPoint a(int paramInt1, int paramInt2, int paramInt3, int paramInt4, double paramDouble, EnumDirection paramEnumDirection) {
PathPoint localPathPoint = null;
BlockPosition localBlockPosition1 = new BlockPosition(paramInt1, paramInt2, paramInt3);
BlockPosition localBlockPosition2 = localBlockPosition1.down();
double d1 = paramInt2 - (1.0D - this.a.getType(localBlockPosition2).d(this.a, localBlockPosition2).e);
if (d1 - paramDouble > 1.125D) {
return null;
}
PathType localPathType1 = a(this.b, paramInt1, paramInt2, paramInt3);
float f = this.b.a(localPathType1);
double d2 = this.b.width / 2.0D;
if (f >= 0.0F) {
localPathPoint = a(paramInt1, paramInt2, paramInt3);
localPathPoint.m = localPathType1;
localPathPoint.l = Math.max(localPathPoint.l, f);
}
if (localPathType1 == PathType.WALKABLE) {
return localPathPoint;
}
if ((localPathPoint == null) && (paramInt4 > 0) && (localPathType1 != PathType.FENCE) && (localPathType1 != PathType.TRAPDOOR)) {
localPathPoint = a(paramInt1, paramInt2 + 1, paramInt3, paramInt4 - 1, paramDouble, paramEnumDirection);
if ((localPathPoint != null) && ((localPathPoint.m == PathType.OPEN) || (localPathPoint.m == PathType.WALKABLE)) && (this.b.width < 1.0F)) {
double d3 = paramInt1 - paramEnumDirection.getAdjacentX() + 0.5D;
double d4 = paramInt3 - paramEnumDirection.getAdjacentZ() + 0.5D;
AxisAlignedBB localAxisAlignedBB1 = new AxisAlignedBB(d3 - d2, paramInt2 + 0.001D, d4 - d2, d3 + d2, paramInt2 + this.b.length, d4 + d2);
AxisAlignedBB localAxisAlignedBB2 = this.a.getType(localBlockPosition1).d(this.a, localBlockPosition1);
AxisAlignedBB localAxisAlignedBB3 = localAxisAlignedBB1.b(0.0D, localAxisAlignedBB2.e - 0.002D, 0.0D);
if (this.b.world.b(localAxisAlignedBB3)) {
localPathPoint = null;
}
}
}
if (localPathType1 == PathType.OPEN) {
AxisAlignedBB localAxisAlignedBB4 = new AxisAlignedBB(paramInt1 - d2 + 0.5D, paramInt2 + 0.001D, paramInt3 - d2 + 0.5D, paramInt1 + d2 + 0.5D, paramInt2 + this.b.length, paramInt3 + d2 + 0.5D);
if (this.b.world.b(localAxisAlignedBB4)) {
return null;
}
if (this.b.width >= 1.0F) {
PathType localPathType2 = a(this.b, paramInt1, paramInt2 - 1, paramInt3);
if (localPathType2 == PathType.BLOCKED) {
localPathPoint = a(paramInt1, paramInt2, paramInt3);
localPathPoint.m = PathType.WALKABLE;
localPathPoint.l = Math.max(localPathPoint.l, f);
return localPathPoint;
}
}
int i = 0;
while ((paramInt2 > 0) && (localPathType1 == PathType.OPEN)) {
paramInt2--;
if (i++ >= Setting.MC_NAVIGATION_MAX_FALL_DISTANCE.asInt()) {
return null;
}
localPathType1 = a(this.b, paramInt1, paramInt2, paramInt3);
f = this.b.a(localPathType1);
if ((localPathType1 != PathType.OPEN) && (f >= 0.0F)) {
localPathPoint = a(paramInt1, paramInt2, paramInt3);
localPathPoint.m = localPathType1;
localPathPoint.l = Math.max(localPathPoint.l, f);
} else if (f < 0.0F) {
return null;
}
}
}
return localPathPoint;
}
use of net.minecraft.server.v1_16_R2.BlockPosition in project Citizens2 by CitizensDev.
the class ItemFrameController method createEntity.
@Override
protected Entity createEntity(Location at, NPC npc) {
Entity e = super.createEntity(at, npc);
EntityItemFrame item = (EntityItemFrame) ((CraftEntity) e).getHandle();
item.setDirection(EnumDirection.EAST);
item.blockPosition = new BlockPosition(at.getX(), at.getY(), at.getZ());
return e;
}
use of net.minecraft.server.v1_16_R2.BlockPosition in project Citizens2 by CitizensDev.
the class NMSImpl method flyingMoveLogic.
public static void flyingMoveLogic(EntityLiving entity, Vec3D vec3d) {
double d0;
float f;
if (entity.df() || entity.ca()) {
d0 = 0.08D;
boolean flag = entity.getMot().y <= 0.0D;
if (flag && entity.hasEffect(MobEffects.SLOW_FALLING)) {
d0 = 0.01D;
entity.fallDistance = 0.0F;
}
double d1;
float f1;
double d2;
Vec3D vec3d5;
Vec3D vec3d2;
if (!entity.isInWater() || entity instanceof EntityHuman && ((EntityHuman) entity).abilities.isFlying) {
Vec3D vec3d4;
if (entity.aD() && (!(entity instanceof EntityHuman) || !((EntityHuman) entity).abilities.isFlying)) {
d1 = entity.locY;
entity.a(0.02F, vec3d);
entity.move(EnumMoveType.SELF, entity.getMot());
entity.setMot(entity.getMot().a(0.5D));
if (!entity.isNoGravity()) {
entity.setMot(entity.getMot().add(0.0D, -d0 / 4.0D, 0.0D));
}
vec3d4 = entity.getMot();
if (entity.positionChanged && entity.d(vec3d4.x, vec3d4.y + 0.6000000238418579D - entity.locY + d1, vec3d4.z)) {
entity.setMot(vec3d4.x, 0.30000001192092896D, vec3d4.z);
}
} else if (entity.isGliding()) {
vec3d4 = entity.getMot();
if (vec3d4.y > -0.5D) {
entity.fallDistance = 1.0F;
}
vec3d5 = entity.getLookDirection();
f1 = entity.pitch * 0.017453292F;
double d3 = Math.sqrt(vec3d5.x * vec3d5.x + vec3d5.z * vec3d5.z);
double d4 = Math.sqrt(Entity.b(vec3d4));
d2 = vec3d5.f();
float f3 = MathHelper.cos(f1);
f3 = (float) ((double) f3 * (double) f3 * Math.min(1.0D, d2 / 0.4D));
vec3d4 = entity.getMot().add(0.0D, d0 * (-1.0D + f3 * 0.75D), 0.0D);
double d5;
if (vec3d4.y < 0.0D && d3 > 0.0D) {
d5 = vec3d4.y * -0.1D * f3;
vec3d4 = vec3d4.add(vec3d5.x * d5 / d3, d5, vec3d5.z * d5 / d3);
}
if (f1 < 0.0F && d3 > 0.0D) {
d5 = d4 * (-MathHelper.sin(f1)) * 0.04D;
vec3d4 = vec3d4.add(-vec3d5.x * d5 / d3, d5 * 3.2D, -vec3d5.z * d5 / d3);
}
if (d3 > 0.0D) {
vec3d4 = vec3d4.add((vec3d5.x / d3 * d4 - vec3d4.x) * 0.1D, 0.0D, (vec3d5.z / d3 * d4 - vec3d4.z) * 0.1D);
}
entity.setMot(vec3d4.d(0.9900000095367432D, 0.9800000190734863D, 0.9900000095367432D));
entity.move(EnumMoveType.SELF, entity.getMot());
if (entity.positionChanged && !entity.world.isClientSide) {
d5 = Math.sqrt(Entity.b(entity.getMot()));
double d6 = d4 - d5;
float f4 = (float) (d6 * 10.0D - 3.0D);
if (f4 > 0.0F) {
try {
entity.a((SoundEffect) ENTITY_GET_SOUND_FALL.invoke(entity, (int) f4), 1.0F, 1.0F);
} catch (Throwable e) {
e.printStackTrace();
}
entity.damageEntity(DamageSource.FLY_INTO_WALL, f4);
}
}
if (entity.onGround && !entity.world.isClientSide && entity.getFlag(7) && !CraftEventFactory.callToggleGlideEvent(entity, false).isCancelled()) {
entity.setFlag(7, false);
}
} else {
BlockPosition blockposition = new BlockPosition(entity.locX, entity.getBoundingBox().minY - 1.0D, entity.locZ);
float f5 = entity.world.getType(blockposition).getBlock().m();
f1 = entity.onGround ? f5 * 0.91F : 0.91F;
try {
entity.a((float) ENTITY_R.invoke(entity, f5), vec3d);
entity.setMot((Vec3D) ISCLIMBING_METHOD.invoke(entity, entity.getMot()));
} catch (Throwable e) {
e.printStackTrace();
}
entity.move(EnumMoveType.SELF, entity.getMot());
vec3d2 = entity.getMot();
try {
if ((entity.positionChanged || (boolean) JUMP_FIELD.invoke(entity)) && entity.isClimbing()) {
vec3d2 = new Vec3D(vec3d2.x, 0.2D, vec3d2.z);
}
} catch (Throwable e) {
e.printStackTrace();
}
double d7 = vec3d2.y;
if (entity.hasEffect(MobEffects.LEVITATION)) {
d7 += (0.05D * (entity.getEffect(MobEffects.LEVITATION).getAmplifier() + 1) - vec3d2.y) * 0.2D;
entity.fallDistance = 0.0F;
} else if (entity.world.isClientSide && !entity.world.isLoaded(blockposition)) {
if (entity.locY > 0.0D) {
d7 = -0.1D;
} else {
d7 = 0.0D;
}
} else if (!entity.isNoGravity()) {
d7 -= d0;
}
entity.setMot(vec3d2.x * f1, d7 * 0.9800000190734863D, vec3d2.z * f1);
}
} else {
d1 = entity.locY;
f1 = entity.isSprinting() ? 0.9F : entity instanceof EntityPolarBear ? 0.98F : 0.8F;
f = 0.02F;
float f2 = EnchantmentManager.e(entity);
if (f2 > 3.0F) {
f2 = 3.0F;
}
if (!entity.onGround) {
f2 *= 0.5F;
}
if (f2 > 0.0F) {
f1 += (0.54600006F - f1) * f2 / 3.0F;
f += (entity.db() - f) * f2 / 3.0F;
}
if (entity.hasEffect(MobEffects.DOLPHINS_GRACE)) {
f1 = 0.96F;
}
entity.a(f, vec3d);
entity.move(EnumMoveType.SELF, entity.getMot());
vec3d5 = entity.getMot();
if (entity.positionChanged && entity.isClimbing()) {
vec3d5 = new Vec3D(vec3d5.x, 0.2D, vec3d5.z);
}
entity.setMot(vec3d5.d(f1, 0.800000011920929D, f1));
if (!entity.isNoGravity() && !entity.isSprinting()) {
vec3d2 = entity.getMot();
if (flag && Math.abs(vec3d2.y - 0.005D) >= 0.003D && Math.abs(vec3d2.y - d0 / 16.0D) < 0.003D) {
d2 = -0.003D;
} else {
d2 = vec3d2.y - d0 / 16.0D;
}
entity.setMot(vec3d2.x, d2, vec3d2.z);
}
vec3d2 = entity.getMot();
if (entity.positionChanged && entity.d(vec3d2.x, vec3d2.y + 0.6000000238418579D - entity.locY + d1, vec3d2.z)) {
entity.setMot(vec3d2.x, 0.30000001192092896D, vec3d2.z);
}
}
}
entity.aE = entity.aF;
d0 = entity.locX - entity.lastX;
double d8 = entity.locZ - entity.lastZ;
double d9 = entity instanceof EntityBird ? entity.locY - entity.lastY : 0.0D;
f = MathHelper.sqrt(d0 * d0 + d9 * d9 + d8 * d8) * 4.0F;
if (f > 1.0F) {
f = 1.0F;
}
entity.aF += (f - entity.aF) * 0.4F;
entity.aG += entity.aF;
}
use of net.minecraft.server.v1_16_R2.BlockPosition in project Citizens2 by CitizensDev.
the class PlayerPathfinder method a.
public PathEntity a(IWorldReader var0, EntityHumanNPC var1, Set<BlockPosition> var2, float var3, int var4) {
this.a.a();
this.e.a(var0, var1);
PathPoint var5 = this.e.b();
Map var6 = var2.stream().collect(Collectors.toMap((var0x) -> {
return this.e.a((double) var0x.getX(), (double) var0x.getY(), (double) var0x.getZ());
}, Function.identity()));
PathEntity var7 = this.a(var5, var6, var3, var4);
this.e.a();
return var7;
}
Aggregations