Initial commit

This commit is contained in:
2025-11-08 13:13:31 +01:00
commit c0d96b04df
30 changed files with 3371 additions and 0 deletions
@@ -0,0 +1,39 @@
package net.fretux.ascend.network;
import net.fretux.ascend.AscendMod;
import net.minecraft.resources.ResourceLocation;
import net.minecraftforge.fml.loading.FMLEnvironment;
import net.minecraftforge.network.NetworkDirection;
import net.minecraftforge.network.NetworkRegistry;
import net.minecraftforge.network.simple.SimpleChannel;
public class PacketHandler {
private static final String PROTOCOL_VERSION = "1";
public static SimpleChannel INSTANCE;
private static int id = 0;
public static void register() {
System.out.println("[Ascend] Registering network packets...");
System.out.println("[Ascend] Registering packets on side: " +
(FMLEnvironment.dist.isClient() ? "CLIENT" : "SERVER"));
INSTANCE = NetworkRegistry.newSimpleChannel(
new ResourceLocation(AscendMod.MODID, "main"),
() -> PROTOCOL_VERSION,
PROTOCOL_VERSION::equals,
PROTOCOL_VERSION::equals
);
INSTANCE.messageBuilder(ServerboundSpendPointPacket.class, id++, NetworkDirection.PLAY_TO_SERVER)
.encoder(ServerboundSpendPointPacket::toBytes)
.decoder(ServerboundSpendPointPacket::new)
.consumerMainThread(ServerboundSpendPointPacket::handle)
.add();
INSTANCE.messageBuilder(ClientboundSyncStatsPacket.class, id++, NetworkDirection.PLAY_TO_CLIENT)
.encoder(ClientboundSyncStatsPacket::toBytes)
.decoder(ClientboundSyncStatsPacket::new)
.consumerMainThread(ClientboundSyncStatsPacket::handle)
.add();
}
}