Skip to content
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

Fixed issue #228 Relative teleports not working with teleport_warmup #230

Merged
merged 6 commits into from
Jan 3, 2025

Conversation

FishyFinn
Copy link
Contributor

Fixed issue #228 where using relative teleports with teleport_warmup would teleport player to 0 0 0 due to incorrect use of PositionFlags

@sakurawald
Copy link
Owner

sakurawald commented Dec 24, 2024

Hello, can you fix the style checking in CI. (This can be done via running the checkstyleMain gradle task).

P.S. The wild-card import is not recommended, this is related to the JVM loading mechanism. The loading of a class may trigger the static initialization, and in fabric developing, it's also possible to trigger a mixin initialization. So for the compatibility, I myself always try to avoid the wild-card imports.

@sakurawald
Copy link
Owner

sakurawald commented Dec 24, 2024

Maybe another better solution is to:

  1. Track the position flags in TeleportTicket
  2. Add a overload teleport function that accepts the flags, and keep the original function, to reduce the dupe of none flags.

Something like

    public void teleport(@NotNull ServerPlayerEntity player, EnumSet<PositionFlag> flags) {
        RegistryKey<World> worldKey = RegistryKey.of(RegistryKeys.WORLD, Identifier.of(this.level));
        ServerWorld serverLevel = ServerHelper.getServer().getWorld(worldKey);
        if (serverLevel == null) {
            TextHelper.sendMessageByKey(player, "world.dimension.not_found", this.level);
            return;
        }

        /* make position flags */
        player.teleport(serverLevel, this.x, this.y, this.z, flags, this.yaw, this.pitch, true);
    }

    public void teleport(@NotNull ServerPlayerEntity player) {
        teleport(player, EnumSet.noneOf(PositionFlag.class));
    }

Which keeps the original function signature, and in most case, the teleport requires no flags.

@sakurawald
Copy link
Owner

sakurawald commented Dec 26, 2024

Hello, please let me know if it's okay to modify the commit in your side, if you are not convenient to do this, I can just merge this request, and do the modification in my side. Thank you~

@FishyFinn
Copy link
Contributor Author

Hello, please let me know if it's okay to modify the commit in your side, if you are not convenient to do this, I can just merge this request, and do the modification in my side. Thank you~

I’ll be all good to make these changes next week as i’m busy with the holiday season, if you’d like to get this done asap you’re very welcome to merge it and modify it.

@sakurawald
Copy link
Owner

Hello, please let me know if it's okay to modify the commit in your side, if you are not convenient to do this, I can just merge this request, and do the modification in my side. Thank you~

I’ll be all good to make these changes next week as i’m busy with the holiday season, if you’d like to get this done asap you’re very welcome to merge it and modify it.

Okay, have a nice holiday!

…f 'none' tags. also removed some instances of wild card imports
@FishyFinn
Copy link
Contributor Author

Ive made the requested changes, let me know if there is anything else

@sakurawald sakurawald merged commit 4780e3e into sakurawald:dev Jan 3, 2025
1 check passed
@sakurawald
Copy link
Owner

Ive made the requested changes, let me know if there is anything else

Looks nice, thank you very much!

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