@SuppressWarnings("unchecked") @Override public boolean openTradeWindow(String name, List<ItemStack[]> recipes, Player player) { try { EntityVillager villager = new EntityVillager(((CraftPlayer) player).getHandle().world, 0); if (name != null && !name.isEmpty()) { villager.setCustomName(name); } Field recipeListField = EntityVillager.class.getDeclaredField("bu"); recipeListField.setAccessible(true); MerchantRecipeList recipeList = (MerchantRecipeList) recipeListField.get(villager); if (recipeList == null) { recipeList = new MerchantRecipeList(); recipeListField.set(villager, recipeList); } recipeList.clear(); for (ItemStack[] recipe : recipes) { recipeList.add(createMerchantRecipe(recipe[0], recipe[1], recipe[2])); } villager.a(((CraftPlayer) player).getHandle()); return true; } catch (Exception e) { e.printStackTrace(); return false; } }