Jump to content

Recommended Posts

Posted

Hey guys,

i have a easy problem, but i do not know how to fix this..i want to make a crafting recipe with a custom block i made in another class, but i do not know how to define the ItemStack for it. At the moment it looks like this:

 

 

@EventHandler

public void preInit (FMLPreInitializationEvent event){

 

//Materialien

ItemStack stackTNT = new ItemStack(Blocks.tnt);

ItemStack stackDirt = new ItemStack(Blocks.dirt);

ItemStack stackBetterBomb = new ItemStack(BlockBetterBomb.getBlockFromItem(betterbomb));

 

//Craftingrezept, BetterBomb

GameRegistry.addRecipe(stackDirt,

"ttt",

"tdt",

"ttt",

't', stackTNT, 'd', stackBetterBomb);

}

 

 

And this is my Class for the Block:

 

 

public class BlockBetterBomb extends Block{

 

private final String name = "betterbomb";

 

public BlockBetterBomb() {

 

super(Material.tnt);

 

this.setUnlocalizedName("betterbomb");

this.setCreativeTab(CreativeTabs.tabAllSearch);

 

}

 

public String getName() {

 

return name;

}

 

public static Block getBlockFromName(Block betterbomb) {

 

return betterbomb;

}

 

public static Block getBlockFromItem(Block betterbomb) {

 

return betterbomb;

}

 

 

}

 

 

How do i manage, that my ItemStack takes this block?

Thanks for help,

 

bastianum :)

Posted

ItemStack stackBetterBomb = new ItemStack(BlockBetterBomb.getBlockFromItem(betterbomb));

 

What?  No!  Stop that.  Do it like you did your other two stacks.

 

ItemStack stackBetterBomb = new ItemStack(betterbomb)

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

I am not really understanding what you want to do but if you want to get more than 1 piece of the item you created you do this:

 

GameRegistry.addRecipe(new ItemStack(YourClass.YourItem, 1)); //this number here is the output

 

But if you want your item to take part in the crafting recipe to create a new item then you do this:

 

GameRegistry.addRecipe(new ItemStack(YourClass.YourItem, 1), new Object[]{"ABA","ABA","ABA", 'A', YourClass.YourItem, 'B', Items.Stick});

 

YourClass.YourItem is used to define the items that you created in the mod.

While Items.Stick (Stick is an example) is used to define the minecraft items in the recipe.

 

Hope it helped, but if this isn't what you wanted then i am sorry. I told you i didn't understand what you actually wanted.

Posted
  On 4/18/2015 at 2:33 PM, Draco18s said:

ItemStack stackBetterBomb = new ItemStack(BlockBetterBomb.getBlockFromItem(betterbomb));

 

What?  No!  Stop that.  Do it like you did your other two stacks.

 

ItemStack stackBetterBomb = new ItemStack(betterbomb)

 

well, this doesn't work :( i still cannot craft with my betterbomb ItemStack, if i put the items into the workbench the way i did in the source code i do not get an output :(

Posted
  On 4/18/2015 at 2:36 PM, Cerandior said:

I am not really understanding what you want to do but if you want to get more than 1 piece of the item you created you do this:

 

GameRegistry.addRecipe(new ItemStack(YourClass.YourItem, 1)); //this number here is the output

 

But if you want your item to take part in the crafting recipe to create a new item then you do this:

 

GameRegistry.addRecipe(new ItemStack(YourClass.YourItem, 1), new Object[]{"ABA","ABA","ABA", 'A', YourClass.YourItem, 'B', Items.Stick});

 

YourClass.YourItem is used to define the items that you created in the mod.

While Items.Stick (Stick is an example) is used to define the minecraft items in the recipe.

 

Hope it helped, but if this isn't what you wanted then i am sorry. I told you i didn't understand what you actually wanted.

 

No, this is not what i asked..:D i know how to make a recipe, but in my case it does not work, i do not know how to define the ItemStack for my custom block 'betterbomb' :)

Posted

Have you registered your item into the mod?

Try registering it like this:

 

GameRegistry.registerItem(nameofyouritem, youritem.getUnlocalizedName()); ==> that's for items

GameRegistry.registerBlock(nameofyouritem, youritem.getUnlocalizedName()); ==> that's for blocks

 

It may also be a problem that your mod files organize is bad.

Try creating a main class file wich loads all of your mod classes.

Also add a Strings class wich will be loaded in the main class.

Add a class for block, for items ... and so on.

This will help your mod a lot and also won't mess up the code.

Posted

package com.bastianum.betterbombs;

 

import com.bastianum.betterbombs.blocks.BlockBetterBomb;

 

import net.minecraft.block.Block;

import net.minecraft.client.Minecraft;

import net.minecraft.client.resources.model.ModelResourceLocation;

import net.minecraft.init.Blocks;

import net.minecraft.init.Items;

import net.minecraft.item.Item;

import net.minecraft.item.ItemStack;

import net.minecraftforge.fml.common.Mod;

import net.minecraftforge.fml.common.Mod.EventHandler;

import net.minecraftforge.fml.common.asm.transformers.ItemStackTransformer;

import net.minecraftforge.fml.common.event.FMLInitializationEvent;

import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;

import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;

import net.minecraftforge.fml.common.registry.GameRegistry;

 

@Mod(modid = BetterBombs.MODID)

public class BetterBombs {

 

// STANDARD

public static final String MODID = "betterbombs";

 

// ITEMS

// public static Item fireresistance_stone = new ItemFireresistancestone();

 

// BLOCKS

public static Block betterbomb = new BlockBetterBomb();

 

/**

* PREINIT

* */

 

@EventHandler

public void preInit(FMLPreInitializationEvent event) {

 

// Materialien

ItemStack stackTNT = new ItemStack(Blocks.tnt);

ItemStack stackDirt = new ItemStack(Blocks.dirt);

ItemStack stackBetterBomb = new ItemStack(betterbomb);

 

// Craftingrezept, BetterBomb

GameRegistry.addRecipe(stackDirt, "ttt", "tdt", "ttt", 't', stackTNT,

'd', stackBetterBomb);

}

 

/**

* INIT

* */

 

@EventHandler

public void init(FMLInitializationEvent event) {

 

// Item-Rendering

/*

* GameRegistry.registerItem(fireSword, "fireSword");

* ModelResourceLocation res1 = new

* ModelResourceLocation("bastianum:fireSword", "inventory");

* Minecraft.getMinecraft

* ().getRenderItem().getItemModelMesher().register(fireSword, 0, res1);

*/

 

// Block-Rendering

GameRegistry.registerBlock(betterbomb, "betterbomb");

Minecraft

.getMinecraft()

.getRenderItem()

.getItemModelMesher()

.register(

Item.getItemFromBlock(betterbomb),

0,

new ModelResourceLocation(MODID + ":"

+ ((BlockBetterBomb) betterbomb).getName(),

"inventory"));

}

 

/**

* POSTINIT

* */

 

@EventHandler

public void postInit(FMLPostInitializationEvent event) {

 

}

}

 

Posted
  On 4/18/2015 at 5:22 PM, bastianum said:

package com.bastianum.betterbombs;

 

import com.bastianum.betterbombs.blocks.BlockBetterBomb;

 

import net.minecraft.block.Block;

import net.minecraft.client.Minecraft;

import net.minecraft.client.resources.model.ModelResourceLocation;

import net.minecraft.init.Blocks;

import net.minecraft.init.Items;

import net.minecraft.item.Item;

import net.minecraft.item.ItemStack;

import net.minecraftforge.fml.common.Mod;

import net.minecraftforge.fml.common.Mod.EventHandler;

import net.minecraftforge.fml.common.asm.transformers.ItemStackTransformer;

import net.minecraftforge.fml.common.event.FMLInitializationEvent;

import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;

import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;

import net.minecraftforge.fml.common.registry.GameRegistry;

 

@Mod(modid = BetterBombs.MODID)

public class BetterBombs {

 

// STANDARD

public static final String MODID = "betterbombs";

 

// ITEMS

// public static Item fireresistance_stone = new ItemFireresistancestone();

 

// BLOCKS

[glow=red,2,300]public static Block YourBlockName;[/glow]

 

/**

* PREINIT

* */

 

@EventHandler

public void preInit(FMLPreInitializationEvent event) {

 

// Materialien

YourBlockName = new [glow=red,2,300]YourBlockName(Material.yourmaterial).setBlockName("YourDesiredName").setCreativeTab(CreativeTabs.tabBlock);[/glow]

ItemStack stackDirt = new ItemStack(Blocks.dirt);

ItemStack stackBetterBomb = new ItemStack(betterbomb);

 

// Craftingrezept, BetterBomb

GameRegistry.addRecipe(stackDirt, "ttt", "tdt", "ttt", 't', stackTNT,

'd', stackBetterBomb);

}

 

/**

* INIT

* */

 

@EventHandler

public void init(FMLInitializationEvent event) {

 

// Item-Rendering

/*

* GameRegistry.registerItem(fireSword, "fireSword");

* ModelResourceLocation res1 = new

* ModelResourceLocation("bastianum:fireSword", "inventory");

* Minecraft.getMinecraft

* ().getRenderItem().getItemModelMesher().register(fireSword, 0, res1);

*/

 

// Block-Rendering

[glow=red,2,300]GameRegistry.registerBlock(YourBlockName, YourBlockName.getUnlocalizedName());[/glow]

Minecraft

.getMinecraft()

.getRenderItem()

.getItemModelMesher()

.register(

Item.getItemFromBlock(betterbomb),

0,

new ModelResourceLocation(MODID + ":"

+ ((BlockBetterBomb) betterbomb).getName(),

"inventory"));

}

 

/**

* POSTINIT

* */

 

@EventHandler

public void postInit(FMLPostInitializationEvent event) {

 

}

}

 

Change the glowing code.

Also if this doesn't work, is your model name the same as it was in Techne or whatever program you used to create that model. Did you create the lang folder? Did you add the blocks into the lang folder? Try removing the custom model.

 

If none of these works then i am afraid i can't help you :/

I am new myself to this.

Posted
  On 4/18/2015 at 5:43 PM, bastianum said:

Thanks for trying man, but my items/blocks work well..i just need to know how i get this crafting recipe with my betterbomb compatible..:D

 

No, they don't work, because you're trying to define/declare them outside of the correct mod lifecycle.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

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

    • One fateful day, my life took an unexpected turn when I received a phone call that would change everything. The voice on the other end claimed to be from my bank, delivering alarming news: my account had been frozen due to suspicious activity. Panic surged through me as I listened, my heart racing at the thought of losing my hard-earned savings. At that moment, I had about 130,000 USD in my bank, equivalent to around 2 BTC. The caller spoke with such authority and urgency that I felt compelled to act immediately. They insisted that the only way to protect my funds was to transfer Bitcoin BTC to them for "safekeeping. In my fear and confusion, I believed I was making a wise decision to secure my finances. Without fully grasping the implications, I complied and transferred the equivalent of my savings in Bitcoin, convinced I was safeguarding my money. It wasn’t until later that the reality of my situation hit me like a ton of bricks. I had been duped, and the weight of my mistake was unbearable. Shame and disbelief washed over me as I realized how easily I had been manipulated. How could I have let this happen? The feeling of vulnerability was overwhelming, and I was left grappling with the consequences of my actions. I learned about a recovery expert named RAPID DIGITAL RECOVERY. Desperate to reclaim what I had lost, I reached out for help. RAPID DIGITAL RECOVERY was knowledgeable and reassuring, explaining that there was a chance to trace the Bitcoin I had sent. With their expertise, they tracked the stolen funds to a peer-to-peer (P2P) exchanger based in the United Kingdom. This revelation sparked a glimmer of hope within me, a sense that perhaps justice could be served. RAPID DIGITAL RECOVERY collaborated with Action Fraud, the UK's national reporting center for fraud and cybercrime, to take decisive action against the scammers. Knowing that law enforcement was involved provided me with a sense of relief. The thought that the culprits behind my suffering could be brought to justice was comforting. In an incredible turn of events, RAPID DIGITAL RECOVERY successfully recovered all my funds, restoring my faith in the possibility of justice and recovery.
    • My game crashed in 1.12.2 here is the crash log https://pastebin.com/6MYu4mGy
    • I created a Modpack Forge in 1.20.1 for my friend and I. There are 135 mods including "Essential". I was able to play an 8 hour session without problem but when I relaunch my world, I crashed when I opened the menu of the game "ESC" or after about 15 minutes of session. I can't find the source of the problem. Latest.log and Debug.log : https://paste.ee/p/B0npvlRw
    • Hello! Faced with the same problem. Can you please describe in more detail how you rewrote the toNetwork and fromNetwork methods?
    • Why not?   Please explain what you have tried, in detail. Step by step is installing the server, placing mod .jar files in the mods folder within the folder you installed the server, and running the run.bat file. If this is not working for you, please post the debug.log from the logs folder to a site like https://mclo.gs and post the link to it here.
  • Topics

×
×
  • Create New...

Important Information

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