Skip to content

Commit 0556dbc

Browse files
committed
Avoid teleport out of spawnable bounds
1 parent d98142e commit 0556dbc

File tree

9 files changed

+88
-26
lines changed

9 files changed

+88
-26
lines changed

paper-api/src/main/java/org/bukkit/event/entity/EntityTeleportEvent.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,10 @@ public Location getFrom() {
4444
* Sets the location that this entity moved from
4545
*
4646
* @param from New location this entity moved from
47+
* @throws IllegalArgumentException if the location is not finite
4748
*/
4849
public void setFrom(@NotNull Location from) {
50+
from.checkFinite();
4951
this.from = from.clone();
5052
}
5153

@@ -63,9 +65,15 @@ public Location getTo() {
6365
* Sets the location that this entity moved to
6466
*
6567
* @param to New Location this entity moved to
68+
* @throws IllegalArgumentException if the location is not finite
6669
*/
6770
public void setTo(@Nullable Location to) {
68-
this.to = to != null ? to.clone() : null;
71+
if (to != null) {
72+
to.checkFinite();
73+
this.to = to.clone();
74+
} else {
75+
this.to = null;
76+
}
6977
}
7078

7179
@Override

paper-api/src/main/java/org/bukkit/event/player/PlayerMoveEvent.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public void setFrom(@NotNull Location from) {
5353
*
5454
* @return Location the player moved to
5555
*/
56-
@NotNull // Paper
56+
@NotNull
5757
public Location getTo() {
5858
return to;
5959
}
@@ -139,7 +139,8 @@ public void setCancelled(boolean cancel) {
139139

140140
private void validateLocation(@NotNull Location loc) {
141141
Preconditions.checkArgument(loc != null, "Cannot use null location!");
142-
Preconditions.checkArgument(loc.getWorld() != null, "Cannot use null location with null world!");
142+
Preconditions.checkArgument(loc.getWorld() != null, "Cannot use location with null world!");
143+
loc.checkFinite();
143144
}
144145

145146
@NotNull

paper-server/patches/features/0001-Moonrise-optimisation-patches.patch

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27000,7 +27000,7 @@ index 704733ff5e558a12f2f9dde924ab4c507745595d..5e305c9a64e856de70ed787901c01d09
2700027000
}
2700127001

2700227002
diff --git a/net/minecraft/server/level/ServerPlayer.java b/net/minecraft/server/level/ServerPlayer.java
27003-
index a5bc4e8a3dde40c416c05e91dfec25bc7efdd013..66c25f323b9a19e25fcaea782dc72f477fd32629 100644
27003+
index 50396c988e0c44ab4e04255c8c32281fbbfb2e95..657827b0342a12fc53d4197fa0ecbde5df1fce31 100644
2700427004
--- a/net/minecraft/server/level/ServerPlayer.java
2700527005
+++ b/net/minecraft/server/level/ServerPlayer.java
2700627006
@@ -201,7 +201,7 @@ import net.minecraft.world.scores.Team;
@@ -28098,7 +28098,7 @@ index 8cc5c0716392ba06501542ff5cbe71ee43979e5d..09fd99c9cbd23b5f3c899bfb00c9b896
2809828098
+ // Paper end - block counting
2809928099
}
2810028100
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
28101-
index d5c38171be43b9a4a17e28889746f0c25e084176..1ca1a5b897a9a9375ccc9ca02e7ae77ee7ecddea 100644
28101+
index 32be8212b28db5bb759a69498852a812f4c9aa04..5602df8a3214a2e672fb2e1abed4756a9e2aa9c5 100644
2810228102
--- a/net/minecraft/world/entity/Entity.java
2810328103
+++ b/net/minecraft/world/entity/Entity.java
2810428104
@@ -149,7 +149,7 @@ import net.minecraft.world.waypoints.WaypointTransmitter;
@@ -28573,7 +28573,7 @@ index d5c38171be43b9a4a17e28889746f0c25e084176..1ca1a5b897a9a9375ccc9ca02e7ae77e
2857328573
}
2857428574

2857528575
public InteractionResult interact(Player player, InteractionHand hand) {
28576-
@@ -4298,15 +4535,17 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name
28576+
@@ -4297,15 +4534,17 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name
2857728577
}
2857828578

2857928579
public Iterable<Entity> getIndirectPassengers() {
@@ -28599,7 +28599,7 @@ index d5c38171be43b9a4a17e28889746f0c25e084176..1ca1a5b897a9a9375ccc9ca02e7ae77e
2859928599
}
2860028600

2860128601
public int countPlayerPassengers() {
28602-
@@ -4449,77 +4688,126 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name
28602+
@@ -4448,77 +4687,126 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name
2860328603
return Mth.lerp(partialTick, this.yRotO, this.yRot);
2860428604
}
2860528605

@@ -28784,7 +28784,7 @@ index d5c38171be43b9a4a17e28889746f0c25e084176..1ca1a5b897a9a9375ccc9ca02e7ae77e
2878428784

2878528785
public boolean touchingUnloadedChunk() {
2878628786
AABB aabb = this.getBoundingBox().inflate(1.0);
28787-
@@ -4675,6 +4963,15 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name
28787+
@@ -4674,6 +4962,15 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name
2878828788
}
2878928789

2879028790
public final void setPosRaw(double x, double y, double z, boolean forceBoundingBoxUpdate) {
@@ -28800,7 +28800,7 @@ index d5c38171be43b9a4a17e28889746f0c25e084176..1ca1a5b897a9a9375ccc9ca02e7ae77e
2880028800
if (!checkPosition(this, x, y, z)) {
2880128801
return;
2880228802
}
28803-
@@ -4826,6 +5123,12 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name
28803+
@@ -4825,6 +5122,12 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name
2880428804

2880528805
@Override
2880628806
public final void setRemoved(Entity.RemovalReason removalReason, @Nullable org.bukkit.event.entity.EntityRemoveEvent.Cause cause) { // CraftBukkit - add Bukkit remove cause
@@ -28813,7 +28813,7 @@ index d5c38171be43b9a4a17e28889746f0c25e084176..1ca1a5b897a9a9375ccc9ca02e7ae77e
2881328813
org.bukkit.craftbukkit.event.CraftEventFactory.callEntityRemoveEvent(this, cause); // CraftBukkit
2881428814
final boolean alreadyRemoved = this.removalReason != null; // Paper - Folia schedulers
2881528815
if (this.removalReason == null) {
28816-
@@ -4836,7 +5139,7 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name
28816+
@@ -4835,7 +5138,7 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name
2881728817
this.stopRiding();
2881828818
}
2881928819

@@ -28822,7 +28822,7 @@ index d5c38171be43b9a4a17e28889746f0c25e084176..1ca1a5b897a9a9375ccc9ca02e7ae77e
2882228822
this.levelCallback.onRemove(removalReason);
2882328823
this.onRemoval(removalReason);
2882428824
// Paper start - Folia schedulers
28825-
@@ -4870,7 +5173,7 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name
28825+
@@ -4869,7 +5172,7 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name
2882628826
public boolean shouldBeSaved() {
2882728827
return (this.removalReason == null || this.removalReason.shouldSave())
2882828828
&& !this.isPassenger()

paper-server/patches/features/0026-Optimise-EntityScheduler-ticking.patch

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,10 @@ index d5f3083354d70c4da3c39e2f909ce4c7e170295c..4b1ffb5396138fc0d165ac647797b83f
6767
io.papermc.paper.adventure.providers.ClickCallbackProviderImpl.DIALOG_CLICK_MANAGER.handleQueue(this.tickCount); // Paper
6868
profilerFiller.push("commandFunctions");
6969
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
70-
index fea14f27503369185c867d269c5b8b416ce76eda..80dce02ac088eccaff71ab7fa85516036177a804 100644
70+
index ad818ffb2565f137fb41b18bfcc28d9b80097074..de934ad9e1ef1712da9b2f7c376a17fde3540d97 100644
7171
--- a/net/minecraft/world/entity/Entity.java
7272
+++ b/net/minecraft/world/entity/Entity.java
73-
@@ -5190,6 +5190,11 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name
73+
@@ -5189,6 +5189,11 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name
7474
this.getBukkitEntity().taskScheduler.retire();
7575
}
7676
// Paper end - Folia schedulers

paper-server/patches/sources/net/minecraft/server/level/ServerPlayer.java.patch

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -750,26 +750,24 @@
750750
if (this.isRemoved()) {
751751
return null;
752752
} else {
753-
@@ -1084,13 +_,48 @@
753+
@@ -1084,13 +_,46 @@
754754

755755
ServerLevel level = teleportTransition.newLevel();
756756
ServerLevel serverLevel = this.level();
757757
- ResourceKey<Level> resourceKey = serverLevel.dimension();
758758
+ // CraftBukkit start
759759
+ ResourceKey<net.minecraft.world.level.dimension.LevelStem> resourceKey = serverLevel.getTypeKey();
760760
+
761-
+ org.bukkit.Location enter = this.getBukkitEntity().getLocation();
762761
+ PositionMoveRotation absolutePosition = PositionMoveRotation.calculateAbsolute(PositionMoveRotation.of(this), PositionMoveRotation.of(teleportTransition), teleportTransition.relatives());
763762
+ org.bukkit.Location exit = org.bukkit.craftbukkit.util.CraftLocation.toBukkit(absolutePosition.position(), level, absolutePosition.yRot(), absolutePosition.xRot());
764763
+ final org.bukkit.event.player.PlayerTeleportEvent tpEvent;
765764
+ // Paper start - gateway-specific teleport event
766765
+ if (this.portalProcess != null && this.portalProcess.isSamePortal(((net.minecraft.world.level.block.EndGatewayBlock) net.minecraft.world.level.block.Blocks.END_GATEWAY)) && this.level().getBlockEntity(this.portalProcess.getEntryPosition()) instanceof net.minecraft.world.level.block.entity.TheEndGatewayBlockEntity theEndGatewayBlockEntity) {
767-
+ tpEvent = new com.destroystokyo.paper.event.player.PlayerTeleportEndGatewayEvent(this.getBukkitEntity(), enter, exit.clone(), new org.bukkit.craftbukkit.block.CraftEndGateway(this.level().getWorld(), theEndGatewayBlockEntity));
766+
+ tpEvent = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerTeleportEndGatewayEvent(this, exit.clone(), theEndGatewayBlockEntity);
768767
+ } else {
769-
+ tpEvent = new org.bukkit.event.player.PlayerTeleportEvent(this.getBukkitEntity(), enter, exit.clone(), teleportTransition.cause());
768+
+ tpEvent = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerTeleportEvent(this.getBukkitEntity(), this.getBukkitEntity().getLocation(), exit.clone(), teleportTransition.cause(), null);
770769
+ }
771770
+ // Paper end - gateway-specific teleport event
772-
+ org.bukkit.Bukkit.getServer().getPluginManager().callEvent(tpEvent);
773771
+ org.bukkit.Location newExit = tpEvent.getTo();
774772
+ if (tpEvent.isCancelled()) {
775773
+ return null;

paper-server/patches/sources/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -996,7 +996,7 @@
996996

997997
return true;
998998
} else {
999-
@@ -1181,10 +_,77 @@
999+
@@ -1181,10 +_,76 @@
10001000
}
10011001

10021002
public void teleport(double x, double y, double z, float yRot, float xRot) {
@@ -1032,9 +1032,8 @@
10321032
+ final io.papermc.paper.entity.TeleportFlag.Relative flag = org.bukkit.craftbukkit.entity.CraftEntity.deltaRelativeToAPI(relativeArgument);
10331033
+ if (flag != null) relativeFlags.add(flag);
10341034
+ }
1035-
+ PlayerTeleportEvent event = new PlayerTeleportEvent(player, from.clone(), to.clone(), cause, java.util.Set.copyOf(relativeFlags));
1035+
+ PlayerTeleportEvent event = CraftEventFactory.callPlayerTeleportEvent(player, from.clone(), to.clone(), cause, java.util.Set.copyOf(relativeFlags));
10361036
+ // Paper end - Teleport API
1037-
+ this.cserver.getPluginManager().callEvent(event);
10381037
+
10391038
+ if (event.isCancelled() || !to.equals(event.getTo())) {
10401039
+ relatives = Set.of(); // target pos is absolute

paper-server/patches/sources/net/minecraft/world/entity/Entity.java.patch

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1463,7 +1463,7 @@
14631463
try (ProblemReporter.ScopedCollector scopedCollector = new ProblemReporter.ScopedCollector(this.problemPath(), LOGGER)) {
14641464
TagValueOutput tagValueOutput = TagValueOutput.createWithContext(scopedCollector, entity.registryAccess());
14651465
entity.saveWithoutId(tagValueOutput);
1466-
@@ -2935,7 +_,65 @@
1466+
@@ -2935,7 +_,64 @@
14671467

14681468
@Nullable
14691469
public Entity teleport(TeleportTransition teleportTransition) {
@@ -1481,8 +1481,7 @@
14811481
+ // Paper start - gateway-specific teleport event
14821482
+ final org.bukkit.event.entity.EntityTeleportEvent teleEvent;
14831483
+ if (this.portalProcess != null && this.portalProcess.isSamePortal(((net.minecraft.world.level.block.EndGatewayBlock) Blocks.END_GATEWAY)) && this.level.getBlockEntity(this.portalProcess.getEntryPosition()) instanceof net.minecraft.world.level.block.entity.TheEndGatewayBlockEntity theEndGatewayBlockEntity) {
1484-
+ teleEvent = new com.destroystokyo.paper.event.entity.EntityTeleportEndGatewayEvent(this.getBukkitEntity(), this.getBukkitEntity().getLocation(), to, new org.bukkit.craftbukkit.block.CraftEndGateway(to.getWorld(), theEndGatewayBlockEntity));
1485-
+ teleEvent.callEvent();
1484+
+ teleEvent = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTeleportEndGatewayEvent(this, to, theEndGatewayBlockEntity);
14861485
+ } else {
14871486
+ teleEvent = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTeleportEvent(this, to);
14881487
+ }

paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,9 +288,10 @@ public boolean teleport(Location location, TeleportCause cause) {
288288

289289
@Override
290290
public boolean teleport(Location location, TeleportCause cause, TeleportFlag... flags) {
291+
Preconditions.checkState(!this.entity.generation, "Cannot teleport entity to an other world during world generation");
291292
Preconditions.checkArgument(location != null, "location cannot be null");
292293
Preconditions.checkArgument(location.getWorld() != null, "Target world cannot be null");
293-
Preconditions.checkState(!this.entity.generation, "Cannot teleport entity to an other world during world generation");
294+
Preconditions.checkArgument(ServerLevel.isInSpawnableBounds(CraftLocation.toBlockPosition(location)), "location is out of spawnable bounds [x/z between %s and %s or y between %s and %s]", -ServerLevel.MAX_LEVEL_SIZE, ServerLevel.MAX_LEVEL_SIZE, ServerLevel.MIN_ENTITY_SPAWN_Y, ServerLevel.MAX_ENTITY_SPAWN_Y);
294295
location.checkFinite();
295296

296297
return this.teleport0(location, cause, flags);

paper-server/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package org.bukkit.craftbukkit.event;
22

3+
import com.destroystokyo.paper.event.entity.EntityTeleportEndGatewayEvent;
4+
import com.destroystokyo.paper.event.player.PlayerTeleportEndGatewayEvent;
35
import com.google.common.base.Function;
46
import com.google.common.base.Functions;
57
import com.google.common.base.Preconditions;
@@ -9,6 +11,7 @@
911
import io.papermc.paper.adventure.PaperAdventure;
1012
import io.papermc.paper.connection.HorriblePlayerLoginEventHack;
1113
import io.papermc.paper.connection.PlayerConnection;
14+
import io.papermc.paper.entity.TeleportFlag;
1215
import io.papermc.paper.event.connection.PlayerConnectionValidateLoginEvent;
1316
import io.papermc.paper.event.entity.ItemTransportingEntityValidateTargetEvent;
1417
import java.util.ArrayList;
@@ -63,6 +66,7 @@
6366
import net.minecraft.world.level.Level;
6467
import net.minecraft.world.level.LevelAccessor;
6568
import net.minecraft.world.level.block.entity.SignBlockEntity;
69+
import net.minecraft.world.level.block.entity.TheEndGatewayBlockEntity;
6670
import net.minecraft.world.level.block.state.properties.NoteBlockInstrument;
6771
import net.minecraft.world.level.redstone.Redstone;
6872
import net.minecraft.world.level.storage.loot.LootContext;
@@ -103,6 +107,7 @@
103107
import org.bukkit.craftbukkit.inventory.CraftItemStack;
104108
import org.bukkit.craftbukkit.inventory.CraftItemType;
105109
import org.bukkit.craftbukkit.potion.CraftPotionUtil;
110+
import org.bukkit.craftbukkit.util.CraftLocation;
106111
import org.bukkit.craftbukkit.util.CraftNamespacedKey;
107112
import org.bukkit.craftbukkit.util.CraftVector;
108113
import org.bukkit.entity.AbstractHorse;
@@ -1932,6 +1937,38 @@ public static PlayerRecipeBookClickEvent callRecipeBookClickEvent(ServerPlayer p
19321937
return event;
19331938
}
19341939

1940+
public static PlayerTeleportEvent callPlayerTeleportEvent(Player player, Location from, Location to, PlayerTeleportEvent.TeleportCause cause, @Nullable Set<TeleportFlag.Relative> teleportFlags) {
1941+
PlayerTeleportEvent event;
1942+
if (teleportFlags == null) {
1943+
event = new PlayerTeleportEvent(player, from, to, cause);
1944+
} else {
1945+
event = new PlayerTeleportEvent(player, from, to, cause, teleportFlags);
1946+
}
1947+
1948+
event.callEvent();
1949+
1950+
Preconditions.checkArgument(ServerLevel.isInSpawnableBounds(CraftLocation.toBlockPosition(event.getFrom())), "origin for PlayerTeleportEvent is out of spawnable bounds [x/z between %s and %s or y between %s and %s]", -ServerLevel.MAX_LEVEL_SIZE, ServerLevel.MAX_LEVEL_SIZE, ServerLevel.MIN_ENTITY_SPAWN_Y, ServerLevel.MAX_ENTITY_SPAWN_Y);
1951+
if (!event.isCancelled()) {
1952+
Preconditions.checkArgument(ServerLevel.isInSpawnableBounds(CraftLocation.toBlockPosition(event.getTo())), "destination for PlayerTeleportEvent is out of spawnable bounds [x/z between %s and %s or y between %s and %s]", -ServerLevel.MAX_LEVEL_SIZE, ServerLevel.MAX_LEVEL_SIZE, ServerLevel.MIN_ENTITY_SPAWN_Y, ServerLevel.MAX_ENTITY_SPAWN_Y);
1953+
}
1954+
1955+
return event;
1956+
}
1957+
1958+
public static PlayerTeleportEndGatewayEvent callPlayerTeleportEndGatewayEvent(ServerPlayer nmsPlayer, Location to, TheEndGatewayBlockEntity nmsTheEndGatewayBlockEntity) {
1959+
CraftPlayer entity = nmsPlayer.getBukkitEntity();
1960+
PlayerTeleportEndGatewayEvent event = new PlayerTeleportEndGatewayEvent(entity, entity.getLocation(), to, new org.bukkit.craftbukkit.block.CraftEndGateway(nmsPlayer.level().getWorld(), nmsTheEndGatewayBlockEntity));
1961+
1962+
event.callEvent();
1963+
1964+
Preconditions.checkArgument(ServerLevel.isInSpawnableBounds(CraftLocation.toBlockPosition(event.getFrom())), "origin for PlayerTeleportEndGatewayEvent is out of spawnable bounds [x/z between %s and %s or y between %s and %s]", -ServerLevel.MAX_LEVEL_SIZE, ServerLevel.MAX_LEVEL_SIZE, ServerLevel.MIN_ENTITY_SPAWN_Y, ServerLevel.MAX_ENTITY_SPAWN_Y);
1965+
if (!event.isCancelled()) {
1966+
Preconditions.checkArgument(ServerLevel.isInSpawnableBounds(CraftLocation.toBlockPosition(event.getTo())), "destination for PlayerTeleportEndGatewayEvent is out of spawnable bounds [x/z between %s and %s or y between %s and %s]", -ServerLevel.MAX_LEVEL_SIZE, ServerLevel.MAX_LEVEL_SIZE, ServerLevel.MIN_ENTITY_SPAWN_Y, ServerLevel.MAX_ENTITY_SPAWN_Y);
1967+
}
1968+
1969+
return event;
1970+
}
1971+
19351972
public static EntityTeleportEvent callEntityTeleportEvent(Entity nmsEntity, double x, double y, double z) {
19361973
CraftEntity entity = nmsEntity.getBukkitEntity();
19371974
Location to = new Location(entity.getWorld(), x, y, z, nmsEntity.getYRot(), nmsEntity.getXRot());
@@ -1942,7 +1979,26 @@ public static EntityTeleportEvent callEntityTeleportEvent(Entity nmsEntity, Loca
19421979
CraftEntity entity = nmsEntity.getBukkitEntity();
19431980
EntityTeleportEvent event = new org.bukkit.event.entity.EntityTeleportEvent(entity, entity.getLocation(), to);
19441981

1945-
Bukkit.getPluginManager().callEvent(event);
1982+
event.callEvent();
1983+
1984+
Preconditions.checkArgument(ServerLevel.isInSpawnableBounds(CraftLocation.toBlockPosition(event.getFrom())), "origin for EntityTeleportEvent is out of spawnable bounds [x/z between %s and %s or y between %s and %s]", -ServerLevel.MAX_LEVEL_SIZE, ServerLevel.MAX_LEVEL_SIZE, ServerLevel.MIN_ENTITY_SPAWN_Y, ServerLevel.MAX_ENTITY_SPAWN_Y);
1985+
if (!event.isCancelled() && event.getTo() != null) {
1986+
Preconditions.checkArgument(ServerLevel.isInSpawnableBounds(CraftLocation.toBlockPosition(event.getTo())), "destination for EntityTeleportEvent is out of spawnable bounds [x/z between %s and %s or y between %s and %s]", -ServerLevel.MAX_LEVEL_SIZE, ServerLevel.MAX_LEVEL_SIZE, ServerLevel.MIN_ENTITY_SPAWN_Y, ServerLevel.MAX_ENTITY_SPAWN_Y);
1987+
}
1988+
1989+
return event;
1990+
}
1991+
1992+
public static EntityTeleportEndGatewayEvent callEntityTeleportEndGatewayEvent(Entity nmsEntity, Location to, TheEndGatewayBlockEntity nmsTheEndGatewayBlockEntity) {
1993+
CraftEntity entity = nmsEntity.getBukkitEntity();
1994+
EntityTeleportEndGatewayEvent event = new com.destroystokyo.paper.event.entity.EntityTeleportEndGatewayEvent(entity, entity.getLocation(), to, new org.bukkit.craftbukkit.block.CraftEndGateway(to.getWorld(), nmsTheEndGatewayBlockEntity));
1995+
1996+
event.callEvent();
1997+
1998+
Preconditions.checkArgument(ServerLevel.isInSpawnableBounds(CraftLocation.toBlockPosition(event.getFrom())), "origin for EntityTeleportEndGatewayEvent is out of spawnable bounds [x/z between %s and %s or y between %s and %s]", -ServerLevel.MAX_LEVEL_SIZE, ServerLevel.MAX_LEVEL_SIZE, ServerLevel.MIN_ENTITY_SPAWN_Y, ServerLevel.MAX_ENTITY_SPAWN_Y);
1999+
if (!event.isCancelled() && event.getTo() != null) {
2000+
Preconditions.checkArgument(ServerLevel.isInSpawnableBounds(CraftLocation.toBlockPosition(event.getTo())), "destination for EntityTeleportEndGatewayEvent is out of spawnable bounds [x/z between %s and %s or y between %s and %s]", -ServerLevel.MAX_LEVEL_SIZE, ServerLevel.MAX_LEVEL_SIZE, ServerLevel.MIN_ENTITY_SPAWN_Y, ServerLevel.MAX_ENTITY_SPAWN_Y);
2001+
}
19462002

19472003
return event;
19482004
}

0 commit comments

Comments
 (0)