Jump to content

Contributing to Forge? (dealing with patch files - what are they relative to?)


Raekye
 Share

Recommended Posts

I'm starting to look at Forge code. At the moment, there are some events I want to add (like on block destroy). I know and can read the code (ie: follow conventions), but have no idea how to deal with the patch files (in this case - to add the EVENT_BUS.post... call). I know how patch files work, but what are the line numbers relative to? I got regular MCP and decompiled the vanilla source, but the line numbers seem to point at totally different places. Any pointers would be greatly appreciated.

Link to comment
Share on other sites

I'm starting to look at Forge code. At the moment, there are some events I want to add (like on block destroy). I know and can read the code (ie: follow conventions), but have no idea how to deal with the patch files (in this case - to add the EVENT_BUS.post... call). I know how patch files work, but what are the line numbers relative to? I got regular MCP and decompiled the vanilla source, but the line numbers seem to point at totally different places. Any pointers would be greatly appreciated.

Link to comment
Share on other sites

If you want to contribute to forge the setup is different.

Here are the steps I took:

1) Clone the forge repository from github and make sure to initialize the FML submodule

2) Make sure the repository folder is named forge

3) Run setup.py with the python_fml.exe from somewhere in the fml subfolder

4) Open eclipse and point it to the eclipse folder in fml.

5) Modifiy the stuff you need in eclipse

6) When you're done run update_patches. It will apply the changes to the patch files.

7) Most likely submit a Pull Request containing your changes.

(If you are working on block destroy events: I doubt its worth it. There have been plenty and they all get rejected).

Link to comment
Share on other sites

If you want to contribute to forge the setup is different.

Here are the steps I took:

1) Clone the forge repository from github and make sure to initialize the FML submodule

2) Make sure the repository folder is named forge

3) Run setup.py with the python_fml.exe from somewhere in the fml subfolder

4) Open eclipse and point it to the eclipse folder in fml.

5) Modifiy the stuff you need in eclipse

6) When you're done run update_patches. It will apply the changes to the patch files.

7) Most likely submit a Pull Request containing your changes.

(If you are working on block destroy events: I doubt its worth it. There have been plenty and they all get rejected).

Link to comment
Share on other sites

Thanks. Any idea why block destroy events are rejected? Do you know what's the alternative (how are we supposed to 'listen' to these events; it seems like a lot of people want it if it keeps getting brought up)

 

Okay, so this is what I did

 

1. Clone MinecraftForge/MinecraftForge

2. Rename MinecraftForge to just 'forge', not sure why this is needed (everything should be accessible by relative paths... this is the root folder), but I haven't tried not naming it forge :P and I trust diesieben

3. Delete FML

4. Clone MinecraftForge/FML (rename to lowercase fml to be safe) into the forge root

5. To "initialize the FML submodule" I followed these steps: https://github.com/MinecraftForge/FML/wiki/If-you-want-to-contribute-to-FML

8. For fmlbuild.properties, I set the dev home to FML and the mcp home to {dev home}/mcp

9. Run ant setupenvironment

10. Run .\fml\python\python_fml setup.py

11. Got an eclipse folder under fml (set this as my eclipse workspace)

12. There are two projects - Clean and FML. I belive you don't touch clean (can someone confirm?). Inside FML, there is mc-client, fml-client, and fml-common. I also think mc-client is actually mc-client and "mc-server" (the distinction was removed in Forge 7.7)

 

However, in all the minecraft files (Clean project => src, FML => mc-client) the class names and packages are there but all the variables and function names are still obfuscated (eg: func_71934_m (method), field_72995_K (instance var), p_71908_2_ (parameter), k1 (local var)). Any ideas how to fix this?

 

Here's what I did first, think I got a better setup now so I hid it

 

1. Clone MinecraftForge/MinecraftForge

2. Rename MinecraftForge to just 'forge', not sure why this is needed (everything should be accessible by relative paths... this is the root folder), but I haven't tried not naming it forge :P and I trust diesieben

3. Delete FML

4. Clone MinecraftForge/FML (rename to lowercase fml to be safe) into the forge root

5. To "initialize the FML submodule" I followed these steps: https://github.com/MinecraftForge/FML/wiki/If-you-want-to-contribute-to-FML

