Jump to content

Custom subclasses of World or Chunk in Forge?


RgSW

To allow or not to allow custom World or Chunk subclasses?  

2 members have voted

  1. 1. Do you think this would create new possibilities in forge?

    • Yes
      0
    • No
      0
    • Maybe
      2
  2. 2. Do you think mods will still work properly together?

    • Yes
      0
    • No
      1
    • Maybe
      1


Recommended Posts

I've been wondering about this for a long time...

Minecraft has a class World in it's code, that (as most modders know) represents a World. This class has many methods and fields for manipulating and ticking this world. Subclasses as WorldServer and WorldClient exist for server and client side. More functionality is added here for specific proxy sides.

When I started messing with Minecraft and Forge, I came to the conclusion that every mechanic that is different in another dimension is hardcoded into the code of these World classes. I'm working on a mod now that is going to add some more dimensions, that all need some things to be hardcoded into the World class. This is almost impossible to do, since the source code of Minecraft is not editable in an easy way (I need to use coremods for it). The only different option to me was to create a custom instance of World and override some methods there... But the construction of World instances seems to be hardcoded too, so there is no easy way to get my subclasses working in Minecraft.

Using a coremod, I got this done, including a way to get custom Chunk-sublcass instances on both client and server side, which can be different per dimension (overworld uses vanilla classes, my dimension a modded subclass).

 

My coremod is now working both from IDE as from the launcher, but it was a time consuming task (it took me a month to get it working) and the code is really messy... I guess other modders would like to use this too (my mod is open source so you can copy my system), so I was wondering if an event could be added to forge for this...

A typical implementation would be to register the world subclasses (one for client and another for server) in the dimension manager and use reflection to create certain instances from it.

 

But all of all, that is not my main question. Since forge is made to have many mods working together without any problem, I started wondering if this system would cause any problem with this 'mod collaboration'. Wouldn't this break forge?

 

So, is it a good idea to allow custom subclasses of World or Chunk to be used in custom dimensions, and could a system for that be added to forge in some way? It would add some great possibilities...

Link to comment
Share on other sites

There are multiple things where I could use it:

  • Checking block placement, to (for example) make a vanilla torch die (could maybe be done with an event)
  • Lighting, which is must work different in my dimensions.
  • Biome logic, to ensure every biome in my dimension is of specific type (provider could do this)
  • Checking if a specific block is powered (to make redstone lamps turn on by my custom fiberglass system)
  • To notify specific blocks of neighbor change when adding blocks (to make reeds die when water is gone)
  • To check if player may place blocks
  • Maybe some more things in the future...

Ok, I just implemented custom chunks to make biomes store as integers and make the debug and minimap show the right biome. Since I'm not planning to have a 1.12 release, this is not actually neccesary...

Edited by RgSW
Link to comment
Share on other sites

I've never done such thing before, so I have some questions on that:

  • How to do this (i know with github and such things, but how to make, apply and test those patches)?
  • Does this work when launching from launcher?

 

Edit:

Oh haha, found a tutorial on it already: https://mcforge.readthedocs.io/en/latest/forgedev/#making-changes-and-pull-requests

 

Edited by RgSW
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.