use of net.minecraft.server.v1_9_R2.BlockPosition in project Citizens2 by CitizensDev.
the class NMSImpl method flyingMoveLogic.
public static void flyingMoveLogic(EntityLiving entity, float f, float f1) {
if (entity.bM()) {
if ((entity.V())) {
double d0 = entity.locY;
float f3 = 0.8F;
float f4 = 0.02F;
float f2 = EnchantmentManager.b(entity);
if (f2 > 3.0F) {
f2 = 3.0F;
}
if (!entity.onGround) {
f2 *= 0.5F;
}
if (f2 > 0.0F) {
f3 += (0.54600006F - f3) * f2 / 3.0F;
f4 += (entity.bI() * 1.0F - f4) * f2 / 3.0F;
}
entity.a(f, f1, f4);
entity.move(entity.motX, entity.motY, entity.motZ);
entity.motX *= f3;
entity.motY *= 0.800000011920929D;
entity.motZ *= f3;
entity.motY -= 0.02D;
if ((entity.positionChanged) && (entity.c(entity.motX, entity.motY + 0.6000000238418579D - entity.locY + d0, entity.motZ))) {
entity.motY = 0.30000001192092896D;
}
} else if ((entity.ab())) {
double d0 = entity.locY;
entity.a(f, f1, 0.02F);
entity.move(entity.motX, entity.motY, entity.motZ);
entity.motX *= 0.5D;
entity.motY *= 0.5D;
entity.motZ *= 0.5D;
entity.motY -= 0.02D;
if ((entity.positionChanged) && (entity.c(entity.motX, entity.motY + 0.6000000238418579D - entity.locY + d0, entity.motZ))) {
entity.motY = 0.30000001192092896D;
}
} else {
float f5 = 0.91F;
if (entity.onGround) {
f5 = entity.world.getType(new BlockPosition(MathHelper.floor(entity.locX), MathHelper.floor(entity.getBoundingBox().b) - 1, MathHelper.floor(entity.locZ))).getBlock().frictionFactor * 0.91F;
}
float f6 = 0.16277136F / (f5 * f5 * f5);
float f3;
if (entity.onGround) {
f3 = entity.bI() * f6;
} else {
f3 = entity.aM;
}
entity.a(f, f1, f3);
f5 = 0.91F;
if (entity.onGround) {
f5 = entity.world.getType(new BlockPosition(MathHelper.floor(entity.locX), MathHelper.floor(entity.getBoundingBox().b) - 1, MathHelper.floor(entity.locZ))).getBlock().frictionFactor * 0.91F;
}
if (entity.k_()) {
float f4 = 0.15F;
entity.motX = MathHelper.a(entity.motX, -f4, f4);
entity.motZ = MathHelper.a(entity.motZ, -f4, f4);
entity.fallDistance = 0.0F;
if (entity.motY < -0.15D) {
entity.motY = -0.15D;
}
boolean flag = (entity.isSneaking()) && ((entity instanceof EntityHuman));
if ((flag) && (entity.motY < 0.0D)) {
entity.motY = 0.0D;
}
}
entity.move(entity.motX, entity.motY, entity.motZ);
if ((entity.positionChanged) && (entity.k_())) {
entity.motY = 0.2D;
}
if ((entity.world.isClientSide) && ((!entity.world.isLoaded(new BlockPosition((int) entity.locX, 0, (int) entity.locZ))) || (!entity.world.getChunkAtWorldCoords(new BlockPosition((int) entity.locX, 0, (int) entity.locZ)).o()))) {
if (entity.locY > 0.0D) {
entity.motY = -0.1D;
} else {
entity.motY = 0.0D;
}
} else {
entity.motY -= 0.08D;
}
entity.motY *= 0.9800000190734863D;
entity.motX *= f5;
entity.motZ *= f5;
}
}
entity.aA = entity.aB;
double d0 = entity.locX - entity.lastX;
double d1 = entity.locZ - entity.lastZ;
float f2 = MathHelper.sqrt(d0 * d0 + d1 * d1) * 4.0F;
if (f2 > 1.0F) {
f2 = 1.0F;
}
entity.aB += (f2 - entity.aB) * 0.4F;
entity.aC += entity.aB;
}
use of net.minecraft.server.v1_9_R2.BlockPosition in project Citizens2 by CitizensDev.
the class PlayerNavigation method a.
@Override
public PathEntity a(BlockPosition paramBlockPosition) {
if (!b()) {
return null;
}
float f1 = i();
this.c.methodProfiler.a("pathfind");
BlockPosition localBlockPosition = new BlockPosition(this.b);
int k = (int) (f1 + 8.0F);
ChunkCache localChunkCache = new ChunkCache(this.c, localBlockPosition.a(-k, -k, -k), localBlockPosition.a(k, k, k), 0);
PathEntity localPathEntity = this.j.a(localChunkCache, this.b, paramBlockPosition, f1);
this.c.methodProfiler.b();
return localPathEntity;
}
use of net.minecraft.server.v1_9_R2.BlockPosition in project Citizens2 by CitizensDev.
the class PlayerNavigation method a.
private boolean a(int paramInt1, int paramInt2, int paramInt3, int paramInt4, int paramInt5, int paramInt6, Vec3D paramVec3D, double paramDouble1, double paramDouble2) {
int i = paramInt1 - paramInt4 / 2;
int j = paramInt3 - paramInt6 / 2;
if (!b(i, paramInt2, j, paramInt4, paramInt5, paramInt6, paramVec3D, paramDouble1, paramDouble2)) {
return false;
}
for (int k = i; k < i + paramInt4; k++) {
for (int m = j; m < j + paramInt6; m++) {
double d1 = k + 0.5D - paramVec3D.a;
double d2 = m + 0.5D - paramVec3D.c;
if (d1 * paramDouble1 + d2 * paramDouble2 >= 0.0D) {
Block localBlock = this.c.getType(new BlockPosition(k, paramInt2 - 1, m)).getBlock();
Material localMaterial = localBlock.getMaterial();
if (localMaterial == Material.AIR) {
return false;
}
if ((localMaterial == Material.WATER) && (!this.b.V())) {
return false;
}
if (localMaterial == Material.LAVA) {
return false;
}
}
}
}
return true;
}
use of net.minecraft.server.v1_9_R2.BlockPosition in project Citizens2 by CitizensDev.
the class PlayerNavigation method a.
@Override
public PathEntity a(BlockPosition paramBlockPosition) {
BlockPosition localBlockPosition;
if (this.b.getType(paramBlockPosition).getMaterial() == Material.AIR) {
localBlockPosition = paramBlockPosition.down();
while ((localBlockPosition.getY() > 0) && (this.b.getType(localBlockPosition).getMaterial() == Material.AIR)) {
localBlockPosition = localBlockPosition.down();
}
if (localBlockPosition.getY() > 0) {
return a2(localBlockPosition.up());
}
while ((localBlockPosition.getY() < this.b.getHeight()) && (this.b.getType(localBlockPosition).getMaterial() == Material.AIR)) {
localBlockPosition = localBlockPosition.up();
}
paramBlockPosition = localBlockPosition;
}
if (this.b.getType(paramBlockPosition).getMaterial().isBuildable()) {
localBlockPosition = paramBlockPosition.up();
while ((localBlockPosition.getY() < this.b.getHeight()) && (this.b.getType(localBlockPosition).getMaterial().isBuildable())) {
localBlockPosition = localBlockPosition.up();
}
return a2(localBlockPosition);
}
return a2(paramBlockPosition);
}
use of net.minecraft.server.v1_9_R2.BlockPosition in project Citizens2 by CitizensDev.
the class PlayerNavigation method l.
@Override
public void l() {
this.g += 1;
if (this.o) {
j();
}
if (n()) {
return;
}
if (b()) {
m();
} else if ((this.c != null) && (this.c.e() < this.c.d())) {
Vec3D localVec3D = c();
Vec3D localObject = this.c.a(this.a, this.c.e());
if ((localVec3D.y > localObject.y) && (!this.a.onGround) && (MathHelper.floor(localVec3D.x) == MathHelper.floor(localObject.x)) && (MathHelper.floor(localVec3D.z) == MathHelper.floor(localObject.z))) {
this.c.c(this.c.e() + 1);
}
}
if (n()) {
return;
}
Vec3D localVec3D = this.c.a(this.a);
if (localVec3D == null) {
return;
}
Object localObject = new BlockPosition(localVec3D).down();
AxisAlignedBB localAxisAlignedBB = this.b.getType((BlockPosition) localObject).d(this.b, (BlockPosition) localObject);
localVec3D = localVec3D.a(0.0D, 1.0D - localAxisAlignedBB.e, 0.0D);
this.a.getControllerMove().a(localVec3D.x, localVec3D.y, localVec3D.z, this.d);
}
Aggregations