Skip to content

Conversation

@LolitaIceMia
Copy link

Summary
In earlier versions, the RTP (Random Teleport) feature had a known issue where players could be teleported above water, leading to drowning, or into unsafe terrain. Similarly, the back command could sometimes return players to locations covered by lava, destroyed blocks, or otherwise unsafe areas, resulting in accidental deaths or players getting stuck.

  • Changes in this version
    Fixed RTP logic: Random teleportation now validates target positions to ensure safety. Players are only teleported above solid ground with enough headroom, avoiding water or other hazardous blocks.
    Optimized Back command: The system records more accurate pre-teleportation locations and validates them upon return. If the original spot becomes unsafe (e.g., covered by lava or void), it automatically searches for the nearest safe position to prevent player damage.
  • Impact
    These changes significantly improve gameplay experience by preventing unintentional player deaths and frustration caused by unsafe teleports.

desht and others added 7 commits February 10, 2025 13:43
…wn issue: the system could teleport players to positions above water surfaces, causing them to fall directly into water or even drown; meanwhile, the back command would sometimes teleport players back to locations covered by lava or destroyed terrain in certain circumstances, leading to accidental death or getting stuck, severely impacting gameplay experience. In this version, we have implemented critical fixes for these issues:

     Fixed RTP teleport position determination logic: The system now checks if generated random positions are safe, avoiding teleporting players above water surfaces or into dangerous areas. Target teleportation points will ensure they are above solid blocks with sufficient headroom, guaranteeing safe player landing.

     Optimized Back command location retracing mechanism: The back command now records more precise pre-teleportation positions and checks target area safety upon return. If the original location has been covered by lava, void, or other hazardous environments, the system will automatically search for nearby safe points for teleportation, preventing player damage due to environmental changes.
…wn issue: the system could teleport players to positions above water surfaces, causing them to fall directly into water or even drown; meanwhile, the back command would sometimes teleport players back to locations covered by lava or destroyed terrain in certain circumstances, leading to accidental death or getting stuck, severely impacting gameplay experience. In this version, we have implemented critical fixes for these issues:

     Fixed RTP teleport position determination logic: The system now checks if generated random positions are safe, avoiding teleporting players above water surfaces or into dangerous areas. Target teleportation points will ensure they are above solid blocks with sufficient headroom, guaranteeing safe player landing.

     Optimized Back command location retracing mechanism: The back command now records more precise pre-teleportation positions and checks target area safety upon return. If the original location has been covered by lava, void, or other hazardous environments, the system will automatically search for nearby safe points for teleportation, preventing player damage due to environmental changes.
@CLAassistant
Copy link

CLAassistant commented Sep 4, 2025

CLA assistant check
All committers have signed the CLA.

@LolitaIceMia LolitaIceMia reopened this Sep 4, 2025
@LolitaIceMia LolitaIceMia changed the base branch from 1.21.1/main to 1.21.1/dev September 4, 2025 07:11
@LolitaIceMia
Copy link
Author

Could you please add the bugfix and rtp labels to this PR? Thanks!

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR enhances the teleportation safety system by improving the RTP (Random Teleport) and back command functionality to prevent players from being teleported to unsafe locations. The changes focus on validating teleport positions to avoid water, lava, and other hazardous blocks.

  • Implemented position validation for both RTP and back commands to ensure players only teleport to safe locations
  • Added Chinese localization updates and a new "no safe position found" message
  • Reduced RTP cooldown from 600 to 420 seconds

Reviewed Changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
fabric/build.gradle Removed empty line for code formatting
common/src/main/resources/assets/ftbessentials/lang/zh_cn.json Updated Chinese translations with improved consistency and terminology
common/src/main/resources/assets/ftbessentials/lang/en_us.json Added new error message for when no safe position is found
common/src/main/java/dev/ftb/mods/ftbessentials/util/TeleportPos.java Added getter method for dimension access
common/src/main/java/dev/ftb/mods/ftbessentials/config/FTBEConfig.java Reduced RTP command cooldown from 600 to 420 seconds
common/src/main/java/dev/ftb/mods/ftbessentials/commands/groups/TeleportingCommands.java Enhanced safety validation for RTP and back commands with position checking logic

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

BlockPos goodPos = null;
if (hmPos.getY() < world.getLogicalHeight()) {
// 检查该位置是否在液体中
if (hmPos.getY() < world.getLogicalHeight() && !world.getFluidState(hmPos.below()).is(FluidTags.WATER)||world.getFluidState(hmPos.below()).is(FluidTags.LAVA)) {
Copy link

Copilot AI Sep 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logical operator precedence is incorrect. The condition !world.getFluidState(hmPos.below()).is(FluidTags.WATER)||world.getFluidState(hmPos.below()).is(FluidTags.LAVA) should be parenthesized as !(world.getFluidState(hmPos.below()).is(FluidTags.WATER) || world.getFluidState(hmPos.below()).is(FluidTags.LAVA)) to avoid both water and lava positions.

Suggested change
if (hmPos.getY() < world.getLogicalHeight() && !world.getFluidState(hmPos.below()).is(FluidTags.WATER)||world.getFluidState(hmPos.below()).is(FluidTags.LAVA)) {
if (hmPos.getY() < world.getLogicalHeight() && !(world.getFluidState(hmPos.below()).is(FluidTags.WATER) || world.getFluidState(hmPos.below()).is(FluidTags.LAVA))) {

Copilot uses AI. Check for mistakes.
Comment on lines 227 to 247
//世界边界检查
if (!world.getWorldBorder().isWithinBounds(currentPos)) {
continue;
}
//生物群系黑名单检查
if (world.getBiome(currentPos).is(IGNORE_RTP_BIOMES)) {
continue;
}
// FTB Chunks (via FTB XMod Compat) listens to this. Other mods can too.
//事件系统检查
EventResult res = FTBEssentialsEvents.RTP_EVENT.invoker().teleport(world, player, currentPos, attempt);
if (res.isFalse()) {
continue;
}

world.getChunkAt(currentPos);
//高度图检查
BlockPos hmPos = world.getHeightmapPos(Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, currentPos);

if (hmPos.getY() > 0) {
BlockPos goodPos = null;
if (hmPos.getY() < world.getLogicalHeight()) {
// 检查该位置是否在液体中
Copy link

Copilot AI Sep 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comments are written in Chinese instead of English. For consistency with the rest of the codebase, these should be translated to English: '// World border check', '// Biome blacklist check', '// Event system check', '// Heightmap check', '// Check if position is in liquid'.

Copilot uses AI. Check for mistakes.
if (!world.getWorldBorder().isWithinBounds(currentPos)) {
continue;
}
//生物群系黑名单检查
Copy link

Copilot AI Sep 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comments are written in Chinese instead of English. For consistency with the rest of the codebase, these should be translated to English: '// World border check', '// Biome blacklist check', '// Event system check', '// Heightmap check', '// Check if position is in liquid'.

Suggested change
//生物群系黑名单检查
// Biome blacklist check

Copilot uses AI. Check for mistakes.
continue;
}
// FTB Chunks (via FTB XMod Compat) listens to this. Other mods can too.
//事件系统检查
Copy link

Copilot AI Sep 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comments are written in Chinese instead of English. For consistency with the rest of the codebase, these should be translated to English: '// World border check', '// Biome blacklist check', '// Event system check', '// Heightmap check', '// Check if position is in liquid'.

Suggested change
//事件系统检查
// Event system check

Copilot uses AI. Check for mistakes.
Comment on lines 227 to 247
//世界边界检查
if (!world.getWorldBorder().isWithinBounds(currentPos)) {
continue;
}
//生物群系黑名单检查
if (world.getBiome(currentPos).is(IGNORE_RTP_BIOMES)) {
continue;
}
// FTB Chunks (via FTB XMod Compat) listens to this. Other mods can too.
//事件系统检查
EventResult res = FTBEssentialsEvents.RTP_EVENT.invoker().teleport(world, player, currentPos, attempt);
if (res.isFalse()) {
continue;
}

world.getChunkAt(currentPos);
//高度图检查
BlockPos hmPos = world.getHeightmapPos(Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, currentPos);

if (hmPos.getY() > 0) {
BlockPos goodPos = null;
if (hmPos.getY() < world.getLogicalHeight()) {
// 检查该位置是否在液体中
Copy link

Copilot AI Sep 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comments are written in Chinese instead of English. For consistency with the rest of the codebase, these should be translated to English: '// World border check', '// Biome blacklist check', '// Event system check', '// Heightmap check', '// Check if position is in liquid'.

Copilot uses AI. Check for mistakes.
if (hmPos.getY() > 0) {
BlockPos goodPos = null;
if (hmPos.getY() < world.getLogicalHeight()) {
// 检查该位置是否在液体中
Copy link

Copilot AI Sep 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comments are written in Chinese instead of English. For consistency with the rest of the codebase, these should be translated to English: '// World border check', '// Biome blacklist check', '// Event system check', '// Heightmap check', '// Check if position is in liquid'.

Suggested change
// 检查该位置是否在液体中
// Check if position is in liquid

Copilot uses AI. Check for mistakes.
ServerPlayer player = source.getPlayerOrException();

BlockHitResult res = BlockUtil.getFocusedBlock(player, player.getServer().getPlayerList().getViewDistance() * 16)
BlockHitResult res = BlockUtil.getFocusedBlock(player, source.getServer().getPlayerList().getViewDistance() * 16)
Copy link

Copilot AI Sep 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed from player.getServer() to source.getServer() but this could potentially cause issues if the source is not a player. The original player.getServer() was more appropriate since we know player is not null from the line above.

Suggested change
BlockHitResult res = BlockUtil.getFocusedBlock(player, source.getServer().getPlayerList().getViewDistance() * 16)
BlockHitResult res = BlockUtil.getFocusedBlock(player, player.getServer().getPlayerList().getViewDistance() * 16)

Copilot uses AI. Check for mistakes.
Comment on lines 176 to 177
return !world.getFluidState(pos).is(FluidTags.LAVA) && !world.getFluidState(headPos).is(FluidTags.LAVA);

Copy link

Copilot AI Sep 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The safety check only validates against lava but ignores water, which could still be unsafe for teleportation. Consider also checking for water: !world.getFluidState(pos).is(FluidTags.WATER) && !world.getFluidState(headPos).is(FluidTags.WATER).

Suggested change
return !world.getFluidState(pos).is(FluidTags.LAVA) && !world.getFluidState(headPos).is(FluidTags.LAVA);
return !world.getFluidState(pos).is(FluidTags.LAVA)
&& !world.getFluidState(headPos).is(FluidTags.LAVA)
&& !world.getFluidState(pos).is(FluidTags.WATER)
&& !world.getFluidState(headPos).is(FluidTags.WATER);

Copilot uses AI. Check for mistakes.
- **Improved teleport safety checks**: Added water fluid check in [isSafePosition](file://E:\BACKEND\FTB-Essentials\common\src\main\java\dev\ftb\mods\ftbessentials\commands\groups\TeleportingCommands.java#L146-L168) method to prevent unsafe teleportation into water bodies
- **Code consistency**: Updated fluid safety validation to check both lava and water for player and head positions
- **Enhanced player protection**: Prevents players from being teleported into potentially dangerous liquid environments
# Conflicts:
#	common/src/main/java/dev/ftb/mods/ftbessentials/commands/groups/TeleportingCommands.java
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants