Skip to content

Commit

Permalink
Vanilla end teleportation
Browse files Browse the repository at this point in the history
Player should be teleported to Vec3.atBottomCenterOf(targetPos.below());
Other entities should be teleported to Vec3.atBottomCenterOf(targetPos);
And end-teleportation keep velocity (this.getDeltaMovement)
  • Loading branch information
sofianedjerbi committed Jun 29, 2023
1 parent 801cff1 commit 85ad6b0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 15 deletions.
28 changes: 15 additions & 13 deletions patches/server/0003-Threaded-Regions.patch
Original file line number Diff line number Diff line change
Expand Up @@ -17684,7 +17684,7 @@ index ea27b46eec01bda427653335f922ccd068cffcb5..e551d3b875eab6851b75041f418c9a08
return blockToFallLocation(blockState);
} else {
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index b38c4cbcf0405d82c7b6e018e80a3174e460c1a4..5a71b5a37a55baea204821aba734d53dc49cb336 100644
index b38c4cbcf0405d82c7b6e018e80a3174e460c1a4..edf569f2c7c3178e03898f2aa26c0da4586c2cb4 100644
--- a/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 {
Expand Down Expand Up @@ -17867,7 +17867,7 @@ index b38c4cbcf0405d82c7b6e018e80a3174e460c1a4..5a71b5a37a55baea204821aba734d53d
return;
}
// CraftBukkit end
@@ -3506,6 +3532,771 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
@@ -3506,6 +3532,773 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
this.portalEntrancePos = original.portalEntrancePos;
}

Expand Down Expand Up @@ -18376,11 +18376,13 @@ index b38c4cbcf0405d82c7b6e018e80a3174e460c1a4..5a71b5a37a55baea204821aba734d53d
+ ca.spottedleaf.concurrentutil.executor.standard.PrioritisedExecutor.Priority.HIGH,
+ (chunks) -> {
+ ServerLevel.makeObsidianPlatform(destination, null, targetPos);
+
+ Vec3 finalPos;
+ if (this instanceof Player) finalPos = Vec3.atBottomCenterOf(targetPos.below());
+ else finalPos = Vec3.atBottomCenterOf(targetPos);
+ // the portal obsidian is placed at targetPos.y - 2, so if we want to place the entity
+ // on the obsidian, we need to spawn at targetPos.y - 1
+ portalInfoCompletable.complete(
+ new PortalInfo(Vec3.atBottomCenterOf(targetPos.below()), Vec3.ZERO, 90.0f, 0.0f, destination, null)
+ new PortalInfo(finalPos, this.getDeltaMovement(), 90.0f, 0.0f, destination, null)
+ );
+ }
+ );
Expand Down Expand Up @@ -18639,7 +18641,7 @@ index b38c4cbcf0405d82c7b6e018e80a3174e460c1a4..5a71b5a37a55baea204821aba734d53d
@Nullable
public Entity changeDimension(ServerLevel destination) {
// CraftBukkit start
@@ -3514,6 +4305,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
@@ -3514,6 +4307,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {

@Nullable
public Entity teleportTo(ServerLevel worldserver, PositionImpl location) {
Expand All @@ -18651,7 +18653,7 @@ index b38c4cbcf0405d82c7b6e018e80a3174e460c1a4..5a71b5a37a55baea204821aba734d53d
// CraftBukkit end
// Paper start - fix bad state entities causing dupes
if (!this.isAlive() || !this.valid) {
@@ -3597,6 +4393,12 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
@@ -3597,6 +4395,12 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
}
}

Expand All @@ -18664,7 +18666,7 @@ index b38c4cbcf0405d82c7b6e018e80a3174e460c1a4..5a71b5a37a55baea204821aba734d53d
protected void removeAfterChangingDimensions() {
this.setRemoved(Entity.RemovalReason.CHANGED_DIMENSION);
}
@@ -4041,17 +4843,13 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
@@ -4041,17 +4845,13 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {

// Paper start
public void startSeenByPlayer(ServerPlayer player) {
Expand All @@ -18684,7 +18686,7 @@ index b38c4cbcf0405d82c7b6e018e80a3174e460c1a4..5a71b5a37a55baea204821aba734d53d
}
// Paper end

@@ -4546,7 +5344,8 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
@@ -4546,7 +5346,8 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
}
}
// Paper end - fix MC-4
Expand All @@ -18694,7 +18696,7 @@ index b38c4cbcf0405d82c7b6e018e80a3174e460c1a4..5a71b5a37a55baea204821aba734d53d
synchronized (this.posLock) { // Paper
this.position = new Vec3(x, y, z);
} // Paper
@@ -4567,7 +5366,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
@@ -4567,7 +5368,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {

// Paper start - never allow AABB to become desynced from position
// hanging has its own special logic
Expand All @@ -18703,7 +18705,7 @@ index b38c4cbcf0405d82c7b6e018e80a3174e460c1a4..5a71b5a37a55baea204821aba734d53d
this.setBoundingBox(this.makeBoundingBox());
}
// Paper end
@@ -4654,6 +5453,12 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
@@ -4654,6 +5455,12 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
return this.removalReason != null;
}

