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:
@@ -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 )
|
||||
{
|
||||
|
@@ -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;
|
||||
|
@@ -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 );
|
||||
|
@@ -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 );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -21,7 +21,8 @@
|
||||
"MixinMinecraftClient",
|
||||
"MixinScreen",
|
||||
"MixinGameRenderer",
|
||||
"MixinWorldRenderer"
|
||||
"MixinWorldRenderer",
|
||||
"MixinHandledScreen"
|
||||
],
|
||||
"server": [
|
||||
"MixinLanguage"
|
||||
|
Reference in New Issue
Block a user