Paper/nms-patches/TileEntityEndGateway.patch

61 Zeilen
3.5 KiB
Diff

--- a/net/minecraft/server/TileEntityEndGateway.java
+++ b/net/minecraft/server/TileEntityEndGateway.java
@@ -6,6 +6,12 @@
import javax.annotation.Nullable;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
+// CraftBukkit start
+import org.bukkit.Bukkit;
+import org.bukkit.Location;
+import org.bukkit.craftbukkit.entity.CraftPlayer;
+import org.bukkit.event.player.PlayerTeleportEvent;
+// CraftBukkit end
public class TileEntityEndGateway extends TileEntityEnderPortal implements ITickable {
@@ -138,6 +144,26 @@
entity1 = entity.getRootVehicle();
}
+ // CraftBukkit start - Fire PlayerTeleportEvent
+ if (entity1 instanceof EntityPlayer) {
+ org.bukkit.craftbukkit.entity.CraftPlayer player = (CraftPlayer) entity1.getBukkitEntity();
+ org.bukkit.Location location = new Location(world.getWorld(), (double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.5D, (double) blockposition.getZ() + 0.5D);
+ location.setPitch(player.getLocation().getPitch());
+ location.setYaw(player.getLocation().getYaw());
+
+ PlayerTeleportEvent teleEvent = new PlayerTeleportEvent(player, player.getLocation(), location, PlayerTeleportEvent.TeleportCause.END_GATEWAY);
+ Bukkit.getPluginManager().callEvent(teleEvent);
+ if (teleEvent.isCancelled()) {
+ return;
+ }
+
+ ((EntityPlayer) entity1).playerConnection.teleport(teleEvent.getTo());
+ this.h(); // CraftBukkit - call at end of method
+ return;
+
+ }
+ // CraftBukkit end
+
entity1.enderTeleportAndLoad((double) blockposition.getX() + 0.5D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.5D);
}
@@ -173,7 +199,7 @@
if (this.exitPortal == null) {
this.exitPortal = new BlockPosition(vec3d1.x + 0.5D, 75.0D, vec3d1.z + 0.5D);
TileEntityEndGateway.LOGGER.debug("Failed to find suitable block, settling on {}", this.exitPortal);
- WorldGenerator.END_ISLAND.b((WorldGenFeatureConfiguration) WorldGenFeatureConfiguration.k).a(worldserver, worldserver.getStructureManager(), worldserver.getChunkProvider().getChunkGenerator(), new Random(this.exitPortal.asLong()), this.exitPortal);
+ WorldGenerator.END_ISLAND.b(WorldGenFeatureConfiguration.k).a(worldserver, worldserver.getStructureManager(), worldserver.getChunkProvider().getChunkGenerator(), new Random(this.exitPortal.asLong()), this.exitPortal); // CraftBukkit - decompile error
} else {
TileEntityEndGateway.LOGGER.debug("Found block at {}", this.exitPortal);
}
@@ -241,7 +267,7 @@
}
private void a(WorldServer worldserver, BlockPosition blockposition) {
- WorldGenerator.END_GATEWAY.b((WorldGenFeatureConfiguration) WorldGenEndGatewayConfiguration.a(this.getPosition(), false)).a(worldserver, worldserver.getStructureManager(), worldserver.getChunkProvider().getChunkGenerator(), new Random(), blockposition);
+ WorldGenerator.END_GATEWAY.b(WorldGenEndGatewayConfiguration.a(this.getPosition(), false)).a(worldserver, worldserver.getStructureManager(), worldserver.getChunkProvider().getChunkGenerator(), new Random(), blockposition); // CraftBukkit - decompile error
}
public void a(BlockPosition blockposition, boolean flag) {