Jump to content

[1.14.4] [Solved] Trouble With Packets


Recommended Posts

I wasn't able to get my item sync using shareTags, so I decided to use packets. However I have not used packets before and I am finding their implementation a little tricky. The lack of mods running forge 1.14 makes it hard to find examples related to specific things you want to do so I am asking for help here.
I want to sync my item capability to the client, because I am using a part of the data stored in that capability to render the durability bar.
I followed the docs instructions for my packet implementation, but the data in the client is still not synced with the server. What have I done wrong here?

Packet Handler Class

Packet Class

Item Class


Thank you in advance.

Edited by Cerandior
Link to comment
Share on other sites

13 minutes ago, diesieben07 said:

There is no way to sync ItemStack data using custom packets. ItemStacks are written do various packets and your data needs to be included in all of them.

The share tag is the only way to include data here.


I can't get the shareTags working, no idea why they don't work. If there is really no way I can fix that, then maybe I can use GUI to inform the player of the item cooldown.

Can I render a UI element on the client using server data? I was thinking about rendering a [ Cooldown : (cooldown) ] text above the slots, but I still need the correct cooldown values from the item capability for that to work.

Edited by Cerandior
Link to comment
Share on other sites

4 minutes ago, diesieben07 said:

You cannot possibly control all GUIs that show ItemStacks.

How about sending a chat message to the player when he activates the item to tell him when the item is in cooldown?. It is the ugliest way of doing this, but if nothing else works, to hell with it.

Link to comment
Share on other sites

20 minutes ago, diesieben07 said:

The share tag should work. If it does not work for you, you need to debug why.

Ok, I did something and it now worked. I looked carefully into it and apparently the stack.hasTag() was returning false for my item. So whenever I Use the item, if the stack's tag is null, I set its tag to readShareTag(itemstack).
Basically I am treating the readShareTag as a normal method since it wasn't being updated automatically. It is working now, the client and the server data is synced.

This is what I did:

