Skip to content

Fix inverted isSafeLocation branch logic in backtrack teleport#168

Draft
Copilot wants to merge 2 commits intodevelopfrom
copilot/sub-pr-164-another-one
Draft

Fix inverted isSafeLocation branch logic in backtrack teleport#168
Copilot wants to merge 2 commits intodevelopfrom
copilot/sub-pr-164-another-one

Conversation

Copy link
Contributor

Copilot AI commented Mar 8, 2026

The if/else branches in PlayerListener.onPlayerLeaveIsland were swapped: the safe branch teleported home and the unsafe branch teleported to the ray-traced position.

Changes

  • PlayerListener.java — Correct the condition and restructure the branches:

    // Before: inverted — safe → home, unsafe → targetPos
    if (!addon.getIslands().isSafeLocation(targetPos)) {
        // place block
        Util.teleportAsync(p, targetPos)...
    } else {
        Util.teleportAsync(p, i.getHome(""))...  // BUG: teleports home when safe!
    }
    
    // After: correct — safe → targetPos, unsafe → place block → re-check → home or targetPos
    if (addon.getIslands().isSafeLocation(targetPos)) {
        Util.teleportAsync(p, targetPos)...
    } else {
        // place appropriate floor block per world environment
        if (!addon.getIslands().isSafeLocation(targetPos)) {
            Util.teleportAsync(p, i.getHome(""))...  // fallback if still unsafe
        } else {
            Util.teleportAsync(p, targetPos)...
        }
    }
  • PlayerListenerTest.java — Add three tests covering: safe position teleports directly, always-unsafe falls back to home, and becomes-safe-after-block-placement teleports to target.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

The if/else branches were swapped: when isSafeLocation() returned true (safe),
the code was teleporting home; when it returned false (unsafe), it placed a
block and teleported there.

Now: if safe → log + teleport to targetPos; if unsafe → place floor block →
re-check → if still unsafe → fall back to home; if now safe → teleport to targetPos.

Also adds three targeted tests covering the corrected behaviour.

Co-authored-by: tastybento <4407265+tastybento@users.noreply.github.com>
Copilot AI changed the title [WIP] Address feedback from PR #164 on Release 4.8.1 Fix inverted isSafeLocation branch logic in backtrack teleport Mar 8, 2026
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.

2 participants