diff --git a/xplat/src/main/java/fzzyhmstrs/emi_loot/EMILoot.java b/xplat/src/main/java/fzzyhmstrs/emi_loot/EMILoot.java index 62eb276b..742cab30 100644 --- a/xplat/src/main/java/fzzyhmstrs/emi_loot/EMILoot.java +++ b/xplat/src/main/java/fzzyhmstrs/emi_loot/EMILoot.java @@ -2,6 +2,7 @@ import com.google.gson.JsonElement; import fzzyhmstrs.emi_loot.client.ClientLootTables; +import fzzyhmstrs.emi_loot.client.ClientLootTablesReceiver; import fzzyhmstrs.emi_loot.networking.ArchaeologyLootPayload; import fzzyhmstrs.emi_loot.networking.BlockLootPayload; import fzzyhmstrs.emi_loot.networking.ChestLootPayload; @@ -16,7 +17,6 @@ import me.fzzyhmstrs.fzzy_config.annotations.IgnoreVisibility; import me.fzzyhmstrs.fzzy_config.annotations.NonSync; import me.fzzyhmstrs.fzzy_config.annotations.RequiresAction; -import me.fzzyhmstrs.fzzy_config.annotations.RequiresRestart; import me.fzzyhmstrs.fzzy_config.annotations.Version; import me.fzzyhmstrs.fzzy_config.api.ConfigApi; import me.fzzyhmstrs.fzzy_config.api.ConfigApiJava; @@ -70,11 +70,11 @@ public static Identifier identity(String path) { public static void onInitialize() { ConfigApi.INSTANCE.network().registerS2C(ClearPayload.TYPE, ClearPayload.CODEC, (payload, ctx) -> ClientLootTables.INSTANCE.clearLoots()); - ConfigApi.INSTANCE.network().registerS2C(ChestLootPayload.TYPE, ChestLootPayload.CODEC, (payload, ctx) -> ClientLootTables.INSTANCE.receiveChestSender(payload, ctx)); - ConfigApi.INSTANCE.network().registerS2C(BlockLootPayload.TYPE, BlockLootPayload.CODEC, (payload, ctx) -> ClientLootTables.INSTANCE.receiveBlockSender(payload, ctx)); - ConfigApi.INSTANCE.network().registerS2C(MobLootPayload.TYPE, MobLootPayload.CODEC, (payload, ctx) -> ClientLootTables.INSTANCE.receiveMobSender(payload, ctx)); - ConfigApi.INSTANCE.network().registerS2C(GameplayLootPayload.TYPE, GameplayLootPayload.CODEC, (payload, ctx) -> ClientLootTables.INSTANCE.receiveGameplaySender(payload, ctx)); - ConfigApi.INSTANCE.network().registerS2C(ArchaeologyLootPayload.TYPE, ArchaeologyLootPayload.CODEC, (payload, ctx) -> ClientLootTables.INSTANCE.receiveArchaeologySender(payload, ctx)); + ConfigApi.INSTANCE.network().registerS2C(ChestLootPayload.TYPE, ChestLootPayload.CODEC, ClientLootTablesReceiver::receiveChestSender); + ConfigApi.INSTANCE.network().registerS2C(BlockLootPayload.TYPE, BlockLootPayload.CODEC, ClientLootTablesReceiver::receiveBlockSender); + ConfigApi.INSTANCE.network().registerS2C(MobLootPayload.TYPE, MobLootPayload.CODEC, ClientLootTablesReceiver::receiveMobSender); + ConfigApi.INSTANCE.network().registerS2C(GameplayLootPayload.TYPE, GameplayLootPayload.CODEC, ClientLootTablesReceiver::receiveGameplaySender); + ConfigApi.INSTANCE.network().registerS2C(ArchaeologyLootPayload.TYPE, ArchaeologyLootPayload.CODEC, ClientLootTablesReceiver::receiveArchaeologySender); } public static void parseTables(ResourceManager resourceManager, Registry lootManager, RegistryOps ops) { @@ -212,4 +212,4 @@ public enum Type { this.logUntranslatedTablesSupplier = logUntranslatedTablesSupplier; } } -} +} \ No newline at end of file diff --git a/xplat/src/main/java/fzzyhmstrs/emi_loot/client/ClientLootTables.java b/xplat/src/main/java/fzzyhmstrs/emi_loot/client/ClientLootTables.java index f550c2dc..90e8df34 100644 --- a/xplat/src/main/java/fzzyhmstrs/emi_loot/client/ClientLootTables.java +++ b/xplat/src/main/java/fzzyhmstrs/emi_loot/client/ClientLootTables.java @@ -27,54 +27,34 @@ public void clearLoots() { loots.clear(); } - public void receiveChestSender(payload: ChestLootPayload, context: ClientPlayNetworkContext) { - receiveChestSender(payload.buf(), ctx.player().clientWorld) - } - - private void receiveChestSender(PacketByteBuf buf, World world) { + void receiveChestSender(PacketByteBuf buf, World world) { LootReceiver table = ClientChestLootTable.INSTANCE.fromBuf(buf, world); loots.add(table); if (EMILoot.config.isDebug(EMILoot.Type.CHEST)) EMILoot.LOGGER.info("received chest " + table.getId()); } - public void receiveBlockSender(payload: ChestLootPayload, context: ClientPlayNetworkContext) { - receiveBlockSender(payload.buf(), ctx.player().clientWorld) - } - - private void receiveBlockSender(PacketByteBuf buf, World world) { + void receiveBlockSender(PacketByteBuf buf, World world) { LootReceiver table = ClientBlockLootTable.INSTANCE.fromBuf(buf, world); loots.add(table); if (EMILoot.config.isDebug(EMILoot.Type.BLOCK)) EMILoot.LOGGER.info("received block " + table.getId()); } - public void receiveMobSender(payload: ChestLootPayload, context: ClientPlayNetworkContext) { - receiveMobSender(payload.buf(), ctx.player().clientWorld) - } - - private void receiveMobSender(PacketByteBuf buf, World world) { + void receiveMobSender(PacketByteBuf buf, World world) { LootReceiver table = ClientMobLootTable.INSTANCE.fromBuf(buf, world); loots.add(table); if (EMILoot.config.isDebug(EMILoot.Type.MOB)) EMILoot.LOGGER.info("received mob " + table.getId()); } - public void receiveGameplaySender(payload: ChestLootPayload, context: ClientPlayNetworkContext) { - receiveGameplaySender(payload.buf(), ctx.player().clientWorld) - } - - private void receiveGameplaySender(PacketByteBuf buf, World world) { + void receiveGameplaySender(PacketByteBuf buf, World world) { LootReceiver table = ClientGameplayLootTable.INSTANCE.fromBuf(buf, world); loots.add(table); if (EMILoot.config.isDebug(EMILoot.Type.GAMEPLAY)) EMILoot.LOGGER.info("received gameplay loot: " + table.getId()); } - public void receiveArchaeologySender(payload: ChestLootPayload, context: ClientPlayNetworkContext) { - receiveArchaeologySender(payload.buf(), ctx.player().clientWorld) - } - - private void receiveArchaeologySender(PacketByteBuf buf, World world) { + void receiveArchaeologySender(PacketByteBuf buf, World world) { LootReceiver table = ClientArchaeologyLootTable.INSTANCE.fromBuf(buf, world); loots.add(table); if (EMILoot.config.isDebug(EMILoot.Type.ARCHAEOLOGY)) EMILoot.LOGGER.info("received archaeology loot: " + table.getId()); } -} +} \ No newline at end of file diff --git a/xplat/src/main/java/fzzyhmstrs/emi_loot/client/ClientLootTablesReceiver.java b/xplat/src/main/java/fzzyhmstrs/emi_loot/client/ClientLootTablesReceiver.java new file mode 100644 index 00000000..4369c15d --- /dev/null +++ b/xplat/src/main/java/fzzyhmstrs/emi_loot/client/ClientLootTablesReceiver.java @@ -0,0 +1,32 @@ +package fzzyhmstrs.emi_loot.client; + +import fzzyhmstrs.emi_loot.networking.ArchaeologyLootPayload; +import fzzyhmstrs.emi_loot.networking.BlockLootPayload; +import fzzyhmstrs.emi_loot.networking.ChestLootPayload; +import fzzyhmstrs.emi_loot.networking.GameplayLootPayload; +import fzzyhmstrs.emi_loot.networking.MobLootPayload; +import me.fzzyhmstrs.fzzy_config.networking.api.ClientPlayNetworkContext; + +public class ClientLootTablesReceiver { + + public static void receiveChestSender(ChestLootPayload payload, ClientPlayNetworkContext ctx) { + ClientLootTables.INSTANCE.receiveChestSender(payload.buf(), ctx.player().getWorld()); + } + + public static void receiveBlockSender(BlockLootPayload payload, ClientPlayNetworkContext ctx) { + ClientLootTables.INSTANCE.receiveBlockSender(payload.buf(), ctx.player().getWorld()); + } + + public static void receiveMobSender(MobLootPayload payload, ClientPlayNetworkContext ctx) { + ClientLootTables.INSTANCE.receiveMobSender(payload.buf(), ctx.player().getWorld()); + } + + public static void receiveGameplaySender(GameplayLootPayload payload, ClientPlayNetworkContext ctx) { + ClientLootTables.INSTANCE.receiveGameplaySender(payload.buf(), ctx.player().getWorld()); + } + + public static void receiveArchaeologySender(ArchaeologyLootPayload payload, ClientPlayNetworkContext ctx) { + ClientLootTables.INSTANCE.receiveArchaeologySender(payload.buf(), ctx.player().getWorld()); + } + +} \ No newline at end of file