public ActionResult<ItemStack> onItemRightClick(World worldIn, PlayerEntity playerIn, Hand handIn) {
    ItemStack stack = playerIn.getHeldItem(handIn);
    ICoolDownItem cap = stack.getCapability(CapabilityRegistry.COOLDOWN_ITEM, null).orElse(null);

    if(stack.getTag() == null){

    if(!worldIn.isRemote && cap.isOffCooldown()){
        if(hasHeads(playerIn) || playerIn.abilities.isCreativeMode){
            Random rn = new Random(20);
            StaffZombie zm = new StaffZombie(worldIn, playerIn);
            zm.setPosition(playerIn.posX + rn.nextDouble() * 2, playerIn.posY, playerIn.posZ + rn.nextDouble() * 2);
            zm.setItemStackToSlot(EquipmentSlotType.HEAD, new ItemStack(Items.GOLDEN_HELMET));
            for(int i = 0; i<36; i++){
                if(playerIn.inventory.getStackInSlot(i).getItem() == Items.ZOMBIE_HEAD && !playerIn.abilities.isCreativeMode){
            return new ActionResult<>(ActionResultType.SUCCESS, playerIn.getHeldItem(handIn));
    return new ActionResult<>(ActionResultType.FAIL, playerIn.getHeldItem(handIn));


One slight worry that I have right now is a warning showing up on the console:

[Client thread/WARN] [minecraft/ClientPlayNetHandler]: Received passengers for unknown entity

Why is that happening?

Link to comment
Share on other sites

36 minutes ago, diesieben07 said:

This makes no sense.

And getShareTag / readShareTag are still called all the time. No matter what. Look at the code. PacketBuffer#writeItemStack literally always calls getShareTag.

There is no reason why hasTag being false will cause getShareTag or readShareTag to no longer be called.


Show your entity code and where you register it.



I have no idea man. I tried setting the breakpoints at different parts of the class because intelliJ displays a tree of all the methods called at that point and I never found any of the shareTags methods where I expected them to be. And I know, what I did doesn't really make too much sense because the stack should call the readShareTag and getShareTag automatically (I did look into a lot of methods related to itemstacks), but for some reason nothing was working as expected for me. I just tried that and everything works fine now, if I get rid of that line of code nothing works again.


As for the entity, that is probably caused by the "unique" type of zombie that my staff spawns. I forgot to register that in my registry events. I am surprised the entity was spawning considering I haven't registered them actually. I will register them right now, and check if the error will persist.

Thank you for your help.

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.

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.

  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • We need the crash report or debug.log, as explained in the FAQ
    • i have the decocraft mod and i can see all of them. i can click right click and place the items but as soon as i put it down it disappears. im so sad it doesnt work and i dont know how to fix it. i used cursed forge to launch minecraft as well.
    • Me and my friend wanted to make a custom mod pack hosted on aternos. I downloaded the same mods as the server then started the server and my minecraft and I joined the server without issues. Then I sent the mods to my friend compressed in a zip folder (i don’t know if that has anything to do with the issue). He unpacked it put it in his mod folder and started it but couldn't join the server and got this issue:   internal exception: java.lang.runtimeexception: server not initialized yet! call IMDLib.entityHandler (modid)   Also we are using curseforge launcher to manage the mods on client side. But as I said it works on my side but not with my friend, that’s why it doesn’t make sense   Mod list:   xplosives-1.2.0.jar whisperwoods-1.18.2-2.1.0-forge.jar waystones-forge-1.18.2-10.2.2.jar voicechat-forge-1.18.2-2.4.32.jar trashslot-forge-1.18.2-11.0.3.jar towns_and_towers_forge- torchmaster-18.2.1.jar ToolBelt-1.18.2-1.18.9.jar toms_storage-1.18.2-1.4.4.jar swingthroughgrass-1.18.2-1.9.1.jar strictly_origins_v5.1_1.18.2.jar starlight-1.0.2+forge.546ae87.jar SpartanWeaponry-1.18.2-3.0.4.jar SimpleQuarry-1.18.2-18.2.5.jar simpleplanes-1.18.2-5.2.2.jar secretrooms-1.18.2-1.1.5.jar right-click-harvest-3.2.0+1.18.2-forge.jar REIPluginCompatibilities-forge-8.0.89.jar RoughlyEnough|tems-8.3.681-forge.jar RegionsUnexploredForge-0.4.1_1+1.18.2.jar TerraBlender-forge-1.18.2- Recall_Potion_v1.0.3-1.18.2.jar Quark-3.2-358.jar PickleTweaks-1.18.2-6.1.2.jar Pehkui-3.7.11+1.18.2-forge.jar Origins-1.18.2- naturalist-forge-1.1.1-1.18.2.jar mysticaloaktree-1.18.2-1.2.jar selene-1.18.2-1.17.14.jar MysticalAgradditions-1.18.2-5.1.4.jar MysticalAgriculture-1.18.2-5.1.5.jar MultiMine-1.18.7.jar moyai-1.18.2-1.1.4.jar ModernDynamicSurroundings- lootbeams-1.18.1-release-july1722.jar journeymap-1.18.2-5.9.7-forge.jar ironfurnaces-1.18.2-3.3.3.jar ironchest-1.18.2-13.2.11.jar industrial-foregoing-1.18.2- titanium-1.18.2-3.5.11-45.jar immersive_armors-1.5.6+1.18.2-forge.jar hardcorerevival-forge-1.18.2-8.0.1.jar HammerLib-1.18.2-18.2.16. jar gravestone-1.18.2-1.0.1.jar geckolib-forge-1.18-3.0.57.jar findme-3.0.6-forge.jar faithfulbackrooms3.0.0.7.jar elevatorid-1.18.2-1.8.4.jar EasyMagic-v3.3.0-1.18.2-Forge.jar PuzzlesLib-v3.5.9-1.18.2-Forge.jar easy_villagers-1.18.2-1.0.11.jar easy_mob_farm_1.18.2-7.1.0.jar DynamicTrees-1.18.2-1.0.4.jar dragonseeker-1.1.1-1.18.2.jar iceandfire-2.1.12-1.18.2.jar Cucumber-1.18.2-5.1.5 jar cloth-config-6.5.116-forge.jar citadel-1.11.3-1.18.2.jar chunkloaders-1.2.8a-forge-mc1.18.jar supermartijn642configlib-1.1.8-forge-mc1.18.jar supermartijn642corelib-1.1.17-forge-mc1.18.jar cave_dweller-1.18.2-1.6.4.jar carryon-1.18.2- caelus-forge-1.18.1- BotanyTrees-Forge-1.18.2-4.0.13.jar BotanyPots-Forge-1.18.2-8.1.29.jar Bookshelf-Forge-1.18.2-13.3.56.jar balm-3.2.6.jar AutoRegLib-1.7-53.jar ars_nouveau-1.18.2-2.9.0.jar curios-forge-1.18.2- Patchouli-1.18.2-71.1.jar architectury-4.12.94-forge.jar almostunified-forge-1.18.2-0.3.10.jar [1.18.2] SecurityCraft v1.9.8.jar
    • Thank you for trying, I really appreciate it
  • Topics

  • Create New...

Important Information

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