Skip to content
This repository has been archived by the owner on Nov 27, 2021. It is now read-only.

Commit

Permalink
Merge pull request #78 from ga2mer/1.17-alpha
Browse files Browse the repository at this point in the history
fix: more correct mouseReleased event
  • Loading branch information
Merith-TK authored Oct 12, 2021
2 parents 02c63ce + 6e5e682 commit bc23584
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,6 @@ public final boolean mouseDragged( double x, double y, int button, double deltaX
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 )
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,8 @@
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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ protected void init()
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 );
Expand Down
Original file line number Diff line number Diff line change
@@ -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 [email protected]
*/
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 );
}
}
}
}
3 changes: 2 additions & 1 deletion src/main/resources/computercraft.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
"MixinMinecraftClient",
"MixinScreen",
"MixinGameRenderer",
"MixinWorldRenderer"
"MixinWorldRenderer",
"MixinHandledScreen"
],
"server": [
"MixinLanguage"
Expand Down

0 comments on commit bc23584

Please sign in to comment.