예제 #1
0
 @Override
 public void addMerchantRecipe(MC_MerchantRecipe recipe) {
   Field field = ReflectionAPI.getField(this.villager.getClass(), "br", true);
   MerchantRecipeList recipes = (MerchantRecipeList) ReflectionAPI.getValue(this.villager, field);
   recipes.add((MerchantRecipe) recipe.toMerchantRecipeNms());
   ReflectionAPI.setValue(this.villager, field, recipes);
 }
예제 #2
0
 @Override
 public void setMerchantRecipe(List<MC_MerchantRecipe> recipes) {
   MerchantRecipeList nms_recipes = new MerchantRecipeList();
   for (MC_MerchantRecipe recipe : recipes) {
     nms_recipes.add((MerchantRecipe) recipe.toMerchantRecipeNms());
   }
   ReflectionAPI.setValue(
       this.villager, ReflectionAPI.getField(this.villager.getClass(), "br", true), nms_recipes);
 }
예제 #3
0
 @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);
 }
예제 #4
0
 @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;
 }