Repository navigation
Labels
status: acceptedDisputed bug is accepted as valid or Feature accepted as desired to be added.type: bugSomething doesn't work as it was intended to.version: 1.20.6Game version 1.20.6
Description
Expected behavior
When you get a MerchantRecipe from a villager and call one of the setters on it, either they should not be reflected without setting back the recipe to the villager, or all of the setters should be reflected. In other words, it should be consistent one way or another.
Observed/Actual behavior
Some of the setters mutate the actual nms MerchantOffer, while others only take effect after a "refresh" of the trades by actually making a trade.
Steps/models to reproduce
Use the code below in a test plugin
@EventHandler
public void onEvent(PlayerChatEvent event) {
final Location loc = event.getPlayer().getTargetBlockExact(5).getLocation();
final Villager villager = event.getPlayer().getWorld().spawn(loc.toCenterLocation().add(0, 1.5, 0), Villager.class);
villager.setProfession(Villager.Profession.CLERIC);
final MerchantRecipe recipe = new MerchantRecipe(new ItemStack(Material.DIAMOND, 64), 0, 100, false);
recipe.addIngredient(new ItemStack(Material.STICK, 10));
Bukkit.getServer().getScheduler().runTaskLater(this, () -> {
villager.setMemory(MemoryKey.JOB_SITE, loc);
villager.setRecipes(List.of(recipe));
}, 50L);
}
@EventHandler
public void onEvent(PlayerInteractEvent event) {
final ItemStack item = event.getItem();
if (item != null && item.getType() == Material.STICK) {
final Villager villager = event.getPlayer().getLocation().getNearbyEntitiesByType(Villager.class, 5).iterator().next();
final MerchantRecipe recipe = villager.getRecipe(0);
recipe.setExperienceReward(true);
recipe.setIngredients(List.of(new ItemStack(Material.STICK, 5)));
}
}- Look at brewing stand and type in chat
- Wait a few seconds, then check that the villager only has 1 trade (10 sticks -> 54 diamonds). If it's not there, just try again.
- Get some sticks and make a trade. NOTE how there is no xp rewarded.
- hold a stick and hit the ground
- Open the trade screen again (notice how its still 10 sticks)
- Make another trade, it should only take 5 sticks because the act of interacting with the trade screen refreshes the changes made
- XP is rewarded indicating the trade was changed, but the visuals only change after you actually interact. If you close and re-open now, you should see the changed trade.
Plugin and Datapack List
just a test plugin
Paper version
Other
No response
Metadata
Metadata
Assignees
Labels
status: acceptedDisputed bug is accepted as valid or Feature accepted as desired to be added.type: bugSomething doesn't work as it was intended to.version: 1.20.6Game version 1.20.6
Type
Fields
MC Issue
None yet
Projects
- StatusShow more project fields✅ Accepted
Activity