Skip to content

Commit

Permalink
Add support for 1.20.3/4
Browse files Browse the repository at this point in the history
Closes #15
  • Loading branch information
kb-1000 committed Dec 11, 2023
1 parent e44eb29 commit 1bcc85b
Show file tree
Hide file tree
Showing 12 changed files with 74 additions and 35 deletions.
3 changes: 1 addition & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ import java.io.Reader
import java.io.StringReader

plugins {
id("fabric-loom") version "1.0-SNAPSHOT"
id("io.github.juuxel.loom-quiltflower") version "1.8.0"
id("fabric-loom") version "1.4-SNAPSHOT"
`maven-publish`
}

Expand Down
10 changes: 5 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ org.gradle.jvmargs=-Xmx1G

# Fabric Properties
# check these on https://fabricmc.net/versions.html
minecraft_version=1.19.4
yarn_mappings=1.19.4+build.1
loader_version=0.14.17
minecraft_version=1.20.4
yarn_mappings=1.20.4+build.1
loader_version=0.15.1

# Forge
forge_version=1.19.4-45.0.18
forge_version=1.20.4-49.0.3

# Mod Properties
mod_version=1.7.0
mod_version=1.8.0
maven_group=de.kb1000
archives_base_name=no-telemetry
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
3 changes: 2 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
29 changes: 17 additions & 12 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,8 @@ done
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down Expand Up @@ -133,26 +131,29 @@ location of your Java installation."
fi
else
JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
fi

# Increase the maximum file descriptors if we can.
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
Expand Down Expand Up @@ -197,11 +198,15 @@ if "$cygwin" || "$msys" ; then
done
fi

# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
# double quotes to make sure that they get re-expanded; and
# * put everything else in single quotes, so that it's not re-expanded.

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.

set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@ public boolean shouldApplyMixin(String targetClassName, String mixinClassName) {
return switch (mixinClassName) {
case "de.kb1000.notelemetry.mixin.NewYggdrasilUserApiServiceMixin" ->
CommonUtil.classExists("com.mojang.authlib.yggdrasil.response.UserAttributesResponse$Privileges");
case "de.kb1000.notelemetry.mixin.Post1193TelemetryManagerMixin", "de.kb1000.notelemetry.mixin.Pre1193TelemetryManagerMixin" ->
mixinClassName.equals("de.kb1000.notelemetry.mixin.Post1193TelemetryManagerMixin") == CommonUtil.minecraftNewerThan("1.19.3-alpha.22.46.a");
case "de.kb1000.notelemetry.mixin.OptionsScreenMixin" -> CommonUtil.minecraftNewerThan("1.19.3-alpha.22.46.a");
case "de.kb1000.notelemetry.mixin.Pre1193TelemetryManagerMixin" ->
!CommonUtil.minecraftNewerThan("1.19.3-alpha.22.46.a");
case "de.kb1000.notelemetry.mixin.MinecraftClientMixin", "de.kb1000.notelemetry.mixin.OptionsScreenMixin",
"de.kb1000.notelemetry.mixin.Post1193TelemetryManagerMixin" -> CommonUtil.minecraftNewerThan("1.19.3-alpha.22.46.a");
default -> true;
};
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package de.kb1000.notelemetry.mixin;

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(targets = "net.minecraft.client.MinecraftClient")
public class MinecraftClientMixin {
@Inject(method = "isTelemetryEnabledByApi()Z", at = @At("HEAD"), cancellable = true)
public void isTelemetryEnabledByApi(CallbackInfoReturnable<Boolean> cir) {
cir.setReturnValue(false);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ public class OptionsScreenMixin {
return widget;
}

@Redirect(method = "init", at = @At(value = "INVOKE", target = "Lnet/minecraft/class_7845$class_7939;method_47612(Lnet/minecraft/class_339;)Lnet/minecraft/class_339;", ordinal = 0), slice = @Slice(from = @At(value = "FIELD", target = "Lnet/minecraft/client/gui/screen/option/OptionsScreen;TELEMETRY_TEXT:Lnet/minecraft/text/Text;")))
@Group(name = "removeTelemetryButton", min = 1, max = 1)
@Redirect(method = "init", at = @At(value = "INVOKE", target = "Lnet/minecraft/class_7845$class_7939;method_47612(Lnet/minecraft/class_339;)Lnet/minecraft/class_339;", ordinal = 0), slice = @Slice(from = @At(value = "FIELD", target = "Lnet/minecraft/client/gui/screen/option/OptionsScreen;TELEMETRY_TEXT:Lnet/minecraft/text/Text;")))
private @Coerce Object removeTelemetryButtonOld(@Coerce Object adder, @Coerce Object widget) {
return widget;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,23 @@
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Pseudo;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Coerce;
import org.spongepowered.asm.mixin.injection.Group;
import org.spongepowered.asm.mixin.injection.Redirect;

@Mixin(targets = "net.minecraft.client.util.telemetry.TelemetryManager")
@Mixin(targets = "net.minecraft.client.session.telemetry.TelemetryManager")
@Environment(EnvType.CLIENT)
public class Post1193TelemetryManagerMixin {
@Redirect(method = "Lnet/minecraft/client/util/telemetry/TelemetryManager;getSender", at = @At(value = "FIELD", target = "Lnet/minecraft/SharedConstants;isDevelopment:Z"), remap = true)
private boolean disableTelemetrySession() {
@Group(name = "disableTelemetrySessionPost1193", min = 1, max = 1)
@Redirect(method = "Lnet/minecraft/client/session/telemetry/TelemetryManager;computeSender", at = @At(value = "FIELD", target = "Lnet/minecraft/SharedConstants;isDevelopment:Z"))
private boolean disableTelemetrySessionPre1203() {
return true;
}

@Group(name = "disableTelemetrySessionPost1193", min = 1, max = 1)
@Redirect(method = "Lnet/minecraft/client/session/telemetry/TelemetryManager;computeSender", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/MinecraftClient;isTelemetryEnabledByApi()Z"))
private boolean disableTelemetrySessionPost1203(@Coerce Object minecraftClient) {
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import org.spongepowered.asm.mixin.injection.Redirect;

@Pseudo
@Mixin(targets = "net.minecraft.client.util.telemetry.TelemetryManager")
@Mixin(targets = "net.minecraft.client.session.telemetry.TelemetryManager")
@Environment(EnvType.CLIENT)
public class Pre1193TelemetryManagerMixin {
@Redirect(method = "<init>", at = @At(value = "FIELD", target = "Lnet/minecraft/SharedConstants;isDevelopment:Z"))
Expand Down
22 changes: 16 additions & 6 deletions src/main/resources/no-telemetry-forge-refmap.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
{
"mappings": {
"de/kb1000/notelemetry/mixin/MinecraftClientMixin": {
"isTelemetryEnabledByApi()Z": "Lnet/minecraft/client/Minecraft;m_261210_()Z",
"net.minecraft.client.MinecraftClient": "net/minecraft/client/Minecraft"
},
"de/kb1000/notelemetry/mixin/Pre1193TelemetryManagerMixin": {
"net.minecraft.client.util.telemetry.TelemetryManager": "net/minecraft/client/ClientTelemetryManager",
"net.minecraft.client.session.telemetry.TelemetryManager": "net/minecraft/client/ClientTelemetryManager",
"Lnet/minecraft/SharedConstants;isDevelopment:Z": "Lnet/minecraft/SharedConstants;f_136183_:Z"
},
"de/kb1000/notelemetry/mixin/OptionsScreenMixin": {
Expand All @@ -12,15 +16,20 @@
"net.minecraft.client.gui.screen.option.OptionsScreen": "net/minecraft/client/gui/screens/OptionsScreen"
},
"de/kb1000/notelemetry/mixin/Post1193TelemetryManagerMixin": {
"net.minecraft.client.util.telemetry.TelemetryManager": "net/minecraft/client/telemetry/ClientTelemetryManager",
"net.minecraft.client.session.telemetry.TelemetryManager": "net/minecraft/client/telemetry/ClientTelemetryManager",
"Lnet/minecraft/SharedConstants;isDevelopment:Z": "Lnet/minecraft/SharedConstants;f_136183_:Z",
"Lnet/minecraft/client/util/telemetry/TelemetryManager;getSender": "Lnet/minecraft/client/telemetry/ClientTelemetryManager;m_261052_()Lnet/minecraft/client/telemetry/TelemetryEventSender;"
"Lnet/minecraft/client/session/telemetry/TelemetryManager;computeSender": "Lnet/minecraft/client/telemetry/ClientTelemetryManager;m_261052_()Lnet/minecraft/client/telemetry/TelemetryEventSender;",
"Lnet/minecraft/client/MinecraftClient;isTelemetryEnabledByApi()Z": "Lnet/minecraft/client/Minecraft;m_261210_()Z"
}
},
"data": {
"searge": {
"de/kb1000/notelemetry/mixin/MinecraftClientMixin": {
"isTelemetryEnabledByApi()Z": "Lnet/minecraft/client/Minecraft;m_261210_()Z",
"net.minecraft.client.MinecraftClient": "net/minecraft/client/Minecraft"
},
"de/kb1000/notelemetry/mixin/Pre1193TelemetryManagerMixin": {
"net.minecraft.client.util.telemetry.TelemetryManager": "net/minecraft/client/ClientTelemetryManager",
"net.minecraft.client.session.telemetry.TelemetryManager": "net/minecraft/client/ClientTelemetryManager",
"Lnet/minecraft/SharedConstants;isDevelopment:Z": "Lnet/minecraft/SharedConstants;f_136183_:Z"
},
"de/kb1000/notelemetry/mixin/OptionsScreenMixin": {
Expand All @@ -31,9 +40,10 @@
"net.minecraft.client.gui.screen.option.OptionsScreen": "net/minecraft/client/gui/screens/OptionsScreen"
},
"de/kb1000/notelemetry/mixin/Post1193TelemetryManagerMixin": {
"net.minecraft.client.util.telemetry.TelemetryManager": "net/minecraft/client/telemetry/ClientTelemetryManager",
"net.minecraft.client.session.telemetry.TelemetryManager": "net/minecraft/client/telemetry/ClientTelemetryManager",
"Lnet/minecraft/SharedConstants;isDevelopment:Z": "Lnet/minecraft/SharedConstants;f_136183_:Z",
"Lnet/minecraft/client/util/telemetry/TelemetryManager;getSender": "Lnet/minecraft/client/telemetry/ClientTelemetryManager;m_261052_()Lnet/minecraft/client/telemetry/TelemetryEventSender;"
"Lnet/minecraft/client/session/telemetry/TelemetryManager;computeSender": "Lnet/minecraft/client/telemetry/ClientTelemetryManager;m_261052_()Lnet/minecraft/client/telemetry/TelemetryEventSender;",
"Lnet/minecraft/client/MinecraftClient;isTelemetryEnabledByApi()Z": "Lnet/minecraft/client/Minecraft;m_261210_()Z"
}
}
}
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/no-telemetry.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"compatibilityLevel": "JAVA_16",
"plugin": "de.kb1000.notelemetry.NoTelemetryMixinConfigPlugin",
"client": [
"MinecraftClientMixin",
"NewYggdrasilUserApiServiceMixin",
"OptionsScreenMixin",
"Post1193TelemetryManagerMixin",
Expand Down

0 comments on commit 1bcc85b

Please sign in to comment.