Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Servercore incompatability #31

Open
arazadaz opened this issue May 13, 2023 · 1 comment
Open

Servercore incompatability #31

arazadaz opened this issue May 13, 2023 · 1 comment
Labels
help wanted Extra attention is needed

Comments

@arazadaz
Copy link

This mod is incompatible with the servercore performance optimization mod.

Here is the crash report:
https://mclo.gs/CdfGrJW

@13rac1
Copy link
Owner

13rac1 commented Jul 5, 2023

The specific error from the log

[14:53:13] [main/ERROR]: Mixin apply for mod servercore failed servercore.common.mixins.json:optimizations.ticking.chunk.random.LiquidBlockMixin from mod servercore -> net.minecraft.class_2404: org.spongepowered.asm.mixin.injection.throwables.InvalidInjectionException @at("INVOKE") on net/minecraft/class_2404::servercore$cancelDuplicateFluidTicks with priority 1000 cannot inject into net/minecraft/class_2404::method_9542(Lnet/minecraft/class_2680;)Z merged by com._13rac1.erosion.fabric.mixin.LiquidBlockMixin with priority 1000 [PREINJECT Applicator Phase -> servercore.common.mixins.json:optimizations.ticking.chunk.random.LiquidBlockMixin from mod servercore -> Prepare Injections -> -> redirect$hjd000$servercore$cancelDuplicateFluidTicks(Lnet/minecraft/class_3610;)Z -> Prepare]
org.spongepowered.asm.mixin.injection.throwables.InvalidInjectionException: @at("INVOKE") on net/minecraft/class_2404::servercore$cancelDuplicateFluidTicks with priority 1000 cannot inject into net/minecraft/class_2404::method_9542(Lnet/minecraft/class_2680;)Z merged by com._13rac1.erosion.fabric.mixin.LiquidBlockMixin with priority 1000 [PREINJECT Applicator Phase -> servercore.common.mixins.json:optimizations.ticking.chunk.random.LiquidBlockMixin from mod servercore -> Prepare Injections -> -> redirect$hjd000$servercore$cancelDuplicateFluidTicks(Lnet/minecraft/class_3610;)Z -> Prepare]

This is crash caused by duplicate Mixin Framework @Override/@Redirect of LiquidBlock.isRandomlyTicking() by Servercore and Water Erosion. isRandomlyTicking() must be enabled for Water Erosion to function, but Servercore disables the ticks. [Mixin Injection Point reference]

servercore 1.19.2 : https://github.com/Wesley1808/ServerCore/blob/bbddbc8c/common/src/main/java/me/wesley1808/servercore/mixin/optimizations/ticking/chunk/random/LiquidBlockMixin.java#L14-L27

    /**
     * Liquid blocks already run their fluid random ticks in {@link ServerLevel#tickChunk(LevelChunk, int)}
     * This patch gets rid of the second 'duplicate' random tick.
     */
    @Redirect(
            method = "isRandomlyTicking",
            at = @At(
                    value = "INVOKE",
                    target = "Lnet/minecraft/world/level/material/FluidState;isRandomlyTicking()Z"
            )
    )
    private boolean servercore$cancelDuplicateFluidTicks(FluidState fluidState) {
        return false;
    }

water-erosion:

@Override
public boolean isRandomlyTicking(BlockState state) {
// Water only, not Lava.
return state.getBlock() == Blocks.WATER;
}

🤔 The Servercore code comment states: Liquid blocks already run their fluid random ticks in {@link ServerLevel#tickChunk(LevelChunk, int)} So, I look at the ServerLevel.class and find:

      if (i > 0) {
         LevelChunkSection[] levelChunkSections = levelChunk.getSections();

         for(int n = 0; n < levelChunkSections.length; ++n) {
            LevelChunkSection levelChunkSection = levelChunkSections[n];
            if (levelChunkSection.isRandomlyTicking()) {
               l = levelChunk.getSectionYFromSectionIndex(n);
               int o = SectionPos.sectionToBlockCoord(l);

               for(m = 0; m < i; ++m) {
                  BlockPos blockPos3 = this.getBlockRandomPos(j, o, k, 15);
                  profilerFiller.push("randomTick");
                  BlockState blockState4 = levelChunkSection.getBlockState(blockPos3.getX() - j, blockPos3.getY() - o, blockPos3.getZ() - k);
                  if (blockState4.isRandomlyTicking()) {
                     blockState4.randomTick(this, blockPos3, this.random);
                  }

                  FluidState fluidState = blockState4.getFluidState();
                  if (fluidState.isRandomlyTicking()) {
                     fluidState.randomTick(this, blockPos3, this.random);
                  }

When fluidState.isRandomlyTicking() is false, fluidState.randomTick() is never called. Where is the other call to fluidState.randomTick()? Is there really a "second 'duplicate' random tick"? I must be missing something here. I'm open to suggestions for how to make this compatible with Servercore, but I've reached my time limit for researching this issue.

@13rac1 13rac1 added the help wanted Extra attention is needed label Apr 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants