mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-30 16:19:03 +01:00
Add configurable portal search radius
This commit is contained in:
parent
eaf365a7b7
commit
1f86344458
2 changed files with 17 additions and 9 deletions
|
@ -48,7 +48,7 @@
|
|||
entity.setAsInsidePortal(this, pos);
|
||||
}
|
||||
|
||||
@@ -121,51 +133,66 @@
|
||||
@@ -121,51 +133,72 @@
|
||||
@Nullable
|
||||
@Override
|
||||
public TeleportTransition getPortalDestination(ServerLevel world, Entity entity, BlockPos pos) {
|
||||
|
@ -67,8 +67,14 @@
|
|||
WorldBorder worldborder = worldserver1.getWorldBorder();
|
||||
double d0 = DimensionType.getTeleportationScale(world.dimensionType(), worldserver1.dimensionType());
|
||||
BlockPos blockposition1 = worldborder.clampToBounds(entity.getX() * d0, entity.getY(), entity.getZ() * d0);
|
||||
+ // Paper start - Configurable portal search radius
|
||||
+ int portalSearchRadius = worldserver1.paperConfig().environment.portalSearchRadius;
|
||||
+ if (entity.level().paperConfig().environment.portalSearchVanillaDimensionScaling && flag) { // flag = is going to nether
|
||||
+ portalSearchRadius = (int) (portalSearchRadius / worldserver1.dimensionType().coordinateScale());
|
||||
+ }
|
||||
+ // Paper end - Configurable portal search radius
|
||||
+ // CraftBukkit start
|
||||
+ CraftPortalEvent event = entity.callPortalEvent(entity, CraftLocation.toBukkit(blockposition1, worldserver1.getWorld()), PlayerTeleportEvent.TeleportCause.NETHER_PORTAL, flag ? 16 : 128, 16);
|
||||
+ CraftPortalEvent event = entity.callPortalEvent(entity, CraftLocation.toBukkit(blockposition1, worldserver1.getWorld()), PlayerTeleportEvent.TeleportCause.NETHER_PORTAL, portalSearchRadius, worldserver1.paperConfig().environment.portalCreateRadius); // Paper - use custom portal search radius
|
||||
+ if (event == null) {
|
||||
+ return null;
|
||||
+ }
|
||||
|
@ -128,7 +134,7 @@
|
|||
}
|
||||
|
||||
private static TeleportTransition getDimensionTransitionFromExit(Entity entity, BlockPos pos, BlockUtil.FoundRectangle exitPortalRectangle, ServerLevel world, TeleportTransition.PostTeleportTransition postDimensionTransition) {
|
||||
@@ -203,7 +230,7 @@
|
||||
@@ -203,7 +236,7 @@
|
||||
Vec3 vec3d1 = new Vec3((double) blockposition.getX() + (flag ? d2 : d4), (double) blockposition.getY() + d3, (double) blockposition.getZ() + (flag ? d4 : d2));
|
||||
Vec3 vec3d2 = PortalShape.findCollisionFreePosition(vec3d1, world, entity, entitysize);
|
||||
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
--- a/net/minecraft/world/level/portal/PortalForcer.java
|
||||
+++ b/net/minecraft/world/level/portal/PortalForcer.java
|
||||
@@ -43,33 +43,50 @@
|
||||
@@ -42,34 +42,52 @@
|
||||
this.level = world;
|
||||
}
|
||||
|
||||
+ @io.papermc.paper.annotation.DoNotUse // Paper
|
||||
public Optional<BlockPos> findClosestPortalPosition(BlockPos pos, boolean destIsNether, WorldBorder worldBorder) {
|
||||
+ // CraftBukkit start
|
||||
+ return this.findClosestPortalPosition(pos, worldBorder, destIsNether ? 16 : 128); // Search Radius
|
||||
|
@ -62,7 +64,7 @@
|
|||
|
||||
int j;
|
||||
int k;
|
||||
@@ -95,7 +112,7 @@
|
||||
@@ -95,7 +113,7 @@
|
||||
if (i1 <= 0 || i1 >= 3) {
|
||||
blockposition_mutableblockposition1.setY(k);
|
||||
if (this.canHostFrame(blockposition_mutableblockposition1, blockposition_mutableblockposition, enumdirection, 0)) {
|
||||
|
@ -71,7 +73,7 @@
|
|||
|
||||
if (this.canHostFrame(blockposition_mutableblockposition1, blockposition_mutableblockposition, enumdirection, -1) && this.canHostFrame(blockposition_mutableblockposition1, blockposition_mutableblockposition, enumdirection, 1) && (d0 == -1.0D || d0 > d2)) {
|
||||
d0 = d2;
|
||||
@@ -122,6 +139,7 @@
|
||||
@@ -122,6 +140,7 @@
|
||||
int j1;
|
||||
int k1;
|
||||
|
||||
|
@ -79,7 +81,7 @@
|
|||
if (d0 == -1.0D) {
|
||||
j1 = Math.max(this.level.getMinY() - -1, 70);
|
||||
k1 = i - 9;
|
||||
@@ -129,7 +147,7 @@
|
||||
@@ -129,7 +148,7 @@
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
|
@ -88,7 +90,7 @@
|
|||
blockposition1 = worldborder.clampToBounds(blockposition1);
|
||||
Direction enumdirection1 = enumdirection.getClockWise();
|
||||
|
||||
@@ -139,7 +157,7 @@
|
||||
@@ -139,7 +158,7 @@
|
||||
BlockState iblockdata = i1 < 0 ? Blocks.OBSIDIAN.defaultBlockState() : Blocks.AIR.defaultBlockState();
|
||||
|
||||
blockposition_mutableblockposition.setWithOffset(blockposition1, l * enumdirection.getStepX() + k * enumdirection1.getStepX(), i1, l * enumdirection.getStepZ() + k * enumdirection1.getStepZ());
|
||||
|
@ -97,7 +99,7 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
@@ -149,20 +167,30 @@
|
||||
@@ -149,20 +168,30 @@
|
||||
for (k1 = -1; k1 < 4; ++k1) {
|
||||
if (j1 == -1 || j1 == 2 || k1 == -1 || k1 == 3) {
|
||||
blockposition_mutableblockposition.setWithOffset(blockposition1, j1 * enumdirection.getStepX(), k1, j1 * enumdirection.getStepZ());
|
||||
|
|
Loading…
Reference in a new issue