-
Type: Bug
-
Resolution: Fixed
-
Priority: Minor
-
None
-
Affects Version/s: None
-
None
-
This server is running CraftBukkit version 4306-Spigot-a759b62-bd8aded (MC: 1.21.1) (Implementing API version 1.21.1-R0.1-SNAPSHOT)
-
Yes
The second ingredient in trades can no longer be removed using `MerchantRecipe.removeIngredient(1)` or `MerchantRecipe.setIngredients(...)`.
Sample code:
@EventHandler
public void onAcquireTrade(VillagerAcquireTradeEvent event) {
event.getRecipe().setIngredients(List.of(new ItemStack(Material.STICK, 12), new ItemStack(Material.EMERALD, 1)));
AbstractVillager villager = event.getEntity();
Bukkit.getScheduler().runTaskLater(BugReport.getPlugin(BugReport.class), () -> {
for (int i = 0; i < villager.getRecipeCount(); i++) {
MerchantRecipe recipe = villager.getRecipe;
getLogger().info("Ingredients: " + recipe.getIngredients());
// also doesn't work
// if (recipe.getIngredients().size() > 1)
// recipe.removeIngredient(1);
recipe.setIngredients(List.of(new ItemStack(Material.OAK_LOG, 11)));
villager.setRecipe(i, recipe);
}, 1);
Expected behavior: ingredient 1 will be empty
Actual behavior: ingredient 1 is still an emerald