Skip to content

Commit

Permalink
Add version to server config packet
Browse files Browse the repository at this point in the history
for forward compatibility
  • Loading branch information
mschae23 committed Dec 1, 2024
1 parent 43b481e commit eac273f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ plugins {
id 'maven-publish'
}

sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21

version = "${project.mod_version}+${project.minecraft_version}"
group = project.maven_group
Expand Down Expand Up @@ -81,7 +81,7 @@ processResources {

tasks.withType(JavaCompile).configureEach {
// Minecraft 1.18 (1.18-pre2) upwards uses Java 17.
it.options.release = 17
it.options.release = 21
}

java {
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ org.gradle.jvmargs=-Xmx1G
loader_version=0.16.9

# Mod Properties
mod_version = 4.0.0-beta.1
mod_version = 4.0.0-beta.2
maven_group = de.mschae23.minecraft.mod
archives_base_name = grind-enchantments

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import net.minecraft.network.PacketByteBuf;
import net.minecraft.network.codec.PacketCodec;
import net.minecraft.network.codec.PacketCodecs;
import net.minecraft.network.packet.CustomPayload;
import net.minecraft.util.Identifier;
import de.mschae23.grindenchantments.GrindEnchantmentsMod;
Expand All @@ -37,6 +38,11 @@ public Id<? extends CustomPayload> getId() {
}

public static PacketCodec<PacketByteBuf, ServerConfigS2CPayload> createPacketCodec(PacketCodec<PacketByteBuf, CostFunction> costFunctionCodec) {
return ServerConfig.createPacketCodec(costFunctionCodec).xmap(ServerConfigS2CPayload::new, ServerConfigS2CPayload::config);
return PacketCodec.tuple(
// Version field for forward compatibility
PacketCodecs.BYTE, payload -> (byte) 1,
ServerConfig.createPacketCodec(costFunctionCodec), ServerConfigS2CPayload::config,
(version, config) -> new ServerConfigS2CPayload(config)
);
}
}

0 comments on commit eac273f

Please sign in to comment.