diff --git a/paper-server/patches/sources/net/minecraft/world/level/portal/PortalForcer.java.patch b/paper-server/patches/sources/net/minecraft/world/level/portal/PortalForcer.java.patch new file mode 100644 index 0000000000..76fbe68029 --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/level/portal/PortalForcer.java.patch @@ -0,0 +1,115 @@ +--- a/net/minecraft/world/level/portal/PortalForcer.java ++++ b/net/minecraft/world/level/portal/PortalForcer.java +@@ -38,18 +_,32 @@ + this.level = level; + } + ++ @io.papermc.paper.annotation.DoNotUse // Paper + public Optional findClosestPortalPosition(BlockPos exitPos, boolean isNether, WorldBorder worldBorder) { ++ // CraftBukkit start ++ return this.findClosestPortalPosition(exitPos, worldBorder, isNether ? 16 : 128); // Search Radius ++ } ++ ++ public Optional findClosestPortalPosition(BlockPos exitPos, WorldBorder worldBorder, int i) { + PoiManager poiManager = this.level.getPoiManager(); +- int i = isNether ? 16 : 128; ++ // int i = isNether ? 16 : 128; ++ // CraftBukkit end + poiManager.ensureLoadedAndValid(this.level, exitPos, i); + return poiManager.getInSquare(holder -> holder.is(PoiTypes.NETHER_PORTAL), exitPos, i, PoiManager.Occupancy.ANY) + .map(PoiRecord::getPos) + .filter(worldBorder::isWithinBounds) ++ .filter(pos -> !(this.level.getTypeKey() == net.minecraft.world.level.dimension.LevelStem.NETHER && this.level.paperConfig().environment.netherCeilingVoidDamageHeight.test(v -> pos.getY() >= v))) // Paper - Configurable nether ceiling damage + .filter(blockPos -> this.level.getBlockState(blockPos).hasProperty(BlockStateProperties.HORIZONTAL_AXIS)) + .min(Comparator.comparingDouble(blockPos -> blockPos.distSqr(exitPos)).thenComparingInt(Vec3i::getY)); + } + + public Optional createPortal(BlockPos pos, Direction.Axis axis) { ++ // CraftBukkit start ++ return this.createPortal(pos, axis, null, 16); ++ } ++ ++ public Optional createPortal(BlockPos pos, Direction.Axis axis, net.minecraft.world.entity.Entity entity, int createRadius) { ++ // CraftBukkit end + Direction direction = Direction.get(Direction.AxisDirection.POSITIVE, axis); + double d = -1.0; + BlockPos blockPos = null; +@@ -57,10 +_,15 @@ + BlockPos blockPos1 = null; + WorldBorder worldBorder = this.level.getWorldBorder(); + int min = Math.min(this.level.getMaxY(), this.level.getMinY() + this.level.getLogicalHeight() - 1); ++ // Paper start - Configurable nether ceiling damage; make sure the max height doesn't exceed the void damage height ++ if (this.level.getTypeKey() == net.minecraft.world.level.dimension.LevelStem.NETHER && this.level.paperConfig().environment.netherCeilingVoidDamageHeight.enabled()) { ++ min = Math.min(min, this.level.paperConfig().environment.netherCeilingVoidDamageHeight.intValue() - 1); ++ } ++ // Paper end - Configurable nether ceiling damage + int i = 1; + BlockPos.MutableBlockPos mutableBlockPos = pos.mutable(); + +- for (BlockPos.MutableBlockPos mutableBlockPos1 : BlockPos.spiralAround(pos, 16, Direction.EAST, Direction.SOUTH)) { ++ for (BlockPos.MutableBlockPos mutableBlockPos1 : BlockPos.spiralAround(pos, createRadius, Direction.EAST, Direction.SOUTH)) { // CraftBukkit + int min1 = Math.min(min, this.level.getHeight(Heightmap.Types.MOTION_BLOCKING, mutableBlockPos1.getX(), mutableBlockPos1.getZ())); + if (worldBorder.isWithinBounds(mutableBlockPos1) && worldBorder.isWithinBounds(mutableBlockPos1.move(direction, 1))) { + mutableBlockPos1.move(direction.getOpposite(), 1); +@@ -104,6 +_,7 @@ + d = d1; + } + ++ org.bukkit.craftbukkit.util.BlockStateListPopulator blockList = new org.bukkit.craftbukkit.util.BlockStateListPopulator(this.level); // CraftBukkit - Use BlockStateListPopulator + if (d == -1.0) { + int max = Math.max(this.level.getMinY() - -1, 70); + int i4 = min - 9; +@@ -122,7 +_,7 @@ + mutableBlockPos.setWithOffset( + blockPos, i2 * direction.getStepX() + i1x * clockWise.getStepX(), i3, i2 * direction.getStepZ() + i1x * clockWise.getStepZ() + ); +- this.level.setBlockAndUpdate(mutableBlockPos, blockState); ++ blockList.setBlock(mutableBlockPos, blockState, 3); // CraftBukkit + } + } + } +@@ -132,7 +_,7 @@ + for (int i4 = -1; i4 < 4; i4++) { + if (max == -1 || max == 2 || i4 == -1 || i4 == 3) { + mutableBlockPos.setWithOffset(blockPos, max * direction.getStepX(), i4, max * direction.getStepZ()); +- this.level.setBlock(mutableBlockPos, Blocks.OBSIDIAN.defaultBlockState(), 3); ++ blockList.setBlock(mutableBlockPos, Blocks.OBSIDIAN.defaultBlockState(), 3); // CraftBukkit + } + } + } +@@ -142,10 +_,20 @@ + for (int i4x = 0; i4x < 2; i4x++) { + for (int min1 = 0; min1 < 3; min1++) { + mutableBlockPos.setWithOffset(blockPos, i4x * direction.getStepX(), min1, i4x * direction.getStepZ()); +- this.level.setBlock(mutableBlockPos, blockState1, 18); ++ blockList.setBlock(mutableBlockPos, blockState1, 18); // CraftBukkit + } + } + ++ // CraftBukkit start ++ org.bukkit.World bworld = this.level.getWorld(); ++ org.bukkit.event.world.PortalCreateEvent event = new org.bukkit.event.world.PortalCreateEvent((java.util.List) (java.util.List) blockList.getList(), bworld, (entity == null) ? null : entity.getBukkitEntity(), org.bukkit.event.world.PortalCreateEvent.CreateReason.NETHER_PAIR); ++ ++ this.level.getCraftServer().getPluginManager().callEvent(event); ++ if (event.isCancelled()) { ++ return Optional.empty(); ++ } ++ blockList.updateList(); ++ // CraftBukkit end + return Optional.of(new BlockUtil.FoundRectangle(blockPos.immutable(), 2, 3)); + } + +@@ -165,6 +_,13 @@ + i1, + direction.getStepZ() * i + clockWise.getStepZ() * offsetScale + ); ++ // Paper start - Protect Bedrock and End Portal/Frames from being destroyed ++ if (!io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.allowPermanentBlockBreakExploits) { ++ if (!this.level.getBlockState(offsetPos).isDestroyable()) { ++ return false; ++ } ++ } ++ // Paper end - Protect Bedrock and End Portal/Frames from being destroyed + if (i1 < 0 && !this.level.getBlockState(offsetPos).isSolid()) { + return false; + } diff --git a/paper-server/patches/sources/net/minecraft/world/level/portal/PortalShape.java.patch b/paper-server/patches/sources/net/minecraft/world/level/portal/PortalShape.java.patch new file mode 100644 index 0000000000..d92f339f46 --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/level/portal/PortalShape.java.patch @@ -0,0 +1,154 @@ +--- a/net/minecraft/world/level/portal/PortalShape.java ++++ b/net/minecraft/world/level/portal/PortalShape.java +@@ -37,8 +_,12 @@ + private final BlockPos bottomLeft; + private final int height; + private final int width; ++ // CraftBukkit start - add field ++ private final org.bukkit.craftbukkit.util.BlockStateListPopulator blocks; + +- private PortalShape(Direction.Axis axis, int numPortalBlocks, Direction rightDir, BlockPos bottomLeft, int width, int height) { ++ private PortalShape(Direction.Axis axis, int numPortalBlocks, Direction rightDir, BlockPos bottomLeft, int width, int height, org.bukkit.craftbukkit.util.BlockStateListPopulator blocks) { ++ this.blocks = blocks; ++ // CraftBukkit end + this.axis = axis; + this.numPortalBlocks = numPortalBlocks; + this.rightDir = rightDir; +@@ -62,24 +_,25 @@ + } + + public static PortalShape findAnyShape(BlockGetter level, BlockPos bottomLeft, Direction.Axis axis) { ++ org.bukkit.craftbukkit.util.BlockStateListPopulator blocks = new org.bukkit.craftbukkit.util.BlockStateListPopulator(((LevelAccessor) level).getMinecraftWorld()); // CraftBukkit + Direction direction = axis == Direction.Axis.X ? Direction.WEST : Direction.SOUTH; +- BlockPos blockPos = calculateBottomLeft(level, direction, bottomLeft); ++ BlockPos blockPos = calculateBottomLeft(level, direction, bottomLeft, blocks); // CraftBukkit + if (blockPos == null) { +- return new PortalShape(axis, 0, direction, bottomLeft, 0, 0); ++ return new PortalShape(axis, 0, direction, bottomLeft, 0, 0, blocks); // CraftBukkit + } else { +- int i = calculateWidth(level, blockPos, direction); ++ int i = calculateWidth(level, blockPos, direction, blocks); // CraftBukkit + if (i == 0) { +- return new PortalShape(axis, 0, direction, blockPos, 0, 0); ++ return new PortalShape(axis, 0, direction, blockPos, 0, 0, blocks); // CraftBukkit + } else { + MutableInt mutableInt = new MutableInt(); +- int i1 = calculateHeight(level, blockPos, direction, i, mutableInt); +- return new PortalShape(axis, mutableInt.getValue(), direction, blockPos, i, i1); ++ int i1 = calculateHeight(level, blockPos, direction, i, mutableInt, blocks); // CraftBukkit ++ return new PortalShape(axis, mutableInt.getValue(), direction, blockPos, i, i1, blocks); // CraftBukkit + } + } + } + + @Nullable +- private static BlockPos calculateBottomLeft(BlockGetter level, Direction direction, BlockPos pos) { ++ private static BlockPos calculateBottomLeft(BlockGetter level, Direction direction, BlockPos pos, org.bukkit.craftbukkit.util.BlockStateListPopulator blocks) { // CraftBukkit + int max = Math.max(level.getMinY(), pos.getY() - 21); + + while (pos.getY() > max && isEmpty(level.getBlockState(pos.below()))) { +@@ -87,16 +_,16 @@ + } + + Direction opposite = direction.getOpposite(); +- int i = getDistanceUntilEdgeAboveFrame(level, pos, opposite) - 1; ++ int i = getDistanceUntilEdgeAboveFrame(level, pos, opposite, blocks) - 1; // CraftBukkit + return i < 0 ? null : pos.relative(opposite, i); + } + +- private static int calculateWidth(BlockGetter level, BlockPos bottomLeft, Direction direction) { +- int distanceUntilEdgeAboveFrame = getDistanceUntilEdgeAboveFrame(level, bottomLeft, direction); ++ private static int calculateWidth(BlockGetter level, BlockPos bottomLeft, Direction direction, org.bukkit.craftbukkit.util.BlockStateListPopulator blocks) { // CraftBukkit ++ int distanceUntilEdgeAboveFrame = getDistanceUntilEdgeAboveFrame(level, bottomLeft, direction, blocks); // CraftBukkit + return distanceUntilEdgeAboveFrame >= 2 && distanceUntilEdgeAboveFrame <= 21 ? distanceUntilEdgeAboveFrame : 0; + } + +- private static int getDistanceUntilEdgeAboveFrame(BlockGetter level, BlockPos pos, Direction direction) { ++ private static int getDistanceUntilEdgeAboveFrame(BlockGetter level, BlockPos pos, Direction direction, org.bukkit.craftbukkit.util.BlockStateListPopulator blocks) { // CraftBukkit + BlockPos.MutableBlockPos mutableBlockPos = new BlockPos.MutableBlockPos(); + + for (int i = 0; i <= 21; i++) { +@@ -104,6 +_,7 @@ + BlockState blockState = level.getBlockState(mutableBlockPos); + if (!isEmpty(blockState)) { + if (FRAME.test(blockState, level, mutableBlockPos)) { ++ blocks.setBlock(mutableBlockPos, blockState, 18); // CraftBukkit - lower left / right + return i; + } + break; +@@ -113,32 +_,34 @@ + if (!FRAME.test(blockState1, level, mutableBlockPos)) { + break; + } ++ blocks.setBlock(mutableBlockPos, blockState1, 18); // CraftBukkit - bottom row + } + + return 0; + } + +- private static int calculateHeight(BlockGetter level, BlockPos pos, Direction direction, int width, MutableInt portalBlocks) { ++ private static int calculateHeight(BlockGetter level, BlockPos pos, Direction direction, int width, MutableInt portalBlocks, org.bukkit.craftbukkit.util.BlockStateListPopulator blocks) { // CraftBukkit + BlockPos.MutableBlockPos mutableBlockPos = new BlockPos.MutableBlockPos(); +- int distanceUntilTop = getDistanceUntilTop(level, pos, direction, mutableBlockPos, width, portalBlocks); +- return distanceUntilTop >= 3 && distanceUntilTop <= 21 && hasTopFrame(level, pos, direction, mutableBlockPos, width, distanceUntilTop) ++ int distanceUntilTop = getDistanceUntilTop(level, pos, direction, mutableBlockPos, width, portalBlocks, blocks); // CraftBukkit ++ return distanceUntilTop >= 3 && distanceUntilTop <= 21 && hasTopFrame(level, pos, direction, mutableBlockPos, width, distanceUntilTop, blocks) // CraftBukkit + ? distanceUntilTop + : 0; + } + +- private static boolean hasTopFrame(BlockGetter level, BlockPos pos, Direction direction, BlockPos.MutableBlockPos checkPos, int width, int distanceUntilTop) { ++ private static boolean hasTopFrame(BlockGetter level, BlockPos pos, Direction direction, BlockPos.MutableBlockPos checkPos, int width, int distanceUntilTop, org.bukkit.craftbukkit.util.BlockStateListPopulator blocks) { // CraftBukkit + for (int i = 0; i < width; i++) { + BlockPos.MutableBlockPos mutableBlockPos = checkPos.set(pos).move(Direction.UP, distanceUntilTop).move(direction, i); + if (!FRAME.test(level.getBlockState(mutableBlockPos), level, mutableBlockPos)) { + return false; + } ++ blocks.setBlock(mutableBlockPos, level.getBlockState(mutableBlockPos), 18); // CraftBukkit - upper row + } + + return true; + } + + private static int getDistanceUntilTop( +- BlockGetter level, BlockPos pos, Direction direction, BlockPos.MutableBlockPos checkPos, int width, MutableInt portalBlocks ++ BlockGetter level, BlockPos pos, Direction direction, BlockPos.MutableBlockPos checkPos, int width, MutableInt portalBlocks, org.bukkit.craftbukkit.util.BlockStateListPopulator blocks // CraftBukkit + ) { + for (int i = 0; i < 21; i++) { + checkPos.set(pos).move(Direction.UP, i).move(direction, -1); +@@ -162,6 +_,10 @@ + portalBlocks.increment(); + } + } ++ // CraftBukkit start - left and right ++ blocks.setBlock(checkPos.set(pos).move(Direction.UP, i).move(direction, -1), level.getBlockState(checkPos), 18); ++ blocks.setBlock(checkPos.set(pos).move(Direction.UP, i).move(direction, i), level.getBlockState(checkPos), 18); ++ // CraftBukkit end + } + + return 21; +@@ -175,10 +_,23 @@ + return this.width >= 2 && this.width <= 21 && this.height >= 3 && this.height <= 21; + } + +- public void createPortalBlocks(LevelAccessor level) { ++ // CraftBukkit start - return boolean, add entity ++ public boolean createPortalBlocks(LevelAccessor level, Entity entity) { ++ org.bukkit.World bworld = level.getMinecraftWorld().getWorld(); ++ // Copy below for loop + BlockState blockState = Blocks.NETHER_PORTAL.defaultBlockState().setValue(NetherPortalBlock.AXIS, this.axis); + BlockPos.betweenClosed(this.bottomLeft, this.bottomLeft.relative(Direction.UP, this.height - 1).relative(this.rightDir, this.width - 1)) ++ .forEach(pos -> this.blocks.setBlock(pos, blockState, 18)); ++ org.bukkit.event.world.PortalCreateEvent event = new org.bukkit.event.world.PortalCreateEvent((java.util.List) (java.util.List) this.blocks.getList(), bworld, (entity == null) ? null : entity.getBukkitEntity(), org.bukkit.event.world.PortalCreateEvent.CreateReason.FIRE); ++ level.getMinecraftWorld().getServer().server.getPluginManager().callEvent(event); ++ ++ if (event.isCancelled()) { ++ return false; ++ } ++ // CraftBukkit end ++ BlockPos.betweenClosed(this.bottomLeft, this.bottomLeft.relative(Direction.UP, this.height - 1).relative(this.rightDir, this.width - 1)) + .forEach(pos -> level.setBlock(pos, blockState, 18)); ++ return true; // CraftBukkit + } + + public boolean isComplete() { diff --git a/paper-server/patches/sources/net/minecraft/world/level/portal/TeleportTransition.java.patch b/paper-server/patches/sources/net/minecraft/world/level/portal/TeleportTransition.java.patch new file mode 100644 index 0000000000..b65e02e918 --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/level/portal/TeleportTransition.java.patch @@ -0,0 +1,80 @@ +--- a/net/minecraft/world/level/portal/TeleportTransition.java ++++ b/net/minecraft/world/level/portal/TeleportTransition.java +@@ -19,15 +_,34 @@ + boolean asPassenger, + Set relatives, + TeleportTransition.PostTeleportTransition postTeleportTransition ++ , org.bukkit.event.player.PlayerTeleportEvent.TeleportCause cause // CraftBukkit + ) { + public static final TeleportTransition.PostTeleportTransition DO_NOTHING = entity -> {}; + public static final TeleportTransition.PostTeleportTransition PLAY_PORTAL_SOUND = TeleportTransition::playPortalSound; + public static final TeleportTransition.PostTeleportTransition PLACE_PORTAL_TICKET = TeleportTransition::placePortalTicket; + ++ // CraftBukkit start ++ public TeleportTransition(ServerLevel newLevel, Vec3 position, Vec3 deltaMovement, float yRot, float xRot, boolean missingRespawnBlock, boolean asPassenger, Set relatives, TeleportTransition.PostTeleportTransition postTeleportTransition) { ++ this(newLevel, position, deltaMovement, yRot, xRot, missingRespawnBlock, asPassenger, relatives, postTeleportTransition, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.UNKNOWN); ++ } ++ ++ public TeleportTransition(org.bukkit.event.player.PlayerTeleportEvent.TeleportCause cause) { ++ this(null, Vec3.ZERO, Vec3.ZERO, 0.0F, 0.0F, false, false, Set.of(), DO_NOTHING, cause); ++ } ++ // CraftBukkit end ++ + public TeleportTransition( + ServerLevel newLevel, Vec3 position, Vec3 deltaMovement, float yRot, float xRot, TeleportTransition.PostTeleportTransition postTeleportTransition + ) { +- this(newLevel, position, deltaMovement, yRot, xRot, Set.of(), postTeleportTransition); ++ // CraftBukkit start ++ this(newLevel, position, deltaMovement, yRot, xRot, postTeleportTransition, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.UNKNOWN); ++ } ++ ++ public TeleportTransition( ++ ServerLevel newLevel, Vec3 position, Vec3 deltaMovement, float yRot, float xRot, TeleportTransition.PostTeleportTransition postTeleportTransition, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause cause ++ ) { ++ this(newLevel, position, deltaMovement, yRot, xRot, Set.of(), postTeleportTransition, cause); ++ // CraftBukkit end + } + + public TeleportTransition( +@@ -39,11 +_,30 @@ + Set relatives, + TeleportTransition.PostTeleportTransition postTeleportTransition + ) { +- this(newLevel, position, deltaMovement, yRot, xRot, false, false, relatives, postTeleportTransition); ++ // CraftBukkit start ++ this(newLevel, position, deltaMovement, yRot, xRot, relatives, postTeleportTransition, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.UNKNOWN); ++ } ++ public TeleportTransition( ++ ServerLevel newLevel, ++ Vec3 position, ++ Vec3 deltaMovement, ++ float yRot, ++ float xRot, ++ Set relatives, ++ TeleportTransition.PostTeleportTransition postTeleportTransition, ++ org.bukkit.event.player.PlayerTeleportEvent.TeleportCause cause ++ ) { ++ this(newLevel, position, deltaMovement, yRot, xRot, false, false, relatives, postTeleportTransition, cause); ++ // CraftBukkit end + } + + public TeleportTransition(ServerLevel level, Entity entity, TeleportTransition.PostTeleportTransition postTeleportTransition) { +- this(level, findAdjustedSharedSpawnPos(level, entity), Vec3.ZERO, 0.0F, 0.0F, false, false, Set.of(), postTeleportTransition); ++ // CraftBukkit start ++ this(level, entity, postTeleportTransition, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.UNKNOWN); ++ } ++ public TeleportTransition(ServerLevel level, Entity entity, TeleportTransition.PostTeleportTransition postTeleportTransition, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause cause) { ++ this(level, findAdjustedSharedSpawnPos(level, entity), Vec3.ZERO, level.getSharedSpawnAngle(), 0.0F, false, false, Set.of(), postTeleportTransition, cause); // Paper - MC-200092 - fix first spawn pos yaw being ignored ++ // CraftBukkit end + } + + private static void playPortalSound(Entity entity) { +@@ -57,7 +_,7 @@ + } + + public static TeleportTransition missingRespawnBlock(ServerLevel level, Entity entity, TeleportTransition.PostTeleportTransition postTeleportTransition) { +- return new TeleportTransition(level, findAdjustedSharedSpawnPos(level, entity), Vec3.ZERO, 0.0F, 0.0F, true, false, Set.of(), postTeleportTransition); ++ return new TeleportTransition(level, findAdjustedSharedSpawnPos(level, entity), Vec3.ZERO, level.getSharedSpawnAngle(), 0.0F, true, false, Set.of(), postTeleportTransition); // Paper - MC-200092 - fix spawn pos yaw being ignored + } + + private static Vec3 findAdjustedSharedSpawnPos(ServerLevel level, Entity entity) { diff --git a/paper-server/patches/unapplied/net/minecraft/world/level/portal/PortalForcer.java.patch b/paper-server/patches/unapplied/net/minecraft/world/level/portal/PortalForcer.java.patch deleted file mode 100644 index 2bcc6db1ba..0000000000 --- a/paper-server/patches/unapplied/net/minecraft/world/level/portal/PortalForcer.java.patch +++ /dev/null @@ -1,149 +0,0 @@ ---- a/net/minecraft/world/level/portal/PortalForcer.java -+++ b/net/minecraft/world/level/portal/PortalForcer.java -@@ -42,34 +42,52 @@ - this.level = world; - } - -+ @io.papermc.paper.annotation.DoNotUse // Paper - public Optional findClosestPortalPosition(BlockPos pos, boolean destIsNether, WorldBorder worldBorder) { -+ // CraftBukkit start -+ return this.findClosestPortalPosition(pos, worldBorder, destIsNether ? 16 : 128); // Search Radius -+ } -+ -+ public Optional findClosestPortalPosition(BlockPos blockposition, WorldBorder worldborder, int i) { - PoiManager villageplace = this.level.getPoiManager(); -- int i = destIsNether ? 16 : 128; -+ // int i = flag ? 16 : 128; -+ // CraftBukkit end - -- villageplace.ensureLoadedAndValid(this.level, pos, i); -- Stream stream = villageplace.getInSquare((holder) -> { -+ villageplace.ensureLoadedAndValid(this.level, blockposition, i); -+ Stream stream = villageplace.getInSquare((holder) -> { // CraftBukkit - decompile error - return holder.is(PoiTypes.NETHER_PORTAL); -- }, pos, i, PoiManager.Occupancy.ANY).map(PoiRecord::getPos); -+ }, blockposition, i, PoiManager.Occupancy.ANY).map(PoiRecord::getPos); - -- Objects.requireNonNull(worldBorder); -- return stream.filter(worldBorder::isWithinBounds).filter((blockposition1) -> { -+ Objects.requireNonNull(worldborder); -+ return stream.filter(worldborder::isWithinBounds).filter(pos -> !(this.level.getTypeKey() == net.minecraft.world.level.dimension.LevelStem.NETHER && this.level.paperConfig().environment.netherCeilingVoidDamageHeight.test(v -> pos.getY() >= v))).filter((blockposition1) -> { // Paper - Configurable nether ceiling damage - return this.level.getBlockState(blockposition1).hasProperty(BlockStateProperties.HORIZONTAL_AXIS); -- }).min(Comparator.comparingDouble((blockposition1) -> { -- return blockposition1.distSqr(pos); -+ }).min(Comparator.comparingDouble((BlockPos blockposition1) -> { // CraftBukkit - decompile error -+ return blockposition1.distSqr(blockposition); - }).thenComparingInt(Vec3i::getY)); - } - - public Optional createPortal(BlockPos pos, Direction.Axis axis) { -- Direction enumdirection = Direction.get(Direction.AxisDirection.POSITIVE, axis); -+ // CraftBukkit start -+ return this.createPortal(pos, axis, null, 16); -+ } -+ -+ public Optional createPortal(BlockPos blockposition, Direction.Axis enumdirection_enumaxis, net.minecraft.world.entity.Entity entity, int createRadius) { -+ // CraftBukkit end -+ Direction enumdirection = Direction.get(Direction.AxisDirection.POSITIVE, enumdirection_enumaxis); - double d0 = -1.0D; - BlockPos blockposition1 = null; - double d1 = -1.0D; - BlockPos blockposition2 = null; - WorldBorder worldborder = this.level.getWorldBorder(); - int i = Math.min(this.level.getMaxY(), this.level.getMinY() + this.level.getLogicalHeight() - 1); -+ // Paper start - Configurable nether ceiling damage; make sure the max height doesn't exceed the void damage height -+ if (this.level.getTypeKey() == net.minecraft.world.level.dimension.LevelStem.NETHER && this.level.paperConfig().environment.netherCeilingVoidDamageHeight.enabled()) { -+ i = Math.min(i, this.level.paperConfig().environment.netherCeilingVoidDamageHeight.intValue() - 1); -+ } -+ // Paper end - Configurable nether ceiling damage - boolean flag = true; -- BlockPos.MutableBlockPos blockposition_mutableblockposition = pos.mutable(); -- Iterator iterator = BlockPos.spiralAround(pos, 16, Direction.EAST, Direction.SOUTH).iterator(); -+ BlockPos.MutableBlockPos blockposition_mutableblockposition = blockposition.mutable(); -+ Iterator iterator = BlockPos.spiralAround(blockposition, createRadius, Direction.EAST, Direction.SOUTH).iterator(); // CraftBukkit - - int j; - int k; -@@ -95,7 +113,7 @@ - if (i1 <= 0 || i1 >= 3) { - blockposition_mutableblockposition1.setY(k); - if (this.canHostFrame(blockposition_mutableblockposition1, blockposition_mutableblockposition, enumdirection, 0)) { -- double d2 = pos.distSqr(blockposition_mutableblockposition1); -+ double d2 = blockposition.distSqr(blockposition_mutableblockposition1); - - 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 +140,7 @@ - int j1; - int k1; - -+ org.bukkit.craftbukkit.util.BlockStateListPopulator blockList = new org.bukkit.craftbukkit.util.BlockStateListPopulator(this.level); // CraftBukkit - Use BlockStateListPopulator - if (d0 == -1.0D) { - j1 = Math.max(this.level.getMinY() - -1, 70); - k1 = i - 9; -@@ -129,7 +148,7 @@ - return Optional.empty(); - } - -- blockposition1 = (new BlockPos(pos.getX() - enumdirection.getStepX() * 1, Mth.clamp(pos.getY(), j1, k1), pos.getZ() - enumdirection.getStepZ() * 1)).immutable(); -+ blockposition1 = (new BlockPos(blockposition.getX() - enumdirection.getStepX() * 1, Mth.clamp(blockposition.getY(), j1, k1), blockposition.getZ() - enumdirection.getStepZ() * 1)).immutable(); - blockposition1 = worldborder.clampToBounds(blockposition1); - Direction enumdirection1 = enumdirection.getClockWise(); - -@@ -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()); -- this.level.setBlockAndUpdate(blockposition_mutableblockposition, iblockdata); -+ blockList.setBlock(blockposition_mutableblockposition, iblockdata, 3); // CraftBukkit - } - } - } -@@ -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()); -- this.level.setBlock(blockposition_mutableblockposition, Blocks.OBSIDIAN.defaultBlockState(), 3); -+ blockList.setBlock(blockposition_mutableblockposition, Blocks.OBSIDIAN.defaultBlockState(), 3); // CraftBukkit - } - } - } - -- BlockState iblockdata1 = (BlockState) Blocks.NETHER_PORTAL.defaultBlockState().setValue(NetherPortalBlock.AXIS, axis); -+ BlockState iblockdata1 = (BlockState) Blocks.NETHER_PORTAL.defaultBlockState().setValue(NetherPortalBlock.AXIS, enumdirection_enumaxis); - - for (k1 = 0; k1 < 2; ++k1) { - for (j = 0; j < 3; ++j) { - blockposition_mutableblockposition.setWithOffset(blockposition1, k1 * enumdirection.getStepX(), j, k1 * enumdirection.getStepZ()); -- this.level.setBlock(blockposition_mutableblockposition, iblockdata1, 18); -+ blockList.setBlock(blockposition_mutableblockposition, iblockdata1, 18); // CraftBukkit - } - } - -+ // CraftBukkit start -+ org.bukkit.World bworld = this.level.getWorld(); -+ org.bukkit.event.world.PortalCreateEvent event = new org.bukkit.event.world.PortalCreateEvent((java.util.List) (java.util.List) blockList.getList(), bworld, (entity == null) ? null : entity.getBukkitEntity(), org.bukkit.event.world.PortalCreateEvent.CreateReason.NETHER_PAIR); -+ -+ this.level.getCraftServer().getPluginManager().callEvent(event); -+ if (event.isCancelled()) { -+ return Optional.empty(); -+ } -+ blockList.updateList(); -+ // CraftBukkit end - return Optional.of(new BlockUtil.FoundRectangle(blockposition1.immutable(), 2, 3)); - } - -@@ -178,6 +207,13 @@ - for (int j = -1; j < 3; ++j) { - for (int k = -1; k < 4; ++k) { - temp.setWithOffset(pos, portalDirection.getStepX() * j + enumdirection1.getStepX() * distanceOrthogonalToPortal, k, portalDirection.getStepZ() * j + enumdirection1.getStepZ() * distanceOrthogonalToPortal); -+ // Paper start - Protect Bedrock and End Portal/Frames from being destroyed -+ if (!io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.allowPermanentBlockBreakExploits) { -+ if (!this.level.getBlockState(temp).isDestroyable()) { -+ return false; -+ } -+ } -+ // Paper end - Protect Bedrock and End Portal/Frames from being destroyed - if (k < 0 && !this.level.getBlockState(temp).isSolid()) { - return false; - } diff --git a/paper-server/patches/unapplied/net/minecraft/world/level/portal/PortalShape.java.patch b/paper-server/patches/unapplied/net/minecraft/world/level/portal/PortalShape.java.patch deleted file mode 100644 index f0cf745dd6..0000000000 --- a/paper-server/patches/unapplied/net/minecraft/world/level/portal/PortalShape.java.patch +++ /dev/null @@ -1,226 +0,0 @@ ---- a/net/minecraft/world/level/portal/PortalShape.java -+++ b/net/minecraft/world/level/portal/PortalShape.java -@@ -23,6 +23,11 @@ - import net.minecraft.world.phys.shapes.VoxelShape; - import org.apache.commons.lang3.mutable.MutableInt; - -+// CraftBukkit start -+import org.bukkit.craftbukkit.util.BlockStateListPopulator; -+import org.bukkit.event.world.PortalCreateEvent; -+// CraftBukkit end -+ - public class PortalShape { - - private static final int MIN_WIDTH = 2; -@@ -40,14 +45,18 @@ - private final BlockPos bottomLeft; - private final int height; - private final int width; -+ // CraftBukkit start - add field -+ private final BlockStateListPopulator blocks; - -- private PortalShape(Direction.Axis axis, int foundPortalBlocks, Direction negativeDir, BlockPos lowerCorner, int width, int height) { -- this.axis = axis; -- this.numPortalBlocks = foundPortalBlocks; -- this.rightDir = negativeDir; -- this.bottomLeft = lowerCorner; -- this.width = width; -- this.height = height; -+ private PortalShape(Direction.Axis enumdirection_enumaxis, int i, Direction enumdirection, BlockPos blockposition, int j, int k, BlockStateListPopulator blocks) { -+ this.blocks = blocks; -+ // CraftBukkit end -+ this.axis = enumdirection_enumaxis; -+ this.numPortalBlocks = i; -+ this.rightDir = enumdirection; -+ this.bottomLeft = blockposition; -+ this.width = j; -+ this.height = k; - } - - public static Optional findEmptyPortalShape(LevelAccessor world, BlockPos pos, Direction.Axis firstCheckedAxis) { -@@ -69,110 +78,118 @@ - } - - public static PortalShape findAnyShape(BlockGetter world, BlockPos pos, Direction.Axis axis) { -+ BlockStateListPopulator blocks = new BlockStateListPopulator(((LevelAccessor) world).getMinecraftWorld()); // CraftBukkit - Direction enumdirection = axis == Direction.Axis.X ? Direction.WEST : Direction.SOUTH; -- BlockPos blockposition1 = PortalShape.calculateBottomLeft(world, enumdirection, pos); -+ BlockPos blockposition1 = PortalShape.calculateBottomLeft(world, enumdirection, pos, blocks); // CraftBukkit - - if (blockposition1 == null) { -- return new PortalShape(axis, 0, enumdirection, pos, 0, 0); -+ return new PortalShape(axis, 0, enumdirection, pos, 0, 0, blocks); // CraftBukkit - } else { -- int i = PortalShape.calculateWidth(world, blockposition1, enumdirection); -+ int i = PortalShape.calculateWidth(world, blockposition1, enumdirection, blocks); // CraftBukkit - - if (i == 0) { -- return new PortalShape(axis, 0, enumdirection, blockposition1, 0, 0); -+ return new PortalShape(axis, 0, enumdirection, blockposition1, 0, 0, blocks); // CraftBukkit - } else { - MutableInt mutableint = new MutableInt(); -- int j = PortalShape.calculateHeight(world, blockposition1, enumdirection, i, mutableint); -+ int j = PortalShape.calculateHeight(world, blockposition1, enumdirection, i, mutableint, blocks); // CraftBukkit - -- return new PortalShape(axis, mutableint.getValue(), enumdirection, blockposition1, i, j); -+ return new PortalShape(axis, mutableint.getValue(), enumdirection, blockposition1, i, j, blocks); // CraftBukkit - } - } - } - - @Nullable -- private static BlockPos calculateBottomLeft(BlockGetter world, Direction direction, BlockPos pow) { -- for (int i = Math.max(world.getMinY(), pow.getY() - 21); pow.getY() > i && PortalShape.isEmpty(world.getBlockState(pow.below())); pow = pow.below()) { -+ private static BlockPos calculateBottomLeft(BlockGetter iblockaccess, Direction enumdirection, BlockPos blockposition, BlockStateListPopulator blocks) { // CraftBukkit -+ for (int i = Math.max(iblockaccess.getMinY(), blockposition.getY() - 21); blockposition.getY() > i && PortalShape.isEmpty(iblockaccess.getBlockState(blockposition.below())); blockposition = blockposition.below()) { - ; - } - -- Direction enumdirection1 = direction.getOpposite(); -- int j = PortalShape.getDistanceUntilEdgeAboveFrame(world, pow, enumdirection1) - 1; -+ Direction enumdirection1 = enumdirection.getOpposite(); -+ int j = PortalShape.getDistanceUntilEdgeAboveFrame(iblockaccess, blockposition, enumdirection1, blocks) - 1; // CraftBukkit - -- return j < 0 ? null : pow.relative(enumdirection1, j); -+ return j < 0 ? null : blockposition.relative(enumdirection1, j); - } - -- private static int calculateWidth(BlockGetter world, BlockPos lowerCorner, Direction negativeDir) { -- int i = PortalShape.getDistanceUntilEdgeAboveFrame(world, lowerCorner, negativeDir); -+ private static int calculateWidth(BlockGetter iblockaccess, BlockPos blockposition, Direction enumdirection, BlockStateListPopulator blocks) { // CraftBukkit -+ int i = PortalShape.getDistanceUntilEdgeAboveFrame(iblockaccess, blockposition, enumdirection, blocks); // CraftBukkit - - return i >= 2 && i <= 21 ? i : 0; - } - -- private static int getDistanceUntilEdgeAboveFrame(BlockGetter world, BlockPos lowerCorner, Direction negativeDir) { -+ private static int getDistanceUntilEdgeAboveFrame(BlockGetter iblockaccess, BlockPos blockposition, Direction enumdirection, BlockStateListPopulator blocks) { // CraftBukkit - BlockPos.MutableBlockPos blockposition_mutableblockposition = new BlockPos.MutableBlockPos(); - - for (int i = 0; i <= 21; ++i) { -- blockposition_mutableblockposition.set(lowerCorner).move(negativeDir, i); -- BlockState iblockdata = world.getBlockState(blockposition_mutableblockposition); -+ blockposition_mutableblockposition.set(blockposition).move(enumdirection, i); -+ BlockState iblockdata = iblockaccess.getBlockState(blockposition_mutableblockposition); - - if (!PortalShape.isEmpty(iblockdata)) { -- if (PortalShape.FRAME.test(iblockdata, world, blockposition_mutableblockposition)) { -+ if (PortalShape.FRAME.test(iblockdata, iblockaccess, blockposition_mutableblockposition)) { -+ blocks.setBlock(blockposition_mutableblockposition, iblockdata, 18); // CraftBukkit - lower left / right - return i; - } - break; - } - -- BlockState iblockdata1 = world.getBlockState(blockposition_mutableblockposition.move(Direction.DOWN)); -+ BlockState iblockdata1 = iblockaccess.getBlockState(blockposition_mutableblockposition.move(Direction.DOWN)); - -- if (!PortalShape.FRAME.test(iblockdata1, world, blockposition_mutableblockposition)) { -+ if (!PortalShape.FRAME.test(iblockdata1, iblockaccess, blockposition_mutableblockposition)) { - break; - } -+ blocks.setBlock(blockposition_mutableblockposition, iblockdata1, 18); // CraftBukkit - bottom row - } - - return 0; - } - -- private static int calculateHeight(BlockGetter world, BlockPos lowerCorner, Direction negativeDir, int width, MutableInt foundPortalBlocks) { -- BlockPos.MutableBlockPos blockposition_mutableblockposition = new BlockPos.MutableBlockPos(); -- int j = PortalShape.getDistanceUntilTop(world, lowerCorner, negativeDir, blockposition_mutableblockposition, width, foundPortalBlocks); -+ private static int calculateHeight(BlockGetter iblockaccess, BlockPos blockposition, Direction enumdirection, int i, MutableInt mutableint, BlockStateListPopulator blocks) { // CraftBukkit -+ BlockPos.MutableBlockPos blockposition_mutableblockposition = new BlockPos.MutableBlockPos(); -+ int j = PortalShape.getDistanceUntilTop(iblockaccess, blockposition, enumdirection, blockposition_mutableblockposition, i, mutableint, blocks); // CraftBukkit - -- return j >= 3 && j <= 21 && PortalShape.hasTopFrame(world, lowerCorner, negativeDir, blockposition_mutableblockposition, width, j) ? j : 0; -+ return j >= 3 && j <= 21 && PortalShape.hasTopFrame(iblockaccess, blockposition, enumdirection, blockposition_mutableblockposition, i, j, blocks) ? j : 0; // CraftBukkit - } - -- private static boolean hasTopFrame(BlockGetter world, BlockPos lowerCorner, Direction direction, BlockPos.MutableBlockPos pos, int width, int height) { -- for (int k = 0; k < width; ++k) { -- BlockPos.MutableBlockPos blockposition_mutableblockposition1 = pos.set(lowerCorner).move(Direction.UP, height).move(direction, k); -+ private static boolean hasTopFrame(BlockGetter iblockaccess, BlockPos blockposition, Direction enumdirection, BlockPos.MutableBlockPos blockposition_mutableblockposition, int i, int j, BlockStateListPopulator blocks) { // CraftBukkit -+ for (int k = 0; k < i; ++k) { -+ BlockPos.MutableBlockPos blockposition_mutableblockposition1 = blockposition_mutableblockposition.set(blockposition).move(Direction.UP, j).move(enumdirection, k); - -- if (!PortalShape.FRAME.test(world.getBlockState(blockposition_mutableblockposition1), world, blockposition_mutableblockposition1)) { -+ if (!PortalShape.FRAME.test(iblockaccess.getBlockState(blockposition_mutableblockposition1), iblockaccess, blockposition_mutableblockposition1)) { - return false; - } -+ blocks.setBlock(blockposition_mutableblockposition1, iblockaccess.getBlockState(blockposition_mutableblockposition1), 18); // CraftBukkit - upper row - } - - return true; - } - -- private static int getDistanceUntilTop(BlockGetter world, BlockPos lowerCorner, Direction negativeDir, BlockPos.MutableBlockPos pos, int width, MutableInt foundPortalBlocks) { -+ private static int getDistanceUntilTop(BlockGetter iblockaccess, BlockPos blockposition, Direction enumdirection, BlockPos.MutableBlockPos blockposition_mutableblockposition, int i, MutableInt mutableint, BlockStateListPopulator blocks) { // CraftBukkit - for (int j = 0; j < 21; ++j) { -- pos.set(lowerCorner).move(Direction.UP, j).move(negativeDir, -1); -- if (!PortalShape.FRAME.test(world.getBlockState(pos), world, pos)) { -+ blockposition_mutableblockposition.set(blockposition).move(Direction.UP, j).move(enumdirection, -1); -+ if (!PortalShape.FRAME.test(iblockaccess.getBlockState(blockposition_mutableblockposition), iblockaccess, blockposition_mutableblockposition)) { - return j; - } - -- pos.set(lowerCorner).move(Direction.UP, j).move(negativeDir, width); -- if (!PortalShape.FRAME.test(world.getBlockState(pos), world, pos)) { -+ blockposition_mutableblockposition.set(blockposition).move(Direction.UP, j).move(enumdirection, i); -+ if (!PortalShape.FRAME.test(iblockaccess.getBlockState(blockposition_mutableblockposition), iblockaccess, blockposition_mutableblockposition)) { - return j; - } - -- for (int k = 0; k < width; ++k) { -- pos.set(lowerCorner).move(Direction.UP, j).move(negativeDir, k); -- BlockState iblockdata = world.getBlockState(pos); -+ for (int k = 0; k < i; ++k) { -+ blockposition_mutableblockposition.set(blockposition).move(Direction.UP, j).move(enumdirection, k); -+ BlockState iblockdata = iblockaccess.getBlockState(blockposition_mutableblockposition); - - if (!PortalShape.isEmpty(iblockdata)) { - return j; - } - - if (iblockdata.is(Blocks.NETHER_PORTAL)) { -- foundPortalBlocks.increment(); -+ mutableint.increment(); - } - } -+ // CraftBukkit start - left and right -+ blocks.setBlock(blockposition_mutableblockposition.set(blockposition).move(Direction.UP, j).move(enumdirection, -1), iblockaccess.getBlockState(blockposition_mutableblockposition), 18); -+ blocks.setBlock(blockposition_mutableblockposition.set(blockposition).move(Direction.UP, j).move(enumdirection, i), iblockaccess.getBlockState(blockposition_mutableblockposition), 18); -+ // CraftBukkit end - } - - return 21; -@@ -186,12 +203,28 @@ - return this.width >= 2 && this.width <= 21 && this.height >= 3 && this.height <= 21; - } - -- public void createPortalBlocks(LevelAccessor world) { -+ // CraftBukkit start - return boolean, add entity -+ public boolean createPortalBlocks(LevelAccessor generatoraccess, Entity entity) { -+ org.bukkit.World bworld = generatoraccess.getMinecraftWorld().getWorld(); -+ -+ // Copy below for loop - BlockState iblockdata = (BlockState) Blocks.NETHER_PORTAL.defaultBlockState().setValue(NetherPortalBlock.AXIS, this.axis); - - BlockPos.betweenClosed(this.bottomLeft, this.bottomLeft.relative(Direction.UP, this.height - 1).relative(this.rightDir, this.width - 1)).forEach((blockposition) -> { -- world.setBlock(blockposition, iblockdata, 18); -+ this.blocks.setBlock(blockposition, iblockdata, 18); - }); -+ -+ PortalCreateEvent event = new PortalCreateEvent((java.util.List) (java.util.List) this.blocks.getList(), bworld, (entity == null) ? null : entity.getBukkitEntity(), PortalCreateEvent.CreateReason.FIRE); -+ generatoraccess.getMinecraftWorld().getServer().server.getPluginManager().callEvent(event); -+ -+ if (event.isCancelled()) { -+ return false; -+ } -+ // CraftBukkit end -+ BlockPos.betweenClosed(this.bottomLeft, this.bottomLeft.relative(Direction.UP, this.height - 1).relative(this.rightDir, this.width - 1)).forEach((blockposition) -> { -+ generatoraccess.setBlock(blockposition, iblockdata, 18); -+ }); -+ return true; // CraftBukkit - } - - public boolean isComplete() { diff --git a/paper-server/patches/unapplied/net/minecraft/world/level/portal/TeleportTransition.java.patch b/paper-server/patches/unapplied/net/minecraft/world/level/portal/TeleportTransition.java.patch deleted file mode 100644 index 1d72cf288c..0000000000 --- a/paper-server/patches/unapplied/net/minecraft/world/level/portal/TeleportTransition.java.patch +++ /dev/null @@ -1,71 +0,0 @@ ---- a/net/minecraft/world/level/portal/TeleportTransition.java -+++ b/net/minecraft/world/level/portal/TeleportTransition.java -@@ -8,26 +8,55 @@ - import net.minecraft.world.entity.Entity; - import net.minecraft.world.entity.Relative; - import net.minecraft.world.phys.Vec3; -+// CraftBukkit start -+import org.bukkit.event.player.PlayerTeleportEvent; - --public record TeleportTransition(ServerLevel newLevel, Vec3 position, Vec3 deltaMovement, float yRot, float xRot, boolean missingRespawnBlock, boolean asPassenger, Set relatives, TeleportTransition.PostTeleportTransition postTeleportTransition) { -+public record TeleportTransition(ServerLevel newLevel, Vec3 position, Vec3 deltaMovement, float yRot, float xRot, boolean missingRespawnBlock, boolean asPassenger, Set relatives, TeleportTransition.PostTeleportTransition postTeleportTransition, PlayerTeleportEvent.TeleportCause cause) { - -+ public TeleportTransition(ServerLevel newLevel, Vec3 position, Vec3 deltaMovement, float yRot, float xRot, boolean missingRespawnBlock, boolean asPassenger, Set relatives, TeleportTransition.PostTeleportTransition postTeleportTransition) { -+ this(newLevel, position, deltaMovement, yRot, xRot, missingRespawnBlock, asPassenger, relatives, postTeleportTransition, PlayerTeleportEvent.TeleportCause.UNKNOWN); -+ } -+ -+ public TeleportTransition(PlayerTeleportEvent.TeleportCause cause) { -+ this(null, Vec3.ZERO, Vec3.ZERO, 0.0F, 0.0F, false, false, Set.of(), DO_NOTHING, cause); -+ } -+ // CraftBukkit end -+ - public static final TeleportTransition.PostTeleportTransition DO_NOTHING = (entity) -> { - }; - public static final TeleportTransition.PostTeleportTransition PLAY_PORTAL_SOUND = TeleportTransition::playPortalSound; - public static final TeleportTransition.PostTeleportTransition PLACE_PORTAL_TICKET = TeleportTransition::placePortalTicket; - - public TeleportTransition(ServerLevel world, Vec3 pos, Vec3 velocity, float yaw, float pitch, TeleportTransition.PostTeleportTransition postDimensionTransition) { -- this(world, pos, velocity, yaw, pitch, Set.of(), postDimensionTransition); -+ // CraftBukkit start -+ this(world, pos, velocity, yaw, pitch, postDimensionTransition, PlayerTeleportEvent.TeleportCause.UNKNOWN); - } - -+ public TeleportTransition(ServerLevel worldserver, Vec3 vec3d, Vec3 vec3d1, float f, float f1, TeleportTransition.PostTeleportTransition teleporttransition_a, PlayerTeleportEvent.TeleportCause cause) { -+ this(worldserver, vec3d, vec3d1, f, f1, Set.of(), teleporttransition_a, cause); -+ // CraftBukkit end -+ } -+ - public TeleportTransition(ServerLevel world, Vec3 pos, Vec3 velocity, float yaw, float pitch, Set flags, TeleportTransition.PostTeleportTransition postDimensionTransition) { -- this(world, pos, velocity, yaw, pitch, false, false, flags, postDimensionTransition); -+ // CraftBukkit start -+ this(world, pos, velocity, yaw, pitch, flags, postDimensionTransition, PlayerTeleportEvent.TeleportCause.UNKNOWN); - } - -+ public TeleportTransition(ServerLevel worldserver, Vec3 vec3d, Vec3 vec3d1, float f, float f1, Set set, TeleportTransition.PostTeleportTransition teleporttransition_a, PlayerTeleportEvent.TeleportCause cause) { -+ this(worldserver, vec3d, vec3d1, f, f1, false, false, set, teleporttransition_a, cause); -+ // CraftBukkit end -+ } -+ - public TeleportTransition(ServerLevel world, Entity entity, TeleportTransition.PostTeleportTransition postDimensionTransition) { -- this(world, findAdjustedSharedSpawnPos(world, entity), Vec3.ZERO, 0.0F, 0.0F, false, false, Set.of(), postDimensionTransition); -+ // CraftBukkit start -+ this(world, entity, postDimensionTransition, PlayerTeleportEvent.TeleportCause.UNKNOWN); - } - -+ public TeleportTransition(ServerLevel worldserver, Entity entity, TeleportTransition.PostTeleportTransition teleporttransition_a, PlayerTeleportEvent.TeleportCause cause) { -+ this(worldserver, findAdjustedSharedSpawnPos(worldserver, entity), Vec3.ZERO, worldserver.getSharedSpawnAngle(), 0.0F, false, false, Set.of(), teleporttransition_a, cause); // Paper - MC-200092 - fix first spawn pos yaw being ignored -+ // CraftBukkit end -+ } -+ - private static void playPortalSound(Entity entity) { - if (entity instanceof ServerPlayer entityplayer) { - entityplayer.connection.send(new ClientboundLevelEventPacket(1032, BlockPos.ZERO, 0, false)); -@@ -40,7 +69,7 @@ - } - - public static TeleportTransition missingRespawnBlock(ServerLevel world, Entity entity, TeleportTransition.PostTeleportTransition postDimensionTransition) { -- return new TeleportTransition(world, findAdjustedSharedSpawnPos(world, entity), Vec3.ZERO, 0.0F, 0.0F, true, false, Set.of(), postDimensionTransition); -+ return new TeleportTransition(world, findAdjustedSharedSpawnPos(world, entity), Vec3.ZERO, world.getSharedSpawnAngle(), 0.0F, true, false, Set.of(), postDimensionTransition); // Paper - MC-200092 - fix spawn pos yaw being ignored - } - - private static Vec3 findAdjustedSharedSpawnPos(ServerLevel world, Entity entity) {