Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 06/06/18 in all areas

  1. I think it works like this. For your capability since on server you need NBT to save / load, you should have the Capability.IStorage methods for readNBT() and writeNBT() implemented which can be accessed through convenience methods Capability#readNBT() and Capability#writeNBT(). And on server you can get the Capability with the ItemStack#getCapability() method. Lastly, the Item class has the getShareTag() and getNBTShareTag() methods to allow you to add NBT data to the packets that are used to sync to client. Putting it together, I think you want to do the following: Make sure your custom Capability IStorage properly implements a readNBT() and writeNBT() method. In your custom Item class make sure that the getShareTag() returns true and that the getNBTShareTag() method adds the cability NBT (which you can get from Capability#writeNBT()). IMPORTANT: You will want to specify some sort of key that you can use on client side to extract the data. In your client rendering or wherever, you use look in the ItemStack NBT for the key that you specified in Step 2 above. You should not need to actually get that NBT info into the client Capability, I think you can just use it directly from the NBT. Note that to make it simpler you don't have to transmit the whole Capability NBT, if you just want a simple piece of data you could just transmit that instead. In any case, the key is the getNBTShareTag() and you just have to look up the data from the capability and come up with (there is some flexibility here) a NBT element to add that you can inspect on the client side. One other thing, it isn't clear to me whether changes in Capability will trigger an ItemStack update packet or not. There have been various PRs over the years discussing this. My point is you may want to force the update by sending the vanilla packet when your Capability changes. Lastly, I find that working with NBT is technically simple but easy to get confused in the details because the compounds can get complex due to the fact they can be nested -- you can have a list of compound, a compound with lists, and so forth. So I highly recommend using console print statements throughout your code to print out the tag information at critical points so you can trace what is going on.
    2 points
  2. 1.7.10 is no longer supported on this forum. If you are part of the TEALS-K12 team I found through a quick google search I highly suggest the project be updated for a more recent version of Minecraft.
    1 point
  3. User was suspended for 7 days for being an ass twards someone who was trying to help him.
    1 point
×
×
  • Create New...

Important Information

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