Compare commits

...

6 Commits

Author SHA1 Message Date
Michael Pfaff 1c93749fab Update mod metadata 2023-09-18 16:57:21 -04:00
Michael Pfaff 8228947989 Update the mod to work with all versions from >=1.16
Support for older versions is planned, but I don't have a reason to
actively work on it

The mixins are updated to apply the smallest change possible: only
replacing relevant accesses to `MinecraftClient.IS_SYSTEM_MAC` with
`false`.
2023-09-18 16:41:19 -04:00
Michael Pfaff 8709b82e2a
Change required minecraft version to 1.16.x 2021-04-13 19:35:42 -04:00
Michael Pfaff e38d66bbee
Patch dropping entire stacks 2021-03-05 21:10:06 -05:00
Michael Pfaff d59884e1d2
Bump build number 2021-01-08 22:29:07 -05:00
Michael Pfaff 0495e84f66
Fix compatibility issue 2021-01-08 22:28:32 -05:00
8 changed files with 59 additions and 135 deletions

View File

@ -1,11 +1,8 @@
plugins {
id 'fabric-loom' version '0.6-SNAPSHOT'
id 'fabric-loom' version '1.3-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
@ -59,15 +56,15 @@ dependencies {
}
processResources {
inputs.property "version", "${project.version}+build.${versionBuild}"
inputs.property "version", project.version
inputs.property "minecraft_version", project.minecraft_version
inputs.property "loader_version", project.loader_version
filteringCharset "UTF-8"
from(sourceSets.main.resources.srcDirs) {
include "fabric.mod.json"
expand "version": "${project.version}+build.${versionBuild}"
}
from(sourceSets.main.resources.srcDirs) {
exclude "fabric.mod.json"
filesMatching("fabric.mod.json") {
expand "version": project.version,
"minecraft_version": project.minecraft_version,
"loader_version": project.loader_version
}
}
@ -78,12 +75,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 {

View File

@ -2,11 +2,11 @@
org.gradle.jvmargs=-Xmx1G
# Fabric Properties
# check these on https://modmuss50.me/fabric.html
minecraft_version=1.16.4
yarn_mappings=1.16.4+build.9
loader_version=0.10.8
minecraft_version=1.20.1
yarn_mappings=1.20.1+build.10
loader_version=0.14.22
# Mod Properties
mod_version=1.0.0
mod_version=1.1.1
maven_group=dev.pfaff
archives_base_name=thinksame

View File

@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

View File

@ -1,113 +1,16 @@
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.options.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;
// TODO: modify injection to not overwrite whole method.
@Mixin(Mouse.class)
public abstract class MouseMixin {
@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;
@SuppressWarnings("OverwriteAuthorRequired")
@Overwrite
private void onMouseButton(long window, int button, int action, int mods) {
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.overlay == 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.overlay == 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));
}
}
}
}
@Redirect(method = "onMouseButton", at = @At(value = "FIELD", opcode = GETSTATIC, target = "Lnet/minecraft/client/MinecraftClient;IS_SYSTEM_MAC:Z"))
private boolean onMouseButton$noMacOS() {
return false;
}
}

View File

@ -0,0 +1,16 @@
package dev.pfaff.thinksame.mixin;
import net.minecraft.client.gui.screen.Screen;
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;
@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;
}
}

View File

@ -2,14 +2,13 @@
"schemaVersion": 1,
"id": "thinksame",
"version": "${version}",
"name": "ThinkSame",
"description": "Fixes issues on macOS including Ctrl+Left-Click simulating Right-Click.",
"name": "Think Same",
"description": "Patches for bugs and anti-features on macOS",
"authors": [
{
"name": "Michael Pfaff",
"contact": {
"email": "michael@pfaff.dev",
"matrix": "@michael:pfaff.dev"
"email": "michael@pfaff.dev"
}
}
],
@ -26,6 +25,6 @@
],
"depends": {
"fabricloader": ">=0.10.8",
"minecraft": "1.16.4"
"minecraft": ">=1.16"
}
}

View File

@ -5,7 +5,8 @@
"compatibilityLevel": "JAVA_8",
"mixins": [],
"client": [
"MouseMixin"
"MouseMixin",
"ScreenMixin"
],
"injectors": {
"defaultRequire": 1

View File

@ -1,2 +1,2 @@
#Fri Jan 08 17:57:39 EST 2021
VERSION_BUILD=1
#Mon Sep 18 16:40:55 EDT 2023
VERSION_BUILD=20