Looking for some help with Ore Dictionary

ReignOfMagic

New Member
Jul 29, 2019
55
0
0
I wish to register my ores/gems in the ore dictionary, but am having no luck doing so.. I am able to use things for testing purposes that are already in the ore dictionary (vanilla items). As an example in my recipes section I had my Malachite Pickaxe being made with "blockGold" and "stickWood". So I understand that portion, I am mainly having the problem registering my metadata items into the ore Dictionary.

Here are the links to the relevant areas on my github

Main File:
https://github.com/Reignofmagic/GTFO/blob/NewMaster/src/main/java/com/reignofmagic/gems/Gems.java

Dictionary:
https://github.com/Reignofmagic/GTF...com/reignofmagic/gems/handler/Dictionary.java

Recipes:
https://github.com/Reignofmagic/GTF...com/reignofmagic/gems/handler/ModRecipes.java

Pastebin dump of the ore dictionary:
http://pastebin.com/SGu4cMRD
 

gardenapple

Well-Known Member
Mod Developer
Jan 14, 2014
176
265
93
I've noticed that in your main class the init and post-init methods don't have an @EventHandler annotation. You need to insert that or else the code inside of them will never run.

If that still doesn't help, you could try switching the order of registering things. Initialize your Ores in preInit() and your recipes in init(), that's what most mods do.
 

Hlaaftana

New Member
Jul 29, 2019
304
0
0
Your code's quite messy... I see that you followed TheXFactor117's tutorials and are a new modder but good lord buddy
Do what @goldenapple says. Do both of what he says, except be careful to register the ores AFTER the blocks or items are registered.
Also, why is your worldgen class labeled "EventHandler"?
Another also, Java methods typically start with a lowercase letter and the following words have a capitalized letter as the first one. e.g. "do stuff" would be "doStuff".
Yet another also, "Topaz" is not spelled "Toapz".
YET ANOTHER ALSO, what the heck are you doing
I kinda wanna help out by pull requesting.
 
Last edited:

Type1Ninja

New Member
Jul 29, 2019
1,393
-7
0
Your code's quite messy... I see that you followed TheXFactor117's tutorials and are a new modder but good lord buddy
Do what @@goldenapple says. Do both of what he says, except be careful to register the ores AFTER the blocks or items are registered.
Also, why is your worldgen class labeled "EventHandler"?
Another also, Java methods typically start with a lowercase letter and the following words have a capitalized letter as the first one. e.g. "do stuff" would be "doStuff".
Yet another also, "Topaz" is not spelled "Toapz".
YET ANOTHER ALSO, what the heck are you doing
I kinda wanna help out by pull requesting.
... That's probably what you should do. Also, regardless of whether you intended to sound rude, it does come off a little harsh; try improving your wording. :)
 
Last edited:

ReignOfMagic

New Member
Jul 29, 2019
55
0
0
... That's probably what you should do. Also, regardless of whether you intended to sound rude, it does come off a little harsh; try improving your wording. :)

I work by the theory of if it is true, it can't be too rude. Also yes.. my code is horrific that comes from having no programming experience prior to this. This is actually a far more clean version ... if that can even be believed. I used to have comments of entire blocks of not working code simply for reference of what not to do....




dammit now that you quoted it the first version will still be seen

No worries, I appreciate the feedback. As for your first post I'll take a look at that when I get home tonight to see if I can get it working
 
Last edited:

ReignOfMagic

New Member
Jul 29, 2019
55
0
0
I've noticed that in your main class the init and post-init methods don't have an @EventHandler annotation. You need to insert that or else the code inside of them will never run.

If that still doesn't help, you could try switching the order of registering things. Initialize your Ores in preInit() and your recipes in init(), that's what most mods do.

That got it to work. Thanks for spotting that, the ore dictionary problems I've been having are now gone with this last tidbit that I managed to miss previously.


Your code's quite messy... I see that you followed TheXFactor117's tutorials and are a new modder but good lord buddy
Do what @goldenapple says. Do both of what he says, except be careful to register the ores AFTER the blocks or items are registered.
Also, why is your worldgen class labeled "EventHandler"?
Another also, Java methods typically start with a lowercase letter and the following words have a capitalized letter as the first one. e.g. "do stuff" would be "doStuff".
Yet another also, "Topaz" is not spelled "Toapz".
YET ANOTHER ALSO, what the heck are you doing
I kinda wanna help out by pull requesting.

Responding to the points in order:

1: I followed many different tutorials, to name a few, Wuppy's Live Modding, Wuppy's Book, Wuppy's online tutorials, xfactor, Pahimar's Lets Mod Reboot, other random youtubers for specific things like ore gen. Additionally I've been going through many different githubs to see how they implemented things and then attempted to do similar things. So that is potentially why my code is so messy, it is a combination of many different ways in addition to being my first time.

2: I have done as @goldenapple said. That fixed the ore dictionary problems I've been having. I just have one question for you although. Why register the ores after other blocks and items? To do this Would I make a second dictionary class and name it something like DictionaryOres then put it after the first dictionary, or would I simply have them last in the dictionary file??
This is the first time I've ever seen this suggested and am curious as to the reason for it.

2a: I have the worldgen class labeled as ReignEventHandler simply because this is the way that I saw it done on a tutorial off of youtube. I could rename the class easily if that is wrong/bad practice

3. Thanks for pointing that out. That was one of the earlier files I made, and I guess I forgot to go back and change that once I learned of the lowercase then Uppercase grammar for java.

4. Yeah I noticed that right after pushing that to github, in my next commit I already have it changed.

5. Currently eating a ton of item ID slots, because I am not sure if tools can work with metadata. If your question was not pertaining to that, then I am making tools and armor for the various gem types that appear in other mods, plus adding a few of my own. Think Metallurgy but for gems, with a more strict progression through the tiers like how iguana tinker tweaks handles mining levels.

6. Feel free to pull request, It is open source as this is a first mod for me and I would love input on how to make it better/improve the code. All I ask is if the code gets a bit complicated to comment now and then to explain what it does. I can figure most things out, but it would help me a lot.
 
Last edited:

SatanicSanta

New Member
Jul 29, 2019
4,849
-3
0
@Nelriana

2. Hlaaftana means to register your things with the OreDictionary after you let the game know that those things exist. Otherwise it will come up as null, probably.
2a. You should only name things WhateverEventHandler if it is... an event handler. That class is not an event handler, it's a WorldGenerator. I'd recommend something like GTFOWorldGen or something. EventHandlers are classes that have methods that have the @SubscribeEvent annotation and are registered with the Forge Event bus (MinecraftForge.EVENT_BUS.register(new WhateverEventHandler());)
5. Tools can work with metadata.

By the way, you have a lot of stuff in your GitHub that should be .gitignore'd. You will have to remove them temporarily from your project folder while you push, but once pushed and ignored properly, you should be able to put them back. You should ignore:

.gradle/
.metadata/
.settings/
RemoteSystemsTempFiles/
bin/
eclipse/
.classpath
.project
CREDITS-fml.txt
LICENSE-fml.txt
MinecraftForge-Credits.txt
MinecraftForge-License.txt
README.txt
forge-1.7.10-10.13.4.1448-1.7.10-changelog.txt

You should also probably just get rid of that build - Copy.gradle

I'd recommend doing this by:
1. Copy https://github.com/github/gitignore/blob/master/Java.gitignore into .gitignore in your project's directory (where README.md is)
2. Add the list of files I provided
3. git status to reveal new files and modified files. If there is anyhing besides .gitignore and whatever else you have changed in your code, license, readmes, or build files, add them to your gitignore.
 
  • Like
Reactions: Hlaaftana

Hlaaftana

New Member
Jul 29, 2019
304
0
0
1: I followed many different tutorials, to name a few, Wuppy's Live Modding, Wuppy's Book, Wuppy's online tutorials, xfactor, Pahimar's Lets Mod Reboot, other random youtubers for specific things like ore gen. Additionally I've been going through many different githubs to see how they implemented things and then attempted to do similar things. So that is potentially why my code is so messy, it is a combination of many different ways in addition to being my first time.

2: I have done as @goldenapple said. That fixed the ore dictionary problems I've been having. I just have one question for you although. Why register the ores after other blocks and items? To do this Would I make a second dictionary class and name it something like DictionaryOres then put it after the first dictionary, or would I simply have them last in the dictionary file??
This is the first time I've ever seen this suggested and am curious as to the reason for it.

2a: I have the worldgen class labeled as ReignEventHandler simply because this is the way that I saw it done on a tutorial off of youtube. I could rename the class easily if that is wrong/bad practice

3. Thanks for pointing that out. That was one of the earlier files I made, and I guess I forgot to go back and change that once I learned of the lowercase then Uppercase grammar for java.

4. Yeah I noticed that right after pushing that to github, in my next commit I already have it changed.

5. Currently eating a ton of item ID slots, because I am not sure if tools can work with metadata. If your question was not pertaining to that, then I am making tools and armor for the various gem types that appear in other mods, plus adding a few of my own. Think Metallurgy but for gems, with a more strict progression through the tiers like how iguana tinker tweaks handles mining levels.

6. Feel free to pull request, It is open source as this is a first mod for me and I would love input on how to make it better/improve the code. All I ask is if the code gets a bit complicated to comment now and then to explain what it does. I can figure most things out, but it would help me a lot.
1. Some tutorials conflict with each other, so sometimes it's hard to use more than one.
2. Santa answered this, but I'll make it simple: Logically, your items and blocks need to be registered before you can register OreDict entries for them. You don't need a separate one.
2a. Santa answered this too.
3. well originally pascal
5. Tools can work with metadata, but what I meant was the 2 billion files. You could have just used 4 tool item classes and added parameters to them.
6. I'll pull request, and I'll make sure to comment a lot.
 

ReignOfMagic

New Member
Jul 29, 2019
55
0
0
@Nelriana

2. Hlaaftana means to register your things with the OreDictionary after you let the game know that those things exist. Otherwise it will come up as null, probably.
2a. You should only name things WhateverEventHandler if it is... an event handler. That class is not an event handler, it's a WorldGenerator. I'd recommend something like GTFOWorldGen or something. EventHandlers are classes that have methods that have the @SubscribeEvent annotation and are registered with the Forge Event bus (MinecraftForge.EVENT_BUS.register(new WhateverEventHandler());)
5. Tools can work with metadata.

By the way, you have a lot of stuff in your GitHub that should be .gitignore'd. You will have to remove them temporarily from your project folder while you push, but once pushed and ignored properly, you should be able to put them back. You should ignore:

.gradle/
.metadata/
.settings/
RemoteSystemsTempFiles/
bin/
eclipse/
.classpath
.project
CREDITS-fml.txt
LICENSE-fml.txt
MinecraftForge-Credits.txt
MinecraftForge-License.txt
README.txt
forge-1.7.10-10.13.4.1448-1.7.10-changelog.txt

You should also probably just get rid of that build - Copy.gradle

I'd recommend doing this by:
1. Copy https://github.com/github/gitignore/blob/master/Java.gitignore into .gitignore in your project's directory (where README.md is)
2. Add the list of files I provided
3. git status to reveal new files and modified files. If there is anyhing besides .gitignore and whatever else you have changed in your code, license, readmes, or build files, add them to your gitignore.

Yeah I know that those files are not supposed to be there. I just havn't bothered to remove them yet. I'll make that .gitignore a priority for the next push. I shall also change my world gen file to be labeled as such. Thanks for the clarification as to why not have it named as I currently do.

1. Some tutorials conflict with each other, so sometimes it's hard to use more than one.
2. Santa answered this, but I'll make it simple: Logically, your items and blocks need to be registered before you can register OreDict entries for them. You don't need a separate one.
2a. Santa answered this too.
3. well originally pascal
5. Tools can work with metadata, but what I meant was the 2 billion files. You could have just used 4 tool item classes and added parameters to them.
6. I'll pull request, and I'll make sure to comment a lot.

That makes sense, for the ore dictionary. I didn't think of that.

As for the many different files, I was doing that since I didn't get metadata items to work initially, so I just made a ton of different files. A little messy I know, but it still works since they are all named at least somewhat intelligently.
 

ReignOfMagic

New Member
Jul 29, 2019
55
0
0
Pull requested ;)
Uhh... uhh... k. Let me just gaze at this and wonder what just happened

Also you got a comment on your pull request saying the world gen changes you made should be redacted. Care to comment?

**edit**

So uh, just for clarification in the ItemGTFOHoe for example. the line

setUnlocalizedName(Reference.MODID + "_" + name + "Hoe");

Name references the ModItems file, and is the bit in quotes correct?

amberPickaxe = new ItemGTFOPickaxe(gemAMBER, "amber");
RegisterHelper.registerItem(amberPickaxe);
 
Last edited:

Hlaaftana

New Member
Jul 29, 2019
304
0
0
it's normally wrong but you set them up like that
by the way i didn't make world gen changes, i just added another method to generate in stone by default
 

ReignOfMagic

New Member
Jul 29, 2019
55
0
0
Alright I understand what you were doing with the world gen, I think I prefer my method simply because at least to me it is clearer what is happening. Your version works just fine, I'm just not sold on adding what I see to be complication to the code.

As for your "It's normally wrong". What in particular do you mean?
 

Hlaaftana

New Member
Jul 29, 2019
304
0
0
Mine isn't complication, it's simplification in fact. You just don't have to add the target block, and it'll default to stone. It just makes it easier for you to code. Your method still exists, my one uses your one, yet uses stone as the default target block. As you're a new programmer, I suggested my version since Santa's version is much more complicated.

By the way, merging Santa's PR after mine shouldn't cause issues. Go ahead and do it if you want
 
Last edited:

Hlaaftana

New Member
Jul 29, 2019
304
0
0
His original version still exists. While Java might not love my extra method, it still works and all it does is cull text.

EDIT: Didn't notice the GitHub comments. He thinks my code is unnecessary because "it just simply shortened the code for each specific ore slightly."

But my code might be helpful since "Whoops, forgot to put Blocks.stone after i"
 
Last edited:

SatanicSanta

New Member
Jul 29, 2019
4,849
-3
0
But my code might be helpful since "Whoops, forgot to put Blocks.stone after i"
you're missing my point entirely. It's not just about the complexity of the code.

Also that sort f error only happens when you use an editor that is not an IDE. As I said in he git comments I used a plain text editor for that pr. It's closer to a typo than a fundamental error or mistake.
 

ReignOfMagic

New Member
Jul 29, 2019
55
0
0
His original version still exists. While Java might not love my extra method, it still works and all it does is cull text.

EDIT: Didn't notice the GitHub comments. He thinks my code is unnecessary because "it just simply shortened the code for each specific ore slightly."

But my code might be helpful since "Whoops, forgot to put Blocks.stone after i"

What I meant by that was you removed that one section, replaced it with world by adding another section of code at the bottom. So that is why I said it just shortened the code slightly, as it does the same thing.

you're missing my point entirely. It's not just about the complexity of the code.

Also that sort f error only happens when you use an editor that is not an IDE. As I said in he git comments I used a plain text editor for that pr. It's closer to a typo than a fundamental error or mistake.

Also the main point of Satanic's pull was to illustrate another method of doing it via arrays, which I'm not completely sure how they work yet, but was insightful none the less.