Jump to content

Recommended Posts

Posted

I'm not too new and not too old in modding. I remember I saw using Enum for making same tools but with different materials, adn I think it's easier to make one Enum with all COPPER, TIN and etc than adding it manually, but I haven't saw a lot mods for 1.15.1[1.14.4] so is it still working, and maybe you can help me understand it?

Posted (edited)

Well, you could use a gray texture for your tool and then color it in the corresponding color of the material you chose with your enum. So you would have to make an enum with a constructor that has a color as an argument. Then you could for each material you have in your enum register all the tools automatically with the texture colored in the color of the material. At least that is how I would do it.

Edited by MartinTheDragon
Posted
4 minutes ago, MartinTheDragon said:

Well, you could use a gray texture for your tool and then color it in the corresponding color of the material you chose with your enum. So you would have to make an enum with a constructor that has a color as an argument. Then you could for each material you have in your enum register all the tools automatically with the texture colored in the color of the material. At least that is how I would do it.

I did something, now learning on code optimization and then I want to add example ore blocks through Enum. An I doing it right? Would be very thankfull if you help
https://github.com/ScarlettShooter/hier/blob/master/src/main/java/com/scrl0/hier/utility/MaterialType.java

Posted
1 minute ago, MartinTheDragon said:

That is a way of doing it, but you would have to set so many parameters for every material you create. And if you just set the durability for the material and not for the tool itself, are you using a multiplier for the tool?

Isn't maxUses that you exactly mean? I used some other's mod sources to understand how it works

Posted

Also, I think I use this theme for questions. What is the best way to store blocks\items to array? I want to try making registration in loop to not spam cause I think it's not the best way to do it(check down). And it's not even item registration or other blocks, only ores...

	e.getRegistry().register(new ModBlocks().tin_ore);
	e.getRegistry().register(new ModBlocks().aluminium_ore);
	e.getRegistry().register(new ModBlocks().silver_ore);
	e.getRegistry().register(new ModBlocks().zinc_ore);
	e.getRegistry().register(new ModBlocks().chrome_ore);
	e.getRegistry().register(new ModBlocks().lead_ore);
	e.getRegistry().register(new ModBlocks().platinum_ore);
	e.getRegistry().register(new ModBlocks().titanium_ore);
	e.getRegistry().register(new ModBlocks().nickel_ore);

 

Posted (edited)
3 hours ago, ScarlettSh0 said:

Nope, but trying to speak less shitty. It doesn't work, does it?)

Your English skill sounds pretty good to me.

 

34 minutes ago, ScarlettSh0 said:

Also, I think I use this theme for questions. What is the best way to store blocks\items to array? I want to try making registration in loop to not spam cause I think it's not the best way to do it(check down). And it's not even item registration or other blocks, only ores...


	e.getRegistry().register(new ModBlocks().tin_ore);
	e.getRegistry().register(new ModBlocks().aluminium_ore);
	e.getRegistry().register(new ModBlocks().silver_ore);
	e.getRegistry().register(new ModBlocks().zinc_ore);
	e.getRegistry().register(new ModBlocks().chrome_ore);
	e.getRegistry().register(new ModBlocks().lead_ore);
	e.getRegistry().register(new ModBlocks().platinum_ore);
	e.getRegistry().register(new ModBlocks().titanium_ore);
	e.getRegistry().register(new ModBlocks().nickel_ore);

 

If you are storing all your values in an enum, you can call

YourEnum.values()

to get a collection of all the values, which you could iterate through and initialize the block from. Simply create another list and store the initialized blocks into it during the iteration.

 

I would suggest to post more of your code, preferably as a GitHub repo. This allows other members to give more accurate suggestions on your code.

Edited by DavidM

Some tips:

Spoiler

Modder Support:

Spoiler

1. Do not follow tutorials on YouTube, especially TechnoVision (previously called Loremaster) and HarryTalks, due to their promotion of bad practice and usage of outdated code.

2. Always post your code.

3. Never copy and paste code. You won't learn anything from doing that.

4. 

Quote

Programming via Eclipse's hotfixes will get you nowhere

5. Learn to use your IDE, especially the debugger.

6.

Quote

The "picture that's worth 1000 words" only works if there's an obvious problem or a freehand red circle around it.

Support & Bug Reports:

Spoiler

1. Read the EAQ before asking for help. Remember to provide the appropriate log(s).

2. Versions below 1.11 are no longer supported due to their age. Update to a modern version of Minecraft to receive support.

 

 

Posted (edited)
10 minutes ago, DavidM said:

Your English skill sounds pretty good to me.

 

If you are storing all your values in an enum, you can call


YourEnum.values()

to get a collection of all the values, which you could iterate through and initialize the block from. Simply create another list and store the initialized blocks into it during the iteration.

 

I would suggest to post more of your code, preferably as a GitHub repo. This allows other members to give more accurate suggestions on your code.

I already droped it, just uploaded a commit cause things changed a little. Also I didn't have moved to enums yet. I want, but I learning deeps now)

https://github.com/ScarlettShooter/hier

I'm in process of making code better, so you can see something that have no use now, I'm working only in ModItems now

Edited by ScarlettSh0
Explanation of so weird code
Posted

This is static so there is no reason to call new here or here.

But you should not be creating your items in a static location (common issues, problematic code #14).

 

The indentation levels in your ModSetup class are broken. What does this } close?

 

All three of these methods are empty.

 

Double cast. You're casting a BlockState to a BlockState and then to a BlockState. Same here.

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

Ough...
I made it. I totally rewrote system to enums. It's amazing and both tiringly experience. But I want to know if it don't broke some features in future so it would be very pleasure if you could check if there is errors. Curently I'm using basic HiER and MaterialType classes, no ModBlocks/Items. Also, I get this in my Creative Tab(check image below). I saw somewhere that is how Forge works Block - Item - Blocks - Item, but maybe not?
 

Spoiler

2019-12-24_23_11_11.thumb.png.f75e5e43b95f7748c4ccb99c00652565.png

Also, in respond I don't know :D I was going through tutorials and there McJTY said it is for future. I want to do all the works with basic blocks and items in right way immediatly so here I am. Also what you said about static and #14 means if I add blocks I shouldn't make them static like "public static Block copper_ore;"? Sorry for that question, I need more practice in English to understand some sentences first time... If it is, the problem is that you actually gets memory for that blocks when you calling proper methods so making those blocks static only use more memory, does it? Anyway, thanks :)

 

2 hours ago, Draco18s said:

This is static so there is no reason to call new here or here.

But you should not be creating your items in a static location (common issues, problematic code #14).

 

The indentation levels in your ModSetup class are broken. What does this } close?

 

All three of these methods are empty.

 

Double cast. You're casting a BlockState to a BlockState and then to a BlockState. Same here.

 

Posted
3 hours ago, ScarlettSh0 said:

I add blocks I shouldn't make them static like "public static Block copper_ore;"? Sorry for that question, I need more practice in English to understand some sentences first time.

The field can be static, that's ok. You just can't call new there. This has to do with SetRegistryName and Forge needing to insure that the correct domain is applied, which is can only do if the constructor is called in a Forge-controlled event. static blocks can get executed at any time.

You should only call new Block() or new Item() in the registry event that registers them and use @ObjectHolder annotations to populate the static field with a value.

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)
9 hours ago, Draco18s said:

The field can be static, that's ok. You just can't call new there. This has to do with SetRegistryName and Forge needing to insure that the correct domain is applied, which is can only do if the constructor is called in a Forge-controlled event. static blocks can get executed at any time.

You should only call new Block() or new Item() in the registry event that registers them and use @ObjectHolder annotations to populate the static field with a value.

I think I understand what you mean. When I will be adding new blocks I'll do it like you said. Also do you know why in Tab items like saving theirs position from previos entrance?

 

Also I just did generator way you said(I think, but not sure). In ModBlocks class I have 

@ObjectHolder(MOD_ID + ":generator")
	public static Block generator;

In main class I have
 

/*Block register event*/
	ModBlocks.generator = new Generator("generator", 1, 4, 4);
	e.getRegistry().register(ModBlocks.generator);
/*Item register event*/
	e.getRegistry().register(new BlockItem(ModBlocks.generator, properties).setRegistryName(MOD_ID, "generator"));

Am I doing it right?

Edited by ScarlettSh0
Posted
12 hours ago, ScarlettSh0 said:

ModBlocks.generator = new Generator("generator", 1, 4, 4);

No. @ObjectHolder fields are final. You can't set them directly. Just do this:

 

Even.getRegistry().register(new Generator(...));

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
57 minutes ago, Draco18s said:

No. @ObjectHolder fields are final. You can't set them directly. Just do this:

 

Even.getRegistry().register(new Generator(...));

Hm, okey. So this event "does it" instead of you? Didn't realize that. Seems McJTY tut's are a little bit outdated(or maybe he did that in last episodes which I didn't watched yet). Seems like if I do all work like this, I have no need for ModBlocks class. Thank you very much!

Posted
2 hours ago, ScarlettSh0 said:

So this event "does it" instead of you? Didn't realize that.

Not exactly, but yes, but also no.

 

ObjectHolder fields are populated with values by Forge after the event has called all of the handlers that listen for it. Blocks first (object holders for blocks are populated), then items (object holders for items are populated), then everything else, then all object holders are refreshed.

2 hours ago, ScarlettSh0 said:

Seems McJTY tut's are a little bit outdated

Yes, they are. And he probably won't update his practices, because like so many youtube tutorials before him, they regurgitate the same garbage they learned without seeing if there's a better way.

  • Thanks 1

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
10 hours ago, Draco18s said:

Not exactly, but yes, but also no.

 

ObjectHolder fields are populated with values by Forge after the event has called all of the handlers that listen for it. Blocks first (object holders for blocks are populated), then items (object holders for items are populated), then everything else, then all object holders are refreshed.

Yes, they are. And he probably won't update his practices, because like so many youtube tutorials before him, they regurgitate the same garbage they learned without seeing if there's a better way.

So is there something for what ObjectHolder will be better practice?

Posted
5 hours ago, ScarlettSh0 said:

So is there something for what ObjectHolder will be better practice?

ObjectHolders are what allows for mods to override items with their own version (e.g. "I want to make dirt a falling block" -> register your own block as "minecraft:dirt"). Because of the way Forge populates ObjectHolder fields with values, these replacement actions work even for items and blocks added by any mod.

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
3 hours ago, Draco18s said:

ObjectHolders are what allows for mods to override items with their own version (e.g. "I want to make dirt a falling block" -> register your own block as "minecraft:dirt"). Because of the way Forge populates ObjectHolder fields with values, these replacement actions work even for items and blocks added by any mod.

So it's like forge does with bucket. Thanks again. It's important for me to understand why is it(abstract it, including all) working

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

    • Reach Out To Rapid Digital: What sapp Info: +1 41 4 80 7 14 85 Email INFO: rap iddi gita lrecov ery @ exe cs. com Hello, my name is Jayson, and I’m 35 years old from the United Kingdom. My family and I recently endured an incredibly challenging experience that I wouldn’t wish on anyone. We became victims of a cryptocurrency investment fraud scheme that saw us lose a staggering $807,000 in USDT and Bitcoins. The fraudsters had created a convincing facade, and we were lured into investing, only to discover later that the platform was a complete scam. We were left devastated, not just financially, but emotionally, as we had trusted these people and believed in the legitimacy of the investment. After the initial shock wore off, we desperately searched for ways to recover the lost funds. It seemed like an impossible task, and we felt as though there was no hope. That’s when, by sheer luck, we stumbled across a post about Rapid Digital Recovery, a cryptocurrency and funds recovery organization with a proven track record in cybersecurity and fraud recovery. We decided to reach out to them, and from the first interaction, we were impressed with their professionalism and transparency. They explained the recovery process in detail and reassured us that they had the skills and expertise to track down the perpetrators and recover our funds. This gave us a renewed sense of hope, something we hadn’t felt in months. What truly stood out during our experience with Rapid Digital Recovery was their dedication to the recovery process. The team went above and beyond, using sophisticated tracking tools and cyber forensics to gather critical information. Within a matter of weeks, they had successfully located the funds and traced the scam back to the fraudsters responsible. They worked with the authorities to ensure the criminals were held accountable for their actions. To our relief, the team at Rapid Digital Recovery was able to recover every single penny we had lost. The funds were returned in full, and the sense of closure we felt was invaluable. We couldn’t have imagined such a positive outcome in the early stages of our recovery journey, and we are deeply grateful for the work they did. If you ever find yourself in a similar situation, I highly recommend contacting Rapid Digital Recovery. Their expertise, transparency, and dedication to their clients make them the go-to choice for anyone seeking to recover lost cryptocurrency or funds. They truly gave us back our financial future.  
    • This is my first time modding anything, so maybe just skill issue. I'm using Forge 54.0.12 and Temurin 21.0.5+11-LTS I wanted to create a custom keybind and to check whether it works I'd like to send a chat message. I tried using Minecraft.getInstance().player.sendSystemMessage(Component.literal("test")); but IntelliJ couldnt resolve sendSystemMessage(...). Since I saw people using it in earlier versions, I tried the same thing with 1.20.6(- 50.1.0), where it works fine, now I can't figure out if this is intentional and whether there are other options for sending chat messages. On that note, is there more documentation than https://docs.minecraftforge.net/en/1.21.x/? It seems very incomplete compared to something like the Oracle Java docs
    • Hi, i'm having this error and I wanna fix it. we try: -Reload drivers -Eliminate .minecraft -Eliminate Java -Restart launcher -Verify if minecraft is using gpu -Mods  in .minecraft is empty -Install the latest and recomended version of forge idk what i have to do, help me pls. the lastest log is: https://mclo.gs/WAMao8x  
    • Read the FAQ, Rule #2. (https://forums.minecraftforge.net/topic/125488-rules-and-frequently-asked-questions-faq/)  
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

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