简体   繁体   English

Minecraft Forge中的从初始化到初始化错误

[英]PreInitialisation to initialisation error in Minecraft Forge

I was making a mod and tried to add crafting recipies. 我正在制作一个mod,并试图添加手工艺品。
When I tried to launch it, it crashed and left a report. 当我尝试启动它时,它崩溃并留下了报告。 Can someone please tell me what I need to do to fix this? 有人可以告诉我解决该问题我需要做什么吗?

---- Minecraft Crash Report ---- // Quite honestly, I wouldn't worry myself about that. ----《我的世界》崩溃报告---- //老实说,我不会为此担心。

Time: 19/04/16 20:25 Description: Initializing game 时间:2016年4月19日20:25说明:正在初始化游戏

java.lang.StringIndexOutOfBoundsException: String index out of range: 5 at java.lang.String.charAt(Unknown Source) at net.minecraft.item.crafting.CraftingManager.addRecipe(CraftingManager.java:232) at cpw.mods.fml.common.registry.GameRegistry.addShapedRecipe(GameRegistry.java:250) at java.lang.StringIndexOutOfBoundsException:字符串索引超出范围:net.minecraft.item.crafting.CraftingManager.addRecipe(CraftingManager.java:232)处的java.lang.String.charAt(Unknown Source)处为5 .common.registry.GameRegistry.addShapedRecipe(GameRegistry.java:250)位于
cpw.mods.fml.common.registry.GameRegistry.addShapedRecipe(GameRegistry.java:250) at cpw.mods.fml.common.registry.GameRegistry.addRecipe(GameRegistry.java:245) at com.Abhijith.Main.CraftingManager.addCraftingRec(CraftingManager.java:18) at com.Abhijith.Main.CraftingManager.MainRegistry(CraftingManager.java:13) at com.Abhijith.Main.MainRegistry.Preload(MainRegistry.java:23) at A lot of unneeeded lines follow... cpw.mods.fml.common.registry.GameRegistry.addRecipe(GameRegistry.java:245)上的cpw.mods.fml.common.registry.GameRegistry.addShapedRecipe(GameRegistry.java:250)com.Abhijith.Main.CraftingManager上的cpw.mods.fml.common.registry.GameRegistry.addRecipe(GameRegistry.java:245)。 com.Abhijith.Main.CraftingManager.MainRegistry(CraftingManager.java:13)的com.Abhijith.Main.MainRegistry.Preload(MainRegistry.java:23)的addCraftingRec(CraftingManager.java:18)出现在很多地方。 ..

here is my crafting manager 这是我的手工经理

public class CraftingManager {
    public static void MainRegistry(){
        addCraftingRec();
        addSmeltingRec();
    }
    public static void addCraftingRec(){
        //Shaped
        GameRegistry.addRecipe(new ItemStack(MBlocks.DiaSlab, 3), new Object[]{" "," ","XXX",'X', Blocks.diamond_block});
        GameRegistry.addRecipe(new ItemStack(MItems.oStick, 1), new Object[]{" X "," X ", 'X', Blocks.obsidian});
        //Shapeless
    }
    public static void addSmeltingRec(){
        GameRegistry.addSmelting(Blocks.coal_block, new ItemStack(Blocks.obsidian, 1), 20.0f);

    }
}
java.lang.StringIndexOutOfBoundsException: 
String index out of range: 5 at java.lang.String.charAt(Unknown Source) at 
net.minecraft.item.crafting.CraftingManager.addRecipe(CraftingManager.java:232) at 

StringIndexOutOfBounds means: if you have a string that has a length of 4, and try to access position 5, it does not exist, and you get this problem. StringIndexOutOfBounds意思是:如果您有一个长度为4的字符串,并尝试访问位置5,则该字符串不存在,并且会出现此问题。

"hello" > length 5 h 0 e 1 l 2 l 3 o 4 “ hello”>长度5 h 0 e 1 l 2 l 3 o 4

it has 5 elements. 它有5个元素。 But if you try to access it at 5, "hello".charAt(5) you'll get an string index out of bounds, because index 5 does not exist. 但是,如果您尝试在5处访问它,则“ hello” .charAt(5)将使字符串索引超出范围,因为索引5不存在。

You probaly defined your recipe wrong. 您可能将配方定义错误。

So check your recipe in CraftingManager.java:232 <-- line number 因此,请在CraftingManager.java:232 <-行号中检查您的配方

and check your documentation. 并检查您的文档。

Without code, I can't help you. 没有代码,我无能为力。

EDIT 编辑

From the comments: 从评论:

DiaSlab, 3), new Object[]{" "," ","XXX" those strings before the XXX need to be >equal lenth. DiaSlab,3),新的Object [] {“”,“”,“ XXX” XXX之前的那些字符串必须等于等长。 Make them 3 spaces. 使它们成为3个空格。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM