Using /bq item
This is a huge bummer because I have around 900 custom textured items using the durability system and I need to use these items for quests.


This is a known issue that will be resolved once #386 is implemented :)
But at least for the unbreakable tag there is an inbuilt solution:
https://github.com/Co0sh/BetonQuest/wiki/Reference#items
unbreakable - this makes the item unbreakable. You can specify it either as unbreakable or unbreakable:true to require an item to be unbreakable. If you want to check if the item is breakable, use unbreakable:false.
So at least your textures won't be broken! 👍
Sure the textures won't be broken but you can easily 2 hit a player with the easily obtainable salt to their death without the attribute modifiers @MWFIAE
I guess it would be possible to give the items not via questitems but just execute a give command which generates the right items for the players.
Kind of a hacky solution, but thats why I created the issue #386 so one doesn't have to build some workaround.
I am using that hacky solution, but I need the plugin to TAKE items and to CHECK if the player has such items.
To be honest I don't use the questitems at all, so I might be wrong, but as far as I know it it should ignore all nbt-tags and such (with the exception of unbreakable!) and therefore even so you can't give them with betonquest it should be perfectly fine to check and take them. (Of course unless you want to check based on an nbt-tag.)
At least thats what I'm getting from the coding.
@MWFIAE The plugin would check for the wrong item and would check for the diamond sword called Salt in the first picture instead of the actual "Salt" in the second picture because the first picture is what the plugin has in the items.yml
Please show me your entry in the items.yml :)
And it would be nice to include the give command for the real item too, so that I can reproduce it on my server.
@MWFIAE Here's the entry, the /give command isn't possible since I use an automatic script to give me the NBT tags and make the item unbreakable.. so reproducing it would take a while ingame and I'm on my phone.
saltcustom: DIAMOND_SWORD data:-18 name:§fSalt lore:§aUsed_in_food_preservation_as_well_as;§amummification.
You haven't set the unbreakable argument, like I told you to do :P
@MWFIAE It doesn't matter, I need to get rid of the
" When in main hand:
1.6 Attack Speed
7 Attack damage "
otherwise the "salt" will 2 hit kill everyone and last forever.
We are talking about workarounds here, until co0sh finds the time to do ItemStack serialization on top of questitems. (and I have no clue how this should work in a proper way inside betonquest itself.)
For the give we already agreed, that you would have to use the give-command to do so.
Therefore we are just talking about taking and checking here.
And this worked fine for me to check and take, but I had to set the damage value to a positive number, for it to work.
items.yml
saltcustom: DIAMOND_SWORD data:3 name:§fSalt lore:§aUsed_in_food_preservation_as_well_as;§amummification. unbreakable:true
conditions.yml
has_salt: 'item saltcustom'
conversation.yml
NPC_options:
'start_salt':
text:
en: 'Salt'
es: 'Salt'
pl: 'Salt'
fr: 'Salt'
cn: "Salt"
de: 'Salt'
nl: 'Salt'
conditions: '!wood_started,has_salt'
pointer: 'questions,quests,bye'
command to give:
give MWFIAE minecraft:diamond_sword 1 3 {display:{Name:"§fSalt",Lore:["§aUsed in food preservation as well as","§amummification."]},Unbreakable:1,HideFlags:63,AttributeModifiers:[{AttributeName:"generic.attackDamage",Name:"generic.attackDamage",Amount:0,Operation:2,UUIDMost:91667,UUIDLeast:113721}]}
Result:

For some reason I can't get the " § " to work in minecraft.
Nonetheless, here's what the
saltcustom2: DIAMOND_SWORD data:238 name:§fSalt lore:§aUsed_in_food_preservation_as_well_as;§amummification. unbreakable:true
gives me.

and here's what I want the plugin to recognize and take.

Yeah, it's impossible to get the § to work in minecraft, I had to give me the item via console.
I can only say that checking and taking worked just fine for me with the things I wrote...
This is the item I used to test things:

Or with the advanced tooltips enabled:

