Jump to content
  • Home
  • Files
  • Docs
Topics
  • All Content

  • This Topic
  • This Forum

  • Advanced Search
  • Existing user? Sign In  

    Sign In



    • Not recommended on shared computers


    • Forgot your password?

  • Sign Up
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • [1.9.4] Strange issue with capabilities
Currently Supported: 1.16.X (Latest) and 1.15.X (LTS)
Sign in to follow this  
Followers 0
P3pp3rF1y

[1.9.4] Strange issue with capabilities

By P3pp3rF1y, June 7, 2016 in Modder Support

  • Reply to this topic
  • Start new topic

Recommended Posts

P3pp3rF1y    3

P3pp3rF1y

P3pp3rF1y    3

  • Tree Puncher
  • P3pp3rF1y
  • Forge Modder
  • 3
  • 18 posts
Posted June 7, 2016

I have a very strange issue with capabilities losing their state on client side when connected to dedicated server. They basically default to the default value that's set when they are initialized for the given ItemStack. However what's even more strange is the fact that if I put breakpoint in to check for the default value and it stops there when I try to retrieve the capabilities again (ItemStack.capabilities) they have the correct state (not the default one that it just evaluated to in breakpoint)

 

I was trying to debug the issue and stopped when I was in EntityPlayer onUpdate (looking at itemstack.capabilities):

       
if (!ItemStack.areItemStacksEqual(this.itemStackMainHand, itemstack))
        {
            if (!ItemStack.areItemsEqualIgnoreDurability(this.itemStackMainHand, itemstack))
            {
                this.resetCooldown();
            }

            this.itemStackMainHand = itemstack == null ? null : itemstack.copy();
        }

 

It's always the same - breakpoint set to stop on default value which it does and even if I have watches set to show me the capabilities value they would show the default, but the moment I start editing them and just hit enter they would show the correct state.

 

It almost seems as if there was some async call happening which wouldn't be done when the caps are queried by breakpoint, but is done immediately after. But I don't believe there is anything like that in there.

 

Any thoughts on what could be causing this?

 

The primary issue that I have with this is that I use the caps to store charge of staff of flight (Rending Gale) and thus it needs to understand client side if there is a charge and player can still fly. However as it stands it breaks mid air quite a bit.

The same code doesn't seem to have any issues in 1.9 so I suspect some 1.9.4 change.

  • Quote

Share this post


Link to post
Share on other sites

P3pp3rF1y    3

P3pp3rF1y

P3pp3rF1y    3

  • Tree Puncher
  • P3pp3rF1y
  • Forge Modder
  • 3
  • 18 posts
Posted June 8, 2016

So I have figured out what's going on here.

 

Basically it relates to packets and a recent forge change. When I start using the flight stuff capabilities get modified and because there was a change to forge which made capabilities part of ItemStack.areItemStackTagsEqual comparison it figures out that stacks are different. https://github.com/MinecraftForge/MinecraftForge/commit/9df1e4b11e0d2d0fbf938cedae2da130d40cca89

 

Which then triggers SPacketSetSlot to be sent to client, which would be ok if this actually included capabilities. However that is not the case and it only syncs stackTagCompound. Which means that deserialized itemstack on client gets capabilities set to default value.

 

I have my own packet that syncs the capability I need, however packets based on what I have seen seem to be treated async, which means that I am not guaranteed that the capability value gets synced before client starts using it. Thus client a lot of the times suddenly sees 0 in the Staff's charge and stops flying.

 

Now the question is what should be the solution here.

Should forge make a change and sync capabilities in SetStackInSlot given that it uses capability value to see if the packet needs to be sent?

Or should it start ignoring capability comparison in this case again to avoid sending slots that delete capability data on client?

 

Or is the solution really for my case to save capability data on player to avoid this issue? That would seem like an awkward one to me, but at the moment seems like the only solution on the mod side apart from reverting to looking at just charge at the start minus ItemUseDuration and approximating how much charge is still remaining.

  • Quote

Share this post


Link to post
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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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.

    • Insert image from URL
×
  • Desktop
  • Tablet
  • Phone
Sign in to follow this  
Followers 0
Go To Topic Listing



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • ChampionAsh5357
      [1.16.5] Properly using DistExecutor with arguments

      By ChampionAsh5357 · Posted 13 minutes ago

      From what I understand, this is not the correct way to use DistExecutor. For the case where you can't supply a runnable or supplier, DistExecutor#unsafe* should be used instead. This will supply a runnable of what you want to execute (e.g. () -> () -> //Do things). This does not verify nor guarantee that the code is completely safe to access; however, if the runnable executes another method that is isolated in a different class, it is 'safe' since classloading will not occur. So, the proper way to implement the code above is DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> ClientScreenManager#openScreen).
    • diesieben07
      have an error when trying to connect to LAN server with mods

      By diesieben07 · Posted 19 minutes ago

      I guess talk to the Biomes O Plenty people then. This should not be happening if the mod is properly made.
    • Nitrix
      Forge dont want make any profile

      By Nitrix · Posted 22 minutes ago

      Who to have that you cant play minecraft with forge cuz you dont have profile on minecraft launcher? I installed forge 30 times and nothing go    minecraft 1.16.4
    • Choonster
      [1.16.5] Properly using DistExecutor with arguments

      By Choonster · Posted 52 minutes ago

      I have a packet that's sent to the client to open a GUI, which I'm using DistExecutor to do.   The packet's handler method does the following: DistExecutor.safeRunWhenOn(Dist.CLIENT, () -> ClientOnlyNetworkMethods.openClientScreen(message))   ClientOnlyNetworkMethods.openClientScreen currently looks like this: public static DistExecutor.SafeRunnable openClientScreen(final OpenClientScreenMessage message) { return new DistExecutor.SafeRunnable() { @Override public void run() { ClientScreenManager.openScreen(message.getId(), message.getAdditionalData(), Minecraft.getInstance()); } }; }   ClientScreenManager is a client-only class that handles opening the GUI.   As you can see from the code, I need to pass arguments from the packet to the client-only method; which rules out using a method reference as the SafeRunnable implementation.   When I replace the anonymous class implementation of SafeRunnable in ClientOnlyNetworkMethods.openClientScreen with a lambda, DistExecutor.validateSafeReferent throws an "Unsafe Referent usage found in safe referent method" exception. From what I can see, using any non-lambda implementation of SafeReferent simply bypasses the safety checks in validateSafeReferent but doesn't necessarily mean that the code is safe.   The current code with the anonymous class does seem to work on the dedicated server, but is this the correct way to use DistExecutor; or is there a better way to do it?
    • F0RZera
      have an error when trying to connect to LAN server with mods

      By F0RZera · Posted 1 hour ago

      Sorry that I am late, wasn't at home. This one is an attempt to join that I made right now.   debug.log
  • Topics

    • Choonster
      1
      [1.16.5] Properly using DistExecutor with arguments

      By Choonster
      Started 52 minutes ago

    • F0RZera
      9
      have an error when trying to connect to LAN server with mods

      By F0RZera
      Started 4 hours ago

    • Nitrix
      0
      Forge dont want make any profile

      By Nitrix
      Started 22 minutes ago

    • BobbyLikesCake
      8
      1.16.4 Modded not loading singleplayer worlds

      By BobbyLikesCake
      Started 2 hours ago

    • cadbane86140
      0
      Minecraft 1.17 Snapshot 21w03a Showcase!

      By cadbane86140
      Started 1 hour ago

  • Who's Online (See full list)

    • GTAGhostly
    • iHamster
    • Fake_Name131
    • F0RZera
    • st4s1k
    • monkeysHK
    • AzizD
    • Chumbanotz
    • P0SCH1T0
    • loordgek
    • vemerion
    • TurtlesAreHot
    • Aliendestoryer2
    • diesieben07
    • BobbyLikesCake
    • ChampionAsh5357
    • TanManChan
    • squidlex
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • [1.9.4] Strange issue with capabilities
  • Theme

Copyright © 2019 ForgeDevelopment LLC · Ads by Longitude Ads LLC Powered by Invision Community