PaperMC / Paper

The most widely used, high performance Minecraft server that aims to fix gameplay and mechanics inconsistencies
https://papermc.io/
Other
9.86k stars 2.28k forks source link

Removing an entity which is a passenger of another entity does not result in the passengers list being updated #8601

Closed nicolasvac closed 1 year ago

nicolasvac commented 1 year ago

Expected behavior

If i spawn an armor stand and put it as a passenger to a HORSE, and then 5 seconds later I do armorStand.remove() though a sync task, the armor stand despawns correctly and the passengers of that horse should go to zero, as i asked the world to remove that entity.

Observed/Actual behavior

If i spawn an armor stand and put it as a passenger to a HORSE, and then 5 seconds later I do armorStand.remove() though a sync task, the armor stand despawns correctly but the passengers list of that horse stays at 1, and it gets triggered constantly

Steps/models to reproduce

var horseEntity = sender.getWorld().spawnEntity(sender.getLocation().add(0, 2, 0), EntityType.HORSE);

        var dataArmorStand = (ArmorStand) sender.getWorld().spawnEntity(sender.getLocation().subtract(0, 1, 0), EntityType.ARMOR_STAND);

        // Set default armor stand data.
        dataArmorStand.setCustomNameVisible(true);
        dataArmorStand.setInvulnerable(true);
        dataArmorStand.setCollidable(false);
        dataArmorStand.setCanMove(false);
        dataArmorStand.setInvisible(true);
        dataArmorStand.setPersistent(false);
        dataArmorStand.setMetadata("health_bar_armor_stand", new FixedMetadataValue(plugin, horseEntity.getUniqueId()));

        // Set the armor stand name.
        dataArmorStand.customName("X");

        horseEntity.addPassenger(dataArmorStand);

        Bukkit.getScheduler().runTaskLater(plugin, dataArmorStand::remove, 100L);

        Bukkit.getScheduler().runTaskTimer(plugin, () -> {
            sender.sendMessage(Component.text(horseEntity.getPassengers().size()));
        }, 20L, 100L);

Plugin and Datapack List

Plugins (2): LuckPerms, Survival (custom plugin)

Paper version

Checking version, please wait... This server is running Paper version git-Paper-301 (MC: 1.19.2) (Implementing API version 1.19.2-R0.1-SNAPSHOT) (Git: c40f8d5) You are running the latest version Previous version: git-Paper-300 (MC: 1.19.2)

Other

No response

electronicboy commented 1 year ago

This really just sounds like vanilla behavior, in which if it is the case I'm not sure if it's something we care about handling

nicolasvac commented 1 year ago

Even if it comes out being vanilla behavior, it just seems an unlogic thing to have a global remove() method for the entity that does not assure true removal from all the possible relations and behaviors with the world and other entities.

Owen1212055 commented 1 year ago

This is not actually an issue, passengers are correctly removed. Your logic with tasks is causing it to print as 1 because the armorstand hasn't actually been removed yet.