Expand All @@ -18716,7 +18718,7 @@ index b38c4cbcf0405d82c7b6e018e80a3174e460c1a4..5a71b5a37a55baea204821aba734d53d
@Nullable
public Entity.RemovalReason getRemovalReason() {
return this.removalReason;
@@ -4678,7 +5483,23 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
@@ -4678,7 +5485,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)
this.levelCallback.onRemove(reason);
Expand Down Expand Up @@ -24011,7 +24013,7 @@ index cd4ad8261e56365850068db1d83d6a8454026737..78f7e72f2912dae503c2dab7d1992b65
List<String> offers = waitable.get();
if (offers == null) {
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
index 733158b6f2c2bd03fbe798562ff7bc33280548dc..f001d811e930230f729b0340fb54f083fc4a9eb1 100644
index 733158b6f2c2bd03fbe798562ff7bc33280548dc..2fe15f615522b60bba8e7551eef182458d163cd5 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
@@ -203,6 +203,16 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
Expand Down Expand Up @@ -24080,7 +24082,7 @@ index 733158b6f2c2bd03fbe798562ff7bc33280548dc..f001d811e930230f729b0340fb54f083
+ boolean success = nmsEntity.teleportAsync(
+ ((CraftWorld)locationClone.getWorld()).getHandle(),
+ new net.minecraft.world.phys.Vec3(locationClone.getX(), locationClone.getY(), locationClone.getZ()),
+ null, null, net.minecraft.world.phys.Vec3.ZERO,
+ locationClone.getYaw(), locationClone.getPitch(), net.minecraft.world.phys.Vec3.ZERO,
+ cause == null ? TeleportCause.UNKNOWN : cause,
+ Entity.TELEPORT_FLAG_LOAD_CHUNK | Entity.TELEPORT_FLAG_UNMOUNT, // preserve behavior with old API: dismount the entity so it can teleport
+ (Entity entityTp) -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ index d9687722e02dfd4088c7030abbf5008eb0a092c8..62484ebf4550b05182f693a3180bbac5
TickThread.ensureTickThread(thisEntity, "May not tick entity scheduler asynchronously");
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
index 5a71b5a37a55baea204821aba734d53dc49cb336..27b57db24587337ccdce29e492052ca419863323 100644
index edf569f2c7c3178e03898f2aa26c0da4586c2cb4..d267946e49465837a1c2489ce1782c1f0e229d25 100644
--- a/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 {
Expand Down Expand Up @@ -932,7 +932,7 @@ index 75c7645fb5732c43d1da15181cf5c7ee4c3ecd6c..6d3325436a77153438bc40aa86819562
}

diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
index f001d811e930230f729b0340fb54f083fc4a9eb1..76bcfda336e9cfa039d80ea3ccbebbc3d2b13f7f 100644
index 2fe15f615522b60bba8e7551eef182458d163cd5..bcb85a4253b5e44b78cbadfb16c3bf0d47d7369e 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
@@ -822,7 +822,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
Expand Down

0 comments on commit 85ad6b0

Please sign in to comment.