Spyeedy Posted June 26, 2020 Posted June 26, 2020 As the title says, my ItemStack's NBT tags aren't getting transferred to my Block's TileEntity NBT. This worked back on 1.12.2, so I'm not sure why it isn't working now. In the gist linked below are the Item, Block and TileEntity classes. https://gist.github.com/Spyeedy/104a892bd3970d189aaf42a10f8645d7 Thanks for responding :) Quote http://www.startrek.com/uploads/assets/articles/61c89a9d73c284bda486afaeaf01cdb27180359b.jpg[/img] Till next time. Thank you for delivering funny scenes to Star Trek as Chekov . Will always remember you
sciwhiz12 Posted June 26, 2020 Posted June 26, 2020 stack.getTag().getList("lightsPosLight", Constants.NBT.TAG_LIST).forEach(inbt -> te.addLightPos(((LongNBT)inbt).getLong())); private static final String NBT_LIGHTS_KEY = "lightsPosList"; It seems you mistyped your list tag's key. Quote
Spyeedy Posted June 27, 2020 Author Posted June 27, 2020 (edited) 10 hours ago, sciwhiz12 said: stack.getTag().getList("lightsPosLight", Constants.NBT.TAG_LIST).forEach(inbt -> te.addLightPos(((LongNBT)inbt).getLong())); private static final String NBT_LIGHTS_KEY = "lightsPosList"; It seems you mistyped your list tag's key. Well, that first line is part of a commented out block, but hmm, I ain't putting the list tag into the BlockEntityTag since I commented out the code inside Block#onBlockPlacedBy, I'll try uncommenting inside onBlockPlacedBy and fixing that typo Edited June 27, 2020 by Spyeedy Quote http://www.startrek.com/uploads/assets/articles/61c89a9d73c284bda486afaeaf01cdb27180359b.jpg[/img] Till next time. Thank you for delivering funny scenes to Star Trek as Chekov . Will always remember you
Spyeedy Posted June 27, 2020 Author Posted June 27, 2020 (edited) I've fixed that typo, and I've added a print statement in my Block's onBlockPlacedBy to look at the nbt list's size, weirdly enough, it prints out 0, even though in the item's nbt list, it has contents. As well as set the tag compound back into the ItemStack's NBT, just to be extremely sure the Item has the new NBT Updated the gist: https://gist.github.com/Spyeedy/104a892bd3970d189aaf42a10f8645d7 Edited June 27, 2020 by Spyeedy Quote http://www.startrek.com/uploads/assets/articles/61c89a9d73c284bda486afaeaf01cdb27180359b.jpg[/img] Till next time. Thank you for delivering funny scenes to Star Trek as Chekov . Will always remember you
poopoodice Posted June 27, 2020 Posted June 27, 2020 I wonder if write() is getting called? because you've override @Override public CompoundNBT serializeNBT() { CompoundNBT nbt = new CompoundNBT(); System.out.println("serialize"); return nbt; } @Override public void deserializeNBT(CompoundNBT nbt) { System.out.println("deserialize"); } and before that serializeNBT calles write(), and desrializeNBT calls read(). Not sure if it's related tho Quote
Spyeedy Posted June 27, 2020 Author Posted June 27, 2020 Possibly, but the thing is, in the onBlockPlacedBy method, I printed the stack's NBT list count, it returns 0, despite that the item does have content inside the list, hmm https://gist.github.com/Spyeedy/104a892bd3970d189aaf42a10f8645d7#file-lightswitchblock-java-L33 Quote http://www.startrek.com/uploads/assets/articles/61c89a9d73c284bda486afaeaf01cdb27180359b.jpg[/img] Till next time. Thank you for delivering funny scenes to Star Trek as Chekov . Will always remember you
Spyeedy Posted June 27, 2020 Author Posted June 27, 2020 Possibly, but the thing is, in the onBlockPlacedBy method, I printed the stack's NBT list count, it returns 0, despite that the item does have content inside the list, hmm https://gist.github.com/Spyeedy/104a892bd3970d189aaf42a10f8645d7#file-lightswitchblock-java-L33 Quote http://www.startrek.com/uploads/assets/articles/61c89a9d73c284bda486afaeaf01cdb27180359b.jpg[/img] Till next time. Thank you for delivering funny scenes to Star Trek as Chekov . Will always remember you
Spyeedy Posted June 28, 2020 Author Posted June 28, 2020 (edited) Okaaaaay, this is weird, the console prints for Render thread, so that's client, it doesn't print for server? Idk if the NBT really gets saved, because the output always come out as: Before:0 After:1 at these lines https://gist.github.com/Spyeedy/104a892bd3970d189aaf42a10f8645d7#file-lightswitchblockitem-java-L30-L33 Edited June 28, 2020 by Spyeedy Quote http://www.startrek.com/uploads/assets/articles/61c89a9d73c284bda486afaeaf01cdb27180359b.jpg[/img] Till next time. Thank you for delivering funny scenes to Star Trek as Chekov . Will always remember you
poopoodice Posted June 28, 2020 Posted June 28, 2020 (edited) try check for isSneaking instead of isCrouching because it seems like isCrouching is only being used by client Edited June 28, 2020 by poopoodice Quote
Spyeedy Posted June 28, 2020 Author Posted June 28, 2020 There's no isSneaking... only isCrouching, hence my assumption the method got renamed to isCrouching Quote http://www.startrek.com/uploads/assets/articles/61c89a9d73c284bda486afaeaf01cdb27180359b.jpg[/img] Till next time. Thank you for delivering funny scenes to Star Trek as Chekov . Will always remember you
Recommended Posts
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.