-
Notifications
You must be signed in to change notification settings - Fork 47
Enhanced rtp & back command #91
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 1.21.1/dev
Are you sure you want to change the base?
Conversation
…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.
|
Could you please add the |
There was a problem hiding this 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)) { |
Copilot
AI
Sep 5, 2025
There was a problem hiding this comment.
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.
| 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))) { |
| //世界边界检查 | ||
| 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()) { | ||
| // 检查该位置是否在液体中 |
Copilot
AI
Sep 5, 2025
There was a problem hiding this comment.
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'.
| if (!world.getWorldBorder().isWithinBounds(currentPos)) { | ||
| continue; | ||
| } | ||
| //生物群系黑名单检查 |
Copilot
AI
Sep 5, 2025
There was a problem hiding this comment.
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'.
| //生物群系黑名单检查 | |
| // Biome blacklist check |
| continue; | ||
| } | ||
| // FTB Chunks (via FTB XMod Compat) listens to this. Other mods can too. | ||
| //事件系统检查 |
Copilot
AI
Sep 5, 2025
There was a problem hiding this comment.
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'.
| //事件系统检查 | |
| // Event system check |
| //世界边界检查 | ||
| 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()) { | ||
| // 检查该位置是否在液体中 |
Copilot
AI
Sep 5, 2025
There was a problem hiding this comment.
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'.
| if (hmPos.getY() > 0) { | ||
| BlockPos goodPos = null; | ||
| if (hmPos.getY() < world.getLogicalHeight()) { | ||
| // 检查该位置是否在液体中 |
Copilot
AI
Sep 5, 2025
There was a problem hiding this comment.
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'.
| // 检查该位置是否在液体中 | |
| // Check if position is in liquid |
| ServerPlayer player = source.getPlayerOrException(); | ||
|
|
||
| BlockHitResult res = BlockUtil.getFocusedBlock(player, player.getServer().getPlayerList().getViewDistance() * 16) | ||
| BlockHitResult res = BlockUtil.getFocusedBlock(player, source.getServer().getPlayerList().getViewDistance() * 16) |
Copilot
AI
Sep 5, 2025
There was a problem hiding this comment.
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.
| BlockHitResult res = BlockUtil.getFocusedBlock(player, source.getServer().getPlayerList().getViewDistance() * 16) | |
| BlockHitResult res = BlockUtil.getFocusedBlock(player, player.getServer().getPlayerList().getViewDistance() * 16) |
| return !world.getFluidState(pos).is(FluidTags.LAVA) && !world.getFluidState(headPos).is(FluidTags.LAVA); | ||
|
|
Copilot
AI
Sep 5, 2025
There was a problem hiding this comment.
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).
| 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); |
- **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
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.
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.
These changes significantly improve gameplay experience by preventing unintentional player deaths and frustration caused by unsafe teleports.