mirror of
https://github.com/PaperMC/Folia.git
synced 2024-12-22 16:47:51 +01:00
Clear main supporting position on teleport
It becomes invalid switching dimensions or by moving far. If it used after teleporting, then it may also trip thread checks. Fixes https://github.com/PaperMC/Folia/issues/94
This commit is contained in:
parent
8a067cdbdd
commit
db2e6578f8
@ -15648,7 +15648,7 @@ index 18aac3da3c88f33b1a71a5920a8daa27e9723913..b126435b07572e7b8f41647a0179164b
|
|||||||
for (ServerPlayer player : ServerLevel.this.players) {
|
for (ServerPlayer player : ServerLevel.this.players) {
|
||||||
player.getBukkitEntity().onEntityRemove(entity);
|
player.getBukkitEntity().onEntityRemove(entity);
|
||||||
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||||
index 5fad40fa88f697108e42461c41012d5964ed7d75..ab8fb605bf35a3d74af5ede6fcde1461cac43edc 100644
|
index 5fad40fa88f697108e42461c41012d5964ed7d75..93330f077afb241763f186f9ecdf359e2907d027 100644
|
||||||
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||||
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||||
@@ -190,7 +190,7 @@ import org.bukkit.inventory.MainHand;
|
@@ -190,7 +190,7 @@ import org.bukkit.inventory.MainHand;
|
||||||
@ -15793,7 +15793,7 @@ index 5fad40fa88f697108e42461c41012d5964ed7d75..ab8fb605bf35a3d74af5ede6fcde1461
|
|||||||
return horizontalSpawnArea <= 16 ? horizontalSpawnArea - 1 : 17;
|
return horizontalSpawnArea <= 16 ? horizontalSpawnArea - 1 : 17;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1161,6 +1200,344 @@ public class ServerPlayer extends Player {
|
@@ -1161,6 +1200,345 @@ public class ServerPlayer extends Player {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -15985,6 +15985,7 @@ index 5fad40fa88f697108e42461c41012d5964ed7d75..ab8fb605bf35a3d74af5ede6fcde1461
|
|||||||
+ }
|
+ }
|
||||||
+ this.connection.internalTeleport(pos.x, pos.y, pos.z, this.getYRot(), this.getXRot(), java.util.Collections.emptySet());
|
+ this.connection.internalTeleport(pos.x, pos.y, pos.z, this.getYRot(), this.getXRot(), java.util.Collections.emptySet());
|
||||||
+ this.connection.resetPosition();
|
+ this.connection.resetPosition();
|
||||||
|
+ this.mainSupportingBlockPos = Optional.empty();
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ @Override
|
+ @Override
|
||||||
@ -16138,7 +16139,7 @@ index 5fad40fa88f697108e42461c41012d5964ed7d75..ab8fb605bf35a3d74af5ede6fcde1461
|
|||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public Entity changeDimension(ServerLevel destination) {
|
public Entity changeDimension(ServerLevel destination) {
|
||||||
@@ -1170,6 +1547,11 @@ public class ServerPlayer extends Player {
|
@@ -1170,6 +1548,11 @@ public class ServerPlayer extends Player {
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public Entity changeDimension(ServerLevel worldserver, PlayerTeleportEvent.TeleportCause cause) {
|
public Entity changeDimension(ServerLevel worldserver, PlayerTeleportEvent.TeleportCause cause) {
|
||||||
@ -16150,7 +16151,7 @@ index 5fad40fa88f697108e42461c41012d5964ed7d75..ab8fb605bf35a3d74af5ede6fcde1461
|
|||||||
// CraftBukkit end
|
// CraftBukkit end
|
||||||
if (this.isSleeping()) return this; // CraftBukkit - SPIGOT-3154
|
if (this.isSleeping()) return this; // CraftBukkit - SPIGOT-3154
|
||||||
// this.isChangingDimension = true; // CraftBukkit - Moved down and into PlayerList#changeDimension
|
// this.isChangingDimension = true; // CraftBukkit - Moved down and into PlayerList#changeDimension
|
||||||
@@ -2114,6 +2496,12 @@ public class ServerPlayer extends Player {
|
@@ -2114,6 +2497,12 @@ public class ServerPlayer extends Player {
|
||||||
public void setCamera(@Nullable Entity entity) {
|
public void setCamera(@Nullable Entity entity) {
|
||||||
Entity entity1 = this.getCamera();
|
Entity entity1 = this.getCamera();
|
||||||
|
|
||||||
@ -16163,7 +16164,7 @@ index 5fad40fa88f697108e42461c41012d5964ed7d75..ab8fb605bf35a3d74af5ede6fcde1461
|
|||||||
this.camera = (Entity) (entity == null ? this : entity);
|
this.camera = (Entity) (entity == null ? this : entity);
|
||||||
if (entity1 != this.camera) {
|
if (entity1 != this.camera) {
|
||||||
// Paper start - Add PlayerStartSpectatingEntityEvent and PlayerStopSpectatingEntity Event
|
// Paper start - Add PlayerStartSpectatingEntityEvent and PlayerStopSpectatingEntity Event
|
||||||
@@ -2307,7 +2695,7 @@ public class ServerPlayer extends Player {
|
@@ -2307,7 +2696,7 @@ public class ServerPlayer extends Player {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void untrackChunk(ChunkPos chunkPos) {
|
public void untrackChunk(ChunkPos chunkPos) {
|
||||||
@ -16172,7 +16173,7 @@ index 5fad40fa88f697108e42461c41012d5964ed7d75..ab8fb605bf35a3d74af5ede6fcde1461
|
|||||||
this.connection.send(new ClientboundForgetLevelChunkPacket(chunkPos.x, chunkPos.z));
|
this.connection.send(new ClientboundForgetLevelChunkPacket(chunkPos.x, chunkPos.z));
|
||||||
// Paper start
|
// Paper start
|
||||||
if(io.papermc.paper.event.packet.PlayerChunkUnloadEvent.getHandlerList().getRegisteredListeners().length > 0){
|
if(io.papermc.paper.event.packet.PlayerChunkUnloadEvent.getHandlerList().getRegisteredListeners().length > 0){
|
||||||
@@ -2626,7 +3014,7 @@ public class ServerPlayer extends Player {
|
@@ -2626,7 +3015,7 @@ public class ServerPlayer extends Player {
|
||||||
this.experienceLevel = this.newLevel;
|
this.experienceLevel = this.newLevel;
|
||||||
this.totalExperience = this.newTotalExp;
|
this.totalExperience = this.newTotalExp;
|
||||||
this.experienceProgress = 0;
|
this.experienceProgress = 0;
|
||||||
@ -17626,7 +17627,7 @@ index 25a5a3b949a0eb632611355e74ccd4865be108ca..1df8d601e41c2ab35921b6a1534fdec6
|
|||||||
|
|
||||||
itemstack = entityliving2.getMainHandItem();
|
itemstack = entityliving2.getMainHandItem();
|
||||||
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||||
index 92202262eff01ae3bbeff0e6ebdcf26ad613c169..131bf7600ee4a476fb387dea9e0bc85df384447b 100644
|
index 92202262eff01ae3bbeff0e6ebdcf26ad613c169..4e78647f1bba68741eeef08a85caf2d053436472 100644
|
||||||
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||||
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||||
@@ -166,7 +166,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
@@ -166,7 +166,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
||||||
@ -17809,7 +17810,7 @@ index 92202262eff01ae3bbeff0e6ebdcf26ad613c169..131bf7600ee4a476fb387dea9e0bc85d
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// CraftBukkit end
|
// CraftBukkit end
|
||||||
@@ -3506,6 +3532,763 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
@@ -3506,6 +3532,764 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
||||||
this.portalEntrancePos = original.portalEntrancePos;
|
this.portalEntrancePos = original.portalEntrancePos;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -18079,6 +18080,7 @@ index 92202262eff01ae3bbeff0e6ebdcf26ad613c169..131bf7600ee4a476fb387dea9e0bc85d
|
|||||||
+ this.setDeltaMovement(speedDirectionUpdate.normalize().scale(this.getDeltaMovement().length()));
|
+ this.setDeltaMovement(speedDirectionUpdate.normalize().scale(this.getDeltaMovement().length()));
|
||||||
+ }
|
+ }
|
||||||
+ this.moveTo(pos.x, pos.y, pos.z);
|
+ this.moveTo(pos.x, pos.y, pos.z);
|
||||||
|
+ this.mainSupportingBlockPos = Optional.empty();
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ protected void transform(Vec3 pos, Float yaw, Float pitch, Vec3 speedDirectionUpdate) {
|
+ protected void transform(Vec3 pos, Float yaw, Float pitch, Vec3 speedDirectionUpdate) {
|
||||||
@ -18205,7 +18207,7 @@ index 92202262eff01ae3bbeff0e6ebdcf26ad613c169..131bf7600ee4a476fb387dea9e0bc85d
|
|||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ public void postChangeDimension() {
|
+ public void postChangeDimension() {
|
||||||
+
|
+ this.mainSupportingBlockPos = Optional.empty();
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ protected static enum PortalType {
|
+ protected static enum PortalType {
|
||||||
@ -18573,7 +18575,7 @@ index 92202262eff01ae3bbeff0e6ebdcf26ad613c169..131bf7600ee4a476fb387dea9e0bc85d
|
|||||||
@Nullable
|
@Nullable
|
||||||
public Entity changeDimension(ServerLevel destination) {
|
public Entity changeDimension(ServerLevel destination) {
|
||||||
// CraftBukkit start
|
// CraftBukkit start
|
||||||
@@ -3514,6 +4297,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
@@ -3514,6 +4298,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public Entity teleportTo(ServerLevel worldserver, PositionImpl location) {
|
public Entity teleportTo(ServerLevel worldserver, PositionImpl location) {
|
||||||
@ -18585,7 +18587,7 @@ index 92202262eff01ae3bbeff0e6ebdcf26ad613c169..131bf7600ee4a476fb387dea9e0bc85d
|
|||||||
// CraftBukkit end
|
// CraftBukkit end
|
||||||
// Paper start - fix bad state entities causing dupes
|
// Paper start - fix bad state entities causing dupes
|
||||||
if (!this.isAlive() || !this.valid) {
|
if (!this.isAlive() || !this.valid) {
|
||||||
@@ -3597,6 +4385,12 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
@@ -3597,6 +4386,12 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -18598,7 +18600,7 @@ index 92202262eff01ae3bbeff0e6ebdcf26ad613c169..131bf7600ee4a476fb387dea9e0bc85d
|
|||||||
protected void removeAfterChangingDimensions() {
|
protected void removeAfterChangingDimensions() {
|
||||||
this.setRemoved(Entity.RemovalReason.CHANGED_DIMENSION);
|
this.setRemoved(Entity.RemovalReason.CHANGED_DIMENSION);
|
||||||
}
|
}
|
||||||
@@ -4041,17 +4835,13 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
@@ -4041,17 +4836,13 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
||||||
|
|
||||||
// Paper start
|
// Paper start
|
||||||
public void startSeenByPlayer(ServerPlayer player) {
|
public void startSeenByPlayer(ServerPlayer player) {
|
||||||
@ -18618,7 +18620,7 @@ index 92202262eff01ae3bbeff0e6ebdcf26ad613c169..131bf7600ee4a476fb387dea9e0bc85d
|
|||||||
}
|
}
|
||||||
// Paper end
|
// Paper end
|
||||||
|
|
||||||
@@ -4546,7 +5336,8 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
@@ -4546,7 +5337,8 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Paper end - fix MC-4
|
// Paper end - fix MC-4
|
||||||
@ -18628,7 +18630,7 @@ index 92202262eff01ae3bbeff0e6ebdcf26ad613c169..131bf7600ee4a476fb387dea9e0bc85d
|
|||||||
synchronized (this.posLock) { // Paper
|
synchronized (this.posLock) { // Paper
|
||||||
this.position = new Vec3(x, y, z);
|
this.position = new Vec3(x, y, z);
|
||||||
} // Paper
|
} // Paper
|
||||||
@@ -4567,7 +5358,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
@@ -4567,7 +5359,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
||||||
|
|
||||||
// Paper start - never allow AABB to become desynced from position
|
// Paper start - never allow AABB to become desynced from position
|
||||||
// hanging has its own special logic
|
// hanging has its own special logic
|
||||||
@ -18637,7 +18639,7 @@ index 92202262eff01ae3bbeff0e6ebdcf26ad613c169..131bf7600ee4a476fb387dea9e0bc85d
|
|||||||
this.setBoundingBox(this.makeBoundingBox());
|
this.setBoundingBox(this.makeBoundingBox());
|
||||||
}
|
}
|
||||||
// Paper end
|
// Paper end
|
||||||
@@ -4654,6 +5445,12 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
@@ -4654,6 +5446,12 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
||||||
return this.removalReason != null;
|
return this.removalReason != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -18650,7 +18652,7 @@ index 92202262eff01ae3bbeff0e6ebdcf26ad613c169..131bf7600ee4a476fb387dea9e0bc85d
|
|||||||
@Nullable
|
@Nullable
|
||||||
public Entity.RemovalReason getRemovalReason() {
|
public Entity.RemovalReason getRemovalReason() {
|
||||||
return this.removalReason;
|
return this.removalReason;
|
||||||
@@ -4678,7 +5475,23 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
@@ -4678,7 +5476,23 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
||||||
|
|
||||||
if (reason != RemovalReason.UNLOADED_TO_CHUNK) this.getPassengers().forEach(Entity::stopRiding); // Paper - chunk system - don't adjust passenger state when unloading, it's just not safe (and messes with our logic in entity chunk unload)
|
if (reason != RemovalReason.UNLOADED_TO_CHUNK) this.getPassengers().forEach(Entity::stopRiding); // Paper - chunk system - don't adjust passenger state when unloading, it's just not safe (and messes with our logic in entity chunk unload)
|
||||||
this.levelCallback.onRemove(reason);
|
this.levelCallback.onRemove(reason);
|
||||||
|
@ -51,7 +51,7 @@ index d9687722e02dfd4088c7030abbf5008eb0a092c8..62484ebf4550b05182f693a3180bbac5
|
|||||||
TickThread.ensureTickThread(thisEntity, "May not tick entity scheduler asynchronously");
|
TickThread.ensureTickThread(thisEntity, "May not tick entity scheduler asynchronously");
|
||||||
final List<ScheduledTask> toRun;
|
final List<ScheduledTask> toRun;
|
||||||
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||||
index 131bf7600ee4a476fb387dea9e0bc85df384447b..e8c2d4f647b01dfaebccd5a2fa330594bbbcb74f 100644
|
index 4e78647f1bba68741eeef08a85caf2d053436472..08a11d18c0f507ee91163b8693b2a1f8fd9856aa 100644
|
||||||
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||||
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||||
@@ -2889,6 +2889,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
@@ -2889,6 +2889,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
||||||
|
@ -9,7 +9,7 @@ data deserialization and is racey even in Vanilla. But in Folia,
|
|||||||
some accesses may throw and as such we need to fix this directly.
|
some accesses may throw and as such we need to fix this directly.
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||||
index ab8fb605bf35a3d74af5ede6fcde1461cac43edc..9fcf54ecd9703c6c5f2bf508d8e46d685166be6e 100644
|
index 93330f077afb241763f186f9ecdf359e2907d027..4387c65405096345b37cb204d1c305fdf9e1cecf 100644
|
||||||
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||||
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||||
@@ -571,7 +571,7 @@ public class ServerPlayer extends Player {
|
@@ -571,7 +571,7 @@ public class ServerPlayer extends Player {
|
||||||
|
Loading…
Reference in New Issue
Block a user