Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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.

  • 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

  • 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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.