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 client crash with portals #4110

Merged
merged 2 commits into from
Aug 12, 2024

Conversation

MrHell228
Copy link
Contributor

@MrHell228 MrHell228 commented Jul 13, 2024

Fixes java.lang.ClassCastException: class net.minecraft.client.multiplayer.ClientLevel cannot be cast to class net.minecraft.server.level.ServerLevel when player tries to enter portal with Sponge on client (running it in ide).

@@ -424,6 +424,10 @@ public Entity changeDimension(final DimensionTransition transition) {
@Inject(method = "setAsInsidePortal", at = @At(value = "FIELD", opcode = Opcodes.PUTFIELD, shift = At.Shift.AFTER,
target = "Lnet/minecraft/world/entity/Entity;portalProcess:Lnet/minecraft/world/entity/PortalProcessor;"))
public void impl$onCreatePortalProcessor(final Portal $$0, final BlockPos $$1, final CallbackInfo ci) {
if (this.shadow$level().isClientSide()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should check if level is fake, see bridge$isFake

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@ImMorpheus ImMorpheus merged commit 6627ee2 into SpongePowered:api-12 Aug 12, 2024
5 checks passed
@MrHell228 MrHell228 deleted the api-12-fix/portal branch August 12, 2024 21:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants