[SPIGOT-1593] Issues with MerchantRecipe API Created: 01/Mar/16 Updated: 13/Mar/16 Resolved: 12/Mar/16 |
|
Status: | Resolved |
Project: | Spigot |
Component/s: | None |
Affects Version/s: | None |
Fix Version/s: | None |
Type: | Bug | Priority: | Minor |
Reporter: | Nathan Wolf | Assignee: | Xor Boole |
Resolution: | Fixed | Votes: | 1 |
Labels: | 1.9 | ||
Environment: |
Spigot 1.9 |
Attachments: |
![]() |
Description |
I am attempting to use the new MerchantRecipe API via the following code: String outputKey = tradeConfiguration.getString("output"); ItemStack output = controller.createItem(outputKey); if (output == null || output.getType() == Material.AIR) { controller.getLogger().warning("Invalid output specified in villager trade: " + outputKey); continue; } MerchantRecipe recipe = new MerchantRecipe(output, tradeConfiguration.getInt("max_uses", 1)); recipe.setExperienceReward(tradeConfiguration.getBoolean("experience_reward", true)); List<String> ingredientConfiguration = tradeConfiguration.getStringList("ingredients"); for (String ingredientKey : ingredientConfiguration) { ItemStack ingredient = controller.createItem(ingredientKey); if (ingredient == null || ingredient.getType() == Material.AIR) { controller.getLogger().warning("Invalid ingredient specified in villager trade: " + ingredientKey); continue; } recipe.addIngredient(ingredient); } villagerData.recipes.add(recipe); I have verified via debug prints that I am giving valid items to the villager. An example configuration I was testing is a simple emerald to stick conversion. The villager shows the emerald and a blank slot only. If I add an emerald to the trade slot, I will get a client crash. I also get a chunk save error- both logs are attached. |
Comments |
Comment by Nathan Wolf [ 13/Mar/16 ] |
I can verify that this is working now, using the example plugin I provided above or my own plugin code. Thank you! |
Comment by md_5 [ 12/Mar/16 ] |
I think my last commit fixed this, please try again. |
Comment by Nathan Wolf [ 02/Mar/16 ] |
I was able to reproduce with just this simple plugin and nothing else installed: https://github.com/NathanWolf/MerchantRecipeTest Let me know if you want a build, I could throw it up on my CI- should build easily with Maven, though. The only relevant code: Villager villager = (Villager)merchant; List<MerchantRecipe> recipes = new ArrayList<MerchantRecipe>(); MerchantRecipe recipe = new MerchantRecipe(new ItemStack(Material.DIAMOND, 2), 20); recipe.setExperienceReward(true); recipe.addIngredient(new ItemStack(Material.EMERALD)); recipes.add(recipe); villager.setRecipes(recipes); Same behavior- trade with an emerald input and no output, when I put an emerald in the slot I get a client crash and chunk save error. Thanks! |
Comment by Xor Boole [ 02/Mar/16 ] |
I am unable to reproduce... can you either check your code or provide a small test-plugin? |