Update major API Version to add some new interfaces.
This commit is contained in:
parent
1378a6fb21
commit
5d024f425c
26 changed files with 496 additions and 111 deletions
|
@ -1,9 +1,12 @@
|
|||
package dev.zontreck.libzontreck.networking;
|
||||
|
||||
import dev.zontreck.libzontreck.LibZontreck;
|
||||
import dev.zontreck.libzontreck.events.RegisterPacketsEvent;
|
||||
import dev.zontreck.libzontreck.networking.packets.ChestGUIOpenC2S;
|
||||
import dev.zontreck.libzontreck.networking.packets.IPacket;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.network.NetworkDirection;
|
||||
import net.minecraftforge.network.NetworkRegistry;
|
||||
import net.minecraftforge.network.PacketDistributor;
|
||||
|
@ -15,7 +18,11 @@ import net.minecraftforge.network.simple.SimpleChannel;
|
|||
public class ModMessages {
|
||||
private static SimpleChannel INSTANCE;
|
||||
private static int PACKET_ID=0;
|
||||
private static int id()
|
||||
/**
|
||||
* INTERNAL USE ONLY. DO NOT USE THIS, IF YOU ARE NOT LIBZONTRECK!!!!!!
|
||||
* @return
|
||||
*/
|
||||
public static int id()
|
||||
{
|
||||
return PACKET_ID++;
|
||||
}
|
||||
|
@ -26,9 +33,17 @@ public class ModMessages {
|
|||
.clientAcceptedVersions(s->true)
|
||||
.serverAcceptedVersions(s->true)
|
||||
.simpleChannel();
|
||||
|
||||
RegisterPacketsEvent event = new RegisterPacketsEvent();
|
||||
MinecraftForge.EVENT_BUS.post(event);
|
||||
|
||||
INSTANCE=net;
|
||||
|
||||
for(IPacket packet : event.packets)
|
||||
{
|
||||
packet.register(net);
|
||||
}
|
||||
|
||||
net.messageBuilder(ChestGUIOpenC2S.class, id(), NetworkDirection.PLAY_TO_SERVER)
|
||||
.decoder(ChestGUIOpenC2S::new)
|
||||
.encoder(ChestGUIOpenC2S::toBytes)
|
||||
|
|
Reference in a new issue