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

Have at the moment two problems with my mod:

1. When I try to send a packet this message is being printed: 

[04jun2019 20:34:56.138] [Client thread/WARN] [net.minecraft.client.network.NetHandlerPlayClient/]: Unknown custom packed identifier: feuniversal:fenet

2. The new way to display a GuiContainer get stuck(no errors are being printed) at this line:

BlockPos pos = openCon.getAdditionalData().readBlockPos();

I can print to the console before the line but not after and therefore the GuiConatiner isn't returned.

  • Author

Yes, but at the moment I have just one registered:

Packet registry:

public class PacketHandlerFE {
	
	private final String PROTOCOL_VERSION = "1";
	private int ID = 0;
	private final SimpleChannel INSTANCE;
	
	public PacketHandlerFE(String channelName) {
		this.INSTANCE = NetworkRegistry.newSimpleChannel(new ResourceLocation("feuniversal", channelName),
			    () -> PROTOCOL_VERSION,
			    PROTOCOL_VERSION::equals,
			    PROTOCOL_VERSION::equals);
	}
	
	public SimpleChannel getSimpleChannel()
	{
		return this.INSTANCE;
	}
	
	public void registerPackets()
	{
		this.INSTANCE.registerMessage(ID++, UpdateTileEntityS.class, UpdateTileEntityS::encode, UpdateTileEntityS::decode, UpdateTileEntityS.Handler::handle);
	}
	
	public <MSG> void sendTo(MSG msg, EntityPlayerMP player)
	{
		if (!(player instanceof FakePlayer))
		{
			this.INSTANCE.sendTo(msg, player.connection.netManager, NetworkDirection.PLAY_TO_CLIENT);
		}
	}
	
	/*public void send(PacketTarget target, Object msg)
	{
		this.INSTANCE.send(target, msg);
	}*/
	
}

and GuiHandler:

public GuiScreen openGui(FMLPlayMessages.OpenContainer openCon)
	{
		
		BlockPos pos = openCon.getAdditionalData().readBlockPos();
		World world = Minecraft.getInstance().world;
		EntityPlayer player = Minecraft.getInstance().player;
		if(guiElement.get(openCon.getId()) != null)
		{
			return new guiElement.get(openCon.getId()).openGuiContainer(player, world, pos);
		}
		else
		{
			player.sendMessage(new TextComponentTranslation("error.opengui.null"));
			return null;
		}
	}

 

  • Author

I create the PacketHandlerFE in my main mod class.

This where I open it:

@Override
	public boolean onBlockActivated(IBlockState state, World worldIn, BlockPos pos, EntityPlayer player, EnumHand hand,
			EnumFacing side, float hitX, float hitY, float hitZ) {
		if(!player.isSneaking())
		{
			if(!worldIn.isRemote)
			{
				TileEntityProducerBasicDirt tile = (TileEntityProducerBasicDirt) worldIn.getTileEntity(pos);
				NetworkHooks.openGui((EntityPlayerMP) player, new IInteractionObject() {

					@Override
					public ITextComponent getName() {
						return new TextComponentString("");
					}

					@Override
					public boolean hasCustomName() {
						return false;
					}

					@Override
					public ITextComponent getCustomName() {
						return new TextComponentString("");
					}

					@Override
					public Container createContainer(InventoryPlayer playerInventory, EntityPlayer playerIn) {
						return new DirtProducerContainer(playerIn, tile);
					}

					@Override
					public String getGuiID() {
						return FEUniversal.getInstance().dirtProducerID.toString();
					}
					
				});
			}
			else
			{
				return true;
			}
		}
		return super.onBlockActivated(state, worldIn, pos, player, hand, side, hitX, hitY, hitZ);
	}

I can see that "onBlockActivated" is deprecated but I don't what to use instead.

  • Author

The PacketHandler is just created like this: 

private PacketHandlerFE network = new PacketHandlerFE("fenet");
//The following is using that instance
  public PacketHandlerFE getNetwork()
    {
    	return this.network;
    }

//and

private void doSetup(final FMLCommonSetupEvent event)
    {
    	this.network.registerPackets();
    }

The getNetwork() getter is only being used to send packets.

And thank you for informing me, that I had to write additional GUI data. Could find so much information about the new Gui system.

  • Author
7 minutes ago, WOTBLITZ said:

The PacketHandler is just created like this:


private PacketHandlerFE network = new PacketHandlerFE("fenet");
//The following is using that instance
  public PacketHandlerFE getNetwork()
    {
    	return this.network;
    }

//and

private void doSetup(final FMLCommonSetupEvent event)
    {
    	this.network.registerPackets();
    }

The getNetwork() getter is only being used to send packets.

And thank you for informing me, that I had to write additional GUI data. Could find so much information about the new Gui system.

Should I register my SimplChannel at FMLCommonSetupEvent instead?

  • Author

I haven't changed my code apart from my GuiHandler.  The problem is that this

[04jun2019 20:34:56.138] [Client thread/WARN] [net.minecraft.client.network.NetHandlerPlayClient/]: Unknown custom packed identifier: feuniversal:fenet

is being printed whenever I try to send a packet.

  • Author

Hmm..., You really must learn how to read. First I said my main mod class then I mentioned a getter which means that I am created it on when my mod object gets init!

However, I tried to change register the channel st FMLCommonSetupEvent, no difference.

Also tried changing how I registered my channel from:

 NetworkRegistry.newSimpleChannel(new ResourceLocation("feuniversal", channelName),
			    () -> PROTOCOL_VERSION,
			    PROTOCOL_VERSION::equals,
			    PROTOCOL_VERSION::equals);

to

NetworkRegistry.ChannelBuilder
				.named(new ResourceLocation("feuniversal", channelName))
				.clientAcceptedVersions(PROTOCOL_VERSION::equals)
				.serverAcceptedVersions(PROTOCOL_VERSION::equals)
				.networkProtocolVersion(() -> PROTOCOL_VERSION)
				.simpleChannel();

and still no difference. And this was taken from two different projects at Github.

  • 5 months later...

I know this topic is a bit old, but I just had the same issue and a Google search points here.

 

If your packet is working correctly, and its just the warning in the log, you've likely made the same mistake as me.

Inside the "messageConsumer" you provided when registering your packet, you need to set the packet handled flag to true. "context.get().setPacketHandled(true);"

 

If it isn't set to true, NetworkHooks.onCustomPayload will return false, and ClientPlayNetHandler.handleCustomPayload will post the warning

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.