Skript: Bug: "unbreakable" weird bugs

Created on 6 Aug 2018  路  8Comments  路  Source: SkriptLang/Skript

Skript-dev37c
paper 1.12
Reproduce:

command /test:
    trigger:

        set {_i} to diamond hoe
        set {_i}'s data value to 5
        set {_i} to unbreakable {_i}
        add 1 of {_i} to command sender's inventory

The item will not be unbreakable.

But if you use this, it will be:

command /test:
    trigger:

        set {_i} to diamond hoe
        set {_i} to unbreakable {_i}
        set {_i}'s data value to 5
        add 1 of {_i} to command sender's inventory

Unbreakable tools with damage values are needed for resource pack textures, in case you're wondering why anyone would want a "missing texture".

/edit:
More issues - the following code will not set the item's name:

command /test:
    trigger:

        set {_i} to diamond hoe
        set {_i} to unbreakable {_i}
        set {_i}'s name to "test"
        add 1 of {_i} to command sender's inventory

/edit2:
Something really fishy is going on with this

bug completed medium

All 8 comments

I was looking at this for entirely different reasons: https://github.com/SkriptLang/Skript/blob/master/src/main/java/ch/njol/skript/expressions/ExprUnbreakable.java

and line 84 ((ItemMeta) meta).spigot().setUnbreakable(true); is kind of interesting and could have something to do with this. AFAIK and according to the spigot API, the spigot().setUnbreakable has been deprecated.

The new way is this: https://hub.spigotmc.org/javadocs/spigot/org/bukkit/inventory/meta/ItemMeta.html#setUnbreakable-boolean-

Note: the ItemMeta#setUnbreakable(Z)V method has only existed since 1.11

@jaylawl you were right, using the new method fixes the issue :eyes:

I guess we'll use the new method if it exists then

Edit: I guess I should use 'I guess' less

Actually... apparently my commit has fixed your original issue, but not the one with names, interesting

About this code:

command /test:
    trigger:

        set {_i} to diamond hoe
        set {_i} to unbreakable {_i}
        set {_i}'s name to "test"
        add 1 of {_i} to command sender's inventory

The problem seems to be that ItemType isn't automatically converted to the ItemStack (and the return; one line below the highlighted one is called):

image

Should I somehow mess with converted expressions here, or just add a separate case for ItemType (I think the first way sounds like a better solution, but I'm not really sure how to deal with this)

@SkriptLang/developers opinion needed

I have found issues similar to this before where the order in which item modifications are done matters on which ones will actually work and which wont. I have found that if you have a 'real' item that exists in game they will work reliably but when the item only exists in a variable is when it gets glitchy and some modifications to item name, lore, dye color, or enchants may not apply correctly. This issue already exist in #329 and #1318

You were there... 1000 issues ago

@Nicofisi Unless it is urgent, let's revisit this after aliases rework. If it needed to be done yesterday, just hack it together.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

LeotomasMC picture LeotomasMC  路  3Comments

Misio12320 picture Misio12320  路  3Comments

Anoniempje1234 picture Anoniempje1234  路  3Comments

GiraffeCubed picture GiraffeCubed  路  3Comments

ghost picture ghost  路  3Comments