Skip to content

Commit 841098b

Browse files
committed
more robust gtnhlib compat patch
1 parent ca9819c commit 841098b

5 files changed

Lines changed: 104 additions & 1 deletion

File tree

build.gradle.kts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
plugins {
2-
id("fpgradle-minecraft") version ("0.8.2")
2+
id("fpgradle-minecraft") version ("0.8.3")
33
}
44

55
group = "com.falsepattern"
@@ -68,6 +68,7 @@ repositories {
6868
exclusive(mega(), "codechicken")
6969
exclusive(ivy("https://files.vexatos.com/", "[module]/[artifact]-[revision].[ext]"), "vexatos")
7070
exclusive(ivy("https://downloads.gtnewhorizons.com/", "[organisation]/[artifact]-[revision].[ext]"), "Mods_for_Twitch")
71+
exclusive(maven("horizon", "https://mvn.falsepattern.com/horizon/"), "com.gtnewhorizons.retrofuturabootstrap")
7172
}
7273

7374
dependencies {
@@ -79,6 +80,7 @@ dependencies {
7980

8081
compileOnly(deobf("optifine:optifine:1.7.10_hd_u_e7"))
8182

83+
compileOnly("com.gtnewhorizons.retrofuturabootstrap:RetroFuturaBootstrap:1.0.7")
8284
compileOnly("com.github.GTNewHorizons:GTNHLib:0.5.21:api")
8385

8486
compileOnly("com.github.basdxz:Apparatus:2.12.3:dev") { excludeDeps() }
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
* This file is part of FalseTweaks.
3+
*
4+
* Copyright (C) 2022-2024 FalsePattern
5+
* All Rights Reserved
6+
*
7+
* The above copyright notice and this permission notice shall be included
8+
* in all copies or substantial portions of the Software.
9+
*
10+
* FalseTweaks is free software: you can redistribute it and/or modify
11+
* it under the terms of the GNU Lesser General Public License as published by
12+
* the Free Software Foundation, either version 3 of the License, or
13+
* (at your option) any later version.
14+
*
15+
* FalseTweaks is distributed in the hope that it will be useful,
16+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
17+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18+
* GNU Lesser General Public License for more details.
19+
*
20+
* You should have received a copy of the GNU Lesser General Public License
21+
* along with FalseTweaks. If not, see <https://www.gnu.org/licenses/>.
22+
*/
23+
24+
package com.falsepattern.falsetweaks.asm;
25+
26+
import lombok.val;
27+
28+
import net.minecraft.launchwrapper.IClassTransformer;
29+
30+
import java.util.List;
31+
32+
public class ASMFixerUtility {
33+
public static void removeGTNHLibHook(List<IClassTransformer> transformers) {
34+
val iter = transformers.iterator();
35+
while (iter.hasNext()) {
36+
val transformer = (IClassTransformer) iter.next();
37+
if (transformer.getClass().getName().equals("com.gtnewhorizon.gtnhlib.core.transformer.TessellatorRedirectorTransformer")) {
38+
iter.remove();
39+
}
40+
}
41+
}
42+
}

src/main/java/com/falsepattern/falsetweaks/asm/FalseTweaksTransformer.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@
4949
@Getter
5050
@Accessors(fluent = true)
5151
public class FalseTweaksTransformer extends MergeableTurboTransformer {
52+
static {
53+
try {
54+
RFBFixerUtility.removeGTNHLibHook();
55+
} catch (Throwable ignored) {}
56+
}
5257
private static List<TurboClassTransformer> transformers() {
5358
val transformers = new ArrayList<TurboClassTransformer>();
5459
if (FMLLaunchHandler.side().isClient()) {

src/main/java/com/falsepattern/falsetweaks/asm/MixinCompatHackTweaker.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ public String[] getLaunchArguments() {
5656
val f = LaunchClassLoader.class.getDeclaredField("transformers");
5757
f.setAccessible(true);
5858
val transformers = (List<IClassTransformer>) f.get(Launch.classLoader);
59+
try {
60+
ASMFixerUtility.removeGTNHLibHook(transformers);
61+
} catch (Throwable ignored) {}
5962
transformers.add(CoreLoadingPlugin.FIELD_HACK_TF);
6063
return new String[0];
6164
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/*
2+
* This file is part of FalseTweaks.
3+
*
4+
* Copyright (C) 2022-2024 FalsePattern
5+
* All Rights Reserved
6+
*
7+
* The above copyright notice and this permission notice shall be included
8+
* in all copies or substantial portions of the Software.
9+
*
10+
* FalseTweaks is free software: you can redistribute it and/or modify
11+
* it under the terms of the GNU Lesser General Public License as published by
12+
* the Free Software Foundation, either version 3 of the License, or
13+
* (at your option) any later version.
14+
*
15+
* FalseTweaks is distributed in the hope that it will be useful,
16+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
17+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18+
* GNU Lesser General Public License for more details.
19+
*
20+
* You should have received a copy of the GNU Lesser General Public License
21+
* along with FalseTweaks. If not, see <https://www.gnu.org/licenses/>.
22+
*/
23+
24+
package com.falsepattern.falsetweaks.asm;
25+
26+
import com.gtnewhorizons.retrofuturabootstrap.SharedConfig;
27+
import com.gtnewhorizons.retrofuturabootstrap.api.RfbClassTransformerHandle;
28+
import lombok.SneakyThrows;
29+
import lombok.val;
30+
31+
import java.util.ArrayList;
32+
import java.util.Arrays;
33+
import java.util.concurrent.atomic.AtomicReference;
34+
35+
public class RFBFixerUtility {
36+
@SneakyThrows
37+
public static void removeGTNHLibHook() {
38+
val theField = SharedConfig.class.getDeclaredField("rfbTransformers");
39+
theField.setAccessible(true);
40+
val ref = (AtomicReference<RfbClassTransformerHandle[]>) theField.get(null);
41+
val arr = new ArrayList<>(Arrays.asList(ref.get()));
42+
val iter = arr.iterator();
43+
while (iter.hasNext()) {
44+
val elem = iter.next();
45+
if (elem.id().equals("gtnhlib:redirector")) {
46+
iter.remove();
47+
}
48+
}
49+
ref.set(arr.toArray(new RfbClassTransformerHandle[0]));
50+
}
51+
}

0 commit comments

Comments
 (0)