Jump to content

[1.10.2] On oredict registered [Solved]


pfgforge

Recommended Posts

I dont think this is possible because items must be registered in there event which is called prior to preInit. Or it is done during preInit...And typically ore dictionary is done in init or postInit from my experience with it.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

OreRegisterEvent

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.

Link to comment
Share on other sites

Subscribe to it, do whatever you want to.

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

public void OreRegisterEvent(OreRegisterEvent e) { }

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.

Link to comment
Share on other sites

Oh sorry, you were right the first time.  I didn't realize the event was declared as a static class inside the OreDict.

What's your problem?

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.

Link to comment
Share on other sites

Oh sorry, you were right the first time.  I didn't realize the event was declared as a static class inside the OreDict.

What's your problem?

 

It never seems to get called

 

Main mod file:

    @EventHandler
    public void preInit(FMLPreInitializationEvent event){
    	System.out.println("Preinit Was Called"); // Prints
    	MinecraftForge.EVENT_BUS.register(new OreRegisterEventHandler());
    }

 

OreRegisterEventHandler:

public class OreRegisterEventhandler {

   @SubscribeEvent
   public void OreRegisterEvent(OreDictionary.OreRegisterEvent e) {
String name = e.getName();
System.out.println("An ore is being registered "+name); // Never prints
   }

}

Link to comment
Share on other sites

The @SubscribeEvent goes over the method not the class.

 

Sorry, pasted the code wrong. The subscribe event is over the method

Did you re paste the code or just fix that one error? And also are you registering something into the ore dictionary after registering the event?

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

The @SubscribeEvent goes over the method not the class.

 

Sorry, pasted the code wrong. The subscribe event is over the method

Did you re paste the code or just fix that one error? And also are you registering something into the ore dictionary after registering the event?

 

I went back to my post to edit it and add the class part, but accidentally put the subscribe event before the class. My actual code never had that. I am trying to register something into the oredict when the event is called (it won't loop infinitely, I have it set up right), but the event doesn't get called yet

Link to comment
Share on other sites

The @SubscribeEvent goes over the method not the class.

 

Sorry, pasted the code wrong. The subscribe event is over the method

Did you re paste the code or just fix that one error? And also are you registering something into the ore dictionary after registering the event?

 

I went back to my post to edit it and add the class part, but accidentally put the subscribe event before the class. My actual code never had that. I am trying to register something into the oredict when the event is called (it won't loop infinitely, I have it set up right), but the event doesn't get called yet

The event is fired when something is registered to the OreDictionary it is not used to register something to the OreDictionary specifically.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

The @SubscribeEvent goes over the method not the class.

 

Sorry, pasted the code wrong. The subscribe event is over the method

Did you re paste the code or just fix that one error? And also are you registering something into the ore dictionary after registering the event?

 

I went back to my post to edit it and add the class part, but accidentally put the subscribe event before the class. My actual code never had that. I am trying to register something into the oredict when the event is called (it won't loop infinitely, I have it set up right), but the event doesn't get called yet

The event is fired when something is registered to the OreDictionary it is not used to register something to the OreDictionary specifically.

I know. Forge by default registers some ores, and when they are registered I want this method to be called so I can register my own based on them.

Link to comment
Share on other sites

Then instead of registering the event in preInit use the static way of registering it was in the link Dracos provided.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

Then instead of registering the event in preInit use the static way of registering it was in the link Dracos provided.

 

I switched it to a static void, but it still doesn't work

 

    @EventHandler
    public void preInit(FMLPreInitializationEvent event){
    	System.out.println("This is printed, showing that the preinit is running");
    	
    	MinecraftForge.EVENT_BUS.register(OreRegisterEventhandler.class);

 

public class OreRegisterEventhandler {
@SubscribeEvent
public static void OreRegisterEvent(OreDictionary.OreRegisterEvent e) {
	String name = e.getName();
	System.out.println("This never gets called, and is never printed. It should get called because forge registers some ores by default"+name);

Link to comment
Share on other sites

I meant this part

Automatically Registering Static Event Handlers

 

Tried in both OreRegisterEventhandler and in the main mod file.

 

@Mod.EventBusSubscriber
public class OreRegisterEventhandler {
@SubscribeEvent
public static void OreRegisterEvent(OreDictionary.OreRegisterEvent e) {
	String name = e.getName();
	System.out.println("This doesn't get printed ever "+name);

 

@Mod(modid = modname.MODID, version = modname.VERSION)
@Mod.EventBusSubscriber
public class modname {
        // init functions and stuff...

@SubscribeEvent
public static void OreRegisterEvent(OreDictionary.OreRegisterEvent e) {
	String name = e.getName();
	System.out.println("This also doesn't get printed "+name);

Link to comment
Share on other sites

I meant this part

Automatically Registering Static Event Handlers

 

Tried in both OreRegisterEventhandler and in the main mod file.

 

@Mod.EventBusSubscriber
public class OreRegisterEventhandler {
@SubscribeEvent
public static void OreRegisterEvent(OreDictionary.OreRegisterEvent e) {
	String name = e.getName();
	System.out.println("This doesn't get printed ever "+name);

 

@Mod(modid = modname.MODID, version = modname.VERSION)
@Mod.EventBusSubscriber
public class modname {
        // init functions and stuff...

@SubscribeEvent
public static void OreRegisterEvent(OreDictionary.OreRegisterEvent e) {
	String name = e.getName();
	System.out.println("This also doesn't get printed "+name);

The problem now that I am looking at this class is that the method that registers vanilla is called as soon as a static{} gets called.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

I meant this part

Automatically Registering Static Event Handlers

 

Tried in both OreRegisterEventhandler and in the main mod file.

 

@Mod.EventBusSubscriber
public class OreRegisterEventhandler {
@SubscribeEvent
public static void OreRegisterEvent(OreDictionary.OreRegisterEvent e) {
	String name = e.getName();
	System.out.println("This doesn't get printed ever "+name);

 

@Mod(modid = modname.MODID, version = modname.VERSION)
@Mod.EventBusSubscriber
public class modname {
        // init functions and stuff...

@SubscribeEvent
public static void OreRegisterEvent(OreDictionary.OreRegisterEvent e) {
	String name = e.getName();
	System.out.println("This also doesn't get printed "+name);

The problem now that I am looking at this class is that the method that registers vanilla is called as soon as a static{} gets called.

 

So... should I loop over all the oredict entries postinit?

Link to comment
Share on other sites

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.