Jump to content

Recommended Posts

Posted

So I just started using forge to make mods (I use to just use ModLoder) but I've come across an issue. If I want to add smelting or crafting recipes using my custom items/blocks it crashes my game.

 

Here's some examples of recipes I've tried adding.

 

GameRegistry.addSmelting(Block.bedrock.blockID, new ItemStack(tes_BaseMod.moonstone), 100);

 

                GameRegistry.addRecipe(new ItemStack(tes_BaseMod.moonstone, 1), new Object[]{
                	" X ", " X ", "XXX", Character.valueOf('X'), Block.blockClay, Character.valueOf('P'), Item.paper
                });

-

 

- My main mod class is tes_BaseMod.

 

- Bedrock is there just as an example.

 

- If I replace tes_BaseMod.moonstone with a vanilla block/item it works.

 

- What would I add into both highlighted area to make them work with custom blocks/items???

 

-

Posted

just do it like this

 

                GameRegistry.addRecipe(new ItemStack(tes_BaseMod.moonstone, 1), new Object[]{
                	" X ", " X ", "XXX", 'X', Block.blockClay, 'P', Item.paper
                });

 

and this

GameRegistry.addSmelting(Block.bedrock.blockID, new ItemStack(this.moonstone), 100);

Posted

just do it like this

 

                GameRegistry.addRecipe(new ItemStack(tes_BaseMod.moonstone, 1), new Object[]{
                	" X ", " X ", "XXX", 'X', Block.blockClay, 'P', Item.paper
                });

 

and this

GameRegistry.addSmelting(Block.bedrock.blockID, new ItemStack(this.moonstone), 100);

 

I tried both of those and my game continues crashing. Here's the entitre tes_BaseMod file because ive looked at coutless tutorials and after following them I still keep crashing.

 

package gurman8r.tescraft.src;

//Imports
import net.minecraft.block.Block;
import net.minecraft.block.BlockHalfSlab;
import net.minecraft.block.BlockStairs;
import net.minecraft.block.BlockStep;
import net.minecraft.block.BlockTorch;
import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.EnumToolMaterial;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.FurnaceRecipes;
import net.minecraftforge.common.MinecraftForge;

import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.Init;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.Mod.PostInit;
import cpw.mods.fml.common.Mod.PreInit;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.network.NetworkMod;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.LanguageRegistry;



@Mod(modid="tesCraft", name="TES Craft", version="0.0.1")
@NetworkMod(clientSideRequired=true, serverSideRequired=false)
public class tes_BaseMod<daedricIngot> {

        // The instance of your mod that Forge uses.
        @Instance("tesCraft")
        public static tes_BaseMod instance;
        
        // Says where the client and server 'proxy' code is loaded.
        @SidedProxy(clientSide="gurman8r.tescraft.client.ClientProxy", serverSide="gurman8r.tescraft.CommonProxy")
        public static CommonProxy proxy;
        
        @PreInit
        public void preInit(FMLPreInitializationEvent event) 
        {
                // Stub Method
        }
        
        @Init
        public void load(FMLInitializationEvent event) 
        {
                proxy.registerRenderers();
                
                //TES Craft Creative Tab
                LanguageRegistry.instance().addStringLocalization("itemGroup.tabTesCraft", "en_US", "TES Craft");
                
                /**
                 * Put recipes here:
                 */
                GameRegistry.addSmelting(Block.bedrock.blockID, new ItemStack(this.moonstone), 100);
                
                GameRegistry.addRecipe(new ItemStack(tes_BaseMod.moonstone, 1), new Object[]{
                	" X ", " X ", "XXX", 'X', Block.blockClay, 'P', Item.paper
                });

                /**
                 * Put blocks here:
                 */
                final Block tesForge = new BlockForge(500, 0, Material.rock).setHardness(3.5F).setResistance(5.0F).setBlockName("tesForge").setCreativeTab(this.tabTesCraft);
                GameRegistry.registerBlock(tesForge, "tesForge");
                LanguageRegistry.addName(tesForge, "Forge");
                
                final Block moonstoneOre = new BlockMoonstoneOre(517, 16, Material.rock).setHardness(5.0F).setResistance(5.0F).setBlockName("moonstoneOre").setCreativeTab(this.tabTesCraft);
                GameRegistry.registerBlock(moonstoneOre, "moonstoneOre");
                LanguageRegistry.addName(moonstoneOre, "Moonstone Ore");
                MinecraftForge.setBlockHarvestLevel(moonstoneOre, "pickaxe", 0);
                
                final Block malachiteOre = new BlockMalachiteOre(518, 17, Material.rock).setHardness(10.0F).setResistance(5.0F).setBlockName("malachiteOre").setCreativeTab(this.tabTesCraft);
                GameRegistry.registerBlock(malachiteOre, "malachiteOre");
                LanguageRegistry.addName(malachiteOre, "Malachite Ore");
                MinecraftForge.setBlockHarvestLevel(malachiteOre, "pickaxe", 0);
                
                final Block orichalcumOre = new BlockOrichalcumOre(519, 18, Material.rock).setHardness(15.0F).setResistance(5.0F).setBlockName("orichalcumOre").setCreativeTab(this.tabTesCraft);
                GameRegistry.registerBlock(orichalcumOre, "orichalcumOre");
                LanguageRegistry.addName(orichalcumOre, "Orichalcum Ore");
                MinecraftForge.setBlockHarvestLevel(orichalcumOre, "pickaxe", 0);
                
                final Block ebonyOre = new BlockEbonyOre(520, 19, Material.rock).setHardness(40.0F).setResistance(15.0F).setBlockName("ebonyOre").setCreativeTab(this.tabTesCraft);
                GameRegistry.registerBlock(ebonyOre, "ebonyOre");
                LanguageRegistry.addName(ebonyOre, "Ebony Ore");
                MinecraftForge.setBlockHarvestLevel(ebonyOre, "pickaxe", 0);
               
                
                /**
                 * Put items here:
                 */
                steelIngot = new ItemSteelIngot(4000, 0).setItemName("steel ingot").setCreativeTab(this.tabTesCraft);
                LanguageRegistry.addName(steelIngot, "Steel Ingot");

                moonstone = new ItemMoonstone(4001, 1).setItemName("moonstone").setCreativeTab(this.tabTesCraft);
                LanguageRegistry.addName(moonstone, "Moonstone");
                
                malachite = new ItemMalachite(4002, 2).setItemName("malachite").setCreativeTab(this.tabTesCraft);
                LanguageRegistry.addName(malachite, "Malachite");
                
                dwarvenMetal = new ItemDwarvenMetal(4003, 3).setItemName("dwarvenMetal").setCreativeTab(this.tabTesCraft);
                LanguageRegistry.addName(dwarvenMetal, "Dwarven Scrap Metal");
                
                corundumIngot = new ItemCorundumIngot(4004, 4).setItemName("corundumIngot").setCreativeTab(this.tabTesCraft);
                LanguageRegistry.addName(corundumIngot, "Dwarven Metal Ingot");
                
                orichalcumIngot = new ItemOrichalcum(4005, 5).setItemName("orichalcumingot").setCreativeTab(this.tabTesCraft);
                LanguageRegistry.addName(orichalcumIngot, "Orichalcum Ingot");
                
                ebonyIngot = new ItemEbonyIngot(4006, 6).setItemName("ebonyingot").setCreativeTab(this.tabTesCraft);
                LanguageRegistry.addName(ebonyIngot, "Ebony Ingot");
                
                daedricIngot = new ItemDaedricIngot(4007, 7).setItemName("daedric ingot").setCreativeTab(this.tabTesCraft);
                LanguageRegistry.addName(daedricIngot, "Daedric Ingot");
                

        }
        
        @PostInit
        public void postInit(FMLPostInitializationEvent event) 
        {
                // Stub Method
        }
        public static Item steelSword;
        public static Item elvenSword;
        public static Item glassSword;
        public static Item dwarvenSword;
        public static Item orcishSword;
        public static Item ebonySword;
        public static Item daedricSword;
        
        static EnumToolMaterial tesSteel = net.minecraftforge.common.EnumHelper.addToolMaterial("Steel", 2, 350, 6F, 4, 14);
        
        public static CreativeTabs tabTesCraft = new TabTesCraft("tabTesCraft");
        public static Item steelIngot;
        public static Item moonstone;
        public static Item corundumIngot;
        public static Item malachite;
        public static Item dwarvenMetal;
        public static Item orichalcumIngot;
        public static Item ebonyIngot;
        public static Item daedricIngot;
}

Posted

                GameRegistry.addRecipe(new ItemStack(tes_BaseMod.moonstone, 1), new Object[]{

                " X ", " X ", "XXX", 'X', Block.blockClay, 'P', Item.paper

                });

 

I only see You use the block Clay but not the paper. thats the mistake i think because he can not fine the symbol from the paper (P).

Maybe that crashes your game

Posted

I would have done it like this:

ItemStack moonstone = new ItemStack(tes_BaseMod.moonstone);
ItemStack clay = new ItemStack(Block.blockClay);
ItemStack paper = new ItemStack(Item.paper);

GameRegistry.addSmelting(new ItemStack(Block.bedrock, 1), clay, 1.0F);

GameRegistry.addRecipe(new ItemStack(tes_BaseMod.moonstone, 1), " X ", " X ", "XPX", 'X', clay, 'P', paper);

The last parameter in the furnace recipe is a float so you need F at the end. This gives the same ammount of exp that diamonds give you when mined.

 

This won't give you any errors at all.

Posted

No, the @Instance inst what's crashing it, but if another mod that puts @instance loads with yours then it will crash the game

"you seem to be THE best modder I've seen imo."

~spynathan

 

ლ(́◉◞౪◟◉‵ლ

Posted

Can you post the error? That would make it much easier to pinpoint the problem.

 

 

@thebest108: The @Instance has nothing to do with it. Every mod is supposed to have @Instance in it, so having two mods with @Instance in it will not crash the game.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Hi everyone, I'm currently developing a Forge 1.21 mod for Minecraft and I want to display a custom HUD overlay for a minigame. My goal: When the game starts, all players should see an item/block icon (from the base game, not a custom texture) plus its name/text in the HUD – similar to how the bossbar overlay works. The HUD should appear centered above the hotbar (or at a similar prominent spot), and update dynamically (icon and name change as the target item changes). What I've tried: I looked at many online tutorials and several GitHub repos (e.g. SeasonHUD, MiniHUD), but most of them use NeoForge or Forge versions <1.20 that provide the IGuiOverlay API (e.g. implements IGuiOverlay, RegisterGuiOverlaysEvent). In Forge 1.21, it seems that neither IGuiOverlay nor RegisterGuiOverlaysEvent exist anymore – at least, I can't import them and they are missing from the docs and code completion. I tried using RenderLevelStageEvent as a workaround but it is probably not intended for custom HUDs. I am not using NeoForge, and switching the project to NeoForge is currently not an option for me. I tried to look at the original minecraft source code to see how elements like hearts, hotbar etc are drawn on the screen but I am too new to Minecraft modding to understand. What I'm looking for: What is the correct way to add a custom HUD element (icon + text) in Forge 1.21, given that the previous overlay API is missing? Is there a new recommended event, callback, or method in Forge 1.21 for custom HUD overlays, or is everyone just using a workaround? Is there a minimal open-source example repo for Forge 1.21 that demonstrates a working HUD overlay without relying on NeoForge or deprecated Forge APIs? My ideal solution: Centered HUD element with an in-game item/block icon (from the base game's assets, e.g. a diamond or any ItemStack / Item) and its name as text, with a transparent background rectangle. It should be visible to the players when the mini game is running. Easy to update the item (e.g. static variable or other method), so it can change dynamically during the game. Any help, code snippets, or up-to-date references would be really appreciated! If this is simply not possible right now in Forge 1.21, it would also help to know that for sure. Thank you very much in advance!
    • The simple answer is there is not an easy way. You would need to know how to program in Java, as well as at least some familiarity with how Forge works so you could port the differences. You would also need the sourcecode for the original mod, and permission from the author to modify it, if they did not use some sort of open source license. So it's not impossible, but it would take some effort, but doing so would open up a whole new world of possibilities for you!
    • Does it still crash if you remove holdmyitems? Looks like that mod doesn't work on a server as far as I can tell from the error.  
    • Crashes the server when trying to start. Error code -1. Log  
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.