NBT-API

NBT-API

98.9k Downloads

[Question & Suggestion] Trouble modifying blocks

michiexe opened this issue ยท 9 comments

commented

Context:

So, I am trying to use this API to modify a block upon placement using the BlockPlaceEvent. I know that the API is working properly as I use it for other stuff regarding items too and it works fine there. I followed your instructions to install/shade the API into my plugin and also looked at the examples you provided, which really were helpful. Sadly, you did not provide an example how to modify blocks so I had to figure that out on my own, which is fine. I believe I am using the API correctly, but for some reason what I am trying to do does not work and yes, I have debugged the method, and it works fine, and I don't get any errors in the console. Additionally, I just tried trial and error for quite some time and nothing I tried worked (like the greyed-out code in the screenshot and delaying the operation).

TLDR: I am trying to modify blocks with the API and it does not work for me with no errors in the console.

My method for reference:

Image:
image

Code:
https://pastebin.com/fHWmqALK

Question:

Did I do something wrong? Am I missing something, or is the API not working properly in my use case?

Suggestion:

You could add an example for modifying NBT-data of blocks.

Side note:

I am basically trying to make a plugin which allows me to use the Shulker+ mod, used by HermitCraft, on a Paper/Spigot server as the mod only needs the right NBT-tags on the items/blocks to work.

Help would be much appreciated and if it's a bug in the API I would like to help resolve that issue. If more information is needed or anything else just contact me.

commented

A few things: Changing the id of the shulker blockentity to chest wont work(at best be ignored, at worst corrupt stuff).
And setting the Display tag to an apple item won't work because Shulkers BlockEntities don't have a display tag. The Shulker+ mod probably adds custom tags to the blockentity, which is not possible in spigot(there is the persistent data container, but that's probably in the wrong location on the nbt for the mod). If you want to send custom nbt data on the blockentity nbt, you'll have to inject that with protocol lib probably.

commented

Well, I don't really need to change the block id, that was just a test, but it's good to know that won't work and that I shouldn't try something like this.

Regarding the Display Tag, this works with the /data command in vanilla as I tested it, and it actually is not added as a custom tag. Iskall85 also made a video about the mod, explaining that the mod does not use custom NBT-tags and only makes use of preexisting tags found in vanilla Minecraft.

I will definitely look into protocol lib, thanks for the suggestion.

Also, thank you for answering so quickly!

Edit: Well, it seems I was mistaken, on a completely vanilla server it does not work to add the required Display tag to the block, so I don't think that's possible.

commented

grafik
Display is not a vanilla tag, so the shulker just discards it. You will have to inject the tag via protocol lib when the blockentity gets sent. Not 100% sure, but you can save the display tag data in the persistent data container, and then in protocol lib when the packet gets sent to the client move it to the location where clients with the mod will expect it.

commented

Another option: contact Iskal/his team about the option to also read the tag from the persistent data container tag(not 100% sure this gets sent to the client, possible spigot/paper filters it).

commented

Another option: contact Iskal/his team about the option to also read the tag from the persistent data container tag(not 100% sure this gets sent to the client, possible spigot/paper filters it).

Well, I first thought that's what they did, but no they sadly did not add support for the persistent data container, if that were the case the plugin would be done by now as the persistent data container is so easy to use.

Regarding contacting him/his team, I really do not think I really can contact him directly as he is a really big YouTuber and my messages would probably get lost. His team on the other hand, I might be able to get a hold of. I would even like to work with them and provide the Plugin for public use, so everybody can use the mod, regardless of which server type they use.

But hey man, thank you so much for trying to help me, I really appreciate it!

commented

grafik
Display is not a vanilla tag, so the shulker just discards it. You will have to inject the tag via protocol lib when the blockentity gets sent. Not 100% sure, but you can save the display tag data in the persistent data container, and then in protocol lib when the packet gets sent to the client move it to the location where clients with the mod will expect it.

Well yes that's what I would have done but I just can't work with ProtocolLib. I don't really understand which packets and stuff i have to use/alter to achieve this. I tried to use it in the past but I just get lost and don't know what to do at some point in the process. Also tried nms stuff but I just can't wrap my head around how to use it.

commented

I develop ItemSwapper with Xisuma, so I could try to get their attention.

commented

Oh wow, I just watched the video on that mod yesterday, that's crazy! Well, if you somehow could contact them that would be amazing. Well, let me know if you need any more information or if you heard back from them.

Also, I just joined your discord server, if you need to contact me you can just add me from there (discord tag: michi_exe)

commented

I did message him back then, no clue if the message made it through^^. But as this is nothing that nbtapi can directly do anymore, going to close the issue.