UntouchedWagons Posted June 14, 2015 Posted June 14, 2015 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. Quote I like trains.
Abastro Posted June 14, 2015 Posted June 14, 2015 I think, loading the chunk with some mod tickets will be more safe and better than that. Quote I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP) II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.
UntouchedWagons Posted June 14, 2015 Author Posted June 14, 2015 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? Quote I like trains.
UntouchedWagons Posted June 14, 2015 Author Posted June 14, 2015 In any case, how would I go about saving and loading data from a file when a save is loaded? Quote I like trains.
UntouchedWagons Posted June 14, 2015 Author Posted June 14, 2015 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? Quote I like trains.
UntouchedWagons Posted June 14, 2015 Author Posted June 14, 2015 In that case I'd want to load the data when a save is loaded, not when a world is loaded. Is there an event for that? Actually nevermind, since my power lines won't be doing cross-dimensional transfer, saving the power grids per world will be fine. Thanks. Quote I like trains.
Recommended Posts
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.