Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[1.13.2]Network warning/error and GuiConatiner problem


WOTBLITZ
 Share

Recommended Posts

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.

Link to comment
Share on other sites

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;
		}
	}

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

4 minutes ago, WOTBLITZ said:

I create the PacketHandlerFE in my main mod class.

Why do I have to ask every. thing. separately? Please show this...

 

5 minutes ago, WOTBLITZ said:

This where I open it:

You are not writing anything to the additional GUI data, yet you are trying to read a BlockPos from it when it's received. You must read and write the exact same data.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

11 hours ago, WOTBLITZ said:

First I said my main mod class

Which can mean anything.

 

11 hours ago, WOTBLITZ said:

then I mentioned a getter which means that I am created it on when my mod object gets init!

No. No it does not mean that at all. I don't think you know what a getter is.

 

11 hours ago, WOTBLITZ said:

And this was taken from two different projects at Github.

So... you have your code on Github already and you did not post that repository? Why?! in any case: Debugging this further requires actually using a debugger to see what's going on. Either do that yourself or post a working Git repository of your mod.

Link to comment
Share on other sites

  • 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

  • Thanks 4
Link to comment
Share on other sites

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
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.