Jump to content

How and where to override Chunk.java?


freeradicalx

Recommended Posts

Hi, I'm porting my mod that generates roads across the overworld to Forge since I'd like for it to play nice with other mods. This is my first time working with Forge. The original mod modifies Chunk.java by adding a new variable called roadData to keep track of generated roads. How and where would I be able to achieve the same thing in Forge, since the idea is to not modify the base Minecraft classes? Or would I have to do something else entirely?

Link to comment
Share on other sites

I understand how to make my own WorldGen, I can easily add methods that generate one-off structures during chunk generation. However a road is a continuous, potentially infinite curve that snakes through the world so it has to be generated chunk by chunk as the player explores: Only it's start or end can be one-off events. I achieved this functionality in the non-forge version of my mod by adding an array of three points to Chunk.java called roadData. If the chunk contained a point on a highway's curve, roadData would contain the coordinates of that point and of the two adjacent points, so that chunks generating nearby could detect it and see if they had to continue the roadway (And likewise determine the next point in the road's curve).

 

I can no longer edit Chunk.java if I'm to be forge compatible, and I don't know how I could do so by creating my own WorldGen. I'm not a newb but am by no means a master at this stuff, so some guidance would be totally appreciated. Thanks :)

Link to comment
Share on other sites

Not dense at all, that's a great idea. I think that might have been my original plan, but I wasn't sure if data being stored in my WorldGen would get saved on exit the same way that data in Chunk instances do. Would I need do to anything special to make sure my road data saves if it's in the WorldGen or is that already taken care of by Minecraft?

Link to comment
Share on other sites

Not dense at all, that's a great idea. I think that might have been my original plan, but I wasn't sure if data being stored in my WorldGen would get saved on exit the same way that data in Chunk instances do. Would I need do to anything special to make sure my road data saves if it's in the WorldGen or is that already taken care of by Minecraft?

Oh, I see. I suspect you would. I don't know much about this sort of thing, but I think you want to create an extension of WorldSavedData and then use world.perWorldStorage.setData("id",myWSD);

 

Of course, someone's going to tell me I'm wrong or there's a far more elegant way to do it, which I welcome.

BEWARE OF GOD

---

Co-author of Pentachoron Labs' SBFP Tech.

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.