Nedas Bolevičius
Nedas Bolevičius

Reputation: 321

minecraft forge 1.10 creating crafting recipes crashes minecraft

I am trying to make a mod but I encountered this issue. When I try to create a crafting recipe it crashes my game. I am really not sure why. I tried using Items.COOKED_BEEF also tried Item.cooked_beef. I imported everything I needed but it still doesn't work.

package Nedas60.TestMod.init;

import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fml.common.registry.GameRegistry;

public class ModCrafting {

    public static void register() {
        ItemStack diamond  = new ItemStack(Items.DIAMOND);
        ItemStack beef  = new ItemStack(Items.COOKED_BEEF);
        ItemStack DmdBeef = new ItemStack(ModItems.DiamondBeef);

        GameRegistry.addShapedRecipe(DmdBeef, diamond, beef);
    }
}

Eclipse says everything is okay here. Using lowercase letters Items.cooked_beef doesn't work. What is the problem?

Error log: http://pastebin.com/7nmk2tfr

Upvotes: 1

Views: 738

Answers (1)

Alpvax
Alpvax

Reputation: 172

You are trying to add a shaped recipe without defining a shape. You should either use a shapeless recipe, or set the recipe shape using 1-3 strings with 1-3 characters in each (1 string for each row, 1 character for each square in the row).

Some examples of shaped recipes:
//diamond above beef GameRegistry.addShapedRecipe(DmdBeef, "D", "B", 'D', diamond, 'B', beef);

//diamond on the left of beef GameRegistry.addShapedRecipe(DmdBeef, "DB", 'D', diamond, 'B', beef);

//diamond on the left of beef, with a blank space to the left, and 2 blank rows beneath it GameRegistry.addShapedRecipe(DmdBeef, "ADB", "AAA", "AAA", 'D', diamond, 'B', beef);

There are plenty more tutorials and examples on the forge documentation site, the minecraftforums and just googling will show some more.

The characters you use are not important, you could use '@' for diamond for example. Any characters not specified (such as 'A' in the last example) will be required to be blank. If not all 9 characters are specified, the ones that are can be put in the correct formation anywhere in the grid.

Just as an aside, standard java practice is to have variables start with a lowercase letter (DmdBeef should be dmdBeef).

Upvotes: 3

Related Questions