Paper icon indicating copy to clipboard operation
Paper copied to clipboard

When cancelled VillagerCareerChangeEvent particle still spawn

Open dannyball710 opened this issue 3 years ago • 2 comments
trafficstars

Expected behavior

When cancelled career change default particle don't spawn.

Observed/Actual behavior

When cancelled career change but default particle still spawn.

Steps/models to reproduce

@EventHandler
public void onVillagerCareerChange(VillagerCareerChangeEvent e) {
    if (e.getReason() == VillagerCareerChangeEvent.ChangeReason.EMPLOYED) {
        e.setCancelled(true);
    }
}

Plugin and Datapack List

Only my plugin

Paper version

git-Paper-265 (MC: 1.19.2) (Implementing API version 1.19.2-R0.1-SNAPSHOT) (Git: 117579c)

Other

No response

dannyball710 avatar Nov 14 '22 16:11 dannyball710

Hmm the error is because NMS later of modify the memory for the potential and the job site send the particle for happy and try with a optional to set the Career where the event is..

not sure if the particle need to be moved for the completation of the behaviour in NMS..

Doc94 avatar Nov 15 '22 17:11 Doc94

Yea it is a bit of a philosophical question. The entity event right now is part of the villager assigning its job site. This does not correlate with a change in profession, e.g. cancelling the event may not really have to cancel it, just how the event rn does not remove the job site memory when cancelled.

lynxplay avatar Nov 15 '22 17:11 lynxplay

Yeah.. maybe need more comments for think in a PR.. i mean i can move the code for the particles later when the job is set and the event not cancel... but not sure if this affect the perspective of the entity with the particles... like said the particles can be more a start process than a finish process...

Doc94 avatar Nov 28 '22 13:11 Doc94

Based on where the particles are spawned in the logic surrounding assigning job site, this is works as intended. Take the following example where a villager exists and has a job next to a composter. This villager has been traded with so will not lose its profession when the composter is destroyed. Destroy the composter and place a new one. The villager will emit particles but no VillagerCareerChangeEvent will be fired because it didn't change. Therefore the particles are because of the job site being assigned, not the career changed.

Machine-Maker avatar Mar 28 '23 18:03 Machine-Maker