NoToast: updated to optimized method
This commit is contained in:
parent
20b0b9c7e1
commit
6c1e00c3a2
|
@ -0,0 +1,6 @@
|
||||||
|
package me.rigamortis.seppuku.api.event.render;
|
||||||
|
|
||||||
|
import me.rigamortis.seppuku.api.event.EventCancellable;
|
||||||
|
|
||||||
|
public class EventDrawToast extends EventCancellable {
|
||||||
|
}
|
|
@ -62,6 +62,7 @@ public final class PatchManager {
|
||||||
this.patchList.add(new GuiChatPatch());
|
this.patchList.add(new GuiChatPatch());
|
||||||
this.patchList.add(new ParticleManagerPatch());
|
this.patchList.add(new ParticleManagerPatch());
|
||||||
this.patchList.add(new GuiPlayerTabOverlayPatch());
|
this.patchList.add(new GuiPlayerTabOverlayPatch());
|
||||||
|
this.patchList.add(new GuiToastPatch());
|
||||||
|
|
||||||
//load custom external patches
|
//load custom external patches
|
||||||
//TODO this needs more testing
|
//TODO this needs more testing
|
||||||
|
|
|
@ -1,20 +1,17 @@
|
||||||
package me.rigamortis.seppuku.impl.module.misc;
|
package me.rigamortis.seppuku.impl.module.misc;
|
||||||
|
|
||||||
import me.rigamortis.seppuku.api.event.player.EventUpdateWalkingPlayer;
|
import me.rigamortis.seppuku.api.event.render.EventDrawToast;
|
||||||
import me.rigamortis.seppuku.api.module.Module;
|
import me.rigamortis.seppuku.api.module.Module;
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import team.stiff.pomelo.impl.annotated.handler.annotation.Listener;
|
import team.stiff.pomelo.impl.annotated.handler.annotation.Listener;
|
||||||
|
|
||||||
public final class NoToast extends Module {
|
public final class NoToast extends Module {
|
||||||
|
|
||||||
private final Minecraft mc = Minecraft.getMinecraft();
|
|
||||||
|
|
||||||
public NoToast() {
|
public NoToast() {
|
||||||
super("NoToast", new String[]{"Toast"}, "Prevents toasts from being displayed on screen.", "NONE", -1, ModuleType.WORLD);
|
super("NoToast", new String[]{"Toast"}, "Prevents toasts from being displayed on screen.", "NONE", -1, ModuleType.WORLD);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Listener
|
@Listener
|
||||||
public void onWalkingUpdate(EventUpdateWalkingPlayer event) {
|
public void onToast(EventDrawToast event) {
|
||||||
mc.getToastGui().clear();
|
event.setCanceled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,46 @@
|
||||||
|
package me.rigamortis.seppuku.impl.patch;
|
||||||
|
|
||||||
|
import me.rigamortis.seppuku.Seppuku;
|
||||||
|
import me.rigamortis.seppuku.api.event.render.EventDrawToast;
|
||||||
|
import me.rigamortis.seppuku.api.patch.ClassPatch;
|
||||||
|
import me.rigamortis.seppuku.api.patch.MethodPatch;
|
||||||
|
import me.rigamortis.seppuku.impl.management.PatchManager;
|
||||||
|
import org.objectweb.asm.Type;
|
||||||
|
import org.objectweb.asm.tree.*;
|
||||||
|
|
||||||
|
import static org.objectweb.asm.Opcodes.*;
|
||||||
|
|
||||||
|
public class GuiToastPatch extends ClassPatch {
|
||||||
|
|
||||||
|
public GuiToastPatch() {
|
||||||
|
super("net.minecraft.client.gui.toasts.GuiToast", "bkc");
|
||||||
|
}
|
||||||
|
|
||||||
|
@MethodPatch(
|
||||||
|
mcpName = "drawToast",
|
||||||
|
notchName = "a",
|
||||||
|
mcpDesc = "(Lnet/minecraft/client/gui/ScaledResolution;)V",
|
||||||
|
notchDesc = "(Lbit;)V")
|
||||||
|
public void drawToast(MethodNode methodNode, PatchManager.Environment env) {
|
||||||
|
//create a list of instructions
|
||||||
|
final InsnList insnList = new InsnList();
|
||||||
|
//call our hook function
|
||||||
|
insnList.add(new MethodInsnNode(INVOKESTATIC, Type.getInternalName(this.getClass()), "drawToastHook", "()Z", false));
|
||||||
|
//create a label to jump to
|
||||||
|
final LabelNode jmp = new LabelNode();
|
||||||
|
//add "if equals"
|
||||||
|
insnList.add(new JumpInsnNode(IFEQ, jmp));
|
||||||
|
//return so the rest of the function doesnt get called
|
||||||
|
insnList.add(new InsnNode(RETURN));
|
||||||
|
//add our label
|
||||||
|
insnList.add(jmp);
|
||||||
|
//insert the list of instructs at the top of the function
|
||||||
|
methodNode.instructions.insert(insnList);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean drawToastHook() {
|
||||||
|
final EventDrawToast event = new EventDrawToast();
|
||||||
|
Seppuku.INSTANCE.getEventManager().dispatchEvent(event);
|
||||||
|
return event.isCanceled();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue