Skip to content

Commit

Permalink
2.0.4 (1.21 support)
Browse files Browse the repository at this point in the history
  • Loading branch information
BluCobalt committed Jun 29, 2024
1 parent 0cb4c3b commit 1eecef8
Show file tree
Hide file tree
Showing 10 changed files with 215 additions and 9 deletions.
1 change: 1 addition & 0 deletions base/src/main/java/dev/blucobalt/realmsfix/Entrypoint.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public class Entrypoint

static {
VERSION_MAP = new HashMap<>();
VERSION_MAP.put("1.21", "1.21");
VERSION_MAP.put("1.20", "1.20.4");
VERSION_MAP.put("1.19", "1.19.4");
VERSION_MAP.put("1.18", "1.18.2");
Expand Down
26 changes: 21 additions & 5 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id("fabric-loom") version "1.4-SNAPSHOT" apply false
id("legacy-looming") version "1.4-SNAPSHOT" apply false
id("fabric-loom") version "1.7-SNAPSHOT" apply false
id("legacy-looming") version "1.7-SNAPSHOT" apply false
id("com.github.hierynomus.license-base") version "0.16.1"
id("base")
}
Expand All @@ -20,9 +20,25 @@ subprojects {
options.encoding = "UTF-8"
println(project.name)

// if the project is 1.17.1 or newer use java 17 else use java 8
@Suppress("LocalVariableName") // because gradle has a shit ton of variables that match any combination of "target" and "version" you could think of
val target_version = if (project.name == "base" || project.name == "1.7.10" || (project.name.replace(".", "").toInt() < 1171)) "1.8" else "17"
val target_version = when (project.name)
{
"1.7.10" -> JavaVersion.VERSION_1_8
"1.8.9" -> JavaVersion.VERSION_1_8
"1.9.4" -> JavaVersion.VERSION_1_8
"1.10.2" -> JavaVersion.VERSION_1_8
"1.11.2" -> JavaVersion.VERSION_1_8
"1.12.2" -> JavaVersion.VERSION_1_8
"1.13.2" -> JavaVersion.VERSION_1_8
"1.14.4" -> JavaVersion.VERSION_1_8
"1.15.2" -> JavaVersion.VERSION_1_8
"1.16.5" -> JavaVersion.VERSION_1_8
"1.17.1" -> JavaVersion.VERSION_17
"1.18.2" -> JavaVersion.VERSION_17
"1.19.4" -> JavaVersion.VERSION_17
"1.20.4" -> JavaVersion.VERSION_17
"1.21" -> JavaVersion.VERSION_21
else -> JavaVersion.VERSION_1_8
}.toString()
sourceCompatibility = target_version
targetCompatibility = target_version
}
Expand Down
7 changes: 4 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ org.gradle.jvmargs=-Xmx8G
org.gradle.caching=true
#fabric.loom.multiProjectOptimisation=true

version = 2.0.3
version = 2.0.4
yarn_1_21 = 1.21+build.7
yarn_1_20_4 = 1.20.4+build.3
yarn_1_19_4 = 1.19.4+build.2
yarn_1_18_2 = 1.18.2+build.4
Expand All @@ -17,5 +18,5 @@ yarn_1_10_2 = 1.10.2+build.458
yarn_1_9_4 = 1.9.4+build.458
yarn_1_8_9 = 1.8.9+build.458
yarn_1_7_10 = 1.7.10+build.458
loom_version = 1.4-SNAPSHOT
loader_version = 0.15.3
loom_version = 1.7-SNAPSHOT
loader_version = 0.15.11
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Wed Apr 12 14:43:03 PDT 2023
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-8.8-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
16 changes: 16 additions & 0 deletions versions/1.21/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
plugins {
id 'fabric-loom'
}

dependencies {
minecraft "com.mojang:minecraft:1.21"
mappings "net.fabricmc:yarn:${project.yarn_1_21}:v2"
implementation project(path: ":base", configuration: "namedElements")
modImplementation("net.fabricmc:fabric-loader:${project.loader_version}")
}

loom {
mixin {
defaultRefmapName = "realmsfix-1.21.refmap.json"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/**
* This file is part of realmsfix.
*
* realmsfix is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* realmsfix is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with realmsfix. If not, see <http://www.gnu.org/licenses/>.
*/
package dev.blucobalt.realmsfix.mixin;


import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.realms.gui.screen.RealmsNotificationsScreen;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;


@Mixin(RealmsNotificationsScreen.class)
public class RealmsNotificationsScreen1_21
{
@Inject(method = "render", at = @org.spongepowered.asm.mixin.injection.At(value = "HEAD"), cancellable = true)
public void donothing(DrawContext context, int mouseX, int mouseY, float delta, CallbackInfo ci)
{
ci.cancel();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/**
* This file is part of realmsfix.
*
* realmsfix is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* realmsfix is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with realmsfix. If not, see <http://www.gnu.org/licenses/>.
*/
package dev.blucobalt.realmsfix.mixin;


import net.minecraft.client.gui.Drawable;
import net.minecraft.client.gui.screen.Screen;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;

import java.util.List;


@Mixin(Screen.class)
public interface TitleScreenAccessor1_21
{
@Accessor(value = "drawables")
List<Drawable> getDrawables();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/**
* This file is part of realmsfix.
*
* realmsfix is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* realmsfix is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with realmsfix. If not, see <http://www.gnu.org/licenses/>.
*/
package dev.blucobalt.realmsfix.mixin;


import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.Drawable;
import net.minecraft.client.gui.screen.TitleScreen;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.text.MutableText;
import net.minecraft.text.Text;
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.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

import java.util.List;


@Pseudo
@Mixin(TitleScreen.class)
public class TitleScreenMixin1_21
{
@Inject(method = "initWidgetsNormal", at = @At(value = "TAIL"))
public void donothing(int y, int spacingY, CallbackInfo ci)
{
if (MinecraftClient.getInstance().currentScreen instanceof TitleScreen){
TitleScreenAccessor1_21 ts = (TitleScreenAccessor1_21) MinecraftClient.getInstance().currentScreen;
List<Drawable> drawables = ts.getDrawables();
for (Drawable drawable : drawables) {
if (drawable instanceof ButtonWidget){
ButtonWidget buttonWidget = (ButtonWidget) drawable;
Text message = buttonWidget.getMessage();
MutableText t = (MutableText) message;
TranslatableTextAccessor1_21 accessor = (TranslatableTextAccessor1_21) t.getContent();
if (accessor.getKey().equals("menu.online")){
((ButtonWidget) drawable).visible = false;
}
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/**
* This file is part of realmsfix.
*
* realmsfix is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* realmsfix is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with realmsfix. If not, see <http://www.gnu.org/licenses/>.
*/
package dev.blucobalt.realmsfix.mixin;


import net.minecraft.text.TranslatableTextContent;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;


@Mixin(TranslatableTextContent.class)
public interface TranslatableTextAccessor1_21
{
@Accessor(value = "key")
String getKey();
}
16 changes: 16 additions & 0 deletions versions/1.21/src/main/resources/realmsfix-1.21.mixins.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"required": true,
"minVersion": "0.8",
"package": "dev.blucobalt.realmsfix.mixin",
"compatibilityLevel": "JAVA_8",
"injectors": {
"defaultRequire": 1
},
"client": [
"RealmsNotificationsScreen1_21",
"TitleScreenAccessor1_21",
"TitleScreenMixin1_21",
"TranslatableTextAccessor1_21"
],
"refmap": "realmsfix-1.21.refmap.json"
}

0 comments on commit 1eecef8

Please sign in to comment.