If you can provide me any more informations I might be able to help you further.
Until I can reproduce it I have to assume that you don't test right or there is another error in your quests.
@MWFIAE I didn't test it via quests yet, I thought that it would refuse taking or checking for the item with the NBT tags and would demand an item with just 1 NBT tag (green lore) but if it takes the item according to the Unbreakable tag and the lore/name then we're good. I didn't realize that it works like that :O 👍 }
What I did was making the item using the external lore and NBT editor then I used " /bq item saltcustom " for it and when I did " /bq give saltcustom " it gave me that sword so I thought that it wouldn't work properly in quests hence why I reported it! but it's all good now and I can use the 'command' event to give me the item easily since the external NBT editor saves the items and has a simple command to give them with their saved NBT tags. you saved my life.
EDIT: When I read
To be honest I don't use the questitems at all, so I might be wrong, but as far as I know it it should ignore all nbt-tags and such (with the exception of unbreakable!) and therefore even so you can't give them with betonquest it should be perfectly fine to check and take them. (Of course unless you want to check based on an nbt-tag.)
At least thats what I'm getting from the coding.
I realized how stupid I was lol, but you can't blame someone trying to workaround a solution at 5 AM
Everything is fine as long as it's now working for you :)
Could you close the issue yourself? The button is beside the comment button :)
It can be closed as we already have issues to improve the nbt handling ;) :)
Thanks once more.
@MWFIAE For some reason it's refusing to work when I tried it out ingame and via quests, it doesn't check or take the items..
This is what I used for the give.
minecraft:give ItsGamingSoni minecraft:diamond_sword 1 238 {display:{Name:"§fSalt",Lore:["§aUsed in food preservation as well as","§amummification."]},Unbreakable:1,HideFlags:63,AttributeModifiers:[{AttributeName:"generic.attackDamage",Name:"generic.attackDamage",Amount:0,Operation:2,UUIDMost:91667,UUIDLeast:113721}]}
conditions.yml
has_salt: 'item salt'
innkeeper.yml
quester:
en: 'innkeeper'
first: 'start'
stop: 'false'
NPC_options:
'start':
text:
en: 'I know you have salt.'
conditions: 'has_salt'
pointer: 'ok'
player_options:
'ok':
text:
en: 'kek'
events: 'take_salt'
items.yml
salt: DIAMOND_SWORD data:238 name:§fSalt lore:§aUsed_in_food_preservation_as_well_as;§amummification. unbreakable:true
and it's refusing to check the salt in the inventory and take it.
Ok, I will try to reproduce it once I'm at home. :)
Ok, you're right it doesn't work.
And I'm not too sure why, but if I set the data to for example 3 (also tested with 5 and 120) something like that it works flawless.
I also tested 129 and it stopped working, so it works with lower numbers.
But either betonquest or minecraft does something wrong if it is bigger than a signed byte...
it also leads to the funny effect, that one can give the questitem, but a condition on this item fails.
(The data is set on the itemstack correctly. )

@Co0sh @Namnodorel @joblo2213
I need help with this one.
I don't get it.
It doesn't make sense.
Here a minimal package to reproduce.
https://www.file-upload.net/download-12816166/default.zip.html
An kinda interesting observation I made: When I save the example item given by BQ with /bq item, it saves the data correctly until 128. 128 gets turned into -128, and over that it starts counting up... 129 becomes -127, 130 -126 etc.
/bq item simply does item.getData().getData() and pastes the result directly into the file. So it looks like the issue is somewhere during giving the item.
On a side note, /bq item seems to ignore the unbreakable-property
yeah that would be to expect if the data is stored in a signed byte. But I couldn't find the culprit.
Also when giving the item and checking it (via dropping it and executing /entitydata @e[r=3] {} ) it shows the correct data value, 129 in my example.
So it I'm really not sure where exactly it get messed up.
Well, MaterialData does store the data as a byte... While CraftBukkit stores the item damage as an int. So maybe /entitydata accesses the item data correctly, while BQ goes through Bukkit first, which converts the variable.
I gave me the item with betonquest with /bq event give_salt which would just give me the questitem.
give_salt: 'give salt'
So it does get set correctly even with BQ+Bukkit...
Just the condition doesn't seem to work :/
Yes giving works, because the Bukkit ItemStack-constructor passes the value as a final short, and assigns it to the durability. ItemStack.getData() will, if there is no actual data value set take the durability, and create a new MaterialData instance with it. Which then converts the short into a byte.
So, if we really want the data, we'd need to actually call getDurability() in cases where the data is the durability.
Like I said, MC/Bukkit is pretty f** up code-structure-wise...
Ok, thats just plain stupid...
But thank you for clearing it up.
Also getDurability should work for all cases even so it's naming is really bad.
So it would be very easy to fix...
Would you be willing to make a pr?
My internet really can't handle github, so testing it would be impossible for me 👎
Well, it wouldn't work for data applied to the item using setData(), because that again accesses the data-field instead of the durability one.
BQs data is always set as durability, so it'd fix this issue most likely. But it could create more issues in cases where the data-field is important.
thx @Namnodorel , PR #659 should fix this issue.
(It seems the auto-linking just works from commits not pr's )
Strange I did not get a notification for the new posts in this one... :unamused:
So thanks Namnodorel for the fix.
I guess this was also what caused the negative data values for #581
@Namnodorel @MWFIAE Mind giving me the download link to the version that fixes that? kinda new to Github and can't understand it properly yet.
@ItsGamingSoni there is none yet, first the branch has to be merged to the main project.
You could download the sourcecode (or clone it to a local repo on your pc) and compile it by yourself using maven but as you are not experienced with git and maven I would not recommend it.
Just wait until Co0sh merges it and creates a development build which can simply be downloaded using /bq update --dev ingame.
I see, in that case I don't see why this would be an issue seeing that it's fixed now. closed.
As the PR of @Namnodorel couldn't get merged this still needs to be adressed.
I'll reopen the issue to keep it on my agenda.