Posted November 26, 20213 yr I have a tile entity that is used for crafting but I don't want it to craft things every tick. To achieve this I added a button that sends a package to the server whenever it needs to do the crafting. I have no idea what I am doing wrong at this point and I cannot find the cause of the issue in the minecraft code because the exception stack does not reference any of my classes. I am relatively new to minecraft modding and java in general which also isn't very helpful. However I have done my homework and have enough knowledge to know what I actually am doing and not just blindly copy pasting code from tutorials so calling me out to learn java will not help me in any capacity. I am stuck with this problem for about a week now and this is the last place I can think of that can help me It works flawlessly in singleplayer but whenever I try to join a server with this mod installed I get an error message on my screen saying Quote Internal Exception: io.netty.handler.codec.DecoderException: io.netty.handler.codec.EncoderException: java.io.UTFDataFormatExcpetion: malformed input around byte 5 Inside Debug.log it says Quote [25Nov2021 20:17:50.906] [Render thread/FATAL] [net.minecraft.util.concurrent.ThreadTaskExecutor/]: Error executing task on Client java.util.NoSuchElementException: packet_handler I have compared my way of making the packets with multiple mods I found on curseforge most are the same way as I do it. I have asked around in multiple forge and modding related discord servers but no one was able to help me with my problem. All tutorials on youtube did the same as I did. My PacketHandler class looks like this: public static final String PROTOCOL_VERSION = "1"; public static SimpleChannel CHANNEL; public static void init() { int index =0; CHANNEL = NetworkRegistry.ChannelBuilder .named(new ResourceLocation("pepsimc","simple_network")) .clientAcceptedVersions(PROTOCOL_VERSION::equals) .serverAcceptedVersions(PROTOCOL_VERSION::equals) .networkProtocolVersion(()->PROTOCOL_VERSION) .simpleChannel(); CHANNEL.messageBuilder(ProcessingCraftPacket.class, index++, NetworkDirection.PLAY_TO_SERVER) .encoder(ProcessingCraftPacket::encode) .decoder(ProcessingCraftPacket::new) .consumer(ProcessingCraftPacket::handle) .add(); LogManager.getLogger().debug(CHANNEL); } My packet class looks like this: public final BlockPos Pos; public ProcessingCraftPacket(BlockPos Pos) { this.Pos = Pos; } public ProcessingCraftPacket(PacketBuffer buffer) { this(buffer.readBlockPos()); } public void encode(PacketBuffer buffer) { buffer.writeBlockPos(this.Pos); } public static void handle(ProcessingCraftPacket message, Supplier<NetworkEvent.Context> ctx) { ctx.get().enqueueWork(()->{ final TileEntity TE = ctx.get().getSender().level.getBlockEntity(message.Pos); if(TE instanceof ProcessingTile) { final ProcessingTile PT = (ProcessingTile) TE; PT.process(ctx.get().getSender().level); } }); ctx.get().setPacketHandled(true); } Thanks alot in advance.
November 26, 20213 yr show where you call init in your Network class, also the encode and decode should be static
November 26, 20213 yr Author Init is called from my main class like this public static void setup(FMLCommonSetupEvent event) { event.enqueueWork(()->{ PacketHandler.init(); }); } I also changed my encode and decode to static but that didn't change anything
November 28, 20213 yr Author I found the issue. Apparently it had nothing to do with my packets but with my custom recipe type. I didn't read everything from the buffer which was causing the issue.
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.