From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Joseph Hirschfeld Date: Thu, 3 Mar 2016 02:46:17 -0600 Subject: [PATCH] Add configurable portal search radius diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java index 416a6760883cb40367535c7c5acd779742bb8af5..670efbe53241a0ae32d618c83da601ccc1f26e37 100644 --- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java +++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java @@ -196,4 +196,13 @@ public class PaperWorldConfig { private void allChunksAreSlimeChunks() { allChunksAreSlimeChunks = getBoolean("all-chunks-are-slime-chunks", false); } + + public int portalSearchRadius; + public int portalCreateRadius; + public boolean portalSearchVanillaDimensionScaling; + private void portalSearchRadius() { + portalSearchRadius = getInt("portal-search-radius", 128); + portalCreateRadius = getInt("portal-create-radius", 16); + portalSearchVanillaDimensionScaling = getBoolean("portal-search-vanilla-dimension-scaling", true); + } } diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java index 1a3b67fba88c6cea96a08f8d3085a6fb342ada48..db2933ed070a75bf4f46e37b52a8dbb7e9afb364 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java @@ -2901,7 +2901,13 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, n double d4 = DimensionType.getTeleportationScale(this.level.dimensionType(), destination.dimensionType()); BlockPos blockposition = new BlockPos(Mth.clamp(this.getX() * d4, d0, d2), this.getY(), Mth.clamp(this.getZ() * d4, d1, d3)); // CraftBukkit start - CraftPortalEvent event = this.callPortalEvent(this, destination, blockposition, PlayerTeleportEvent.TeleportCause.NETHER_PORTAL, flag2 ? 16 : 128, 16); + // Paper start + int portalSearchRadius = destination.paperConfig.portalSearchRadius; + if (level.paperConfig.portalSearchVanillaDimensionScaling && flag2) { // == THE_NETHER + portalSearchRadius = (int) (portalSearchRadius / destination.dimensionType().coordinateScale()); + } + // Paper end + CraftPortalEvent event = this.callPortalEvent(this, destination, blockposition, PlayerTeleportEvent.TeleportCause.NETHER_PORTAL, portalSearchRadius, destination.paperConfig.portalCreateRadius); // Paper start - configurable portal radius if (event == null) { return null; } diff --git a/src/main/java/net/minecraft/world/level/portal/PortalForcer.java b/src/main/java/net/minecraft/world/level/portal/PortalForcer.java index 4d186a7d6ccf09092c5e1577e4b49e0975787980..d5ba2e679ed1858ea18e18feffce50544ae036c2 100644 --- a/src/main/java/net/minecraft/world/level/portal/PortalForcer.java +++ b/src/main/java/net/minecraft/world/level/portal/PortalForcer.java @@ -44,7 +44,7 @@ public class PortalForcer { public Optional findPortalAround(BlockPos destPos, boolean destIsNether) { // CraftBukkit start - return this.findPortal(destPos, destIsNether ? 16 : 128); // Search Radius + return this.findPortal(destPos, destIsNether ? level.paperConfig.portalCreateRadius : level.paperConfig.portalSearchRadius); // Search Radius // Paper - search Radius } public Optional findPortal(BlockPos blockposition, int i) {