Compare commits

...

2 commits

Author SHA1 Message Date
Shane Freeder
d7c28c9175
More stuff 2023-07-05 23:30:45 +01:00
Shane Freeder
154ba310ee
Reset mainSupportingBlockPos on teleports
I cannot test this due to lack of hardware (took 30 minutes getting paper
updated and loaded into IJ on this machine...), however, this appears to be
doing what the folia equiv patch is
2023-07-05 23:13:30 +01:00
3 changed files with 55 additions and 5 deletions

View file

@ -6641,7 +6641,7 @@ index 337e0a7b3c14e1b1a28744920e0dc0a69e0c5a87..f5829ae484d93b547a5437b85a962134
@Override
public void tell(R runnable) {
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index 29a373eb8f520cf0575e277fdf6e698d711a9ca7..db308228303cac3c42d44d119259d546e42f5e9e 100644
index 6b94211e45eff227277b5630292a855dd0254238..923b9243d97f9a741009f443d2c126b638fbb753 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -323,6 +323,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
@ -6927,14 +6927,15 @@ index bacd4d875642cd93c3185f788745dd73a3cfde8a..003e2064f64115d1f5c48ac97e16100d
return chunk.getBlockState(pos);
}
diff --git a/src/main/java/net/minecraft/world/level/LevelReader.java b/src/main/java/net/minecraft/world/level/LevelReader.java
index e6aabec35f4e27623d1fbbfb285cc78531137014..fe76ec5b10242beb6d6057bd680484fc63b7eac3 100644
index e6aabec35f4e27623d1fbbfb285cc78531137014..cc0d20e9f851268fe8403ac516f426ec1d008150 100644
--- a/src/main/java/net/minecraft/world/level/LevelReader.java
+++ b/src/main/java/net/minecraft/world/level/LevelReader.java
@@ -26,6 +26,8 @@ public interface LevelReader extends BlockAndTintGetter, CollisionGetter, Signal
@@ -26,6 +26,9 @@ public interface LevelReader extends BlockAndTintGetter, CollisionGetter, Signal
@Nullable
ChunkAccess getChunk(int chunkX, int chunkZ, ChunkStatus leastStatus, boolean create);
+ @Nullable ChunkAccess getChunkIfLoadedImmediately(int x, int z); // Paper - ifLoaded api (we need this since current impl blocks if the chunk is loading)
+ @Nullable default ChunkAccess getChunkIfLoadedImmediately(BlockPos pos) { return this.getChunkIfLoadedImmediately(pos.getX() >> 4, pos.getZ() >> 4);}
+
/** @deprecated */
@Deprecated

View file

@ -21199,7 +21199,7 @@ index d87f02c748fe2e5b4ea251f6691e8907a152cb6d..5988c0847af4e8f0094328e91f736f25
+ // Paper end
}
diff --git a/src/main/java/net/minecraft/world/level/LevelReader.java b/src/main/java/net/minecraft/world/level/LevelReader.java
index fe76ec5b10242beb6d6057bd680484fc63b7eac3..e3e2b88b8ade4fa2b482626c7e00ac6a0bf8eb5e 100644
index cc0d20e9f851268fe8403ac516f426ec1d008150..12eaafdbd324fa36b3f46c3b644bc8117a4123ad 100644
--- a/src/main/java/net/minecraft/world/level/LevelReader.java
+++ b/src/main/java/net/minecraft/world/level/LevelReader.java
@@ -26,6 +26,15 @@ public interface LevelReader extends BlockAndTintGetter, CollisionGetter, Signal
@ -21216,8 +21216,8 @@ index fe76ec5b10242beb6d6057bd680484fc63b7eac3..e3e2b88b8ade4fa2b482626c7e00ac6a
+ // Paper end - rewrite chunk system
+
@Nullable ChunkAccess getChunkIfLoadedImmediately(int x, int z); // Paper - ifLoaded api (we need this since current impl blocks if the chunk is loading)
@Nullable default ChunkAccess getChunkIfLoadedImmediately(BlockPos pos) { return this.getChunkIfLoadedImmediately(pos.getX() >> 4, pos.getZ() >> 4);}
/** @deprecated */
diff --git a/src/main/java/net/minecraft/world/level/chunk/ChunkGenerator.java b/src/main/java/net/minecraft/world/level/chunk/ChunkGenerator.java
index f739a175e26f250c652c73b8985158fe37c2823a..5f4fa76fe3a1a0a4fc11064fcf57bfab20bd9729 100644
--- a/src/main/java/net/minecraft/world/level/chunk/ChunkGenerator.java

View file

@ -0,0 +1,49 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Shane Freeder <theboyetronic@gmail.com>
Date: Wed, 5 Jul 2023 23:11:53 +0100
Subject: [PATCH] Reset mainSupportingBlockPos on some teleport calls
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
index b777547cb9f8edf4e7b3c2cfb894f8cd1b1a35a5..5330840a44e1a4eb39554ac7d59f355d74476562 100644
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -1739,11 +1739,13 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
}
this.internalTeleport(d0, d1, d2, f, f1, set);
+ this.player.mainSupportingBlockPos = Optional.empty();
return event.isCancelled(); // CraftBukkit - Return event status
}
public void teleport(Location dest) {
this.internalTeleport(dest.getX(), dest.getY(), dest.getZ(), dest.getYaw(), dest.getPitch(), Collections.emptySet());
+ this.player.mainSupportingBlockPos = Optional.empty();
}
public void internalTeleport(double d0, double d1, double d2, float f, float f1, Set<RelativeMovement> set) { // Paper
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index 3ffb92a82e17af467afb18c81accc482a93d6a6f..305b43071aa1cf8feee75fae757bb7734ae33771 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -1369,7 +1369,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
}
protected BlockPos getOnPos(float offset) {
- if (this.mainSupportingBlockPos.isPresent()) {
+ if (this.mainSupportingBlockPos.isPresent() && this.level().getChunkIfLoadedImmediately(this.mainSupportingBlockPos.get()) != null) { // Paper - ensure no loads
BlockPos blockposition = (BlockPos) this.mainSupportingBlockPos.get();
if (offset <= 1.0E-5F) {
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
index 5b201d2c21f04e0223970035e0631f8f92ea0d3a..318a57f34d304fe00670eb207968138c1fe9d1fb 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -1381,6 +1381,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
// Check if the fromWorld and toWorld are the same.
if (fromWorld == toWorld) {
entity.connection.internalTeleport(to.getX(), to.getY(), to.getZ(), to.getYaw(), to.getPitch(), relativeArguments); // Paper - Teleport API
+ entity.mainSupportingBlockPos = Optional.empty(); // Paper
} else {
// The respawn reason should never be used if the passed location is non null.
server.getHandle().respawn(entity, toWorld, true, to, !toWorld.paperConfig().environment.disableTeleportationSuffocationCheck, null); // Paper