mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-07 11:05:13 +01:00
Better handling of custom end/nether teleports
This commit is contained in:
parent
2b5f172cb8
commit
4b67fed7f6
2 changed files with 34 additions and 16 deletions
|
@ -602,9 +602,12 @@
|
||||||
- BlockPosition blockposition;
|
- BlockPosition blockposition;
|
||||||
+ BlockPosition blockposition = location; // CraftBukkit
|
+ BlockPosition blockposition = location; // CraftBukkit
|
||||||
|
|
||||||
+ if (blockposition == null) { // CraftBukkit
|
- if (this.world.getDimensionKey() == World.THE_END && worldserver.getDimensionKey() == World.OVERWORLD) {
|
||||||
if (this.world.getDimensionKey() == World.THE_END && worldserver.getDimensionKey() == World.OVERWORLD) {
|
|
||||||
- blockposition = worldserver.getHighestBlockYAt(HeightMap.Type.MOTION_BLOCKING_NO_LEAVES, worldserver.getSpawn());
|
- blockposition = worldserver.getHighestBlockYAt(HeightMap.Type.MOTION_BLOCKING_NO_LEAVES, worldserver.getSpawn());
|
||||||
|
- } else if (worldserver.getDimensionKey() == World.THE_END) {
|
||||||
|
- blockposition = WorldServer.a;
|
||||||
|
+ if (blockposition == null) { // CraftBukkit
|
||||||
|
+ if (this.world.getTypeKey() == DimensionManager.THE_END && worldserver.getTypeKey() == DimensionManager.OVERWORLD) { // CraftBukkit
|
||||||
+ // CraftBukkit start
|
+ // CraftBukkit start
|
||||||
+ EntityPortalEvent event = CraftEventFactory.callEntityPortalEvent(this, worldserver, worldserver.getHighestBlockYAt(HeightMap.Type.MOTION_BLOCKING_NO_LEAVES, worldserver.getSpawn()), 0);
|
+ EntityPortalEvent event = CraftEventFactory.callEntityPortalEvent(this, worldserver, worldserver.getHighestBlockYAt(HeightMap.Type.MOTION_BLOCKING_NO_LEAVES, worldserver.getSpawn()), 0);
|
||||||
+ if (event == null) {
|
+ if (event == null) {
|
||||||
|
@ -613,8 +616,7 @@
|
||||||
+ worldserver = ((CraftWorld) event.getTo().getWorld()).getHandle();
|
+ worldserver = ((CraftWorld) event.getTo().getWorld()).getHandle();
|
||||||
+ blockposition = new BlockPosition(event.getTo().getX(), event.getTo().getY(), event.getTo().getZ());
|
+ blockposition = new BlockPosition(event.getTo().getX(), event.getTo().getY(), event.getTo().getZ());
|
||||||
+ // CraftBukkit end
|
+ // CraftBukkit end
|
||||||
} else if (worldserver.getDimensionKey() == World.THE_END) {
|
+ } else if (worldserver.getTypeKey() == DimensionManager.THE_END) { // CraftBukkit
|
||||||
- blockposition = WorldServer.a;
|
|
||||||
+ // CraftBukkit start
|
+ // CraftBukkit start
|
||||||
+ EntityPortalEvent event = CraftEventFactory.callEntityPortalEvent(this, worldserver, WorldServer.a, 0);
|
+ EntityPortalEvent event = CraftEventFactory.callEntityPortalEvent(this, worldserver, WorldServer.a, 0);
|
||||||
+ if (event == null) {
|
+ if (event == null) {
|
||||||
|
@ -656,11 +658,13 @@
|
||||||
|
|
||||||
this.world.getMethodProfiler().exitEnter("reloading");
|
this.world.getMethodProfiler().exitEnter("reloading");
|
||||||
Entity entity = this.getEntityType().a((World) worldserver);
|
Entity entity = this.getEntityType().a((World) worldserver);
|
||||||
@@ -2043,8 +2423,16 @@
|
@@ -2042,9 +2422,17 @@
|
||||||
|
entity.setPositionRotation(blockposition, entity.yaw + f, entity.pitch);
|
||||||
entity.setMot(vec3d);
|
entity.setMot(vec3d);
|
||||||
worldserver.addEntityTeleport(entity);
|
worldserver.addEntityTeleport(entity);
|
||||||
if (worldserver.getDimensionKey() == World.THE_END) {
|
- if (worldserver.getDimensionKey() == World.THE_END) {
|
||||||
- WorldServer.a(worldserver);
|
- WorldServer.a(worldserver);
|
||||||
|
+ if (worldserver.getTypeKey() == DimensionManager.THE_END) { // CraftBukkit
|
||||||
+ WorldServer.a(worldserver, this); // CraftBukkit
|
+ WorldServer.a(worldserver, this); // CraftBukkit
|
||||||
+ }
|
+ }
|
||||||
+ // CraftBukkit start - Forward the CraftEntity to the new entity
|
+ // CraftBukkit start - Forward the CraftEntity to the new entity
|
||||||
|
|
|
@ -372,9 +372,11 @@
|
||||||
+ if (this.isSleeping()) return this; // CraftBukkit - SPIGOT-3154
|
+ if (this.isSleeping()) return this; // CraftBukkit - SPIGOT-3154
|
||||||
+ // this.worldChangeInvuln = true; // CraftBukkit - Moved down and into PlayerList#changeDimension
|
+ // this.worldChangeInvuln = true; // CraftBukkit - Moved down and into PlayerList#changeDimension
|
||||||
WorldServer worldserver1 = this.getWorldServer();
|
WorldServer worldserver1 = this.getWorldServer();
|
||||||
ResourceKey<World> resourcekey = worldserver1.getDimensionKey();
|
- ResourceKey<World> resourcekey = worldserver1.getDimensionKey();
|
||||||
|
+ ResourceKey<DimensionManager> resourcekey = worldserver1.getTypeKey(); // CraftBukkit
|
||||||
|
|
||||||
if (resourcekey == World.THE_END && worldserver.getDimensionKey() == World.OVERWORLD) {
|
- if (resourcekey == World.THE_END && worldserver.getDimensionKey() == World.OVERWORLD) {
|
||||||
|
+ if (resourcekey == DimensionManager.THE_END && worldserver.getTypeKey() == DimensionManager.OVERWORLD) { // CraftBukkit
|
||||||
+ this.worldChangeInvuln = true; // CraftBukkit - Moved down from above
|
+ this.worldChangeInvuln = true; // CraftBukkit - Moved down from above
|
||||||
this.decouple();
|
this.decouple();
|
||||||
this.getWorldServer().removePlayer(this);
|
this.getWorldServer().removePlayer(this);
|
||||||
|
@ -397,14 +399,25 @@
|
||||||
double d0 = this.locX();
|
double d0 = this.locX();
|
||||||
double d1 = this.locY();
|
double d1 = this.locY();
|
||||||
double d2 = this.locZ();
|
double d2 = this.locZ();
|
||||||
@@ -567,6 +777,7 @@
|
@@ -567,7 +777,8 @@
|
||||||
worldserver1.getMethodProfiler().enter("moving");
|
worldserver1.getMethodProfiler().enter("moving");
|
||||||
double d3;
|
double d3;
|
||||||
|
|
||||||
|
- if (worldserver.getDimensionKey() == World.THE_END) {
|
||||||
+ if (worldserver == null) { } else // CraftBukkit - empty to fall through to null to event
|
+ if (worldserver == null) { } else // CraftBukkit - empty to fall through to null to event
|
||||||
if (worldserver.getDimensionKey() == World.THE_END) {
|
+ if (worldserver.getTypeKey() == DimensionManager.THE_END) { // CraftBukkit
|
||||||
BlockPosition blockposition = WorldServer.a;
|
BlockPosition blockposition = WorldServer.a;
|
||||||
|
|
||||||
|
d0 = (double) blockposition.getX();
|
||||||
|
@@ -576,7 +787,7 @@
|
||||||
|
f1 = 90.0F;
|
||||||
|
f = 0.0F;
|
||||||
|
} else {
|
||||||
|
- if (resourcekey == World.OVERWORLD && worldserver.getDimensionKey() == World.THE_NETHER) {
|
||||||
|
+ if (resourcekey == DimensionManager.OVERWORLD && worldserver.getTypeKey() == DimensionManager.THE_NETHER) { // CraftBukkit
|
||||||
|
this.cp = this.getPositionVector();
|
||||||
|
}
|
||||||
|
|
||||||
@@ -593,7 +804,26 @@
|
@@ -593,7 +804,26 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -413,7 +426,7 @@
|
||||||
+ // CraftBukkit start
|
+ // CraftBukkit start
|
||||||
+ Location enter = this.getBukkitEntity().getLocation();
|
+ Location enter = this.getBukkitEntity().getLocation();
|
||||||
+ Location exit = (worldserver == null) ? null : new Location(worldserver.getWorld(), d0, d1, d2, f1, f);
|
+ Location exit = (worldserver == null) ? null : new Location(worldserver.getWorld(), d0, d1, d2, f1, f);
|
||||||
+ PlayerPortalEvent event = new PlayerPortalEvent(this.getBukkitEntity(), enter, exit, cause, 128, true, resourcekey == World.THE_END ? 0 : 16);
|
+ PlayerPortalEvent event = new PlayerPortalEvent(this.getBukkitEntity(), enter, exit, cause, 128, true, resourcekey == DimensionManager.THE_END ? 0 : 16);
|
||||||
+ Bukkit.getServer().getPluginManager().callEvent(event);
|
+ Bukkit.getServer().getPluginManager().callEvent(event);
|
||||||
+ if (event.isCancelled() || event.getTo() == null) {
|
+ if (event.isCancelled() || event.getTo() == null) {
|
||||||
+ return null;
|
+ return null;
|
||||||
|
@ -438,11 +451,7 @@
|
||||||
d0 = MathHelper.a(d0, d4, d5);
|
d0 = MathHelper.a(d0, d4, d5);
|
||||||
d2 = MathHelper.a(d2, d3, d6);
|
d2 = MathHelper.a(d2, d3, d6);
|
||||||
- this.setPositionRotation(d0, d1, d2, f1, f);
|
- this.setPositionRotation(d0, d1, d2, f1, f);
|
||||||
+ // this.setPositionRotation(d0, d1, d2, f1, f); // CraftBukkit - PlayerTeleportEvent handles position changes
|
- if (worldserver.getDimensionKey() == World.THE_END) {
|
||||||
+ // CraftBukkit start - PlayerPortalEvent implementation
|
|
||||||
+ Vec3D exitVelocity = Vec3D.a;
|
|
||||||
+ BlockPosition exitPosition = new BlockPosition(d0, d1, d2);
|
|
||||||
if (worldserver.getDimensionKey() == World.THE_END) {
|
|
||||||
- int i = MathHelper.floor(this.locX());
|
- int i = MathHelper.floor(this.locX());
|
||||||
- int j = MathHelper.floor(this.locY()) - 1;
|
- int j = MathHelper.floor(this.locY()) - 1;
|
||||||
- int k = MathHelper.floor(this.locZ());
|
- int k = MathHelper.floor(this.locZ());
|
||||||
|
@ -453,6 +462,11 @@
|
||||||
- } else if (!worldserver.getTravelAgent().findAndTeleport(this, f2)) {
|
- } else if (!worldserver.getTravelAgent().findAndTeleport(this, f2)) {
|
||||||
- worldserver.getTravelAgent().createPortal(this);
|
- worldserver.getTravelAgent().createPortal(this);
|
||||||
- worldserver.getTravelAgent().findAndTeleport(this, f2);
|
- worldserver.getTravelAgent().findAndTeleport(this, f2);
|
||||||
|
+ // this.setPositionRotation(d0, d1, d2, f1, f); // CraftBukkit - PlayerTeleportEvent handles position changes
|
||||||
|
+ // CraftBukkit start - PlayerPortalEvent implementation
|
||||||
|
+ Vec3D exitVelocity = Vec3D.a;
|
||||||
|
+ BlockPosition exitPosition = new BlockPosition(d0, d1, d2);
|
||||||
|
+ if (worldserver.getTypeKey() == DimensionManager.THE_END) { // CraftBukkit
|
||||||
+ int i = exitPosition.getX();
|
+ int i = exitPosition.getX();
|
||||||
+ int j = exitPosition.getY() - 1;
|
+ int j = exitPosition.getY() - 1;
|
||||||
+ int k = exitPosition.getZ();
|
+ int k = exitPosition.getZ();
|
||||||
|
|
Loading…
Reference in a new issue