diff options
Diffstat (limited to 'src/main/java/com/raeids/stratus/mixin')
-rw-r--r-- | src/main/java/com/raeids/stratus/mixin/GuiIngameForgeMixin.java | 30 | ||||
-rw-r--r-- | src/main/java/com/raeids/stratus/mixin/GuiNewChatMixin.java | 80 |
2 files changed, 104 insertions, 6 deletions
diff --git a/src/main/java/com/raeids/stratus/mixin/GuiIngameForgeMixin.java b/src/main/java/com/raeids/stratus/mixin/GuiIngameForgeMixin.java new file mode 100644 index 0000000..3c500f5 --- /dev/null +++ b/src/main/java/com/raeids/stratus/mixin/GuiIngameForgeMixin.java @@ -0,0 +1,30 @@ +package com.raeids.stratus.mixin; + +import com.raeids.stratus.hook.GuiIngameForgeHook; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraftforge.client.GuiIngameForge; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; + +@Mixin(value = GuiIngameForge.class, remap = false) +public class GuiIngameForgeMixin implements GuiIngameForgeHook { + private int stratus$x = 0; + private int stratus$y = 0; + @Redirect(method = "renderChat", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/GlStateManager;translate(FFF)V", remap = true)) + private void captureTranslate(float x, float y, float z) { + stratus$x = Math.round(x); + stratus$y = Math.round(y); + GlStateManager.translate(x, y, z); + } + + @Override + public int getX() { + return stratus$x; + } + + @Override + public int getY() { + return stratus$y; + } +} diff --git a/src/main/java/com/raeids/stratus/mixin/GuiNewChatMixin.java b/src/main/java/com/raeids/stratus/mixin/GuiNewChatMixin.java index bbe1e9b..5732778 100644 --- a/src/main/java/com/raeids/stratus/mixin/GuiNewChatMixin.java +++ b/src/main/java/com/raeids/stratus/mixin/GuiNewChatMixin.java @@ -3,25 +3,36 @@ package com.raeids.stratus.mixin; import com.raeids.stratus.Stratus; import com.raeids.stratus.hook.ChatSearchingKt; import com.raeids.stratus.hook.ChatTabs; +import com.raeids.stratus.hook.GuiIngameForgeHook; +import com.raeids.stratus.hook.GuiNewChatHook; +import gg.essential.universal.UResolution; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.ChatLine; +import net.minecraft.client.gui.Gui; import net.minecraft.client.gui.GuiNewChat; +import net.minecraft.client.renderer.GlStateManager; import net.minecraft.util.IChatComponent; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.input.Mouse; import org.spongepowered.asm.lib.Opcodes; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.ModifyVariable; -import org.spongepowered.asm.mixin.injection.Redirect; +import org.spongepowered.asm.mixin.Unique; +import org.spongepowered.asm.mixin.injection.*; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import java.util.List; @Mixin(GuiNewChat.class) -public class GuiNewChatMixin { +public class GuiNewChatMixin extends Gui implements GuiNewChatHook { + @Unique private int stratus$x = 0; + @Unique private int stratus$y = 0; + @Unique private boolean stratus$shouldCopy; + @Unique private ChatLine stratus$chatLine; @Shadow @Final private Minecraft mc; + @Shadow @Final private List<ChatLine> drawnChatLines; + @Unique private static final ResourceLocation COPY = new ResourceLocation("stratus:copy.png"); @Inject(method = "setChatLine", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/MathHelper;floor_float(F)I", shift = At.Shift.AFTER)) private void setDoing(IChatComponent chatComponent, int chatLineId, int updateCounter, boolean displayOnly, CallbackInfo ci) { @@ -47,10 +58,67 @@ public class GuiNewChatMixin { : linesToDraw; } - @Shadow @Final private List<ChatLine> drawnChatLines; + @Redirect(method = "drawChat", at = @At(value = "INVOKE", target = "Ljava/util/List;get(I)Ljava/lang/Object;")) + private Object captureChatLine(List<ChatLine> instance, int i) { + stratus$chatLine = instance.get(i); + return stratus$chatLine; + } + + @Redirect(method = "drawChat", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/GuiNewChat;drawRect(IIIII)V"), slice = @Slice(from = @At(value = "INVOKE", target = "Lnet/minecraft/util/MathHelper;clamp_double(DDD)D"), to = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/GlStateManager;enableBlend()V"))) + private void captureDrawRect(int left, int top, int right, int bottom, int color) { + drawRect(left, top, right, bottom, color); + final int k1 = Mouse.getX() * UResolution.getScaledWidth() / this.mc.displayWidth; + final int l1 = UResolution.getScaledHeight() - Mouse.getY() * UResolution.getScaledHeight() / this.mc.displayHeight - 1; + int mouseX = k1 - ((GuiIngameForgeHook) mc.ingameGUI).getX() - 2; + int mouseY = l1 - ((GuiIngameForgeHook) mc.ingameGUI).getY() - 20; + if (mouseX >= left && mouseY <= bottom && mouseX - 9 <= right && mouseY >= top) { + stratus$shouldCopy = true; + GlStateManager.enableRescaleNormal(); + GlStateManager.enableBlend(); + GlStateManager.enableDepth(); + GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); + GlStateManager.pushMatrix(); + mc.getTextureManager().bindTexture(COPY); + GlStateManager.enableRescaleNormal(); + GlStateManager.enableAlpha(); + GlStateManager.alphaFunc(516, 0.1f); + GlStateManager.enableBlend(); + GlStateManager.blendFunc(770, 771); + GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f); + stratus$x = right; + stratus$y = top; + Gui.drawModalRectWithCustomSizedTexture(right, top, 0f, 0f, 9, 9, 9, 9); + GlStateManager.disableAlpha(); + GlStateManager.disableRescaleNormal(); + GlStateManager.disableLighting(); + GlStateManager.popMatrix(); + } else if (stratus$shouldCopy) { + stratus$shouldCopy = false; + } + } @Redirect(method = "drawChat", at = @At(value = "FIELD", target = "Lnet/minecraft/client/gui/GuiNewChat;drawnChatLines:Ljava/util/List;", opcode = Opcodes.GETFIELD)) private List<ChatLine> injected(GuiNewChat instance) { return ChatSearchingKt.filterMessages(drawnChatLines); } + + @Override + public int getX() { + return stratus$x; + } + + @Override + public int getY() { + return stratus$y; + } + + @Override + public boolean shouldCopy() { + return stratus$shouldCopy; + } + + @Override + public String copyString() { + return stratus$chatLine.getChatComponent().getFormattedText(); + } } |