Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void move(EnumMoveType enummovetype, double d0, double d1, double d2) {
- SpigotTimings.entityMoveTimer.startTiming();
- if (this.noclip) {
- this.a(this.getBoundingBox().d(d0, d1, d2));
- this.recalcPosition();
- } else {
- try {
- this.checkBlockCollisions();
- } catch (Throwable var60) {
- CrashReport crashreport = CrashReport.a(var60, "Checking entity block collision");
- CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Entity being checked for collision");
- this.appendEntityCrashDetails(crashreportsystemdetails);
- throw new ReportedException(crashreport);
- }
- if (d0 == 0.0D && d1 == 0.0D && d2 == 0.0D && this.isVehicle() && this.isPassenger()) {
- return;
- }
- if (enummovetype == EnumMoveType.PISTON) {
- long i = this.world.getTime();
- if (i != this.aK) {
- Arrays.fill(this.aJ, 0.0D);
- this.aK = i;
- }
- double d3;
- int j;
- if (d0 != 0.0D) {
- j = EnumAxis.X.ordinal();
- d3 = MathHelper.a(d0 + this.aJ[j], -0.51D, 0.51D);
- d0 = d3 - this.aJ[j];
- this.aJ[j] = d3;
- if (Math.abs(d0) <= 9.999999747378752E-6D) {
- return;
- }
- } else if (d1 != 0.0D) {
- j = EnumAxis.Y.ordinal();
- d3 = MathHelper.a(d1 + this.aJ[j], -0.51D, 0.51D);
- d1 = d3 - this.aJ[j];
- this.aJ[j] = d3;
- if (Math.abs(d1) <= 9.999999747378752E-6D) {
- return;
- }
- } else {
- if (d2 == 0.0D) {
- return;
- }
- j = EnumAxis.Z.ordinal();
- d3 = MathHelper.a(d2 + this.aJ[j], -0.51D, 0.51D);
- d2 = d3 - this.aJ[j];
- this.aJ[j] = d3;
- if (Math.abs(d2) <= 9.999999747378752E-6D) {
- return;
- }
- }
- }
- this.world.methodProfiler.a("move");
- double d4 = this.locX;
- double d5 = this.locY;
- double d6 = this.locZ;
- if (this.E) {
- this.E = false;
- d0 *= 0.25D;
- d1 *= 0.05000000074505806D;
- d2 *= 0.25D;
- this.motX = 0.0D;
- this.motY = 0.0D;
- this.motZ = 0.0D;
- }
- double d7 = d0;
- double d8 = d1;
- double d9 = d2;
- if ((enummovetype == EnumMoveType.SELF || enummovetype == EnumMoveType.PLAYER) && this.onGround && this.isSneaking() && this instanceof EntityHuman) {
- for(; d0 != 0.0D && this.world.getCubes(this, this.getBoundingBox().d(d0, (double)(-this.P), 0.0D)).isEmpty(); d7 = d0) {
- if (d0 < 0.05D && d0 >= -0.05D) {
- d0 = 0.0D;
- } else if (d0 > 0.0D) {
- d0 -= 0.05D;
- } else {
- d0 += 0.05D;
- }
- }
- for(; d2 != 0.0D && this.world.getCubes(this, this.getBoundingBox().d(0.0D, (double)(-this.P), d2)).isEmpty(); d9 = d2) {
- if (d2 < 0.05D && d2 >= -0.05D) {
- d2 = 0.0D;
- } else if (d2 > 0.0D) {
- d2 -= 0.05D;
- } else {
- d2 += 0.05D;
- }
- }
- for(; d0 != 0.0D && d2 != 0.0D && this.world.getCubes(this, this.getBoundingBox().d(d0, (double)(-this.P), d2)).isEmpty(); d9 = d2) {
- if (d0 < 0.05D && d0 >= -0.05D) {
- d0 = 0.0D;
- } else if (d0 > 0.0D) {
- d0 -= 0.05D;
- } else {
- d0 += 0.05D;
- }
- d7 = d0;
- if (d2 < 0.05D && d2 >= -0.05D) {
- d2 = 0.0D;
- } else if (d2 > 0.0D) {
- d2 -= 0.05D;
- } else {
- d2 += 0.05D;
- }
- }
- }
- List list = this.world.getCubes(this, this.getBoundingBox().b(d0, d1, d2));
- AxisAlignedBB axisalignedbb = this.getBoundingBox();
- int k;
- int l;
- if (d1 != 0.0D) {
- k = 0;
- for(l = list.size(); k < l; ++k) {
- d1 = ((AxisAlignedBB)list.get(k)).b(this.getBoundingBox(), d1);
- }
- this.a(this.getBoundingBox().d(0.0D, d1, 0.0D));
- }
- if (d0 != 0.0D) {
- k = 0;
- for(l = list.size(); k < l; ++k) {
- d0 = ((AxisAlignedBB)list.get(k)).a(this.getBoundingBox(), d0);
- }
- if (d0 != 0.0D) {
- this.a(this.getBoundingBox().d(d0, 0.0D, 0.0D));
- }
- }
- if (d2 != 0.0D) {
- k = 0;
- for(l = list.size(); k < l; ++k) {
- d2 = ((AxisAlignedBB)list.get(k)).c(this.getBoundingBox(), d2);
- }
- if (d2 != 0.0D) {
- this.a(this.getBoundingBox().d(0.0D, 0.0D, d2));
- }
- }
- boolean flag = this.onGround || d1 != d1 && d1 < 0.0D;
- double d11;
- if (this.P > 0.0F && flag && (d7 != d0 || d9 != d2)) {
- double d12 = d0;
- double d13 = d1;
- double d14 = d2;
- AxisAlignedBB axisalignedbb1 = this.getBoundingBox();
- this.a(axisalignedbb);
- d1 = (double)this.P;
- List list1 = this.world.getCubes(this, this.getBoundingBox().b(d7, d1, d9));
- AxisAlignedBB axisalignedbb2 = this.getBoundingBox();
- AxisAlignedBB axisalignedbb3 = axisalignedbb2.b(d7, 0.0D, d9);
- d11 = d1;
- int i1 = 0;
- for(int j1 = list1.size(); i1 < j1; ++i1) {
- d11 = ((AxisAlignedBB)list1.get(i1)).b(axisalignedbb3, d11);
- }
- axisalignedbb2 = axisalignedbb2.d(0.0D, d11, 0.0D);
- double d15 = d7;
- int k1 = 0;
- for(int l1 = list1.size(); k1 < l1; ++k1) {
- d15 = ((AxisAlignedBB)list1.get(k1)).a(axisalignedbb2, d15);
- }
- axisalignedbb2 = axisalignedbb2.d(d15, 0.0D, 0.0D);
- double d16 = d9;
- int i2 = 0;
- for(int j2 = list1.size(); i2 < j2; ++i2) {
- d16 = ((AxisAlignedBB)list1.get(i2)).c(axisalignedbb2, d16);
- }
- axisalignedbb2 = axisalignedbb2.d(0.0D, 0.0D, d16);
- AxisAlignedBB axisalignedbb4 = this.getBoundingBox();
- double d17 = d1;
- int k2 = 0;
- for(int l2 = list1.size(); k2 < l2; ++k2) {
- d17 = ((AxisAlignedBB)list1.get(k2)).b(axisalignedbb4, d17);
- }
- axisalignedbb4 = axisalignedbb4.d(0.0D, d17, 0.0D);
- double d18 = d7;
- int i3 = 0;
- for(int j3 = list1.size(); i3 < j3; ++i3) {
- d18 = ((AxisAlignedBB)list1.get(i3)).a(axisalignedbb4, d18);
- }
- axisalignedbb4 = axisalignedbb4.d(d18, 0.0D, 0.0D);
- double d19 = d9;
- int k3 = 0;
- for(int l3 = list1.size(); k3 < l3; ++k3) {
- d19 = ((AxisAlignedBB)list1.get(k3)).c(axisalignedbb4, d19);
- }
- axisalignedbb4 = axisalignedbb4.d(0.0D, 0.0D, d19);
- double d20 = d15 * d15 + d16 * d16;
- double d21 = d18 * d18 + d19 * d19;
- if (d20 > d21) {
- d0 = d15;
- d2 = d16;
- d1 = -d11;
- this.a(axisalignedbb2);
- } else {
- d0 = d18;
- d2 = d19;
- d1 = -d17;
- this.a(axisalignedbb4);
- }
- int i4 = 0;
- for(int j4 = list1.size(); i4 < j4; ++i4) {
- d1 = ((AxisAlignedBB)list1.get(i4)).b(this.getBoundingBox(), d1);
- }
- this.a(this.getBoundingBox().d(0.0D, d1, 0.0D));
- if (d12 * d12 + d14 * d14 >= d0 * d0 + d2 * d2) {
- d0 = d12;
- d1 = d13;
- d2 = d14;
- this.a(axisalignedbb1);
- }
- }
- this.world.methodProfiler.b();
- this.world.methodProfiler.a("rest");
- this.recalcPosition();
- this.positionChanged = d7 != d0 || d9 != d2;
- this.B = d1 != d8;
- this.onGround = this.B && d8 < 0.0D;
- this.C = this.positionChanged || this.B;
- l = MathHelper.floor(this.locX);
- int k4 = MathHelper.floor(this.locY - 0.20000000298023224D);
- int l4 = MathHelper.floor(this.locZ);
- BlockPosition blockposition = new BlockPosition(l, k4, l4);
- IBlockData iblockdata = this.world.getType(blockposition);
- if (iblockdata.getMaterial() == Material.AIR) {
- BlockPosition blockposition1 = blockposition.down();
- IBlockData iblockdata1 = this.world.getType(blockposition1);
- net.minecraft.server.v1_12_R1.Block block = iblockdata1.getBlock();
- if (block instanceof BlockFence || block instanceof BlockCobbleWall || block instanceof BlockFenceGate) {
- iblockdata = iblockdata1;
- blockposition = blockposition1;
- }
- }
- this.a(d1, this.onGround, iblockdata, blockposition);
- if (d7 != d0) {
- this.motX = 0.0D;
- }
- if (d9 != d2) {
- this.motZ = 0.0D;
- }
- net.minecraft.server.v1_12_R1.Block block1 = iblockdata.getBlock();
- if (d8 != d1) {
- block1.a(this.world, this);
- }
- if (this.positionChanged && this.getBukkitEntity() instanceof Vehicle) {
- Vehicle vehicle = (Vehicle)this.getBukkitEntity();
- Block bl = this.world.getWorld().getBlockAt(MathHelper.floor(this.locX), MathHelper.floor(this.locY), MathHelper.floor(this.locZ));
- if (d7 > d0) {
- bl = bl.getRelative(BlockFace.EAST);
- } else if (d7 < d0) {
- bl = bl.getRelative(BlockFace.WEST);
- } else if (d9 > d2) {
- bl = bl.getRelative(BlockFace.SOUTH);
- } else if (d9 < d2) {
- bl = bl.getRelative(BlockFace.NORTH);
- }
- if (bl.getType() != org.bukkit.Material.AIR) {
- VehicleBlockCollisionEvent event = new VehicleBlockCollisionEvent(vehicle, bl);
- this.world.getServer().getPluginManager().callEvent(event);
- }
- }
- if (this.playStepSound() && (!this.onGround || !this.isSneaking() || !(this instanceof EntityHuman)) && !this.isPassenger()) {
- double d22 = this.locX - d4;
- double d23 = this.locY - d5;
- d11 = this.locZ - d6;
- if (block1 != Blocks.LADDER) {
- d23 = 0.0D;
- }
- if (block1 != null && this.onGround) {
- block1.stepOn(this.world, blockposition, this);
- }
- this.J = (float)((double)this.J + (double)MathHelper.sqrt(d22 * d22 + d11 * d11) * 0.6D);
- this.K = (float)((double)this.K + (double)MathHelper.sqrt(d22 * d22 + d23 * d23 + d11 * d11) * 0.6D);
- if (this.K > (float)this.ax && iblockdata.getMaterial() != Material.AIR) {
- this.ax = (int)this.K + 1;
- if (!this.isInWater()) {
- this.a(blockposition, block1);
- } else {
- Entity entity = this.isVehicle() && this.bE() != null ? this.bE() : this;
- float f = entity == this ? 0.35F : 0.4F;
- float f1 = MathHelper.sqrt(entity.motX * entity.motX * 0.20000000298023224D + entity.motY * entity.motY + entity.motZ * entity.motZ * 0.20000000298023224D) * f;
- if (f1 > 1.0F) {
- f1 = 1.0F;
- }
- this.a(this.ae(), f1, 1.0F + (this.random.nextFloat() - this.random.nextFloat()) * 0.4F);
- }
- } else if (this.K > this.ay && this.ah() && iblockdata.getMaterial() == Material.AIR) {
- this.ay = this.d(this.K);
- }
- }
- boolean flag1 = this.an();
- if (this.world.e(this.getBoundingBox().shrink(0.001D))) {
- this.burn(1.0F);
- if (!flag1) {
- ++this.fireTicks;
- if (this.fireTicks == 0) {
- EntityCombustEvent event = new EntityCombustByBlockEvent((Block)null, this.getBukkitEntity(), 8);
- this.world.getServer().getPluginManager().callEvent(event);
- if (!event.isCancelled()) {
- this.setOnFire(event.getDuration());
- }
- }
- }
- } else if (this.fireTicks <= 0) {
- this.fireTicks = -this.getMaxFireTicks();
- }
- if (flag1 && this.isBurning()) {
- this.a(SoundEffects.bW, 0.7F, 1.6F + (this.random.nextFloat() - this.random.nextFloat()) * 0.4F);
- this.fireTicks = -this.getMaxFireTicks();
- }
- this.world.methodProfiler.b();
- }
- SpigotTimings.entityMoveTimer.stopTiming();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement