Jump to content

Recommended Posts

Posted

As we know, vanilla classes aren't fan of overrides. For example, if we look at ItemSeeds, we have this thing:

private final Block crops;

What this means is that if someone overrides your crops block you have nothing you can do and the whole game breaks, because the registry Block is now different.

 

How do I fix this?

 

(@ObjectHolders are still as broken as they were before, since they do nothing to help this.)

No, you do NOT need jar modding!

Posted (edited)

final on a field means nothing about overriding, because overriding applies to methods only. A final field just means it can't be changed after it's been initialised. In ItemSeeds, the crops field is initialised using the Block passed to the constructor, so you can set it to whatever you want when making your own seed item.

 

Maybe explain your actual situation, because this sounds like a potential XY problem.

Edited by Jay Avery
Posted

Forge has a mechanism for overriding blocks. You can replace any block with your own Block as long as it's not Blocks.AIR.

 

This mechanism doesn't extend to final Block fields like the ones found in ItemSeeds. You can crash anything that uses ItemSeeds by overriding the underlying Block. (You *can* override both the block *and* the item, but eh.)

No, you do NOT need jar modding!

Posted

You mean the substitution alias system.

 

That's not override.

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
4 hours ago, SoniEx2 said:

How do I fix this?

Override the item when you override the block.

4 hours ago, SoniEx2 said:

(@ObjectHolders are still as broken as they were before, since they do nothing to help this.)

Um no, they are working just fine. Quit BITCHING about things and actually HELP if you have issues. Seriously you're REALLY pissing off most of the community.

 

Let this be your final warning, you're already banned from almost off IRC/Git Projects for your attitude. Don't make me have to ban you from here to.

I do Forge for free, however the servers to run it arn't free, so anything is appreciated.
Consider supporting the team on Patreon

Posted
1 minute ago, Draco18s said:

You mean the substitution alias system.

 

That's not override.

The substitution alias system was replaced by the override system with the registry overhaul in 1.12.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted

How can I make it so I don't need to override the item when I override the block, at least for my own items?

 

Also it's called "override" in the code.

No, you do NOT need jar modding!

Posted

It doesn't matter what it is called stop using random phrases and expecting others to understand them.

Just describe in unambiguous terms what you're doing so that everyone can understand.

 

As for what to do with your own code. Registry DELEGATES the exact thing we've been telling you to do for years.

I do Forge for free, however the servers to run it arn't free, so anything is appreciated.
Consider supporting the team on Patreon

Posted

What I came up with is, I could extend ItemSeeds and hope nobody's reflecting into the crops field, then override the relevant methods using a static @ObjectHolder field instead of a private final (instance) field, such that I need different classes for different seeds, but at least the Block is automatically updated. That would probably work, but is there a better way I can do it?

No, you do NOT need jar modding!

Posted (edited)

Those would be IRegistryDelegate? Also, that's not exactly what I'd call "a better way", since I still need to override everything.

Edited by SoniEx2

No, you do NOT need jar modding!

Posted

Why in gods name are you overriding YOUR OWN ITEMS?

Seriously dude, Explain in full detail exactly what you are trying to accomplish. Not what you're thinking you should try.

 

I do Forge for free, however the servers to run it arn't free, so anything is appreciated.
Consider supporting the team on Patreon

Posted

I need to override the ItemSeeds methods, not my own items. I want other mods to be able to override my stuff painlessly.

No, you do NOT need jar modding!

Posted

Step 1:

Create a new class

Step 2:

Use the sustitution/override system to replace the vanilla instance with your own instance

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

I need to override the ItemSeed

You want to override the Item, there ya go. Replace the item! What does anyone else matter?

I do Forge for free, however the servers to run it arn't free, so anything is appreciated.
Consider supporting the team on Patreon

Posted

Why? You want to replace the vanilla ItemSeed instances in the registry with your own thing.

Who cares that you are subclassing things. You don't NEED to subclass things.

Just register your override for the Item.

 

Seriously dude, sit down, take 10 seconds. Write down what you're trying to accomplish at the end of the road. What is your mod doing that has interaction with ItemSeed. We need to understand what you want to do, not how you want to do it. http://xyproblem.info/

I do Forge for free, however the servers to run it arn't free, so anything is appreciated.
Consider supporting the team on Patreon

Posted

I have a mod. It registers a Block, and an ItemSeeds which uses that Block. I'd like to let other mods replace the Block using the overrides system, without them also having to replace the ItemSeeds.

 

To do that, the only way I know of is to make my own subclass of ItemSeeds that doesn't use the final Block inside it, but rather uses some sort of thing that stays in sync with the registry. This involves overriding all ItemSeeds methods in my subclass, which defeats using ItemSeeds in the first place.

 

The question is, is there a better way?

No, you do NOT need jar modding!

Posted

Right now there is is no better option. We could patch ItemSeeds to use the delegate system like we do for ItemBlock/ItemBlockSpecial. However as it sits any other modder would need to override the ItemSeed if they replace the Block in vanilla so there isn't any issue. You're making a problem where there isn't one.

I do Forge for free, however the servers to run it arn't free, so anything is appreciated.
Consider supporting the team on Patreon

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.