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 the trusted server issue #22

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -0,0 +1,13 @@
package io.github.homchom.recode.mixin.render;

import net.minecraft.client.gui.components.toasts.SystemToast;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;

@Mixin(SystemToast.class)
public interface ASystemToast {

@Accessor
SystemToast.SystemToastIds getId();

}
@@ -0,0 +1,25 @@
package io.github.homchom.recode.mixin.render;

import io.github.homchom.recode.server.ServerTrust;
import net.minecraft.client.gui.components.toasts.SystemToast;
import net.minecraft.client.gui.components.toasts.Toast;
import net.minecraft.client.gui.components.toasts.ToastComponent;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(ToastComponent.class)
public class MToastComponent {

@Inject(method = "addToast", at = @At("HEAD"), cancellable = true)
public void addToast(Toast toast, CallbackInfo ci) {
if (toast instanceof ASystemToast sysToast) {
if (sysToast.getId() == SystemToast.SystemToastIds.UNSECURE_SERVER_WARNING
&& ServerTrust.isServerTrusted()) {
ci.cancel();
}
}
}

}

This file was deleted.

This file was deleted.

4 changes: 2 additions & 2 deletions src/main/resources/recode.mixins.json
Expand Up @@ -5,8 +5,8 @@
"mixins": [
"render.MBlockEntityRenderDispatcher",
"render.MLevelRenderer",
"server.MClientPacketListener",
"server.MProfilePublicKey"
"render.MToastComponent",
"render.ASystemToast"
],
"client": [],
"server": [],
Expand Down