1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2025-08-30 00:57:55 +00:00

fix: more correct mouseReleased event

WidgetTerminal still calls mouseReleased on every container click instead of terminal only (like Forge does)
This commit is contained in:
Nikita Savyolov
2021-10-12 19:14:03 +03:00
parent fd24d89f89
commit 6e5e682e3a
5 changed files with 41 additions and 10 deletions

View File

@@ -108,12 +108,6 @@ public abstract class ComputerScreenBase<T extends ContainerComputerBase> extend
return getFocused() != null && getFocused().mouseDragged( x, y, button, deltaX, deltaY ) || super.mouseDragged( x, y, button, deltaX, deltaY );
}
@Override
public boolean mouseReleased( double mouseX, double mouseY, int button )
{
return (getFocused() != null && getFocused().mouseReleased( mouseX, mouseY, button )) || super.mouseReleased( x, y, button );
}
@Override
protected void drawForeground( @Nonnull MatrixStack transform, int mouseX, int mouseY )
{

View File

@@ -11,10 +11,8 @@ import dan200.computercraft.client.gui.widgets.ComputerSidebar;
import dan200.computercraft.client.gui.widgets.WidgetTerminal;
import dan200.computercraft.client.render.ComputerBorderRenderer;
import dan200.computercraft.client.render.RenderTypes;
//import dan200.computercraft.shared.computer.inventory.ContainerComputer;
import dan200.computercraft.shared.computer.inventory.ContainerComputerBase;
import dan200.computercraft.shared.computer.inventory.ContainerViewComputer;
//import dan200.computercraft.shared.pocket.inventory.ContainerPocketComputer;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.text.Text;

View File

@@ -49,7 +49,7 @@ public class NoTermComputerScreen<T extends ContainerComputerBase> extends Scree
super.init();
client.keyboard.setRepeatEvents( true );
terminal = addDrawableChild( new WidgetTerminal( (ClientComputer) menu.getComputer(), 0, 0, ComputerCraft.pocketTermWidth, ComputerCraft.pocketTermHeight ) );
terminal = addSelectableChild( new WidgetTerminal( (ClientComputer) menu.getComputer(), 0, 0, ComputerCraft.pocketTermWidth, ComputerCraft.pocketTermHeight ) );
terminal.visible = false;
terminal.active = false;
setFocused( terminal );

View File

@@ -0,0 +1,38 @@
/*
* This file is part of ComputerCraft - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2021. Do not distribute without permission.
* Send enquiries to dratcliffe@gmail.com
*/
package dan200.computercraft.fabric.mixin;
import dan200.computercraft.client.gui.widgets.WidgetTerminal;
import net.minecraft.client.gui.Element;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.screen.ingame.HandledScreen;
import net.minecraft.screen.ScreenHandler;
import net.minecraft.text.Text;
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.CallbackInfoReturnable;
@Mixin( HandledScreen.class )
public class MixinHandledScreen<T extends ScreenHandler> extends Screen
{
protected MixinHandledScreen( Text title )
{
super( title );
}
@Inject( method = "mouseReleased", at = @At ( "HEAD" ) )
public void mouseReleased( double mouseX, double mouseY, int button, CallbackInfoReturnable<Boolean> cir )
{
for ( Element child : this.children() )
{
if ( child instanceof WidgetTerminal )
{
child.mouseReleased( mouseX, mouseY, button );
}
}
}
}

View File

@@ -21,7 +21,8 @@
"MixinMinecraftClient",
"MixinScreen",
"MixinGameRenderer",
"MixinWorldRenderer"
"MixinWorldRenderer",
"MixinHandledScreen"
],
"server": [
"MixinLanguage"