Fix entity teleportation exceptions

Dieser Commit ist enthalten in:
Shane Freeder 2020-01-14 09:14:12 +00:00
Ursprung bd0337b7a9
Commit 1d5bd44d13
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: A3F61EA5A085289C

Datei anzeigen

@ -0,0 +1,89 @@
From 11b5d09894304d6fc730dadb581b06196c71d704 Mon Sep 17 00:00:00 2001
From: Shane Freeder <theboyetronic@gmail.com>
Date: Tue, 14 Jan 2020 09:12:55 +0000
Subject: [PATCH] Fix entity teleportation exceptions
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
index 58e79df57..810a5edb6 100644
--- a/src/main/java/net/minecraft/server/Entity.java
+++ b/src/main/java/net/minecraft/server/Entity.java
@@ -2574,6 +2574,20 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
return teleportTo(dimensionmanager, null);
}
+ // Paper start
+ private EntityPortalEvent callEntityPortalEvent(WorldServer worldserver1, BlockPosition blockposition, int searchRadius) {
+ Location enter = this.getBukkitEntity().getLocation();
+ Location exit = new Location(worldserver1.getWorld(), blockposition.getX(), blockposition.getY(), blockposition.getZ());
+
+ EntityPortalEvent event = new EntityPortalEvent(this.getBukkitEntity(), enter, exit, searchRadius);
+ event.getEntity().getServer().getPluginManager().callEvent(event);
+ if (event.isCancelled() || event.getTo() == null || event.getTo().getWorld() == null || !this.isAlive()) {
+ return null;
+ }
+
+ return event;
+ }
+ // paper end
@Nullable
public Entity teleportTo(DimensionManager dimensionmanager, BlockPosition location) {
// CraftBukkit end
@@ -2599,7 +2613,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
// CraftBukkit start - EntityPortalEvent
// SPIGOT-5136 - don't fire event for CraftEntity.teleport
int searchRadius = world.paperConfig.portalSearchRadius; // Paper - use portal search radius as default
- if (location == null) {
+ if (location == null) { /* // Paper - move up
Location enter = this.getBukkitEntity().getLocation();
Location exit = new Location(worldserver1.getWorld(), blockposition.getX(), blockposition.getY(), blockposition.getZ());
@@ -2613,14 +2627,27 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
worldserver1 = ((CraftWorld) exit.getWorld()).getHandle();
blockposition = new BlockPosition(exit.getX(), exit.getY(), exit.getZ());
searchRadius = event.getSearchRadius();
- }
+ */} // Paper - move up
// CraftBukkit end
if (blockposition == null) { // CraftBukkit
+ ;
if (dimensionmanager1.getType() == DimensionManager.THE_END && dimensionmanager == DimensionManager.OVERWORLD) { // CraftBukkit
- blockposition = worldserver1.getHighestBlockYAt(HeightMap.Type.MOTION_BLOCKING_NO_LEAVES, worldserver1.getSpawn());
+ EntityPortalEvent portalEvent = callEntityPortalEvent(worldserver1, worldserver1.getHighestBlockYAt(HeightMap.Type.MOTION_BLOCKING_NO_LEAVES, worldserver1.getSpawn()), 1); // Paper - EntityPortalEvent - hardcode 1, no search here
+ // Paper start
+ if (portalEvent == null) return null;
+ Location exit = portalEvent.getTo();
+ worldserver1 = ((CraftWorld) exit.getWorld()).getHandle();
+ blockposition = new BlockPosition(exit.getX(), exit.getY(), exit.getZ());
+ //Paper end
} else if (dimensionmanager.getType() == DimensionManager.THE_END) { // CraftBukkit
- blockposition = worldserver1.getDimensionSpawn();
+ EntityPortalEvent portalEvent = callEntityPortalEvent(worldserver1, worldserver1.getDimensionSpawn(), 1); // Paper - EntityPortalEvent - hardcode 1, no search here
+ // Paper start
+ if (portalEvent == null) return null;
+ Location exit = portalEvent.getTo();
+ worldserver1 = ((CraftWorld) exit.getWorld()).getHandle();
+ blockposition = new BlockPosition(exit.getX(), exit.getY(), exit.getZ());
+ //Paper end
} else {
double d0 = this.locX();
double d1 = this.locZ();
@@ -2644,6 +2671,14 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
Vec3D vec3d1 = this.getPortalOffset();
blockposition = new BlockPosition(d0, this.locY(), d1);
+ // Paper start - EntityPortalEvent
+ EntityPortalEvent portalEvent = callEntityPortalEvent(worldserver1, blockposition, searchRadius);
+ if (portalEvent == null) return null;
+ Location exit = portalEvent.getTo();
+ worldserver1 = ((CraftWorld) exit.getWorld()).getHandle();
+ blockposition = new BlockPosition(exit.getX(), exit.getY(), exit.getZ());
+ searchRadius = portalEvent.getSearchRadius();
+ // Paper end
ShapeDetector.Shape shapedetector_shape = worldserver1.getTravelAgent().findPortal(blockposition, vec3d, this.getPortalDirection(), vec3d1.x, vec3d1.y, this instanceof EntityHuman, searchRadius); // CraftBukkit - search radius
if (shapedetector_shape == null) {
--
2.24.1