Skip to content

Commit ad07851

Browse files
committed
build: fabric 1.21.9-pre3
1 parent f22c94a commit ad07851

15 files changed

Lines changed: 289 additions & 30 deletions

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
plugins {
2-
id 'fabric-loom' version '1.10-SNAPSHOT' apply false
2+
id 'fabric-loom' version '1.11-SNAPSHOT' apply false
33
id 'com.github.johnrengelman.shadow' version '7.1.0' apply false
44
id 'org.cadixdev.licenser' version '0.6.1' apply false
55
id 'com.modrinth.minotaur' version '2.+' apply false

fabric/src/main/java/com/ishland/raknetify/fabric/RaknetifyFabric.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import com.google.gson.Gson;
2828
import com.google.gson.GsonBuilder;
2929
import com.ishland.raknetify.common.data.ProtocolMultiChannelMappings;
30+
import com.ishland.raknetify.fabric.common.client.DebugHudUtil1_21_9;
3031
import com.ishland.raknetify.fabric.common.connection.RakNetMultiChannel;
3132
import com.ishland.raknetify.common.util.NetworkInterfaceListener;
3233
import com.ishland.raknetify.fabric.common.util.FieldSignatureParser;
@@ -45,6 +46,7 @@
4546
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
4647
import it.unimi.dsi.fastutil.objects.Object2IntMap;
4748
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
49+
import net.fabricmc.api.EnvType;
4850
import net.fabricmc.api.ModInitializer;
4951
import net.fabricmc.loader.api.FabricLoader;
5052
import net.fabricmc.loader.api.entrypoint.PreLaunchEntrypoint;
@@ -102,6 +104,10 @@ public void onInitialize() {
102104

103105
handleMappings();
104106

107+
if (FabricLoader.getInstance().getEnvironmentType() == EnvType.CLIENT && RaknetifyFabricMixinPlugin.AFTER_1_21_8) {
108+
DebugHudUtil1_21_9.init();
109+
}
110+
105111
// If new property name is present, use it
106112
String levelStr = SystemPropertyUtil.get("io.netty.leakDetection.level", ResourceLeakDetector.Level.SIMPLE.name());
107113
ResourceLeakDetector.Level level = ResourceLeakDetector.Level.SIMPLE;

fabric/src/main/java/com/ishland/raknetify/fabric/mixin/client/hud/MixinDebugHud.java renamed to fabric/src/main/java/com/ishland/raknetify/fabric/common/client/DebugHudUtil.java

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -22,77 +22,69 @@
2222
* THE SOFTWARE.
2323
*/
2424

25-
package com.ishland.raknetify.fabric.mixin.client.hud;
25+
package com.ishland.raknetify.fabric.common.client;
2626

2727
import com.ishland.raknetify.common.connection.MetricsSynchronizationHandler;
2828
import com.ishland.raknetify.common.connection.MultiChannelingStreamingCompression;
2929
import com.ishland.raknetify.common.connection.SimpleMetricsLogger;
3030
import com.ishland.raknetify.fabric.common.util.MultiVersionUtil;
3131
import com.ishland.raknetify.fabric.mixin.access.IClientConnection;
32-
import com.ishland.raknetify.fabric.mixin.access.IClientPlayNetworkHandler;
3332
import io.netty.channel.Channel;
3433
import net.minecraft.client.MinecraftClient;
35-
import net.minecraft.client.gui.hud.DebugHud;
3634
import net.minecraft.client.network.ClientPlayNetworkHandler;
3735
import net.minecraft.network.ClientConnection;
3836
import network.ycc.raknet.RakNet;
39-
import org.spongepowered.asm.mixin.Mixin;
40-
import org.spongepowered.asm.mixin.injection.At;
41-
import org.spongepowered.asm.mixin.injection.Inject;
42-
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
4337

44-
import java.util.List;
38+
import java.util.function.Consumer;
4539

46-
@Mixin(DebugHud.class)
47-
public class MixinDebugHud {
40+
public class DebugHudUtil {
4841

49-
@Inject(method = "getLeftText", at = @At("RETURN"))
50-
private void getLeftText(CallbackInfoReturnable<List<String>> cir) {
42+
public static void getDebugString(Consumer<String> consumer) {
5143
final ClientPlayNetworkHandler networkHandler = MinecraftClient.getInstance().getNetworkHandler();
5244
if (networkHandler != null) {
5345
final ClientConnection connection = (ClientConnection) MultiVersionUtil.ClientPlayNetworkHandler$connection.get(networkHandler);
5446
final Channel channel = ((IClientConnection) connection).getChannel();
5547
if (channel != null) {
5648
if (channel.config() instanceof RakNet.Config config) {
5749
if (config.getMetrics() instanceof SimpleMetricsLogger logger) {
58-
cir.getReturnValue().add(
50+
consumer.accept(
5951
"[Raknetify] A: true, MTU: %d, RTT: %.2f/%.2fms"
6052
.formatted(config.getMTU(),
6153
logger.getMeasureRTTns() / 1_000_000.0,
6254
logger.getMeasureRTTnsStdDev() / 1_000_000.0
6355
));
6456
final MetricsSynchronizationHandler serverSync = logger.getMetricsSynchronizationHandler();
6557
if (serverSync != null && serverSync.isRemoteSupported()) {
66-
cir.getReturnValue().add(
58+
consumer.accept(
6759
"[Raknetify] C: BUF: %.2fMB; S: BUF: %.2fMB"
6860
.formatted(
6961
logger.getCurrentQueuedBytes() / 1024.0 / 1024.0,
7062
serverSync.getQueuedBytes() / 1024.0 / 1024.0
7163
));
7264
} else {
73-
cir.getReturnValue().add(
65+
consumer.accept(
7466
"[Raknetify] C: BUF: %.2fMB"
7567
.formatted(
7668
logger.getCurrentQueuedBytes() / 1024.0 / 1024.0
7769
));
7870
}
7971

80-
cir.getReturnValue().add(
72+
consumer.accept(
8173
"[Raknetify] C: I: %s, O: %s"
8274
.formatted(
8375
logger.getMeasureTrafficInFormatted(),
8476
logger.getMeasureTrafficOutFormatted()
8577
));
8678

87-
cir.getReturnValue().add(
79+
consumer.accept(
8880
"[Raknetify] C: ERR: %.4f%%, %d tx, %d rx, BST: %d"
8981
.formatted(
9082
logger.getMeasureErrorRate() * 100.0,
9183
logger.getMeasureTX(), logger.getMeasureRX(),
9284
logger.getMeasureBurstTokens() + config.getDefaultPendingFrameSets()
9385
));
9486
if (serverSync != null && serverSync.isRemoteSupported()) {
95-
cir.getReturnValue().add(
87+
consumer.accept(
9688
"[Raknetify] S: ERR: %.4f%%, %d tx, %d rx, BST: %d"
9789
.formatted(
9890
serverSync.getErrorRate() * 100.0,
@@ -101,15 +93,15 @@ private void getLeftText(CallbackInfoReturnable<List<String>> cir) {
10193
));
10294
}
10395
} else {
104-
cir.getReturnValue().add(
96+
consumer.accept(
10597
"[Raknetify] A: true, MTU: %d"
10698
.formatted(config.getMTU())
10799
);
108100
}
109101

110102
final MultiChannelingStreamingCompression compression = channel.pipeline().get(MultiChannelingStreamingCompression.class);
111103
if (compression != null && compression.isActive()) {
112-
cir.getReturnValue().add(
104+
consumer.accept(
113105
"[Raknetify] CRatio: I: %.2f%%, O: %.2f%%"
114106
.formatted(compression.getInCompressionRatio() * 100, compression.getOutCompressionRatio() * 100)
115107
);
@@ -119,7 +111,7 @@ private void getLeftText(CallbackInfoReturnable<List<String>> cir) {
119111
}
120112
}
121113
}
122-
cir.getReturnValue().add("[Raknetify] A: false");
114+
consumer.accept("[Raknetify] A: false");
123115
}
124116

125117
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/*
2+
* This file is a part of the Raknetify project, licensed under MIT.
3+
*
4+
* Copyright (c) 2022-2025 ishland
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in
14+
* all copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22+
* THE SOFTWARE.
23+
*/
24+
25+
package com.ishland.raknetify.fabric.common.client;
26+
27+
import com.ishland.raknetify.fabric.mixin.access.IDebugHudEntries;
28+
import net.minecraft.client.gui.hud.debug.DebugHudEntry;
29+
import net.minecraft.client.gui.hud.debug.DebugHudLines;
30+
import net.minecraft.util.Identifier;
31+
import net.minecraft.world.World;
32+
import net.minecraft.world.chunk.WorldChunk;
33+
import org.jetbrains.annotations.Nullable;
34+
35+
import java.util.concurrent.atomic.AtomicBoolean;
36+
37+
public class DebugHudUtil1_21_9 {
38+
39+
private static final AtomicBoolean initialized = new AtomicBoolean(false);
40+
41+
public static void init() {
42+
if (!initialized.compareAndSet(false, true)) return;
43+
44+
Identifier identifier = Identifier.of("raknetify", "raknetify_debug_info");
45+
IDebugHudEntries.invokeRegister(identifier, new DebugHudEntry() {
46+
@Override
47+
public void render(DebugHudLines lines, @Nullable World world, @Nullable WorldChunk clientChunk, @Nullable WorldChunk chunk) {
48+
DebugHudUtil.getDebugString(s -> lines.addLineToSection(identifier, s));
49+
}
50+
51+
@Override
52+
public boolean canShow(boolean reducedDebugInfo) {
53+
return true;
54+
}
55+
});
56+
}
57+
58+
}

fabric/src/main/java/com/ishland/raknetify/fabric/common/connection/RakNetMultiChannel.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,9 @@ private static Set<Class<?>> createClassSet(String[] classNames) {
243243

244244
// 1.20.5
245245
"net/minecraft/class_9632", // ProjectilePowerS2CPacket
246+
247+
"net/minecraft/class_11984", // EntityValueDebugS2CPacket
248+
"net/minecraft/class_11985", // EventDebugS2CPacket
246249
});
247250

248251
// Primarily used for interactions dependent to world
@@ -354,6 +357,11 @@ private static Set<Class<?>> createClassSet(String[] classNames) {
354357
"net/minecraft/class_10387", // PlayerLoadedC2SPacket
355358

356359
"net/minecraft/class_10614", // TestInstanceBlockStatusS2CPacket
360+
361+
"net/minecraft/class_11982", // BlockValueDebugS2CPacket
362+
"net/minecraft/class_11983", // ChunkValueDebugS2CPacket
363+
"net/minecraft/class_11986", // GameTestHighlightPosS2CPacket
364+
357365
});
358366

359367
private static final Set<Class<?>> unreliable = createClassSet(new String[]{
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* This file is a part of the Raknetify project, licensed under MIT.
3+
*
4+
* Copyright (c) 2022-2025 ishland
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in
14+
* all copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22+
* THE SOFTWARE.
23+
*/
24+
25+
package com.ishland.raknetify.fabric.common.util;
26+
27+
import com.ishland.raknetify.fabric.mixin.RaknetifyFabricMixinPlugin;
28+
import net.minecraft.entity.Entity;
29+
import net.minecraft.world.World;
30+
31+
public class LegacySupportUtil {
32+
33+
public static World getEntityWorld(Entity entity) {
34+
if (RaknetifyFabricMixinPlugin.AFTER_1_21_8) {
35+
return entity.getEntityWorld();
36+
} else {
37+
try {
38+
return (World) MultiVersionUtil.Entity$getEntity1_21_8.invokeExact(entity);
39+
} catch (Throwable e) {
40+
throw new RuntimeException(e);
41+
}
42+
}
43+
}
44+
45+
}

fabric/src/main/java/com/ishland/raknetify/fabric/common/util/MultiVersionUtil.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import net.fabricmc.loader.api.FabricLoader;
3030
import net.fabricmc.loader.api.MappingResolver;
3131
import net.minecraft.client.network.ClientPlayNetworkHandler;
32+
import net.minecraft.entity.Entity;
3233
import net.minecraft.entity.player.HungerManager;
3334
import net.minecraft.nbt.NbtCompound;
3435
import net.minecraft.network.ClientConnection;
@@ -57,6 +58,7 @@ public class MultiVersionUtil {
5758
private static final String CLASSNAME_ContextAwareNetworkStateFactory = "net.minecraft.class_10947";
5859
private static final String CLASSNAME_PlayStateFactories = "net.minecraft.class_9095";
5960
private static final String CLASSNAME_HungerManager = "net.minecraft.class_1702";
61+
private static final String CLASSNAME_Entity = "net.minecraft.class_1297";
6062

6163
public static final VarHandle ServerPlayNetworkHandler$connection;
6264
public static final VarHandle ClientPlayNetworkHandler$connection;
@@ -69,6 +71,7 @@ public class MultiVersionUtil {
6971
public static final VarHandle PlayStateFactories$S2C1_20_5;
7072
public static final MethodHandle HungerManager$writeNbt1_21_5;
7173
public static final MethodHandle HungerManager$readNbt1_21_5;
74+
public static final MethodHandle Entity$getEntity1_21_8;
7275

7376
static {
7477
try {
@@ -208,6 +211,18 @@ public class MultiVersionUtil {
208211
}
209212
}
210213

214+
{
215+
final Method getEntity1_21_8 = getOrNull(() -> Entity.class.getDeclaredMethod(resolver.mapFieldName(INTERMEDIARY, CLASSNAME_Entity, "method_37908", "()Lnet/minecraft/class_1937;")), NoSuchMethodException.class);
216+
if (getEntity1_21_8 != null) {
217+
getEntity1_21_8.setAccessible(true);
218+
Entity$getEntity1_21_8 = MethodHandles
219+
.privateLookupIn(Entity.class, MethodHandles.lookup())
220+
.unreflect(getEntity1_21_8);
221+
} else {
222+
Entity$getEntity1_21_8 = null;
223+
}
224+
}
225+
211226
} catch (Throwable t) {
212227
throw new RuntimeException(t);
213228
}

fabric/src/main/java/com/ishland/raknetify/fabric/mixin/RaknetifyFabricMixinPlugin.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ public class RaknetifyFabricMixinPlugin implements IMixinConfigPlugin {
4444
public static final boolean AFTER_1_20_5;
4545
public static final boolean AFTER_1_21_4;
4646
public static final boolean AFTER_1_21_5;
47+
public static final boolean AFTER_1_21_8;
4748

4849
static {
4950
try {
@@ -53,6 +54,7 @@ public class RaknetifyFabricMixinPlugin implements IMixinConfigPlugin {
5354
AFTER_1_20_5 = VersionPredicate.parse(">1.20.5").test(FabricLoader.getInstance().getModContainer("minecraft").get().getMetadata().getVersion());
5455
AFTER_1_21_4 = VersionPredicate.parse(">1.21.4").test(FabricLoader.getInstance().getModContainer("minecraft").get().getMetadata().getVersion());
5556
AFTER_1_21_5 = VersionPredicate.parse(">1.21.5").test(FabricLoader.getInstance().getModContainer("minecraft").get().getMetadata().getVersion());
57+
AFTER_1_21_8 = VersionPredicate.parse(">1.21.8").test(FabricLoader.getInstance().getModContainer("minecraft").get().getMetadata().getVersion());
5658
} catch (VersionParsingException e) {
5759
throw new RuntimeException(e);
5860
}
@@ -78,6 +80,8 @@ public boolean shouldApplyMixin(String targetClassName, String mixinClassName) {
7880
return AFTER_1_20_1 && !AFTER_1_20_4;
7981
if (mixinClassName.equals("com.ishland.raknetify.fabric.mixin.client.MixinMultiplayerServerListPinger1_20_5"))
8082
return AFTER_1_20_4;
83+
if (mixinClassName.equals("com.ishland.raknetify.fabric.mixin.client.hud.MixinDebugHud1_21_8"))
84+
return !AFTER_1_21_8;
8185
return true;
8286
} else {
8387
return false;
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* This file is a part of the Raknetify project, licensed under MIT.
3+
*
4+
* Copyright (c) 2022-2025 ishland
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in
14+
* all copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22+
* THE SOFTWARE.
23+
*/
24+
25+
package com.ishland.raknetify.fabric.mixin.access;
26+
27+
import net.minecraft.client.gui.hud.debug.DebugHudEntries;
28+
import net.minecraft.client.gui.hud.debug.DebugHudEntry;
29+
import net.minecraft.util.Identifier;
30+
import org.spongepowered.asm.mixin.Mixin;
31+
import org.spongepowered.asm.mixin.gen.Invoker;
32+
33+
@Mixin(DebugHudEntries.class)
34+
public interface IDebugHudEntries {
35+
36+
@Invoker
37+
static Identifier invokeRegister(Identifier id, DebugHudEntry entry) {
38+
throw new AbstractMethodError();
39+
}
40+
41+
}

0 commit comments

Comments
 (0)