Jump to content

Recommended Posts

Posted (edited)

I'm creating a mod for 1.12 and I add the Copper Ore and the Ingot Copper, but when I put the Copper Ore in the Furnace nothing happen.

Here's the code:

 

  Reveal hidden contents

 

Please help me!!!

Edited by leosavi25
Posted
  Reveal hidden contents

 

  Reveal hidden contents
  Reveal hidden contents

 

Posted

I saw it in a tutorial on Internet and if I run the code it work(I don't know how it works) : I have the copper block and the copper ingot, but when i put the copper ore in the furnace, it didn't work. I try to change the code to GameRegistry.addSmelting(ItemInit.COPPER_INGOT, new ItemStack(ItemInit.COPPER_INGOT), 0.2f); and it work because if I smelt a copper ingot it makes a Copper Ingot, I try to change also with Blocks.DIRT and it work but with BlockInit.ORE_COPPER_ORE it doesn't work

Posted (edited)

I found where I add the ore copper and the copper ingot

  Reveal hidden contents
  Reveal hidden contents

 

Edited by leosavi25
Posted
  On 1/15/2018 at 3:48 PM, leosavi25 said:

But if it isn't static I can't have access of it in other classes

Expand  

How are you structuring your mod overall? Are you registering each item in their specific class, or do you have a main class like "ModItem" or "ModBlocks" where you list them all? It's unclear from the code you've given us.

Follow these rules when talking to me, and we'll get along fine.

1).I know Java fairly well. I don't know as much about modding. They are not the same, don't compare them.

2). I consider myself to always be learning. I make mistakes, you make mistakes. Who doesn't?

3). Insult me, and I will leave the thread. I have a real life, I don't have time to throw petty insults in a Minecraft Modding forum.

 

ModMCdl - Co-Founder and Director of Design for Artemis Game Studios

Posted (edited)
  On 1/15/2018 at 3:08 PM, leosavi25 said:
  Reveal hidden contents

 

  Reveal hidden contents
  Reveal hidden contents

A Block/Item Init class where I put all blocks and Items and a RegistryHandler that register all Block and Item.

Expand  

 

Edited by leosavi25
Posted
  On 1/15/2018 at 4:29 PM, leosavi25 said:

ok but what I have to do exactly?

Expand  

Follow these steps and everything will work out:

1) Go learn Java

2) Come back and look at your code

3) Profit

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 (edited)

I know the basic of java, like variable method classes subclasses superclasses...I know java only for hobby

I don't understand what I have to do and I'm asking for it

Edited by leosavi25
Posted

This is what you need to do:

  On 1/15/2018 at 3:45 PM, diesieben07 said:

Do not create your items in a static initializer.

Expand  

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
  On 1/15/2018 at 6:03 PM, Draco18s said:

This is what you need to do:

Expand  

I dont't think that this is the problem: if I change BlockInit.ORE_COPPER_BLOCK with ItemInit.COPPER_INGOT and I put the Copper Ingot in the furnace it works and if I change it with Blocks.DIRT and I put a dirt block in the furnace it works. It doesn't work with BlockInit.ORE_COPPER_BLOCK. I try also to create another block and it doesn't work too. Could it be the BlockInit class that have some problem?

Posted
  On 1/15/2018 at 3:08 PM, leosavi25 said:

public class BlockInit {

    public static final List<Block> BLOCKS = new ArrayList<Block>();


    public static final Block ORE_COPPER_BLOCK = new Ore("ore_copper");

}

Expand  

 

  On 1/16/2018 at 4:54 PM, leosavi25 said:

Could it be the BlockInit class that have some problem?

Expand  

Yes.

Specifically:

  On 1/15/2018 at 3:45 PM, diesieben07 said:

Do not create your items in a static initializer.

Expand  

 

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
  Reveal hidden contents
  Reveal hidden contents

what mustn't be static? If BLOCKS or ORE_COPPER_BLOCK are not static it give me error in Ore class

Posted

That is not what D7 said.

Do not create your items in a static initializer.

 

He said nothing about having static fields. He said static initializer.

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
  On 1/17/2018 at 3:47 PM, diesieben07 said:

Preferably in the registry event. It must not happen in a static initializer because then Forge will not be able to detect that the code belongs to your mod and won't be able to set the registry name properly.

Expand  

 

 

  On 1/17/2018 at 5:08 PM, diesieben07 said:

What for?

Expand  

I did this but when I try to enter in a world it says that ore copper block and ore copper item miss

Posted

I'll take a stab at this - sorry I'm pretty new to modding but I can answer the Java-ish related question for you.

 

When they say don't register in the static initializer, they mean that you shouldn't be creating the items as part of static initialization, which is what happens when you assign static fields a value as part of the declaration.  In your code:

 public class BlockInit {
    public static final List<Block> BLOCKS = new ArrayList<Block>();

    public static final Block ORE_COPPER_BLOCK = new Ore("ore_copper");
} 

 

Both of those fields are static initializer fields.  Now, if you want to be able to access them statically but not initialize them statically, do something like this (which you can find by examining a number of mods source code on Github; see for example Vazkii's relatively clean Psi mod here):

public class BlockInit {
	public static final List<Block> BLOCKS = new ArrayList<Block>();
    public static final Block ORE_COPPER_BLOCK;  // DO NOT ASSIGN HERE!
      
    public static void preInit() {
      ORE_COPPER_BLOCK = new Ore("ore_copper");
      BLOCKS.add(ORE_COPPER_BLOCK); // Not sure why you are keeping the list, but if you want to add, you can do so here.
    }
  
    public static void init() {
      OreDictionary.registerOre("<your block ore dict id here>", new ItemStack(ORE_COPPER_BLOCK, 1, 0));
    }
}

 

Then, when handling the FMLPreInitializationEvent , call BlockInit.preInit().  When handling the FMLInitializationEvent , call BlockInit.init().

 

Hope this helps more than harms.  I strongly recommend following one of the other mods' patterns rather than rolling your own Vazkii's more or less follows the Forge documentation recommended guidelines, and it will help your future questions here if you have followed the documentation patterns so you won't have to explain yourself :)

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




×
×
  • Create New...

Important Information

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