gpt4 book ai didi

java - 使用 Eclipse 的 Minecraft 模组在运行时出现错误

转载 作者:行者123 更新时间:2023-12-01 15:35:19 25 4
gpt4 key购买 nike

我用一个 block 制作了一个工具,我在代码中没有犯任何错误。当我尝试单击“构建”时,它给出了此终端错误:我怎样才能解决这个问题?请。这是 RecipesTools.addRecipes 的代码

package net.minecraft.src;

public class RecipesTools
{
private String recipePatterns[][] =
{
{
"XXX", " # ", " # "
}, {
"X", "#", "#"
}, {
"XX", "X#", " #"
}, {
"XX", " #", " #"
}
};
private Object recipeItems[][];

public RecipesTools()
{
recipeItems = (new Object[][]
{
new Object[] {
Block.planks, Block.cobblestone, Item.ingotIron, Item.diamond, Item.ingotGold, Block.RadiatedStone
}, new Object[] {
Item.pickaxeWood, Item.pickaxeStone, Item.pickaxeSteel, Item.pickaxeDiamond, Item.pickaxeGold, Item.pickaxeRadiated
}, new Object[] {
Item.shovelWood, Item.shovelStone, Item.shovelSteel, Item.shovelDiamond, Item.shovelGold
}, new Object[] {
Item.axeWood, Item.axeStone, Item.axeSteel, Item.axeDiamond, Item.axeGold
}, new Object[] {
Item.hoeWood, Item.hoeStone, Item.hoeSteel, Item.hoeDiamond, Item.hoeGold
}
});
}

public void addRecipes(CraftingManager craftingmanager)
{
for (int i = 0; i < recipeItems[0].length; i++)
{
Object obj = recipeItems[0][i];
for (int j = 0; j < recipeItems.length - 1; j++)
{
Item item = (Item)recipeItems[j + 1][i];
craftingmanager.addRecipe(new ItemStack(item), new Object[]
{
recipePatterns[j], Character.valueOf('#'), Item.stick, Character.valueOf('X'), obj
});
}
}

craftingmanager.addRecipe(new ItemStack(Item.shears), new Object[]
{
" #", "# ", Character.valueOf('#'), Item.ingotIron
});
}
}

编辑我还给了 Eclipe 1024mb RAM 并删除了我的 .Minecraft 文件夹。

CONFLICT @ 22
27 achievements
Exception in thread "main" java.lang.ExceptionInInitializerError
at net.minecraft.src.StatList.initCraftableStats(StatList.java:74)
at net.minecraft.src.StatList.initBreakableStats(StatList.java:55)
at net.minecraft.src.Block.<clinit>(Block.java:975)
at net.minecraft.src.TextureWaterFX.<init>(TextureWaterFX.java:13)
at net.minecraft.client.Minecraft.<init>(Minecraft.java:205)
at net.minecraft.src.MinecraftImpl.<init>(MinecraftImpl.java:13)
at net.minecraft.client.Minecraft.startMainThread(Minecraft.java:1984)
at net.minecraft.client.Minecraft.startMainThread1(Minecraft.java:1970)
at net.minecraft.client.Minecraft.main(Minecraft.java:2032)
at Start.main(Start.java:25)
Caused by: java.lang.ArrayIndexOutOfBoundsException: 5
at net.minecraft.src.RecipesTools.addRecipes(RecipesTools.java:44)
at net.minecraft.src.CraftingManager.<init>(CraftingManager.java:19)
at net.minecraft.src.CraftingManager.<clinit>(CraftingManager.java:8)
... 10 more

最佳答案

recipeItems[0].length 是 6。但是 recipeItems[2] 及其后面只有五个元素。因此,您在 addRecipes 中的顶级循环是错误的。

您可能应该为此使用集合类型( vector 、列表、Array...)和迭代器,这将使代码更安全、更具可读性(IMO)。

关于java - 使用 Eclipse 的 Minecraft 模组在运行时出现错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8951494/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com