Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-12-18 12:30:06 +01:00
Improve diff in EntityHanging
Dieser Commit ist enthalten in:
Ursprung
c98d61bfcd
Commit
6a5fc90285
@ -13,92 +13,77 @@
|
|||||||
public abstract class EntityHanging extends Entity {
|
public abstract class EntityHanging extends Entity {
|
||||||
|
|
||||||
protected static final Predicate<Entity> b = (entity) -> {
|
protected static final Predicate<Entity> b = (entity) -> {
|
||||||
@@ -35,43 +41,52 @@
|
@@ -37,28 +43,39 @@
|
||||||
this.updateBoundingBox();
|
|
||||||
}
|
|
||||||
|
|
||||||
- protected void updateBoundingBox() {
|
protected void updateBoundingBox() {
|
||||||
- if (this.direction != null) {
|
if (this.direction != null) {
|
||||||
- double d0 = (double) this.blockPosition.getX() + 0.5D;
|
- double d0 = (double) this.blockPosition.getX() + 0.5D;
|
||||||
- double d1 = (double) this.blockPosition.getY() + 0.5D;
|
- double d1 = (double) this.blockPosition.getY() + 0.5D;
|
||||||
- double d2 = (double) this.blockPosition.getZ() + 0.5D;
|
- double d2 = (double) this.blockPosition.getZ() + 0.5D;
|
||||||
- double d3 = 0.46875D;
|
+ // CraftBukkit start code moved in to calculateBoundingBox
|
||||||
|
+ this.a(calculateBoundingBox(this, this.blockPosition, this.direction, this.getHangingWidth(), this.getHangingHeight()));
|
||||||
|
+ // CraftBukkit end
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ // CraftBukkit start - break out BB calc into own method
|
||||||
|
+ public static AxisAlignedBB calculateBoundingBox(@Nullable Entity entity, BlockPosition blockPosition, EnumDirection direction, int width, int height) {
|
||||||
|
+ {
|
||||||
|
+ double d0 = (double) blockPosition.getX() + 0.5D;
|
||||||
|
+ double d1 = (double) blockPosition.getY() + 0.5D;
|
||||||
|
+ double d2 = (double) blockPosition.getZ() + 0.5D;
|
||||||
|
double d3 = 0.46875D;
|
||||||
- double d4 = this.a(this.getHangingWidth());
|
- double d4 = this.a(this.getHangingWidth());
|
||||||
- double d5 = this.a(this.getHangingHeight());
|
- double d5 = this.a(this.getHangingHeight());
|
||||||
-
|
+ double d4 = a(width);
|
||||||
|
+ double d5 = a(height);
|
||||||
|
|
||||||
- d0 -= (double) this.direction.getAdjacentX() * 0.46875D;
|
- d0 -= (double) this.direction.getAdjacentX() * 0.46875D;
|
||||||
- d2 -= (double) this.direction.getAdjacentZ() * 0.46875D;
|
- d2 -= (double) this.direction.getAdjacentZ() * 0.46875D;
|
||||||
- d1 += d5;
|
+ d0 -= (double) direction.getAdjacentX() * 0.46875D;
|
||||||
|
+ d2 -= (double) direction.getAdjacentZ() * 0.46875D;
|
||||||
|
d1 += d5;
|
||||||
- EnumDirection enumdirection = this.direction.f();
|
- EnumDirection enumdirection = this.direction.f();
|
||||||
+ // CraftBukkit start - break out BB calc into own method
|
+ EnumDirection enumdirection = direction.f();
|
||||||
+ public static AxisAlignedBB calculateBoundingBox(Entity entity, BlockPosition blockPosition, EnumDirection direction, int width, int height) {
|
|
||||||
+ double d0 = (double) blockPosition.getX() + 0.5D;
|
|
||||||
+ double d1 = (double) blockPosition.getY() + 0.5D;
|
|
||||||
+ double d2 = (double) blockPosition.getZ() + 0.5D;
|
|
||||||
+ double d3 = 0.46875D;
|
|
||||||
+ double d4 = a(width);
|
|
||||||
+ double d5 = a(height);
|
|
||||||
+
|
|
||||||
+ d0 -= (double) direction.getAdjacentX() * 0.46875D;
|
|
||||||
+ d2 -= (double) direction.getAdjacentZ() * 0.46875D;
|
|
||||||
+ d1 += d5;
|
|
||||||
+ EnumDirection enumdirection = direction.f();
|
|
||||||
+
|
|
||||||
+ d0 += d4 * (double) enumdirection.getAdjacentX();
|
|
||||||
+ d2 += d4 * (double) enumdirection.getAdjacentZ();
|
|
||||||
+ if (entity != null) {
|
|
||||||
+ entity.locX = d0;
|
|
||||||
+ entity.locY = d1;
|
|
||||||
+ entity.locZ = d2;
|
|
||||||
+ }
|
|
||||||
+ double d6 = (double) width;
|
|
||||||
+ double d7 = (double) height;
|
|
||||||
+ double d8 = (double) width;
|
|
||||||
|
|
||||||
- d0 += d4 * (double) enumdirection.getAdjacentX();
|
d0 += d4 * (double) enumdirection.getAdjacentX();
|
||||||
- d2 += d4 * (double) enumdirection.getAdjacentZ();
|
d2 += d4 * (double) enumdirection.getAdjacentZ();
|
||||||
- this.locX = d0;
|
- this.locX = d0;
|
||||||
- this.locY = d1;
|
- this.locY = d1;
|
||||||
- this.locZ = d2;
|
- this.locZ = d2;
|
||||||
- double d6 = (double) this.getHangingWidth();
|
- double d6 = (double) this.getHangingWidth();
|
||||||
- double d7 = (double) this.getHangingHeight();
|
- double d7 = (double) this.getHangingHeight();
|
||||||
- double d8 = (double) this.getHangingWidth();
|
- double d8 = (double) this.getHangingWidth();
|
||||||
-
|
+ if (entity != null) {
|
||||||
- if (this.direction.k() == EnumDirection.EnumAxis.Z) {
|
+ entity.locX = d0;
|
||||||
- d8 = 1.0D;
|
+ entity.locY = d1;
|
||||||
- } else {
|
+ entity.locZ = d2;
|
||||||
- d6 = 1.0D;
|
+ }
|
||||||
- }
|
+ double d6 = (double) width;
|
||||||
+ if (direction.k() == EnumDirection.EnumAxis.Z) {
|
+ double d7 = (double) height;
|
||||||
+ d8 = 1.0D;
|
+ double d8 = (double) width;
|
||||||
+ } else {
|
|
||||||
+ d6 = 1.0D;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ d6 /= 32.0D;
|
|
||||||
+ d7 /= 32.0D;
|
|
||||||
+ d8 /= 32.0D;
|
|
||||||
+ return new AxisAlignedBB(d0 - d6, d1 - d7, d2 - d8, d0 + d6, d1 + d7, d2 + d8);
|
|
||||||
+ }
|
|
||||||
|
|
||||||
- d6 /= 32.0D;
|
- if (this.direction.k() == EnumDirection.EnumAxis.Z) {
|
||||||
- d7 /= 32.0D;
|
+ if (direction.k() == EnumDirection.EnumAxis.Z) {
|
||||||
- d8 /= 32.0D;
|
d8 = 1.0D;
|
||||||
|
} else {
|
||||||
|
d6 = 1.0D;
|
||||||
|
@@ -67,11 +84,12 @@
|
||||||
|
d6 /= 32.0D;
|
||||||
|
d7 /= 32.0D;
|
||||||
|
d8 /= 32.0D;
|
||||||
- this.a(new AxisAlignedBB(d0 - d6, d1 - d7, d2 - d8, d0 + d6, d1 + d7, d2 + d8));
|
- this.a(new AxisAlignedBB(d0 - d6, d1 - d7, d2 - d8, d0 + d6, d1 + d7, d2 + d8));
|
||||||
+ protected void updateBoundingBox() {
|
+ return new AxisAlignedBB(d0 - d6, d1 - d7, d2 - d8, d0 + d6, d1 + d7, d2 + d8);
|
||||||
+ if (this.direction != null) {
|
|
||||||
+ // CraftBukkit start code moved in to calculateBoundingBox
|
|
||||||
+ this.a(calculateBoundingBox(this, this.blockPosition, this.direction, this.getHangingWidth(), this.getHangingHeight()));
|
|
||||||
+ // CraftBukkit end
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
+ // CraftBukkit end
|
||||||
|
|
||||||
- private double a(int i) {
|
- private double a(int i) {
|
||||||
+ private static double a(int i) { // CraftBukkit - static
|
+ private static double a(int i) { // CraftBukkit - static
|
||||||
return i % 32 == 0 ? 0.5D : 0.0D;
|
return i % 32 == 0 ? 0.5D : 0.0D;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -83,6 +98,24 @@
|
@@ -83,6 +101,24 @@
|
||||||
if (this.e++ == 100 && !this.world.isClientSide) {
|
if (this.e++ == 100 && !this.world.isClientSide) {
|
||||||
this.e = 0;
|
this.e = 0;
|
||||||
if (!this.dead && !this.survives()) {
|
if (!this.dead && !this.survives()) {
|
||||||
@ -123,7 +108,7 @@
|
|||||||
this.die();
|
this.die();
|
||||||
this.a((Entity) null);
|
this.a((Entity) null);
|
||||||
}
|
}
|
||||||
@@ -139,6 +172,21 @@
|
@@ -139,6 +175,21 @@
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
if (!this.dead && !this.world.isClientSide) {
|
if (!this.dead && !this.world.isClientSide) {
|
||||||
@ -145,7 +130,7 @@
|
|||||||
this.die();
|
this.die();
|
||||||
this.velocityChanged();
|
this.velocityChanged();
|
||||||
this.a(damagesource.getEntity());
|
this.a(damagesource.getEntity());
|
||||||
@@ -151,6 +199,18 @@
|
@@ -151,6 +202,18 @@
|
||||||
@Override
|
@Override
|
||||||
public void move(EnumMoveType enummovetype, Vec3D vec3d) {
|
public void move(EnumMoveType enummovetype, Vec3D vec3d) {
|
||||||
if (!this.world.isClientSide && !this.dead && vec3d.g() > 0.0D) {
|
if (!this.world.isClientSide && !this.dead && vec3d.g() > 0.0D) {
|
||||||
@ -164,7 +149,7 @@
|
|||||||
this.die();
|
this.die();
|
||||||
this.a((Entity) null);
|
this.a((Entity) null);
|
||||||
}
|
}
|
||||||
@@ -159,7 +219,7 @@
|
@@ -159,7 +222,7 @@
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void f(double d0, double d1, double d2) {
|
public void f(double d0, double d1, double d2) {
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren