Jump to content

Editing a vanilla feature


DarkNinja2462

Recommended Posts

I need to edit a file. More specifically, change a method in a vanilla file. Could I set the method like I would do with any object or do I directly have to edit the file? I also want to change a block into a new class but it is listed as final. If I do any of this, would there be a need of a certain change in the way my mod is distributed or something? :-\

Link to comment
Share on other sites

If you directly change any base class your mod will (probably) not be compatible with the rest of Forge mods. You can get around this limitation using reflection or ASM.

mnn.getNativeLang() != English

If I helped you please click on the "thank you" button.

Link to comment
Share on other sites

depending on what you want to do exactly there may be workaround from doing that :)

 

As for the block, you want to take a regular block which is defined inn Block.java and create it's own class for it?

Like i.e Bedrock? It's possible to do even without base class editing I believe. Create your BlockBedrock class and then insert it into the block list instead of the current bedrock.

If you guys dont get it.. then well ya.. try harder...

Link to comment
Share on other sites

In Your Class it should say

 

Public class <classname> expands <classname>

 

 

That basically makes it read your class with the other class that you call. Make shure to import the package that the other class in

 

IE-Block better stone

import net.minecraft.blocks

public class Blockbetterstone extends blocks

Link to comment
Share on other sites

Inn your main mod file:

 

@Init
public void load(FMLInitializationEvent event) {
        Block.blocksList[104] = new StemBlock(632);
        Block.blocksList[632] = null; // Frees the double used slot.
}

 

I tried first with the ID 4, but that crashed my mc.

However testing with ID 104 worked perfectly. I got my custom block instead of the original when using pumpkin seeds etc. So it seems to work.

This of course swaps out the original pumpkin stem so any mods that does things to the pumpkin stem will not do anything to your's etc.

and if someone else does the same thing, only the last one will get into the blockList ofcourse.

If you guys dont get it.. then well ya.. try harder...

Link to comment
Share on other sites

When I come to think of it, the blockID of your block would still be wrong if you set it like I did above.

If you instead do:

public static final Block stemBlock;

@Init
public void load(FMLInitializationEvent event) {
Block.blocksList[104] = null; // Makes the spot free for the new block to enter.
stemBlock = new StemBlock(104);

 

I couldn't test this as I'm not at my own computer now but I guess that would work :)

Then you call the constructor for your New StemBlock correctly and it should get setup with the correct BlockID aswell.*

 

Okay, that works. But is the number in [] the block id and can I use Block.blocklist[164] = new BlockDerp(164)

instead of making a new block or will it crash?

yeah that would probably work but it would be redundant because the blockList will already contain that block there after evaluating the right side of '='. Since that makes it call the constructor of BlockDerp which calls the Block's constructor and sets blockList[164] = this; (the new BlockDerp it self)

If you guys dont get it.. then well ya.. try harder...

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.