Posted September 18, 20196 yr I've been trying to figure out how to work with packets, but I've hit a stumbling block. In my packet handler class I get an odd issue that may be related to intellij, but I'm not sure. if it is intellij, where would be the best place to get support? if it's something to do with minecraft/forge, I could use some help. I used EnderUnknown's post about the same topic as a framework to work off of. It is incomplete as I can't really move forward until I get this part figured out. the issue is on the line near the bottom that contains: channel.registerMessage(id++, PacketSellButton.class, PacketSellButton::encode, PacketSellButton::decode, PacketSellButton::handle); this seems to be the correct way to do things. I've seen other peoples packet handlers, and they all seem to do it this way. package com.garrett.merchantcraft.network; import com.garrett.merchantcraft.network.packets.PacketSellButton; import net.minecraft.util.ResourceLocation; import net.minecraftforge.fml.network.NetworkRegistry; import net.minecraftforge.fml.network.simple.SimpleChannel; public final class MerchantcraftPacketHandler { private static final String PROTICOL_VERSION = "1"; public static SimpleChannel channel; public void register() { channel = NetworkRegistry.newSimpleChannel( new ResourceLocation("merchantcraft","main") ,() -> PROTICOL_VERSION , PROTICOL_VERSION::equals , PROTICOL_VERSION::equals); int id = 0; channel.registerMessage(id++, PacketSellButton.class, PacketSellButton::encode, PacketSellButton::decode, PacketSellButton::handle); } } The error message: here's the packet sell button class if that matters: package com.garrett.merchantcraft.network.packets; import com.google.common.base.Supplier; import net.minecraft.entity.player.ServerPlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.network.PacketBuffer; import net.minecraftforge.fml.network.NetworkEvent; public class PacketSellButton { private final ItemStack item; public PacketSellButton(ItemStack stack) { this.item = stack; } public static void encode(PacketSellButton msg, PacketBuffer buf) { buf.writeItemStack(msg.item); } public static PacketSellButton decode(PacketBuffer buf) { return new PacketSellButton(buf.readItemStack()); } public static void handle(PacketSellButton msg, Supplier<NetworkEvent.Context> ctx) { ctx.get().enqueueWork(() -> { // Work that needs to be threadsafe (most work) ServerPlayerEntity sender = ctx.get().getSender(); // the client that sent this packet // do stuff }); ctx.get().setPacketHandled(true); } } [SOLUTION] I imported imported the wrong Supplier "com.google.common.base.Supplier;" correct Supplier: java.util.function.Supplier Edited September 18, 20196 yr by andGarrett
September 18, 20196 yr 2 minutes ago, andGarrett said: import com.google.common.base.Supplier; You've imported the wrong Supplier you need java.util.function.Supplier VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator.
September 18, 20196 yr Author 1 hour ago, Animefan8888 said: You've imported the wrong Supplier you need java.util.function.Supplier You know I love you right?
September 18, 20196 yr 8 minutes ago, andGarrett said: You know I love you right? No I didn't. VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator.
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.