Make portal teleportation adjustment math more accurate

Fixes GH-1295

Non-standard sized portals exacerbate a flaw in the vanilla
portal teleportation adjustment logic.
As a result, an entity can end up slightly inside of the surrounding
portal blocks. In vanilla, this issue is minor and you are adjusted out
as if it never happened. In CraftBukkit and derivatives, the
anti-suffocation behavior activates and players end up teleported on top
of their portals.

This improves the offset so as to keep the issue from ever occurring in
the first place.

Special thanks to CarpetMod who appears to have had this fixed for some
time, and has licensed their code such that we can use it as needed.
This commit is contained in:
Zach Brown
2018-07-31 20:13:40 -05:00
parent fdb8141a2b
commit 5d5faf3cc6
2 changed files with 183 additions and 0 deletions

View File

@@ -126,6 +126,70 @@ index a661789c1..785a1a218 100644
}
public Iterator<IBlockData> iterator() {
diff --git a/src/main/java/net/minecraft/server/EnumDirection.java b/src/main/java/net/minecraft/server/EnumDirection.java
index 188d49d82..854ad49b6 100644
--- a/src/main/java/net/minecraft/server/EnumDirection.java
+++ b/src/main/java/net/minecraft/server/EnumDirection.java
@@ -0,0 +0,0 @@ public enum EnumDirection implements INamable {
return Iterators.forArray(this.c);
}
- public boolean test(@Nullable Object object) {
+ public boolean test(@Nullable EnumDirection object) { // Paper - Decompile fix
return this.a((EnumDirection) object);
}
}
@@ -0,0 +0,0 @@ public enum EnumDirection implements INamable {
return d0;
}
- public boolean test(@Nullable Object object) {
- return super.a((EnumDirection) object);
- }
+ // Paper - Decompile fix
+ //public boolean test(@Nullable Object object) {
+ // return super.a((EnumDirection) object);
+ //}
},
Y("y") {
;
@@ -0,0 +0,0 @@ public enum EnumDirection implements INamable {
return d1;
}
- public boolean test(@Nullable Object object) {
- return super.a((EnumDirection) object);
- }
+ // Paper - Decompile fix
+ //public boolean test(@Nullable Object object) {
+ // return super.a((EnumDirection) object);
+ //}
},
Z("z") {
;
@@ -0,0 +0,0 @@ public enum EnumDirection implements INamable {
return d2;
}
- public boolean test(@Nullable Object object) {
- return super.a((EnumDirection) object);
- }
+ // Paper - Decompile fix
+ //public boolean test(@Nullable Object object) {
+ // return super.a((EnumDirection) object);
+ //}
};
private static final Map<String, EnumDirection.EnumAxis> d = (Map) Arrays.stream(values()).collect(Collectors.toMap(EnumDirection.EnumAxis::a, (enumdirection_enumaxis) -> {
@@ -0,0 +0,0 @@ public enum EnumDirection implements INamable {
public abstract double a(double d0, double d1, double d2);
- public boolean test(@Nullable Object object) {
+ public boolean test(@Nullable EnumDirection object) { // Paper - Decompile fix
return this.a((EnumDirection) object);
}
diff --git a/src/main/java/net/minecraft/server/LocaleLanguage.java b/src/main/java/net/minecraft/server/LocaleLanguage.java
index 8f06c5848..4361b2cee 100644
--- a/src/main/java/net/minecraft/server/LocaleLanguage.java
@@ -139,6 +203,19 @@ index 8f06c5848..4361b2cee 100644
}
this.e = SystemUtils.b();
diff --git a/src/main/java/net/minecraft/server/MathHelper.java b/src/main/java/net/minecraft/server/MathHelper.java
index 86585a13f..f52b9c6f0 100644
--- a/src/main/java/net/minecraft/server/MathHelper.java
+++ b/src/main/java/net/minecraft/server/MathHelper.java
@@ -0,0 +0,0 @@ import java.util.function.IntPredicate;
public class MathHelper {
public static final float a = c(2.0F);
- private static final float[] b = (float[]) SystemUtils.a((Object) (new float[65536]), (afloat) -> {
+ private static final float[] b = (float[]) SystemUtils.a((new float[65536]), (afloat) -> { // Paper - Decompile fix
for (int i = 0; i < afloat.length; ++i) {
afloat[i] = (float) Math.sin((double) i * 3.141592653589793D * 2.0D / 65536.0D);
}
diff --git a/src/main/java/net/minecraft/server/RegistryID.java b/src/main/java/net/minecraft/server/RegistryID.java
index 3b8f6ec16..bde5714dd 100644
--- a/src/main/java/net/minecraft/server/RegistryID.java
@@ -180,6 +257,19 @@ index 3b8f6ec16..bde5714dd 100644
this.e = 0;
this.f = 0;
diff --git a/src/main/java/net/minecraft/server/ShapeDetector.java b/src/main/java/net/minecraft/server/ShapeDetector.java
index 43596cb2d..3faf74a22 100644
--- a/src/main/java/net/minecraft/server/ShapeDetector.java
+++ b/src/main/java/net/minecraft/server/ShapeDetector.java
@@ -0,0 +0,0 @@ public class ShapeDetector {
return new ShapeDetectorBlock(this.a, blockposition, this.b);
}
- public Object load(Object object) throws Exception {
+ public ShapeDetectorBlock load(BlockPosition object) throws Exception { // Paper - Decompile fix
return this.a((BlockPosition) object);
}
}
diff --git a/src/main/java/net/minecraft/server/VoxelShape.java b/src/main/java/net/minecraft/server/VoxelShape.java
index 4b5463cca..53c9f2188 100644
--- a/src/main/java/net/minecraft/server/VoxelShape.java