-
Recently Browsing
No registered users viewing this page.
-
Posts
-
Hi, sorry I didn't get back to you. I have already created a GUI that isn't great but it opens on right click and I have even put on some redstone detection to allow to charge (repair my item) and I think I want a container because this explanation says that it has progress bar which I assume means it is tickable... I haven't been doing coding a for a while because I have had things going on https://greyminecraftcoder.blogspot.com/2020/04/containers-1144.html
-
By diesieben07 · Posted
It looks like you are missing any kind of loading mechanism that keeps track of which data needs to be loaded and which doesn't. It would be better to only keep things loaded for loaded chunks, so a chunk capability would be a better way. -
By TheOrangeInd · Posted
I have fluid pipes in my mod and I use a custom Grid object to distribute fluid in this pipes. This Grid object does not inherit either Tilentity or Entity, but I need to write data from it to the world NBT. The only solution that I have found is to create my own class that inherits WorldSavedData. The problem is that I don't quite understand how to use it correctly in newer versions of the game and I'm not sure if this is the best way. I would be very grateful for any advice. Custom WorldSavedData implementation: public class NBTHandler extends WorldSavedData { private static final String DATA_IDENTIFIER = MainClass.MODID + "_nbt"; public final Set<ISaveable> subscribers = new HashSet(); public NBTHandler() { this(DATA_IDENTIFIER); } public NBTHandler(String name) { super(name); } public static NBTHandler get(World world) { if(!(world instanceof ServerWorld)) throw new RuntimeException("Attempted to get data from client."); ServerWorld w = (ServerWorld)world; DimensionSavedDataManager storage = w.getSavedData(); return storage.getOrCreate(NBTHandler::new, DATA_IDENTIFIER); } public void addSubscriber(ISaveable s) { subscribers.add(s); } @Override public boolean isDirty() { boolean flag = false; for (ISaveable item : subscribers) flag &= item.isDirty(); return super.isDirty() || flag; } @Override public void read(CompoundNBT nbt) { subscribers.forEach(item -> item.readFromNBT(nbt)); } @Override public CompoundNBT write(CompoundNBT nbt) { subscribers.forEach(item -> item.writeToNBT(nbt)); return nbt; } }
-
-
Topics
-
Who's Online (See full list)
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.