6. Make a copy of "fmlbuild.properties-sample" - rename it to "fmlbuild.properties"

7. Change the dev root property to point to my forge folder (not FML)

8. Change the mcp home folder to ${default.dev.home}/mcp (did this because in the "distributed" forge mcp under forge, but at the end of it I see mcp was created in the fml folder (although everything else is too)

9. (The FML wiki steps summarized) Install ANT

10. Run ant setupenvironment

11. Copy the install scripts from the install folder (inside forge folder) to your forge root (up one level)

12. Run install.cmd or install.sh or install.py

13. Got an eclipse folder under fml (set this as my eclipse workspace)

14. There are two projects - Clean and FML. I belive you don't touch clean (can someone confirm?). Inside FML, there is mc-client, fml-client, and fml-common. I also think mc-client is actually mc-client and "mc-server" (the distinction was removed in Forge 7.7)

 

Now when I look at the mc-client sourcecode in eclipse only a few of the name mappings have been applied. Any suggestions what I did wrong?

 

I also noticed MinecraftForge's gitignore has these entries

/mcp/

/eclipse/

 

And my MCP and eclipse are under /fml (folder structure)

 

- forge root (named 'forge')

--- client, common, install, patches, ...

--- fml

----- bin, client, common, conf, patches, eclipse, ...

----- fmlbuild.properties, update_patches.bat, ...

----- mcp

------- jars, lib, source, src-base, src-work, mcp shell script files

 

And my fmlbuild.properties

default.dev.home=forge root

default.mcp.home=${default.dev.home}/mcp

 

It seems like I did something wrong setting up which file goes where, because stuff was duplicated in FML and Forge (although diesieben you say your eclipse is under fml too). I'll play around with it later, but if anyone has suggestions they'd be greatly appreciated.

 

Link to comment
Share on other sites

Thanks. Any idea why block destroy events are rejected? Do you know what's the alternative (how are we supposed to 'listen' to these events; it seems like a lot of people want it if it keeps getting brought up)

 

Okay, so this is what I did

 

1. Clone MinecraftForge/MinecraftForge

2. Rename MinecraftForge to just 'forge', not sure why this is needed (everything should be accessible by relative paths... this is the root folder), but I haven't tried not naming it forge :P and I trust diesieben

3. Delete FML

4. Clone MinecraftForge/FML (rename to lowercase fml to be safe) into the forge root

5. To "initialize the FML submodule" I followed these steps: https://github.com/MinecraftForge/FML/wiki/If-you-want-to-contribute-to-FML

8. For fmlbuild.properties, I set the dev home to FML and the mcp home to {dev home}/mcp

9. Run ant setupenvironment

10. Run .\fml\python\python_fml setup.py

11. Got an eclipse folder under fml (set this as my eclipse workspace)

12. There are two projects - Clean and FML. I belive you don't touch clean (can someone confirm?). Inside FML, there is mc-client, fml-client, and fml-common. I also think mc-client is actually mc-client and "mc-server" (the distinction was removed in Forge 7.7)

 

However, in all the minecraft files (Clean project => src, FML => mc-client) the class names and packages are there but all the variables and function names are still obfuscated (eg: func_71934_m (method), field_72995_K (instance var), p_71908_2_ (parameter), k1 (local var)). Any ideas how to fix this?

 

Here's what I did first, think I got a better setup now so I hid it

 

1. Clone MinecraftForge/MinecraftForge

2. Rename MinecraftForge to just 'forge', not sure why this is needed (everything should be accessible by relative paths... this is the root folder), but I haven't tried not naming it forge :P and I trust diesieben

3. Delete FML

4. Clone MinecraftForge/FML (rename to lowercase fml to be safe) into the forge root

5. To "initialize the FML submodule" I followed these steps: https://github.com/MinecraftForge/FML/wiki/If-you-want-to-contribute-to-FML

6. Make a copy of "fmlbuild.properties-sample" - rename it to "fmlbuild.properties"

7. Change the dev root property to point to my forge folder (not FML)

8. Change the mcp home folder to ${default.dev.home}/mcp (did this because in the "distributed" forge mcp under forge, but at the end of it I see mcp was created in the fml folder (although everything else is too)

9. (The FML wiki steps summarized) Install ANT

10. Run ant setupenvironment

11. Copy the install scripts from the install folder (inside forge folder) to your forge root (up one level)

12. Run install.cmd or install.sh or install.py

13. Got an eclipse folder under fml (set this as my eclipse workspace)

14. There are two projects - Clean and FML. I belive you don't touch clean (can someone confirm?). Inside FML, there is mc-client, fml-client, and fml-common. I also think mc-client is actually mc-client and "mc-server" (the distinction was removed in Forge 7.7)

 

Now when I look at the mc-client sourcecode in eclipse only a few of the name mappings have been applied. Any suggestions what I did wrong?

 

I also noticed MinecraftForge's gitignore has these entries

/mcp/

/eclipse/

 

And my MCP and eclipse are under /fml (folder structure)

 

- forge root (named 'forge')

--- client, common, install, patches, ...

--- fml

----- bin, client, common, conf, patches, eclipse, ...

----- fmlbuild.properties, update_patches.bat, ...

----- mcp

------- jars, lib, source, src-base, src-work, mcp shell script files

 

And my fmlbuild.properties

default.dev.home=forge root

default.mcp.home=${default.dev.home}/mcp

 

It seems like I did something wrong setting up which file goes where, because stuff was duplicated in FML and Forge (although diesieben you say your eclipse is under fml too). I'll play around with it later, but if anyone has suggestions they'd be greatly appreciated.

 

Link to comment
Share on other sites

The issue you are probably having is that you are not initializing FML but cloning it. Thats different.

Clone Forge with git clone --recursive ...... to include submodules. That will automatically setup FML. The steps you followed (from the FML wiki) are for contributing to FML, which is different.

 

Link to comment
Share on other sites

The issue you are probably having is that you are not initializing FML but cloning it. Thats different.

Clone Forge with git clone --recursive ...... to include submodules. That will automatically setup FML. The steps you followed (from the FML wiki) are for contributing to FML, which is different.

 

Link to comment
Share on other sites

Ah, didn't know about that. Anyways, it seems to be working great! I've got a couple more questions if you don't mind... firstly, what can I do instead if they don't allow destroy block hooks? I would guess something to do with asm but I don't see how I could add a hook that way. Or were the rejections just a matter of bad implementation?

 

Here are my steps in case anyone else stumbles on this...

1. git clone --recursive git@github.com:MinecraftForge/MinecraftForge.git forge

2. (The last argument above clones into a forge folder). I haven't tried not naming the root forge folder 'forge', I want to try later

3. Run terminal or command prompt in the forge folder, and do something like

.\fml\python\python_fml.exe setup.py

or

python setup.py

. This does the fml setup stuff too

4. The eclipse folder is in the forge root folder

Link to comment
Share on other sites

Ah, didn't know about that. Anyways, it seems to be working great! I've got a couple more questions if you don't mind... firstly, what can I do instead if they don't allow destroy block hooks? I would guess something to do with asm but I don't see how I could add a hook that way. Or were the rejections just a matter of bad implementation?

 

Here are my steps in case anyone else stumbles on this...

1. git clone --recursive git@github.com:MinecraftForge/MinecraftForge.git forge

2. (The last argument above clones into a forge folder). I haven't tried not naming the root forge folder 'forge', I want to try later

3. Run terminal or command prompt in the forge folder, and do something like

.\fml\python\python_fml.exe setup.py

or

python setup.py

. This does the fml setup stuff too

4. The eclipse folder is in the forge root folder

Link to comment
Share on other sites

You can just try again with a BlockDestroyEvent hook. maybe if it's done properly it will get in. And now that they added the RenderGameOverlay-Events (basically 10-15 events firing every single frame) the argument "that's too many events!" is finally no longer valid.

With asm: It depends on if you want a DestroyBlockByPlayer or a generic Blockdestroy. For DestroyBlockbyPlayer take a look at removeBlockByPlayer in the Block class and from where it's called. (Note: one source is client-side one server-side. You probably only need to hook into the server).

For a generic BlockDestroy hook into the methods in Chunk that are called to set the BlockIds. Check if it's a 0 as block id and if the old block id was not 0. If so, a block got destroyed. Maybe also look at from where breakBlock (also in the Block class) gets called. You probably want to hook into there.

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
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.

 Share



×
×
  • Create New...

Important Information

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