Botania

Botania

133M Downloads

Planestrider's Sash Server speed Bug

superbandit opened this issue ยท 6 comments

commented

only on server:

planestrider's sash doesnt reset your movement speed after stopping.

commented

+1 I am running into this as well. I just have to take it off and put it back on to reset.

commented

This was fun to debug. Looking at common/item/equipment/bauble/ItemSpeedUpBelt.java and common/item/equipment/bauble/ItemTravelBelt.java, it looks like player.moveForward is always 0.0F on the server (aka, it's not persisted across). As such, onMovedTick(ItemStack, EntityPlayer) is never called on the server, and all of the speed increases/decreases are only occuring on the client.

The easy fix is to just allow the client to also reset the speed, by commenting out the remote check in commitPositionAndCompare (in ItemSpeedUpBelt). Aka:

    public boolean commitPositionAndCompare(ItemStack stack, EntityPlayer player) {
        // if(player.worldObj.isRemote)
        //  return true;

        double oldX = ItemNBTHelper.getDouble(stack, TAG_OLD_X, 0);
        double oldY = ItemNBTHelper.getDouble(stack, TAG_OLD_Y, 0);
        double oldZ = ItemNBTHelper.getDouble(stack, TAG_OLD_Z, 0);

        ItemNBTHelper.setDouble(stack, TAG_OLD_X, player.posX);
        ItemNBTHelper.setDouble(stack, TAG_OLD_Y, player.posY);
        ItemNBTHelper.setDouble(stack, TAG_OLD_Z, player.posZ);

        return Math.abs(oldX - player.posX) > 0.001 || Math.abs(oldY - player.posY) > 0.001 || Math.abs(oldZ - player.posZ) > 0.001;
    }

The harder approach is to change it so that the client has no power over player movement speeds and use some more complicated trigonometry to determine if the player's current velocity is in a "forwardish" direction (this isn't quite as hard as it seems), instead of using player.moveForward.

Of course, the second approach is harder, and the above change will work as a hotfix in the meanwhile. As it's a very brief change, it's likely better patched by a developer with write access unless they find merging a 2-line PR easier (ha).

commented

It's also worth noting that the player.moveForward bug means none of the normal "moving" code in ItemTravelBelt is called on the server:

                        float speed = beltItem.getSpeed(belt);
                        player.moveFlying(0F, 1F, player.capabilities.isFlying ? speed : speed);
                        beltItem.onMovedTick(belt, player);

                        if(player.ticksExisted % COST_INTERVAL == 0)
                            ManaItemHandler.requestManaExact(belt, player, COST, true);

which means that mana costs may not be being applied (depending on if the client requesting mana also changes it on the server).

commented

hooboy, sided code!

sarcastically yells yay

commented

@TheWhiteWolves Just an FYI, PR #1748 does fix this problem for now and it can be closed until something horribly breaks again.

commented

Fixed By 0595397