Jump to content

Question about the WorldEvent events


UntouchedWagons

Recommended Posts

I want to make a mod that adds power lines (like the ones in real life) to let you transmit RF large distances without the use of tesseracts or similar "magic" blocks. What I want to do is create power grids that multiple power lines are a part of, this would have the effect of not requiring the entire run of chunks to be loaded. To do this I need to be able to load data about the various power grids in the dimensions when a save is loaded. Thus my question is this: In the WorldEvent class it says, "WorldEvent is fired when an event involving the world occurs.". When it says "World", does this mean a save or a dimension?

 

Also as a bonus question, how would I go about storing data structures to an external file? I'd need to create an NBT structure which I know how to do, but I don't know how to save it. In the World class I see the getSaveHandler method which returns an implementation of ISaveHandler which has a getWorldDirectory method.

I like trains.

Link to comment
Share on other sites

I think, loading the chunk with some mod tickets will be more safe and better than that.

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

Link to comment
Share on other sites

I suppose if a player wanted to transfer power 1000 blocks and a power line could be 50 blocks apart, that would be 20 chunks loaded which wouldn't be too bad. I'm looking at the ForgeChunkManager class now, the first parameter for the setForcedChunkLoadingCallback is an object named mod. I assume I pass the class that I have annotated with the @Mod annotation?

I like trains.

Link to comment
Share on other sites

Okay so by looking at this post by mew and your following post and copying a bit of code from your Questology mod I got this:

 

package untouchedwagons.minecraft.powerlines.grids;

import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
import net.minecraft.world.WorldSavedData;

public class PowerGridWorldData extends WorldSavedData {
    private static final String IDENTIFIER = "power-lines";

    public PowerGridWorldData(String identifier) {
        super(identifier);
    }

    public PowerGridWorldData() {
        super(IDENTIFIER);
    }

    @Override
    public void readFromNBT(NBTTagCompound p_76184_1_) {

    }

    @Override
    public void writeToNBT(NBTTagCompound p_76187_1_) {

    }

    public static PowerGridWorldData get(World world) {
        PowerGridWorldData data = (PowerGridWorldData)world.mapStorage.loadData(PowerGridWorldData.class, IDENTIFIER);

        if (data == null) {
            data = new PowerGridWorldData();
            world.mapStorage.setData(IDENTIFIER, data);
        }
        
        return data;
    }
}

 

My remaining question is in the WorldEvent events, does it mean World as in a single dimension or as in a save encompassing multiple dimensions? Also, is the Load event fired before chunks are loaded?

I like trains.

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.