mrbuilder1961 / ChatPatches

A Minecraft client-side mod that touches up Minecraft's mundane chat, with configurability in mind!
GNU Lesser General Public License v3.0
44 stars 16 forks source link

Resolves mrbuilder1961/ChatPatches#106 #107

Closed ploxxxy closed 11 months ago

ploxxxy commented 11 months ago

image

mrbuilder1961 commented 11 months ago

gonna have to look at this later bc it prevents the search button from being clicked on for some reason

ploxxxy commented 11 months ago

Hm, that's weird. Can't reproduce this on my end

hexadecimal233 commented 11 months ago

cir.getReturnValue() != null seems residual (cuz its boolean value and default returns false) and my original code @Inject(method = "mouseClicked", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/Screen;mouseClicked(DDI)Z", shift = At.Shift.AFTER), cancellable = true) works fine. With these changes,

if(client.inGameHud.getChatHud().getTextStyleAt(mX, mY) != null && isMouseOverSettingsMenu(mX, mY))
                cir.setReturnValue(false);

can also be removed. I wonder what IDE you are using? The code formatting looks pretty weird for me.

ploxxxy commented 11 months ago

cir.getReturnValue() != null seems residual (cuz its boolean value and default returns false) and my original code @Inject(method = "mouseClicked", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/Screen;mouseClicked(DDI)Z", shift = At.Shift.AFTER), cancellable = true) works fine. With these changes,

if(client.inGameHud.getChatHud().getTextStyleAt(mX, mY) != null && isMouseOverSettingsMenu(mX, mY))
              cir.setReturnValue(false);

While your suggestions work well for me, they revert some changes made in https://github.com/mrbuilder1961/ChatPatches/commit/e0c330c57cfe8ebd7d9a7c76e5a176989d6adb7c, which are supposed to fix https://github.com/mrbuilder1961/ChatPatches/issues/102. Waiting for @mrbuilder1961 to comment on that.

ploxxxy commented 11 months ago

gonna have to look at this later bc it prevents the search button from being clicked on for some reason

was able to reproduce this: right clicking on the search button.

Fiz-Victor's original code @Inject(method = "mouseClicked", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/Screen;mouseClicked(DDI)Z", shift = At.Shift.AFTER), cancellable = true) works well and is more reasonable

hexadecimal233 commented 11 months ago

and cir.getReturnValue() != null should be removed? This won't cause a crash

ploxxxy commented 11 months ago

you're absolutely right, i don't see why it would be needed there

mrbuilder1961 commented 11 months ago

ok i will go back and try all this stuff you guys have fixed. not really sure why all these results are so inconsistent though..

mrbuilder1961 commented 11 months ago

the only problem w this is that when the settings menu is open, clicks can trigger click events.

hexadecimal233 commented 11 months ago

Just put a mixin on onMouseClicked with target ChatHud.onClick and cancel it when Menu is open

mrbuilder1961 commented 11 months ago

doing that now! also, unrelated but could either of you explain what this method is supposed to do? i put a comment but i dont think it describes it right:

@WrapOperation(method = "mouseClicked", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/widget/TextFieldWidget;mouseClicked(DDI)Z"))
    private boolean disableChatFieldFocus(TextFieldWidget chatField, double mX, double mY, int button, Operation<Boolean> mouseClicked) {
        if(!config.hideSearchButton)
            return false;
        return mouseClicked.call(chatField, mX, mY, button);
    }
hexadecimal233 commented 11 months ago

This should work:

    @WrapOperation(method = "mouseClicked", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/hud/ChatHud;mouseClicked(DD)Z"))
    private boolean fixClickthroughWhenMenuOpen1(ChatHud chatHud, double mX, double mY, Operation<Boolean> mouseClicked) {
        if (isMouseOverSettingsMenu(mX, mY) || isMouseOverCopyMenu(mX, mY)) return false;
        return mouseClicked.call(chatHud, mX, mY);
    }

    @WrapOperation(method = "mouseClicked", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/ChatScreen;getTextStyleAt(DD)Lnet/minecraft/text/Style;"))
    private Style fixClickthroughWhenMenuOpen2(ChatScreen screen, double mX, double mY, Operation<Style> getStyle) {
        if (isMouseOverSettingsMenu(mX, mY) || isMouseOverCopyMenu(mX, mY)) return null;
        return getStyle.call(screen, mX, mY);
    }

Also Remove this redundant line: (Patched using the 2 mixins above)

if(client.inGameHud.getChatHud().getTextStyleAt(mX, mY) != null && isMouseOverSettingsMenu(mX, mY))
            cir.setReturnValue(false);

@mrbuilder1961 Also I wonder which IDE you are using, cuz the indent looks really weird to me

mrbuilder1961 commented 11 months ago

i checked that and it worked! also, i am using intellij ultimate and i was previously using community edition, with tabs that should be 4spaces in size.