Skip to content

Commit

Permalink
Rework fix can not move entity off main
Browse files Browse the repository at this point in the history
  • Loading branch information
MrHua269 committed Oct 3, 2023
1 parent 5a00f9c commit da10047
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 54 deletions.
52 changes: 21 additions & 31 deletions patches/server/0005-Fix-can-not-move-entity-off-main.patch
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ index d334b3aa4f311f57f2c41ced6c2265c817b78a76..92ad4c7105d5a5d8040d52c85d2274ab
}

diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index fa35d2c1c8de225acd68e08f15976c92f7ab82aa..8ed500a51d88e3267a1a8ea6a318dc9c92459bf3 100644
index fa35d2c1c8de225acd68e08f15976c92f7ab82aa..a428bea07b5a019b8c0d08cd6669407258d103fb 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -7,6 +7,7 @@ import com.google.common.collect.Lists;
Expand All @@ -44,34 +44,24 @@ index fa35d2c1c8de225acd68e08f15976c92f7ab82aa..8ed500a51d88e3267a1a8ea6a318dc9c
import net.minecraft.BlockUtil;
import net.minecraft.CrashReport;
import net.minecraft.CrashReportCategory;
@@ -1122,7 +1125,29 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
}
}

- this.setPos(this.getX() + vec3d1.x, this.getY() + vec3d1.y, this.getZ() + vec3d1.z);
+ //Molia start - Fix can not move entity off main
+ var finalX = this.getX() + vec3d1.x;
+ var finalY = this.getY() + vec3d1.y;
+ var finalZ = this.getZ() + vec3d1.z;
+
+ if (MoliaConfig.fixCanNotMoveEntityOffMain){
+ if (TickThread.isTickThreadFor((ServerLevel) this.level,(int)finalX >> 4,(int)finalZ >> 4)){
+ this.setPos(this.getX() + vec3d1.x, this.getY() + vec3d1.y, this.getZ() + vec3d1.z);
+ }else {
+ this.teleportAsync(
+ ((ServerLevel) this.level),
+ this.position().add(vec3d1),
+ this.getYRot(),
+ this.getXRot(),
+ null,
+ PlayerTeleportEvent.TeleportCause.UNKNOWN,
+ Entity.TELEPORT_FLAG_LOAD_CHUNK | Entity.TELEPORT_FLAG_TELEPORT_PASSENGERS, null
+ );
+ }
+ }else{
+ this.setPos(this.getX() + vec3d1.x, this.getY() + vec3d1.y, this.getZ() + vec3d1.z);
+ }
+ //Molia end
}
@@ -767,6 +770,20 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
}

this.level().getProfiler().pop();
public void setPos(double x, double y, double z) {
+ //Molia start - Teleport if the pos is in another region
+ if (MoliaConfig.fixCanNotMoveEntityOffMain && !TickThread.isTickThreadFor((ServerLevel) this.level,(int)x >> 4,(int)z >> 4)){
+ this.teleportAsync(
+ ((ServerLevel) this.level),
+ new Vec3(x,y,z),
+ this.getYRot(),
+ this.getXRot(),
+ null,
+ PlayerTeleportEvent.TeleportCause.UNKNOWN,
+ Entity.TELEPORT_FLAG_LOAD_CHUNK | Entity.TELEPORT_FLAG_TELEPORT_PASSENGERS, null
+ );
+ return;
+ }
+ //Molia end
this.setPosRaw(x, y, z, true); // Paper - force bounding box update
// this.setBoundingBox(this.makeBoundingBox()); // Paper - move into setPositionRaw
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ Subject: [PATCH] Pufferfish Reduce entity fluid lookups if no fluids


diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index 3a5d9f5d8ce6b2bffbeeb329a44a0bace5478fcd..d2baa6afb8109f4b09e2e31467a1caf8cf93b7ad 100644
index 370f9ef44b0935e1ae3cb7ff341eb70f1caf1e92..e7b47944fc2ab66f27585a6f79c63f903bac8e0a 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -5106,16 +5106,18 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
@@ -5098,16 +5098,18 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
}

public boolean updateFluidHeightAndDoFluidPushing(TagKey<Fluid> tag, double speed) {
Expand All @@ -34,7 +34,7 @@ index 3a5d9f5d8ce6b2bffbeeb329a44a0bace5478fcd..d2baa6afb8109f4b09e2e31467a1caf8
double d1 = 0.0D;
boolean flag = this.isPushedByFluid();
boolean flag1 = false;
@@ -5123,14 +5125,61 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
@@ -5115,14 +5117,61 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
int k1 = 0;
BlockPos.MutableBlockPos blockposition_mutableblockposition = new BlockPos.MutableBlockPos();

Expand Down Expand Up @@ -102,7 +102,7 @@ index 3a5d9f5d8ce6b2bffbeeb329a44a0bace5478fcd..d2baa6afb8109f4b09e2e31467a1caf8

if (d2 >= axisalignedbb.minY) {
flag1 = true;
@@ -5152,9 +5201,12 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
@@ -5144,9 +5193,12 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
// CraftBukkit end
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Subject: [PATCH] Gale Skip entity move if movement is zero


diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index d2baa6afb8109f4b09e2e31467a1caf8cf93b7ad..5b7c8d8ad82cfff8fad52e5fd7ee222b54615029 100644
index e7b47944fc2ab66f27585a6f79c63f903bac8e0a..66d257c3ff9501c41c6bcdf6c2070230198036bd 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -317,6 +317,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
Expand All @@ -16,7 +16,7 @@ index d2baa6afb8109f4b09e2e31467a1caf8cf93b7ad..5b7c8d8ad82cfff8fad52e5fd7ee222b
public boolean onGround;
public boolean horizontalCollision;
public boolean verticalCollision;
@@ -1080,6 +1081,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
@@ -1094,6 +1095,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
// Paper end - detailed watchdog information

public void move(MoverType movementType, Vec3 movement) {
Expand All @@ -28,7 +28,7 @@ index d2baa6afb8109f4b09e2e31467a1caf8cf93b7ad..5b7c8d8ad82cfff8fad52e5fd7ee222b
// Paper start - detailed watchdog information
io.papermc.paper.util.TickThread.ensureTickThread("Cannot move an entity off-main");
synchronized (this.posLock) {
@@ -4790,6 +4796,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
@@ -4782,6 +4788,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
}

public final void setBoundingBox(AABB boundingBox) {
Expand Down
8 changes: 4 additions & 4 deletions patches/server/0020-Leaves-Leaves-Server-Utils.patch
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ index 46954db7ecd35ac4018fdf476df7c8020d7ce6c8..044c51ebb058fc36074fd178929e3279
public PlayerAreaMap() {
super();
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index 5b7c8d8ad82cfff8fad52e5fd7ee222b54615029..4bad93036bf7d18785bed9dab3a615fa9fd8c980 100644
index 66d257c3ff9501c41c6bcdf6c2070230198036bd..8a2fd5aba5200dd7e78138f4860f8861bed40105 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -500,6 +500,8 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
Expand All @@ -43,15 +43,15 @@ index 5b7c8d8ad82cfff8fad52e5fd7ee222b54615029..4bad93036bf7d18785bed9dab3a615fa
public net.minecraft.server.level.FullChunkStatus chunkStatus;

public int sectionX = Integer.MIN_VALUE;
@@ -2479,6 +2481,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
@@ -2471,6 +2473,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
nbt.putBoolean("Paper.FreezeLock", true);
}
// Paper end
+ nbt.put("Leaves.Data", leavesData); // Leaves - leaves ex data
return nbt;
} catch (Throwable throwable) {
CrashReport crashreport = CrashReport.forThrowable(throwable, "Saving entity NBT");
@@ -2647,6 +2650,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
@@ -2639,6 +2642,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
freezeLocked = nbt.getBoolean("Paper.FreezeLock");
}
// Paper end
Expand All @@ -63,7 +63,7 @@ index 5b7c8d8ad82cfff8fad52e5fd7ee222b54615029..4bad93036bf7d18785bed9dab3a615fa

} catch (Throwable throwable) {
CrashReport crashreport = CrashReport.forThrowable(throwable, "Loading entity NBT");
@@ -2661,6 +2669,12 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
@@ -2653,6 +2661,12 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
return true;
}

Expand Down
4 changes: 2 additions & 2 deletions patches/server/0024-Leaves-fakeplayer-support.patch
Original file line number Diff line number Diff line change
Expand Up @@ -324,10 +324,10 @@ index 4f7a9a4ca030c8349a684080b44547f66ed0d2d7..ec3b14457146d1fa18a475e94114d029
+ // Leaves end - fakeplayer support
}
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index 4bad93036bf7d18785bed9dab3a615fa9fd8c980..9bc9bae8faea19bb065850a91ea67efef6901da2 100644
index 8a2fd5aba5200dd7e78138f4860f8861bed40105..bbc4adf6e71b7ae2f8a5f46dff8f2183ca538617 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -1486,7 +1486,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
@@ -1478,7 +1478,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
return offsetFactor;
}

Expand Down
4 changes: 2 additions & 2 deletions patches/server/0034-Gale-Optimize-sun-burn-tick.patch
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Subject: [PATCH] Gale Optimize sun burn tick


diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index 9bc9bae8faea19bb065850a91ea67efef6901da2..89544a19d0ce49ed5dc32823ecb249c4ddf2d08f 100644
index bbc4adf6e71b7ae2f8a5f46dff8f2183ca538617..39fac1d0da5e0e43e9257ce1526229f9cf4ffe83 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -308,7 +308,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
Expand All @@ -17,7 +17,7 @@ index 9bc9bae8faea19bb065850a91ea67efef6901da2..89544a19d0ce49ed5dc32823ecb249c4
public BlockPos blockPosition; // Gale - Pufferfish - optimize entity coordinate key - private -> public
private ChunkPos chunkPosition;
private Vec3 deltaMovement;
@@ -2035,9 +2035,17 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
@@ -2027,9 +2027,17 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
/** @deprecated */
@Deprecated
public float getLightLevelDependentMagicValue() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ Subject: [PATCH] Kaiiju Vanilla end portal teleportation


diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index 89544a19d0ce49ed5dc32823ecb249c4ddf2d08f..391369b487a092677b0f1e072738c904459491b4 100644
index 39fac1d0da5e0e43e9257ce1526229f9cf4ffe83..b6b4e9c3ece0e8357f470d3d7ab4ee637fd1635b 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -4082,12 +4082,17 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
@@ -4074,12 +4074,17 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
targetPos, 16, // load 16 blocks to be safe from block physics
ca.spottedleaf.concurrentutil.executor.standard.PrioritisedExecutor.Priority.HIGH,
(chunks) -> {
Expand All @@ -28,7 +28,7 @@ index 89544a19d0ce49ed5dc32823ecb249c4ddf2d08f..391369b487a092677b0f1e072738c904
);
}
);
@@ -4274,6 +4279,10 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
@@ -4266,6 +4271,10 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
if (!this.canPortalAsync(takePassengers)) {
return false;
}
Expand All @@ -39,7 +39,7 @@ index 89544a19d0ce49ed5dc32823ecb249c4ddf2d08f..391369b487a092677b0f1e072738c904

Vec3 initialPosition = this.position();
ChunkPos initialPositionChunk = new ChunkPos(
@@ -4332,7 +4341,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
@@ -4324,7 +4333,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
// place
passengerTree.root.placeInAsync(
originWorld, destination, Entity.TELEPORT_FLAG_LOAD_CHUNK | (takePassengers ? Entity.TELEPORT_FLAG_TELEPORT_PASSENGERS : 0L),
Expand Down
4 changes: 2 additions & 2 deletions patches/server/0042-Kaiiju-Unsafe-teleportation.patch
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ index 405bc9c2ea13e8b70c70f52c1fc81336b4dd432e..e95a14cec8a6c276adbf787c4af850db
breakRedstoneOnTripDoorEarly = getBoolean("fixes.break_redstone_early_on_tripdoor",breakRedstoneOnTripDoorEarly);
allowVoidTrading = getBoolean("fixes.allow_void_trading",allowVoidTrading);
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index 391369b487a092677b0f1e072738c904459491b4..1fbf7a09556b1dd60c63c21c7005415a6d2310c0 100644
index b6b4e9c3ece0e8357f470d3d7ab4ee637fd1635b..1de6570188d28e53cb81188f05274416bcb8dfad 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -60,7 +60,6 @@ import net.minecraft.network.syncher.EntityDataSerializers;
Expand All @@ -36,7 +36,7 @@ index 391369b487a092677b0f1e072738c904459491b4..1fbf7a09556b1dd60c63c21c7005415a
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
@@ -3997,6 +3996,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
@@ -3989,6 +3988,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {

protected boolean tryEndPortal() {
io.papermc.paper.util.TickThread.ensureTickThread(this, "Cannot portal entity async");
Expand Down
4 changes: 2 additions & 2 deletions patches/server/0044-Pufferfish-Entity-TTL.patch
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ index 4f73701bb810f456146714c8ff67ff9ec423f79b..cde3d3b0cf541cace5c3afeb1467c5cb
fakeplayerSupport = getBoolean("gameplay.leaves.fakeplayer.enabled",fakeplayerSupport);
fakeplayerLimit = getInt("gameplay.leaves.fakeplayer.fake_player_limit",fakeplayerLimit);
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index f34a79f573bd473f6a23a953d9022ff0693ab80e..d4f65c32f747a15dbad3a430c87b1377f3e08efa 100644
index 75d3ac95eaca5f29e020675af8d5f61a925202b4..03ced7057d0a39c0ddd2d623aefcd58e315b5c90 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -811,6 +811,12 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
@@ -825,6 +825,12 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
}

public void tick() {
Expand Down

0 comments on commit da10047

Please sign in to comment.