Skip to content

Commit

Permalink
Update Forge and change the max UTF value.
Browse files Browse the repository at this point in the history
  • Loading branch information
TonimatasDEV committed Dec 22, 2024
1 parent ad64cc5 commit 89100b9
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,19 @@ public abstract class FriendlyByteBufMixin {
public long newSize(long constant) {
return Config.getNbtMaxSize();
}

@ModifyConstant(method = "readUtf()Ljava/lang/String;", constant = @Constant(intValue = 32767))
private int readUtf$newSize(int constant) {
return Config.getUtf8Size();
}

@ModifyConstant(method = "writeUtf(Ljava/lang/String;)Lnet/minecraft/network/FriendlyByteBuf;", constant = @Constant(intValue = 32767))
private int writeUtf$newSize(int constant) {
return Config.getUtf8Size(); // It should work. The error is correct, with the Packet Fixer values. You can change the max in the config.
}

@ModifyConstant(method = "readResourceLocation", constant = @Constant(intValue = 32767))
private int readResourceLocation$newSize(int constant) {
return Config.getUtf8Size();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public static void runProperties() {
properties.setProperty("packetSize", Integer.toString(1048576 * 100));
properties.setProperty("decoderSize", Integer.toString(8388608 * 100));
properties.setProperty("varInt21", Integer.toString(8));
properties.setProperty("utfSize", Integer.toString(32767));

save(propertiesFile);
}
Expand All @@ -37,6 +38,7 @@ public static void runProperties() {
checkVariable("packetSize", Integer.toString(1048576 * 100));
checkVariable("decoderSize", Integer.toString(8388608 * 100));
checkVariable("varInt21", Integer.toString(8));
checkVariable("utfSize", Integer.toString(32767 * 100));
save(propertiesFile);
} catch (IOException e) {
throw new RuntimeException(e);
Expand All @@ -63,6 +65,11 @@ public static int getVarInt21Size() {
return Integer.parseInt(properties.getProperty("varInt21"));
}

public static int getUtf8Size() {
if (properties == null) runProperties();
return Integer.parseInt(properties.getProperty("utfSize"));
}

private static void checkVariable(String variable, String defaultValue) {
if (properties.getProperty(variable) == null) {
properties.setProperty(variable, defaultValue);
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ minecraftVersion=1.20.1
minecraftVersionRange=1.19,1.20.1

# Forge Properties
forgeVersion=47.2.20
forgeVersion=47.3.12

# Fabric Properties
fabricLoaderVersion=0.15.6
Expand Down

0 comments on commit 89100b9

Please sign in to comment.