Vampirism - Become a vampire!

Vampirism - Become a vampire!

16M Downloads

[Bug][Compat] Using BetterPortals portal as bat teleports player upwards

Johni0702 opened this issue ยท 2 comments

commented

Johni0702/BetterPortals#352
MC 1.12.2

BetterPortals allows for see-through and loading-screen-less portals by spawning fake players on the server, tunneling their packets to the client and swapping out mc.world, mc.player, etc. as required during ticking/rendering.
To allow for seamless transition from one world to the other, BP must, until the server acknowledges the change, rapidly swap the player entity between the new world (where it should appear to be during rendering and ticking) and the old one (where it is expected during packet handling until the server swaps them as well).

Every time this happens, Forge fires a EntityJoinWorldEvent and the BatVampireAction gets re-activated which teleports the player up a tiny bit:

if (bat) player.setPosition(player.posX, player.posY + (PLAYER_HEIGHT - BAT_HEIGHT), player.posZ);

Given the player is swapped at least twice every tick, this can quickly move you up hundreds of blocks.

Fixing this is probably fairly easy (at least it seems to be, given my limited knowledge of Vampirism's code):

public void onActivatedClient(IVampirePlayer vampire) {
setPlayerBat(vampire.getRepresentingPlayer(), true);
((VampirePlayer) vampire).getSpecialAttributes().bat = true;
}

This just needs to check if the player already is a bat (capabilities are preserved across swaps) before making them one.

commented

Very sorry for the long delay, lost track of this somehow.

@Hydraheads if you are still playing with both mods, can you update to the latest version of Vampirism and check if the issue has been resolved?

commented

Thx for looking into this and already suggesting a solution :)
I will double check that there are any unexpected side effects and then apply your suggestion.