Jump to content

[1.12.2] Custom IChunkLoader


the4naves

Recommended Posts

So long story short, I need to be able to return any chunk I want when the game requests to load a chunk (Ex: Game requests chunk at (5, -3), I return the chunk at say, (2, 7), then display that chunk at (5, -3)).

Looking through the source code, it seems the way to do this would be to utilize a custom IChunkLoader, and/or IChunkProvider (NOTE: I do NOT mean IChunkGenerator. From what I understand, the chunk generator used to be called the chunk provider, but that serves a completely different purpose now), however there doesn't seem to be any way to access instances of these classes (Or at least the classes that implement them) other than reflection and a custom WorldProvider in a custom dimension, as all fields I could find were private or protected.

So before I go along with my reflection route, is there an easier/intended way of doing this, and are the classes I've found even the correct ones?

I've done a fair amount of research, but no one seems to have an answer.

Edited by the4naves
Ease of Reading
Link to comment
Share on other sites

In essence, yes, though the approach I'm going for is more simply overriding, for example, the loadChunk() method in IChunkLoader. (Or similer)

So in other words, I'd like to "trick" the game into thinking the Chunks I give it when it requests them are the actual world.

For placing blocks, maybe sounds and mob AI, those will probably need more overrides, most likely overriding the methods to get a block in the world, along others, but I can address those later.

In the best case scenario I would just like to be able to provide my own subclasses to be used instead of the vanilla ones.

Edited by the4naves
Extra info
Link to comment
Share on other sites

To your first point, I do mostly agree, I think having the same Chunk loaded in multiple places at the same time could cause all kinds of problems, but what I'm planning on doing shouldn't ever create a situation like that.

To give some context, I'm trying to create a "world wrap" effect, where the world loops infinitely in a specific direction (Generation can be handled by tile-able noise). To do this, there will be an invisible "border" that will teleport you to the other side when you touch it. To prevent the game from having to suddenly load a bunch of chunks and to prevent structures you've build from suddenly popping in, as you approach the border, the game should load chunks on the other side, and provide them to the chunk provider in lieu of what is actually near you.

So I suppose a custom chunk could simply mirror the chunks it needs to, but a custom chunk loader/maybe a provider seems cleaner and might be better for performance.

Link to comment
Share on other sites

Ok, so I've looked into the source code a bit more, and it looks like everything I'm trying to do could be accomplished by overriding the WorldClient and by the looks of it WorldServer classes. (Subclasses of World)

The Minecraft class keeps a public instance of WorldClient (Yay no reflection), and it seems to only be set in loadWorld(). Forge seems to have the job of loading worlds, and when doing so calls launchIntegratedServer(), which starts the server. I'm not sure overriding WorldServer is required though.

Is there a forge event or something similar that fires on world load I could hook into to replace the world with my own subclass? (The subclass would copy over the info from the existing one if needed)

Thanks for your help.

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • The game crashed whilst exception ticking world Error: java.lang.NullPointerException: Cannot invoke "net.minecraft.resources.ResourceLocation.equals(Object)" because "this.lootTableId" is null Error given is above. I was already playing for around 15 minutes and wasn't doing anything specific or even breaking anything when the crashed happened. This is update 1.19.2 forge: 43.2.23 Mod list: ESSENTIAL Mod (by SparkUniverse_) Traveler's Titles (Forge) (by YUNGNICKYOUNG) Resourceful Config (by ThatGravyBoat) Dynamic Lights (by atomicstrykergrumpy) TenzinLib (by CommodoreThrawn) Nature's Compass (by Chaosyr) Library Ferret - Forge (by jtl_elisa) Cold Sweat (by Mikul) Simple Voice Chat (by henkelmax) Waystones (by BlayTheNinth) Carry On (by Tschipp) [Let's Do] Meadow (by satisfy) Creeper Overhaul (by joosh_7889) AutoRegLib (by Vazkii) Moonlight Lib (by MehVahdJukaar) AppleSkin (by squeek502) Xaero's World Map (by xaero96) Rotten Creatures (by fusionstudiomc) YUNG's API (Forge) (by YUNGNICKYOUNG) Village Artifacts (by Lothrazar) Right Click, Get Crops (by TeamCoFH) Supplementaries (by MehVahdJukaar) Automatic Tool Swap (by MelanX) Better Third Person (by Socolio) Supplementaries Squared (by plantspookable) Traveler's Backpack (by Tiviacz1337) Caelus API (Forge/NeoForge) (by TheIllusiveC4) Creatures and Beasts (by joosh_7889) Architectury API (Fabric/Forge/NeoForge) (by shedaniel) Quark Oddities (by Vazkii) Origins (Forge) (by EdwinMindcraft) Villager Names (by Serilum) GeckoLib (by Gecko) Realistic Bees (by Serilum) Illuminations Forge 🔥 (by dimadencep) Serene Seasons (by TheAdubbz) Critters and Companions (by joosh_7889) [Let's Do] Bakery (by satisfy) Falling Leaves (Forge) (by Cheaterpaul) Jade 🔍 (by Snownee) Collective (by Serilum) TerraBlender (Forge) (by TheAdubbz) [Let's Do] API (by Cristelknight) Towns and Towers (by Biban_Auriu) More Villagers (by SameDifferent) Biomes O' Plenty (by Forstride) Goblin Traders (by MrCrayfish) Corpse (by henkelmax) Tree Harvester (by Serilum) Balm (Forge Edition) (by BlayTheNinth) Mouse Tweaks (by YaLTeR) Sound Physics Remastered (by henkelmax) Xaero's Minimap (by xaero96) Just Enough Items (JEI) (by mezz) Terralith (by Starmute) Quark (by Vazkii) [Let's Do] Vinery (by satisfy) [Let's Do] Candlelight (by satisfy) Repurposed Structures (Neoforge/Forge) (by telepathicgrunt) Dusty Decorations (by flint_mischiff) Immersive Armors [Fabric/Forge] (by Conczin) Serene Seasons Fix (by Or_OS) Shutup Experimental Settings! (by Corgi_Taco) Skin Layers 3D (Fabric/Forge) (by tr7zw)
    • Make sure Java is running via Nvidia GPU https://windowsreport.com/minecraft-not-using-gpu/  
    • Also make a test with other Custom Launchers like AT Launcher, MultiMC or Technic Launcher
    • Embeddium and valkyrienskies are not working together - remove one of these mods With removing Embeddium, also remove Oculus, TexTrue's Embeddium Options and Embeddium Extras Or use Rubidium instead
  • Topics

×
×
  • Create New...

Important Information

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