Skip to content

Player desync with server after death #13451

@Clexus

Description

@Clexus

Expected behavior

That shouldn't happen

Observed/Actual behavior

Player client side can do anything, but server side they are just standing there with invulnerability and can't be moved. Kill doesn't work, teleport does work, seems like they are in a state of dead and living.

Steps/models to reproduce

I enabled immediate respawn
below is what I do to players at the time they die in EntityDeathEvent

private void applyLevelEffects(Player player, int lvl) {
        player.getInventory().clear();
        player.getInventory().addItem(getWeapon(lvl));

        addOrReplaceAttribute(player, Attribute.MAX_HEALTH,
                "battle_health_" + lvl, 10);

        addOrReplaceAttribute(player, Attribute.SCALE,
                "battle_scale_" + lvl, 0.25);

        addOrReplaceAttribute(player, Attribute.ARMOR,
                "battle_armor_" + lvl, 5);

        player.setHealth(player.getAttribute(Attribute.MAX_HEALTH).getValue());
    }
private void addOrReplaceAttribute(Player player,
                                       Attribute attribute,
                                       String key,
                                       double amount) {

        var attr = player.getAttribute(attribute);
        if (attr == null) return;

        NamespacedKey nsKey = NamespacedKey.minecraft(key);

        attr.getModifiers().stream()
                .filter(m -> m.getKey().equals(nsKey))
                .forEach(attr::removeModifier);

        attr.addModifier(new AttributeModifier(
                nsKey,
                amount,
                AttributeModifier.Operation.ADD_NUMBER
        ));
    }

I don't know which part triggers the desync, maybe attribute part

Plugin and Datapack List

Luckperms, multiverse, nochatreports, packetevents, PlaceholderAPI, PlugmanX and the test plugin

Paper version

paper 1.21.11-62

Other

For now I delayed the action for 4 ticks and it works fine

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions