From f5d35697f524cda1736740e739f8afd902651c53 Mon Sep 17 00:00:00 2001 From: Anthony Hilyard Date: Sat, 4 Dec 2021 21:27:28 -0800 Subject: Initial 1.18 port. Overhauled tooltip handling, added color code item color support. --- .../iceberg/network/IcebergNetworkProtocol.java | 30 --------------- .../iceberg/network/NewItemPickupEventPacket.java | 45 ---------------------- 2 files changed, 75 deletions(-) delete mode 100644 src/main/java/com/anthonyhilyard/iceberg/network/IcebergNetworkProtocol.java delete mode 100644 src/main/java/com/anthonyhilyard/iceberg/network/NewItemPickupEventPacket.java (limited to 'src/main/java/com/anthonyhilyard/iceberg/network') diff --git a/src/main/java/com/anthonyhilyard/iceberg/network/IcebergNetworkProtocol.java b/src/main/java/com/anthonyhilyard/iceberg/network/IcebergNetworkProtocol.java deleted file mode 100644 index 4b5db06..0000000 --- a/src/main/java/com/anthonyhilyard/iceberg/network/IcebergNetworkProtocol.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.anthonyhilyard.iceberg.network; - -import com.anthonyhilyard.iceberg.Loader; - -import net.minecraft.resources.ResourceLocation; -import net.minecraftforge.fmllegacy.network.NetworkRegistry; -import net.minecraftforge.fmllegacy.network.simple.SimpleChannel; - -public class IcebergNetworkProtocol -{ - private static final String NETWORK_PROTOCOL_VERSION = "1"; - - public static final SimpleChannel CHANNEL = NetworkRegistry.newSimpleChannel( - new ResourceLocation(Loader.MODID, "main"), () -> NETWORK_PROTOCOL_VERSION, - NETWORK_PROTOCOL_VERSION::equals, NETWORK_PROTOCOL_VERSION::equals - ); - - public static final void register() - { - int messageID = 0; - - CHANNEL.registerMessage( - messageID++, - NewItemPickupEventPacket.class, - NewItemPickupEventPacket::encode, - NewItemPickupEventPacket::decode, - NewItemPickupEventPacket::handle - ); - } -} diff --git a/src/main/java/com/anthonyhilyard/iceberg/network/NewItemPickupEventPacket.java b/src/main/java/com/anthonyhilyard/iceberg/network/NewItemPickupEventPacket.java deleted file mode 100644 index b99a36d..0000000 --- a/src/main/java/com/anthonyhilyard/iceberg/network/NewItemPickupEventPacket.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.anthonyhilyard.iceberg.network; - -import net.minecraft.world.item.ItemStack; -import net.minecraft.network.FriendlyByteBuf; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.fmllegacy.network.NetworkEvent; - -import java.util.UUID; -import java.util.function.Supplier; - -import com.anthonyhilyard.iceberg.events.NewItemPickupEvent; - - -public final class NewItemPickupEventPacket -{ - private final UUID playerUUID; - private final ItemStack item; - - public NewItemPickupEventPacket(final UUID playerUUID, final ItemStack item) - { - this.playerUUID = playerUUID; - this.item = item; - } - - public static void encode(final NewItemPickupEventPacket msg, final FriendlyByteBuf packetBuffer) - { - packetBuffer.writeUUID(msg.playerUUID); - packetBuffer.writeItem(msg.item); - } - - public static NewItemPickupEventPacket decode(final FriendlyByteBuf packetBuffer) - { - return new NewItemPickupEventPacket(packetBuffer.readUUID(), packetBuffer.readItem()); - } - - public static void handle(final NewItemPickupEventPacket msg, final Supplier contextSupplier) - { - final NetworkEvent.Context context = contextSupplier.get(); - context.enqueueWork(() -> { - MinecraftForge.EVENT_BUS.post(new NewItemPickupEvent(msg.playerUUID, msg.item)); - }); - context.setPacketHandled(true); - } - -} \ No newline at end of file -- cgit