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

Fix ME hatches crashing on server side #2812

Merged
merged 6 commits into from
Feb 12, 2025
Merged

Conversation

dnk1234567
Copy link
Contributor

@dnk1234567 dnk1234567 commented Feb 1, 2025

What

This PR distinguishes between the code in ME hatches that runs on the server and the code that runs on the client.

Implementation Details

public void setSlotIndex(int slotIndex) {
        this.index = slotIndex;
        writeClientAction(0, buf -> buf.writeVarInt(this.index));
}

This code contains

@Environment(EnvType.CLIENT)
protected final void writeClientAction(int id, Consumer<FriendlyByteBuf> FriendlyByteBufWriter) {
    if (uiAccess != null && !isClientSideWidget) {
        uiAccess.writeClientAction(this, id, FriendlyByteBufWriter);
    }
}

that should only run in client.

The method setSlotIndex was invoked by enableAmount and disableAmount.

In most cases, calls to the above two methods appear in client code with @OnlyIn(Dist.CLIENT).

But the method

public void handleClientAction(int id, FriendlyByteBuf buffer) {
...
}

in AEFluidConfigSlotWidget and AEItemConfigSlotWidget will invoke the enableAmount and disableAmount method.

The server will call a code that only exists in the client then throw NoSuchMethodError and crash.

I added client versions of enableAmount, disableAmount and setSlotIndex then let the handleClientAction to invoke server version.

Outcome

Fix #2805

2025-02-01_11 37 46
2025-02-01_11 41 21

Additional Information

Also tested in Monifactory pack.

Potential Compatibility Issues

I checked these code only exist in ME related hatched/buses.

So it seems unlikely that there is a compatibility issue.

@dnk1234567 dnk1234567 requested a review from a team as a code owner February 1, 2025 06:32
@omergunr100 omergunr100 added the type: bugfix general bug fixes label Feb 1, 2025
@krossgg krossgg changed the title Fix ME hatches crash in server side Fix ME hatches crashing on server side Feb 12, 2025
@krossgg krossgg merged commit 9d8085d into GregTechCEu:1.20.1 Feb 12, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bugfix general bug fixes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Server Crash (ME input hatch)
3 participants