Compare commits
1 Commits
Author | SHA1 | Date |
---|---|---|
Michael Pfaff | ad84dcd16b |
39
build.gradle
39
build.gradle
|
@ -1,8 +1,11 @@
|
|||
plugins {
|
||||
id 'fabric-loom' version '1.3-SNAPSHOT'
|
||||
id 'fabric-loom' version '0.6-SNAPSHOT'
|
||||
id 'maven-publish'
|
||||
}
|
||||
|
||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||
targetCompatibility = JavaVersion.VERSION_1_8
|
||||
|
||||
archivesBaseName = project.archives_base_name
|
||||
version = project.mod_version
|
||||
group = project.maven_group
|
||||
|
@ -56,15 +59,15 @@ dependencies {
|
|||
}
|
||||
|
||||
processResources {
|
||||
inputs.property "version", project.version
|
||||
inputs.property "minecraft_version", project.minecraft_version
|
||||
inputs.property "loader_version", project.loader_version
|
||||
filteringCharset "UTF-8"
|
||||
inputs.property "version", "${project.version}+build.${versionBuild}"
|
||||
|
||||
filesMatching("fabric.mod.json") {
|
||||
expand "version": project.version,
|
||||
"minecraft_version": project.minecraft_version,
|
||||
"loader_version": project.loader_version
|
||||
from(sourceSets.main.resources.srcDirs) {
|
||||
include "fabric.mod.json"
|
||||
expand "version": "${project.version}+build.${versionBuild}"
|
||||
}
|
||||
|
||||
from(sourceSets.main.resources.srcDirs) {
|
||||
exclude "fabric.mod.json"
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -75,22 +78,20 @@ tasks.withType(JavaCompile) {
|
|||
options.encoding = "UTF-8"
|
||||
}
|
||||
|
||||
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
|
||||
// if it is present.
|
||||
// If you remove this task, sources will not be generated.
|
||||
task sourcesJar(type: Jar, dependsOn: classes) {
|
||||
classifier = "sources"
|
||||
from sourceSets.main.allSource
|
||||
}
|
||||
|
||||
gradle.taskGraph.whenReady {taskGraph ->
|
||||
if (taskGraph.hasTask(build)) { /* when run remapJar, build, runClient, or runServer task */
|
||||
autoIncrementBuildNumber()
|
||||
}
|
||||
}
|
||||
|
||||
java {
|
||||
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
|
||||
// if it is present.
|
||||
// If you remove this line, sources will not be generated.
|
||||
withSourcesJar()
|
||||
|
||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||
targetCompatibility = JavaVersion.VERSION_1_8
|
||||
}
|
||||
|
||||
jar {
|
||||
from "LICENSE"
|
||||
}
|
||||
|
|
|
@ -2,11 +2,11 @@
|
|||
org.gradle.jvmargs=-Xmx1G
|
||||
# Fabric Properties
|
||||
# check these on https://modmuss50.me/fabric.html
|
||||
minecraft_version=1.20.1
|
||||
yarn_mappings=1.20.1+build.10
|
||||
loader_version=0.14.22
|
||||
minecraft_version=21w11a
|
||||
yarn_mappings=21w11a+build.16
|
||||
loader_version=0.11.3
|
||||
loomVersion=0.6-SNAPSHOT
|
||||
# Mod Properties
|
||||
mod_version=1.1.1
|
||||
mod_version=1.1.0
|
||||
maven_group=dev.pfaff
|
||||
archives_base_name=thinksame
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5.1-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
|
|
@ -1,16 +1,117 @@
|
|||
package dev.pfaff.thinksame.mixin;
|
||||
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.Mouse;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.option.KeyBinding;
|
||||
import net.minecraft.client.util.GlfwUtil;
|
||||
import net.minecraft.client.util.InputUtil;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Overwrite;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
import static org.objectweb.asm.Opcodes.GETSTATIC;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
// TODO: modify injection to not overwrite whole method.
|
||||
@Mixin(Mouse.class)
|
||||
public abstract class MouseMixin {
|
||||
@Redirect(method = "onMouseButton", at = @At(value = "FIELD", opcode = GETSTATIC, target = "Lnet/minecraft/client/MinecraftClient;IS_SYSTEM_MAC:Z"))
|
||||
private boolean onMouseButton$noMacOS() {
|
||||
return false;
|
||||
@Shadow @Final private MinecraftClient client;
|
||||
|
||||
@Shadow private int field_1796;
|
||||
|
||||
@Shadow private int activeButton;
|
||||
|
||||
@Shadow private double glfwTime;
|
||||
|
||||
@Shadow private boolean cursorLocked;
|
||||
|
||||
@Shadow public abstract void lockCursor();
|
||||
|
||||
@Shadow private double x;
|
||||
|
||||
@Shadow private double y;
|
||||
|
||||
@Shadow private boolean leftButtonClicked;
|
||||
|
||||
@Shadow private boolean middleButtonClicked;
|
||||
|
||||
@Shadow private boolean rightButtonClicked;
|
||||
|
||||
@Inject(method = "onMouseButton", at = @At("HEAD"), cancellable = true)
|
||||
private void onMouseButton(long window, int button, int action, int mods, CallbackInfo ci) {
|
||||
ci.cancel();
|
||||
|
||||
if (window == this.client.getWindow().getHandle()) {
|
||||
boolean bl = action == 1;
|
||||
// if (MinecraftClient.IS_SYSTEM_MAC && button == 0) {
|
||||
// if (bl) {
|
||||
// if ((mods & 2) == 2) {
|
||||
// button = 1;
|
||||
// ++this.controlLeftTicks;
|
||||
// }
|
||||
// } else if (this.controlLeftTicks > 0) {
|
||||
// button = 1;
|
||||
// --this.controlLeftTicks;
|
||||
// }
|
||||
// }
|
||||
|
||||
if (bl) {
|
||||
if (this.client.options.touchscreen && this.field_1796++ > 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.activeButton = button;
|
||||
this.glfwTime = GlfwUtil.getTime();
|
||||
} else if (this.activeButton != -1) {
|
||||
if (this.client.options.touchscreen && --this.field_1796 > 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.activeButton = -1;
|
||||
}
|
||||
|
||||
boolean[] bls = new boolean[]{false};
|
||||
if (this.client.getOverlay() == null) {
|
||||
if (this.client.currentScreen == null) {
|
||||
if (!this.cursorLocked && bl) {
|
||||
this.lockCursor();
|
||||
}
|
||||
} else {
|
||||
double d = this.x * (double)this.client.getWindow().getScaledWidth() / (double)this.client.getWindow().getWidth();
|
||||
double e = this.y * (double)this.client.getWindow().getScaledHeight() / (double)this.client.getWindow().getHeight();
|
||||
if (bl) {
|
||||
Screen.wrapScreenError(() -> {
|
||||
bls[0] = this.client.currentScreen.mouseClicked(d, e, button);
|
||||
}, "mouseClicked event handler", this.client.currentScreen.getClass().getCanonicalName());
|
||||
} else {
|
||||
Screen.wrapScreenError(() -> {
|
||||
bls[0] = this.client.currentScreen.mouseReleased(d, e, button);
|
||||
}, "mouseReleased event handler", this.client.currentScreen.getClass().getCanonicalName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!bls[0] && (this.client.currentScreen == null || this.client.currentScreen.passEvents) && this.client.getOverlay() == null) {
|
||||
if (button == 0) {
|
||||
this.leftButtonClicked = bl;
|
||||
} else if (button == 2) {
|
||||
this.middleButtonClicked = bl;
|
||||
} else if (button == 1) {
|
||||
this.rightButtonClicked = bl;
|
||||
}
|
||||
|
||||
KeyBinding.setKeyPressed(InputUtil.Type.MOUSE.createFromCode(button), bl);
|
||||
if (bl) {
|
||||
if (this.client.player.isSpectator() && button == 2) {
|
||||
this.client.inGameHud.getSpectatorHud().useSelectedCommand();
|
||||
} else {
|
||||
KeyBinding.onKeyPressed(InputUtil.Type.MOUSE.createFromCode(button));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,16 +1,23 @@
|
|||
package dev.pfaff.thinksame.mixin;
|
||||
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.util.InputUtil;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
import static org.objectweb.asm.Opcodes.GETSTATIC;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(Screen.class)
|
||||
public abstract class ScreenMixin {
|
||||
@Redirect(method = "hasControlDown", at = @At(value = "FIELD", opcode = GETSTATIC, target = "Lnet/minecraft/client/MinecraftClient;IS_SYSTEM_MAC:Z"))
|
||||
private static boolean hasControlDown$noMacOS() {
|
||||
return false;
|
||||
@Inject(method = "hasControlDown", at = @At("HEAD"), cancellable = true)
|
||||
private static void hasControlDown(CallbackInfoReturnable<Boolean> ci) {
|
||||
// if (MinecraftClient.IS_SYSTEM_MAC) {
|
||||
// return InputUtil.isKeyPressed(MinecraftClient.getInstance().getWindow().getHandle(), 343) || InputUtil.isKeyPressed(MinecraftClient.getInstance().getWindow().getHandle(), 347);
|
||||
// } else {
|
||||
// return InputUtil.isKeyPressed(MinecraftClient.getInstance().getWindow().getHandle(), 341) || InputUtil.isKeyPressed(MinecraftClient.getInstance().getWindow().getHandle(), 345);
|
||||
// }
|
||||
|
||||
ci.setReturnValue(InputUtil.isKeyPressed(MinecraftClient.getInstance().getWindow().getHandle(), 341) || InputUtil.isKeyPressed(MinecraftClient.getInstance().getWindow().getHandle(), 345));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,13 +2,14 @@
|
|||
"schemaVersion": 1,
|
||||
"id": "thinksame",
|
||||
"version": "${version}",
|
||||
"name": "Think Same",
|
||||
"description": "Patches for bugs and anti-features on macOS",
|
||||
"name": "ThinkSame",
|
||||
"description": "Fixes issues on macOS including Ctrl+Left-Click simulating Right-Click.",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Michael Pfaff",
|
||||
"contact": {
|
||||
"email": "michael@pfaff.dev"
|
||||
"email": "michael@pfaff.dev",
|
||||
"matrix": "@michael:pfaff.dev"
|
||||
}
|
||||
}
|
||||
],
|
||||
|
@ -25,6 +26,6 @@
|
|||
],
|
||||
"depends": {
|
||||
"fabricloader": ">=0.10.8",
|
||||
"minecraft": ">=1.16"
|
||||
"minecraft": "1.17.x"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
#Mon Sep 18 16:40:55 EDT 2023
|
||||
VERSION_BUILD=20
|
||||
#Mon Mar 22 23:55:52 EDT 2021
|
||||
VERSION_BUILD=8
|
||||
|
|
Loading…
Reference in New Issue