From ead950bb8c0bb254ac64cce3db2cb7085715f306 Mon Sep 17 00:00:00 2001 From: dhyces Date: Mon, 6 Nov 2023 16:04:29 -0500 Subject: [PATCH] Remove dep on CommonNetworks --- Common/build.gradle | 2 -- .../src/main/java/dhyces/trimmed/Trimmed.java | 3 +-- .../java/dhyces/trimmed/TrimmedClient.java | 14 +++++----- .../trimmed/impl/network/Networking.java | 23 ---------------- .../impl/network/packets/SyncMapsPacket.java | 21 --------------- .../network/handler/PacketConsumer.java | 27 +++++++++---------- Fabric/build.gradle | 2 -- Forge/build.gradle | 5 ---- 8 files changed, 20 insertions(+), 77 deletions(-) delete mode 100644 Common/src/main/java/dhyces/trimmed/impl/network/Networking.java delete mode 100644 Common/src/main/java/dhyces/trimmed/impl/network/packets/SyncMapsPacket.java diff --git a/Common/build.gradle b/Common/build.gradle index 43219259..404b9693 100644 --- a/Common/build.gradle +++ b/Common/build.gradle @@ -20,8 +20,6 @@ dependencies { modCompileOnly("org.quiltmc:quilt-loader:${quilt_loader_version}") - implementation 'mysticdrew:common-networking-common:1.0.1-1.20.1' - implementation("com.github.llamalad7.mixinextras:mixinextras-common:0.2.0-beta.9") annotationProcessor("com.github.llamalad7.mixinextras:mixinextras-common:0.2.0-beta.9") diff --git a/Common/src/main/java/dhyces/trimmed/Trimmed.java b/Common/src/main/java/dhyces/trimmed/Trimmed.java index ff70e448..6c31268e 100644 --- a/Common/src/main/java/dhyces/trimmed/Trimmed.java +++ b/Common/src/main/java/dhyces/trimmed/Trimmed.java @@ -1,6 +1,5 @@ package dhyces.trimmed; -import dhyces.trimmed.impl.network.Networking; import dhyces.trimmed.modhelper.services.Services; import net.minecraft.resources.ResourceLocation; import org.slf4j.Logger; @@ -15,7 +14,7 @@ public static ResourceLocation id(String id) { public static final Logger LOGGER = LoggerFactory.getLogger("Trimmed"); public static void init() { - Networking.init(); +// Networking.init(); } public static void logInDev(String str) { diff --git a/Common/src/main/java/dhyces/trimmed/TrimmedClient.java b/Common/src/main/java/dhyces/trimmed/TrimmedClient.java index 52fdd761..503269e1 100644 --- a/Common/src/main/java/dhyces/trimmed/TrimmedClient.java +++ b/Common/src/main/java/dhyces/trimmed/TrimmedClient.java @@ -7,9 +7,7 @@ import dhyces.trimmed.impl.client.models.template.ModelTemplateManager; import dhyces.trimmed.impl.client.tags.manager.ClientTagManager; import dhyces.trimmed.impl.mixin.client.ReloadableResourceManagerImplAccessor; -import dhyces.trimmed.impl.network.Networking; -import dhyces.trimmed.modhelper.network.handler.SimplePacketHandler; -import net.minecraft.Util; +//import dhyces.trimmed.impl.network.Networking; import net.minecraft.client.Minecraft; import net.minecraft.client.resources.model.ModelResourceLocation; import net.minecraft.core.RegistryAccess; @@ -20,11 +18,11 @@ public class TrimmedClient { - public static final SimplePacketHandler CLIENT_HANDLER = Util.make(new SimplePacketHandler(), handler -> { - handler.registerPacketConsumer(Networking.SYNC_MAPS, context -> { - Minecraft.getInstance().player.displayClientMessage(context.message().stack.getDisplayName(), false); - }); - }); +// public static final SimplePacketHandler CLIENT_HANDLER = Util.make(new SimplePacketHandler(), handler -> { +// handler.registerPacketConsumer(Networking.SYNC_MAPS, context -> { +// Minecraft.getInstance().player.displayClientMessage(context.message().stack.getDisplayName(), false); +// }); +// }); public static void init() { TrimmedSpriteSourceTypes.bootstrap(); diff --git a/Common/src/main/java/dhyces/trimmed/impl/network/Networking.java b/Common/src/main/java/dhyces/trimmed/impl/network/Networking.java deleted file mode 100644 index 1004106c..00000000 --- a/Common/src/main/java/dhyces/trimmed/impl/network/Networking.java +++ /dev/null @@ -1,23 +0,0 @@ -package dhyces.trimmed.impl.network; - -import commonnetwork.api.Network; -import commonnetwork.networking.data.PacketContext; -import dhyces.trimmed.Trimmed; -import dhyces.trimmed.TrimmedClient; -import dhyces.trimmed.impl.network.packets.SyncMapsPacket; -import dhyces.trimmed.modhelper.network.packet.CommonPacket; - -import java.util.function.Consumer; - -public class Networking { - - public static final CommonPacket.Type SYNC_MAPS = new CommonPacket.Type<>(SyncMapsPacket.class, Trimmed.id("sync_maps"), SyncMapsPacket::new); - - public static void init() { - registerPacket(SYNC_MAPS, packet -> TrimmedClient.CLIENT_HANDLER.getPacketConsumer(SYNC_MAPS).handle(packet)); - } - - private static > void registerPacket(CommonPacket.Type type, Consumer> packetHandler) { - Network.registerPacket(type.id(), type.clazzType(), CommonPacket::writeTo, type.factory(), packetHandler); - } -} diff --git a/Common/src/main/java/dhyces/trimmed/impl/network/packets/SyncMapsPacket.java b/Common/src/main/java/dhyces/trimmed/impl/network/packets/SyncMapsPacket.java deleted file mode 100644 index 82633a2b..00000000 --- a/Common/src/main/java/dhyces/trimmed/impl/network/packets/SyncMapsPacket.java +++ /dev/null @@ -1,21 +0,0 @@ -package dhyces.trimmed.impl.network.packets; - -import dhyces.trimmed.impl.network.Networking; -import dhyces.trimmed.modhelper.network.packet.SimplePacket; -import net.minecraft.network.FriendlyByteBuf; -import net.minecraft.world.item.ItemStack; - -public class SyncMapsPacket extends SimplePacket { - - public final ItemStack stack; - - public SyncMapsPacket(FriendlyByteBuf buf) { - super(Networking.SYNC_MAPS); - this.stack = buf.readItem(); - } - - @Override - public void writeTo(FriendlyByteBuf buf) { - buf.writeItem(stack); - } -} diff --git a/Common/src/main/java/dhyces/trimmed/modhelper/network/handler/PacketConsumer.java b/Common/src/main/java/dhyces/trimmed/modhelper/network/handler/PacketConsumer.java index cda184a1..3244bc91 100644 --- a/Common/src/main/java/dhyces/trimmed/modhelper/network/handler/PacketConsumer.java +++ b/Common/src/main/java/dhyces/trimmed/modhelper/network/handler/PacketConsumer.java @@ -1,22 +1,21 @@ package dhyces.trimmed.modhelper.network.handler; -import commonnetwork.networking.data.PacketContext; import dhyces.trimmed.modhelper.network.packet.CommonPacket; -@FunctionalInterface +//@FunctionalInterface public interface PacketConsumer { - > void handle(PacketContext context); - +// > void handle(PacketContext context); +// interface Typed> extends PacketConsumer { - @Override - default > void handle(PacketContext context) { - handleTyped(cast(context)); - } - - private T cast(Object o) { - return (T) o; - } - - void handleTyped(PacketContext context); +// @Override +// default > void handle(PacketContext context) { +// handleTyped(cast(context)); +// } +// +// private T cast(Object o) { +// return (T) o; +// } +// +// void handleTyped(PacketContext context); } } diff --git a/Fabric/build.gradle b/Fabric/build.gradle index 1e0fd9fd..50a1d480 100644 --- a/Fabric/build.gradle +++ b/Fabric/build.gradle @@ -49,8 +49,6 @@ dependencies { exclude module: "fabric-models-v0" } - include(modImplementation 'mysticdrew:common-networking-fabric:1.0.1-1.20.1') - include(implementation(annotationProcessor("com.github.llamalad7.mixinextras:mixinextras-fabric:0.2.0-beta.9"))) implementation project(path: ":Common", configuration: "namedElements") diff --git a/Forge/build.gradle b/Forge/build.gradle index 1b887bee..58daffcd 100644 --- a/Forge/build.gradle +++ b/Forge/build.gradle @@ -79,11 +79,6 @@ repositories { dependencies { minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}" - implementation fg.deobf('mysticdrew:common-networking-forge:1.0.1-1.20.1') - jarJar('mysticdrew:common-networking-forge:1.0.1-1.20.1') { - jarJar.ranged(it, "[1.0.0,2.0.0)") - } - implementation(annotationProcessor("com.github.llamalad7.mixinextras:mixinextras-common:0.2.0-beta.9")) implementation(jarJar("com.github.llamalad7.mixinextras:mixinextras-forge:0.2.0-beta.9")) { jarJar.ranged(it, "[0.2.0-beta.9,)")