@Override public void setMerchantRecipe(int index, MC_MerchantRecipe recipe) { Field field = ReflectionAPI.getField(this.villager.getClass(), "br", true); MerchantRecipeList recipes = (MerchantRecipeList) ReflectionAPI.getValue(this.villager, field); if (index > recipes.size()) { recipes.set(recipes.size(), (MerchantRecipe) recipe.toMerchantRecipeNms()); } else { recipes.set(index, (MerchantRecipe) recipe.toMerchantRecipeNms()); } ReflectionAPI.setValue(this.villager, field, recipes); }
@Override public List<MC_MerchantRecipe> getMerchantRecipeList() { List<MC_MerchantRecipe> recipes = new ArrayList<MC_MerchantRecipe>(); MerchantRecipeList nms_recipes = (MerchantRecipeList) ReflectionAPI.getValue( this.villager, ReflectionAPI.getField(this.villager.getClass(), "br", true)); MerchantRecipe recipe; for (int i = 0; i < nms_recipes.size(); i++) { recipe = (MerchantRecipe) nms_recipes.get(i); try { recipes.add(new MC_MerchantRecipe(recipe)); } catch (Exception e) { e.printStackTrace(); } } return recipes; }