Immersive Engineering

Immersive Engineering

152M Downloads

Multiblock slave NBT size optimize

roj234 opened this issue · 6 comments

commented

Explain your idea

Change to blusunrize.immersiveengineering.common.blocks.IEBaseBlockEntity

    public void load(CompoundTag nbtIn) {
        super.load(nbtIn);
        this.readCustomNBT(nbtIn, false);
    }
    protected final void load1(CompoundTag nbtIn) {super.load(nbtIn);}

    protected void saveAdditional(CompoundTag nbt) {
        super.saveAdditional(nbt);
        this.writeCustomNBT(nbt, false);
    }
    protected final void saveAdditional1(CompoundTag nbt) {super.saveAdditional(nbt);}

Change to blusunrize.immersiveengineering.common.blocks.generic.MultiblockPartBlockEntity

    @Override
    public void load(CompoundTag nbtIn) {
        if (!nbtIn.getString("id").endsWith("_dummy"))
            super.load(nbtIn);
        else {
            super.load1(nbtIn);
            readCustomNBT1(nbtIn);
        }
    }

    @Override
    protected void saveAdditional(CompoundTag nbt) {
        if (!BlockEntityType.getKey(getType()).getPath().endsWith("_dummy")) super.saveAdditional(nbt);
        else {
            super.saveAdditional1(nbt);
            writeCustomNBT1(nbt);
        }
    }

    public void readCustomNBT(CompoundTag nbt, boolean descPacket) {readCustomNBT1(nbt);}
    public void writeCustomNBT(CompoundTag nbt, boolean descPacket) {writeCustomNBT1(nbt);}

    private void readCustomNBT1(CompoundTag nbt) {
       // original readCustomNBT
    }

    private void writeCustomNBT1(CompoundTag nbt) {
        // original writeCustomNBT
    }

I have test them in my singleplayer world, it seems no bugs in save/load.

Another suggestion, but might too complex to implement for a long-time mod:
In my mod's multiblock structure, I use RenderShape.INVISIBLE and a per world MultiblockManager
Only the block in multiblock center will render
All structure blocks except I/O did not have a BlockEntity, MultiblockManager will handle relative position on BlockBreakEvent event handler
MultiblockManager also listen ChunkLoad/Save/Unload event, to store data in chunks' NBT, rather then data/*.dat

Another thing:
I'm making a modpack, and you know, tech mods often add duplicate ores, dusts, etc.
I have modified your code to delete some block/items, however, your License have mentioned
- Redistribute this project (source or compiled) without explicit permission of the license holder, BluSunrize
is not permitted.
So may I provide my change as a Binary patch and make a mod to automatic apply it on your mod?

commented

IE did originally use invisible slave blocks with the master rendering everything, but it was changed to the current system to allow each block to properly receive lighting and AO independently. For duplicate items, you don't have to remove them, just hide them and change loot tables/recipes so they never appear. IE's already able to automatically produce ores etc from another mod.

commented

Also, your code changes are no longer relevant since 1.19.3 when #5523 was merged. The dummy blocks should have fairly minimal data now. In general for this sort of performance-ish suggestion, you should show that the old state is actually a problem. World size on disk is not my area, but in memory the dummy BEs are negligible.

I will leave this open for @BluSunrize as the formal copyright holder to comment on the last part.

commented

IE did originally use invisible slave blocks with the master rendering everything, but it was changed to the current system to allow each block to properly receive lighting and AO independently. For duplicate items, you don't have to remove them, just hide them and change loot tables/recipes so they never appear. IE's already able to automatically produce ores etc from another mod.

Thank you for your reply.

Now, I still think datapack cannot 'remove' files, it can only 'replace'.
However, in past two days, I made an AbstractPackResources mixin, so I can 'remove' files in other mods' datapack now, but there might be a simpler solution?

At meantime, I refactored MineralVein, MineralMix, ExcavatorBlockEntity and its recipe, to optimize MineralVein's performance by using a chunked Rect3i map, give createoreexcavation an API to let it use IE's virtual mineral, and let Excavator need specied fluid to mine some mineral, and this cannot be done by datapack……

And I don't think binary patch have any difference to mixin, since forge/fabric already using patch to avoid Mojang's License

commented

As the formal copyright holder:
No, you absolutely can not just distribute some weird modifications to IE, lmfao.

If you want IE to be better, you should be submitting pullrequests so that everyone can have a better mod, instead of doing weird hacky shit to it that only applies in your pack.

commented

As the formal copyright holder: No, you absolutely can not just distribute some weird modifications to IE, lmfao.

If you want IE to be better, you should be submitting pullrequests so that everyone can have a better mod, instead of doing weird hacky shit to it that only applies in your pack.

integration

  1. Integration is not universally desired; typically, this should be handled by KubeJS or CraftTweaker for modpack creators. However, neither of these tools currently supports adding FluidTanks to existing BlockEntity or...
  2. Such integrations would require modifying other mods as well, or do you plan to use mixins? If players use an incompatible version of the integration mod, they could experience crashes due to invalid mixins, haha.
  3. Therefore, CreateOreExcavation's integration should be implemented through an ADDON (as per your License), rather than a PR.

optimization

  1. Certain optimizations, such as chunked Rect3i maps, are available in my library. However, this library is not production-ready, extensively uses Unsafe, and is incompatible with Java 22. It contains over 150,000 lines of code unrelated to Minecraft, and creating an independent version without references would not be wise. This is because if I update my library, the standalone version would not automatically receive updates.

previous failure

  1. Previously, I submitted a PR (with only one commit), but the owner rejected it, stating that it changed too much code and was difficult to review. As a result, I closed it and distributed the source code randomly (which was allowed by the license). Many users agreed that it did make things faster. Sometime later, another user made a similar PR with over 10 commits, and the owner accepted it...

conclusion

  1. I have not distributed your source code or compiled versions; I am not violating your License.
  2. Instead, I merely shared some instructions involving copying several bytes from specific offsets within a particular file and inserting bytes at specific offsets, similar to what Forge has done with ARR Minecraft.
  3. Therefore, I am merely informing you politely and sincerely hoping we can reach an understanding (it's not true that I need your approval to proceed).
  4. After all, CraftBukkit (or perhaps Cauldron?) has ceased development, but Forge is still active.
  5. Moreover, applying patches is currently the only viable method for handling certain ARR mods in my mod pack.
  6. Finally, you remain the same as you were a few years—maybe even ten years—ago.
  7. If I find any simpler optimizations, I will create a PR, well, considering point 6. (This might also fall under previous failure.) I probably won't do that...
  8. The translation of this statement was assisted by AI to improve its tone.
commented

Wow whatever AI you are using is not doing you any favors with its tone =p