Jump to content

Recommended Posts

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.

Posted

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

 

Posted

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.

Posted

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.

Posted
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?

Posted

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.

Posted

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

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 5

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

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

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Also check the worldsave / serverconfig folder If there is no such file, make a test without this mod  
    • Hi, I've been having trouble trying to use forge as it shows a black screen when I open the game, but I can still interact with it and hear the music.  I've done all of the step by steps and most common fixes like updating drivers, keeping up to date with Java, deleting and reinstalling minecraft, restarting my computer MANY times, even smaller things like splash.properties (I didn't have that file so I added it and set it to false thinking it would do something, definitely not) and making sure to prioritize my rtx 3070 in the settings but with no luck. Minecraft works as intended when I uninstall forge and I also don't have any mods currently, it just gives me this issue when I install forge. I also increased the ram usage, made sure my hardware isn't full or anything, and even changed the resolution in hopes it would fix things. I checked my antivirus and firewall but that isn't the issue either. Trust me, I've done everything I can think of. For some reason the black screen does flicker a little into the main menu, but obviously unplayable. I couldn't even make my way to the settings with how little it flickered. I'm not sure if it flickered randomly or if it was because I was messing around moving and clicking a bunch, I didn't really test it that much.  
    • I've had a really weird issue recently,  I wanted to add the Depper and Darker mod on my dedicated server (MC 1.21 with Fabric 0.16.9, hosted on nitroserv.com) but whenever I do add the mod the sever stops doing anything after listing the mods, and I get no crash or error or anything, just a stuck server. Here's a normal log of the server booting up: https://pastebin.com/JipFF2Eh and here's the log of the server doing the weird thing: https://pastebin.com/W4JBh3eX I just don't understand it. I've tried removing other mods (somewhat randomly) but deeper and darker still breaks my server whenever I add it. NitroServ support staff is about as confused as I am and I've had no response from the Deeper and Darker support staff... Now I know this is the Forge support not the Fabric support but I'm just trying to know if anyone has any kind of idea to fix this (aside from not using the mod obviously) Also I still have a bunch of errors and warnings whenever the server does start properly, are there any of them I should be worried about?
  • Topics

×
×
  • Create New...

Important Information

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