-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7bc1a9f
commit 932aded
Showing
6 changed files
with
72 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 15 additions & 1 deletion
16
src/main/java/net/tigereye/chestcavity/registration/CCNetworkingPackets.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,50 @@ | ||
package net.tigereye.chestcavity.registration; | ||
|
||
import net.fabricmc.fabric.api.client.networking.v1.ClientLoginNetworking; | ||
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking; | ||
import net.fabricmc.fabric.api.networking.v1.PacketByteBufs; | ||
import net.fabricmc.fabric.api.networking.v1.ServerLoginConnectionEvents; | ||
import net.fabricmc.fabric.api.networking.v1.ServerLoginNetworking; | ||
import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking; | ||
import net.minecraft.network.PacketByteBuf; | ||
import net.minecraft.util.Identifier; | ||
import net.tigereye.chestcavity.ChestCavity; | ||
import net.tigereye.chestcavity.interfaces.ChestCavityEntity; | ||
import net.tigereye.chestcavity.util.NetworkUtil; | ||
|
||
import java.util.Optional; | ||
import java.util.concurrent.CompletableFuture; | ||
|
||
public class CCNetworkingPackets { | ||
public static final Identifier ORGAN_DATA_PACKET_ID = new Identifier(ChestCavity.MODID,"organ_data"); | ||
public static final Identifier UPDATE_PACKET_ID = new Identifier(ChestCavity.MODID,"update"); | ||
public static final Identifier RECEIVED_UPDATE_PACKET_ID = new Identifier(ChestCavity.MODID,"received_update"); | ||
|
||
public static final Identifier HOTKEY_PACKET_ID = new Identifier(ChestCavity.MODID, "hotkey"); | ||
|
||
public static void register(){ | ||
ServerLoginConnectionEvents.QUERY_START.register(NetworkUtil::sendOrganDataPacket); | ||
ServerPlayNetworking.registerGlobalReceiver(CCNetworkingPackets.RECEIVED_UPDATE_PACKET_ID, (server, player, handler, buf, sender) -> { | ||
Optional<ChestCavityEntity> optional = ChestCavityEntity.of(player); | ||
optional.ifPresent(chestCavityEntity -> NetworkUtil.ReadChestCavityReceiveUpdatePacket(chestCavityEntity.getChestCavityInstance())); | ||
optional.ifPresent(chestCavityEntity -> NetworkUtil.ReadChestCavityReceivedUpdatePacket(chestCavityEntity.getChestCavityInstance())); | ||
}); | ||
|
||
ServerPlayNetworking.registerGlobalReceiver(CCNetworkingPackets.HOTKEY_PACKET_ID, (server, player, handler, buf, sender) -> { | ||
Optional<ChestCavityEntity> optional = ChestCavityEntity.of(player); | ||
optional.ifPresent(chestCavityEntity -> NetworkUtil.ReadChestCavityHotkeyPacket(chestCavityEntity.getChestCavityInstance(),buf)); | ||
}); | ||
ServerLoginNetworking.registerGlobalReceiver(CCNetworkingPackets.ORGAN_DATA_PACKET_ID,(server, handler, understood, buf, synchronizer, sender) -> { | ||
}); | ||
} | ||
|
||
public static void registerClient(){ | ||
ClientPlayNetworking.registerGlobalReceiver(CCNetworkingPackets.UPDATE_PACKET_ID, (client, handler, buf, responseSender) -> { | ||
Optional<ChestCavityEntity> optional = ChestCavityEntity.of(client.cameraEntity); | ||
optional.ifPresent(chestCavityEntity -> NetworkUtil.ReadChestCavityUpdatePacket(chestCavityEntity.getChestCavityInstance(), buf)); | ||
}); | ||
ClientLoginNetworking.registerGlobalReceiver(CCNetworkingPackets.ORGAN_DATA_PACKET_ID, (client, handler, buf, responseSender) -> { | ||
NetworkUtil.readOrganDataPacket(buf); | ||
return CompletableFuture.completedFuture(PacketByteBufs.empty()); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters