Jump to content

Inheriting/Overriding the Pumpkin Pie Item


SOLRUK

Recommended Posts

There is no code specific to the pumpkin pie, it is merely a generic

ItemFood

.

 

I guess you would want to create a new class/item inheriting from ItemFood, if you don't mind your pie being differentiated from the pumpkin pie.

 

If you want to replace the vanilla pumpkin pie with your throwable pie, that is a bit more involved, and there are several possible courses of action.

Link to comment
Share on other sites

Look into Java reflection. I have done it for blocks, not items, and even then I didn't understand fully what I was doing at the time.

 

I would not recommend replacing vanilla blocks/items if you are new to modding or Java in general.

Link to comment
Share on other sites

Ok since I am new to modding I will take your advice and avoid that for now, but would creating the new item interfere with recipes (I would prefer to keep the same vanilla recipe) and I would also prefer to not see two pumpkin pies in the creativetab. Also would it be any easier to replace the vanilla Item if I searched through the source code of an already built mod that does this. For instance Thaumcraft 4 replaces the bedrock with it's own code.

Link to comment
Share on other sites

I know that with the old way that blocks/items worked, it was quite easy to replace an item. This was done by hooking into the array of all the blocks and replacing the block via the its ID. So if I wanted to replace the air block, I could do so by replacing blockArray[0].

 

I am not sure if this possible, or even plausible with the way ID's are now done, so yes. Reflection is pretty much how I would go about it.

We all stuff up sometimes... But I seem to be at the bottom of that pot.

Link to comment
Share on other sites

[snip] would creating the new item interfere with recipes (I would prefer to keep the same vanilla recipe) and I would also prefer to not see two pumpkin pies in the creativetab.

Keep in mind recipes relying on the vanilla pumpkin pie would not be able to use your pumpkin pie instead, unless you specifically replace it.

 

Also would it be any easier to replace the vanilla Item if I searched through the source code of an already built mod that does this. For instance Thaumcraft 4 replaces the bedrock with it's own code.

Things have changed from the version Thaumcraft 4 supports (which is 1.7.2, I believe). It would probably not help much, no.

 

So if I wanted to replace the air block, I could do so by replacing blockArray[0].

 

I am not sure if this possible, or even plausible with the way ID's are now done, so yes. Reflection is pretty much how I would go about it.

Reflection seems to be the way to go for now. The relevant issue had a reply with a link to a library of helper methods easing the replacement of vanilla blocks and items, but that link (and indeed the comment itself) has been deleted.

 

Nevertheless, I might be able to provide some insight into using reflection for replacing a vanilla item, if I can find the time. Again, though, you probably don't want to toy with vanilla replacement if you can avoid it.

 

Here is a thread detailing how to remove recipes in [1.7.2] - it might work for [1.7.10] as well.

 

Removing the vanilla recipe, and registering a new identical recipe where the output is your custom pumpkin pie would give you full control of the pumpkin pie, while retaining the vanilla recipe. As said, however, any mods relying on the pumpkin pie as recipe input will not be able to use your replacement in this case.

Link to comment
Share on other sites

Removing the vanilla recipe, and registering a new identical recipe where the output is your custom pumpkin pie would give you full control of the pumpkin pie, while retaining the vanilla recipe. As said, however, any mods relying on the pumpkin pie as recipe input will not be able to use your replacement in this case.

So is there anyway I could use the "OreDict"(I know it's not the proper term but you know what I mean) my pie with the old pie?

Link to comment
Share on other sites

So if I wanted to replace the air block, I could do so by replacing blockArray[0].

 

I am not sure if this possible, or even plausible with the way ID's are now done, so yes. Reflection is pretty much how I would go about it.

Reflection seems to be the way to go for now. The relevant issue had a reply with a link to a library of helper methods easing the replacement of vanilla blocks and items, but that link (and indeed the comment itself) has been deleted.

 

Nevertheless, I might be able to provide some insight into using reflection for replacing a vanilla item, if I can find the time. Again, though, you probably don't want to toy with vanilla replacement if you can avoid it.

 

Here is a thread detailing how to remove recipes in [1.7.2] - it might work for [1.7.10] as well.

 

Removing the vanilla recipe, and registering a new identical recipe where the output is your custom pumpkin pie would give you full control of the pumpkin pie, while retaining the vanilla recipe. As said, however, any mods relying on the pumpkin pie as recipe input will not be able to use your replacement in this case.

 

Then there is what is called overkill in my opinion (and probably many others). ASM and core mods (DEFINITELY NOT FOR BEGINNERS). Using a core mod/asm, one can completely replace a class if the so chose too. (ASM is used by FML to actually load your mod into minecraft. I am not sure, but I think ASM is also used to patch the vanilla classes with Forge's stuff [citation needed] xD).

 

Just throwing it out there.

We all stuff up sometimes... But I seem to be at the bottom of that pot.

Link to comment
Share on other sites

So after having been browsing through the registry code that FML uses... I can't find any way to hook into the code to swap out ID's. FML uses a list of ID's that have already been used so that they cannot be reused. So yes, it is still the methods stated above.

We all stuff up sometimes... But I seem to be at the bottom of that pot.

Link to comment
Share on other sites

There is no need to replace the pumpkin item to add a throwing action.

Actually there is no need to replace any item for any reason.

 

In your case, you could use an item Event (look on the wiki if you don't know about those), cancel the eating, and add the throw. You could also make a custom key handler to send packets to the server and throw the held stuff.

Link to comment
Share on other sites

There is no need to replace the pumpkin item to add a throwing action.

Actually there is no need to replace any item for any reason.

 

In your case, you could use an item Event (look on the wiki if you don't know about those), cancel the eating, and add the throw. You could also make a custom key handler to send packets to the server and throw the held stuff.

 

* Kwibble has a major facepalm moment *

 

Thanks for that... Lack of sleep on my part? Thanks for pointing that out.

We all stuff up sometimes... But I seem to be at the bottom of that pot.

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.