1
我是新來的插件開發BukkitBukkit/JavaPlugin - 設置結果爲現有的各具特色的食譜不工作
對於我的私人服務器的Minecraft我想添加/修改各具特色的食譜。我想手藝SlimeBlocks只有4個SlimeBalls所以這裏是我得到:
@Override
public void onEnable() {
ItemStack slimeBlockStack = new ItemStack(Material.SLIME_BLOCK);
ShapedRecipe slimeBlockRecipe = new ShapedRecipe(slimeBlockStack);
slimeBlockRecipe.shape("###", "#oo", "#oo");
slimeBlockRecipe.setIngredient('o', Material.SLIME_BALL);
slimeBlockRecipe.setIngredient('#', Material.AIR);
getServer().addRecipe(slimeBlockRecipe);
//....here comes more
}
現在讓你無法通過制定與4塊,然後起草回9個slimeballs「欺騙」 slimeballs我要重寫結局現有的手工製作配方 - 我試圖遍歷所有的配方列表,然後設置結果的量,但它不工作...
Iterator<Recipe> it = Bukkit.getServer().recipeIterator();
while(it.hasNext()) {
ItemStack result = it.next().getResult();
if(result.isSimilar(new ItemStack(Material.SLIME_BALL))) {
result.setAmount(4);
}
}
什麼我做錯了,我apreciate每個幫助/提示
任何錯誤onEnable方法/是什麼控制檯說? – MCMastery
只需簡單的看一下,'Bukket.getServer()。recipeIterator()'可能是隻讀的。 – MCMastery
@MCMastery no no錯誤沒有警告,如果我記錄結果的emount它顯示正確的值,但在Minecraft中沒有任何變化。我不認爲它的只讀,因爲然後setAmount會拋出和錯誤/警告?! – KilledByCheese