Posted March 25, 201312 yr 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?
March 25, 201312 yr 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.
March 25, 201312 yr 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...
March 25, 201312 yr 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
March 25, 201312 yr Making the Blockbetterstone inherit from Block is the way you do with all blocks? I'm not sure I follow what you mean Shaken_U If you guys dont get it.. then well ya.. try harder...
March 25, 201312 yr Author I want to edit the BlockStem or at least change pumpkinStem in Block. Like: Block.pumpkinStem = new NewBlockStem....... When I tried it. i cannot because it has the final modifier. I do not want to edit the Block class.
March 25, 201312 yr 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...
March 25, 201312 yr Author 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?
March 25, 201312 yr 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...
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.