mojira.dev

ALEKSANDR USKOV

Assigned

No issues.

Reported

No issues.

Comments

Okay, here's the (almost) minimum reproducible case on 1.14.4:

Edit: I've reassembled all the JSON Text components in accordance to what my particular server implementation returns in `data entity get @s SelectedItem`, creating identical and uniform order of attributes, as suggested above, which fixed most of issues, but some state condition still remains and is desribed here

I have a fancy golden ingot (or any stackable item, basically)

give @p minecraft:gold_ingot{display:{Lore:['{"italic":false,"color":"gold","text":"My Coin"}'],Name:'{"bold":true,"italic":false,"color":"yellow","text":"My Coin"}'},Enchantments:[{id:"minecraft:vanishing_curse",lvl:1}],"custom":"1"} 1

 

 

and a vendor which offers an enchanted elytra in exchange for a basic one + my fancy golden ingot (formatted for convinience)

summon villager ~ {Rotation:[180f,0f],CustomName:'[{"text":"My Vendor","color":"red","bold":true}]',CustomNameVisible:1,
VillagerData:{profession:"minecraft:fletcher",level:6,type:"minecraft:swamp"},CanPickUpLoot:0,PersistenceRequired:1,NoAI:1,Silent:1,Invulnerable:1,Attributes:[{Name:"generic.maxHealth",Base:99999}],Offers:{Recipes:[
{

buy:{id:"minecraft:gold_ingot",Count:1,tag:{display:{Lore:['{"italic":false,"color":"gold","text":"My Coin"}'],Name:'{"bold":true,"italic":false,"color":"yellow","text":"My Coin"}'},Enchantments:[{id:"minecraft:vanishing_curse",lvl:1}],"custom":"1"}},

buyB:{id:"elytra",Count:1},

maxUses:999999,

sell:{id:"elytra",Count:1,tag:{display:{Name:'[{"text":"Fancy Item","italic":false,"color":"gold","bold":true}]',Lore:['[{"text":"With a description","italic":false,"color":"yellow"}]']},Enchantments:[{id:"binding_curse",lvl:1}]}},

xp:0,
rewardExp:0b,
specialPrice:0,
priceMultiplier:0,
demand:0
}]}}

I have an elytra, then I run the first function, then attempt the trade. The recipe fills in as if it is vaild and works. Then I run the function again few more times, so I have an excess of ingots. And then I do `time add 1000s` several times to skip a night, and boom - the trade stops working with those "old" ingots, but works fine if I create new ones with the function, or even get them from another trade. I'm being the only person on server during that experiment. I didn't manage to measure the exact time, it's probably connected to some runtime procedures. I can verify that hard restarting the server while having the item in my inventory breaks the trade next time i log in (3 out of 3 attempts), while it was working right before. Yet again, the item created once more from scratch - works, while the one created on previous session doesn't.

Gonna do some more tests with `Age` tags, just in case, but that's most definitely a hidden state issue which affects only villager trades. Now we need to find out if it's a particular implementation issue, I suppose, so please try reproducing. @Frank Hawk

I can confirm that on Spigot 1.14.4.

I use codegen to create an item and a villager which accepts the item for buy in, and sells the same item as another recipe. The trade breaks in a weird way, I can't take the item from the right slot, and the moment I click it, all of the "buy" items dissapear from inventory until the trade is closed. The only stable behavior I can reproduce is that if an item is bought from the villager itself, it works fine during that trade session. If I take the same item I've just bought and throw it on the ground, then pick up, or relog to the server with the same item in inventory right after purchase, - it's not accepted by the same trader anymore. I've compared both item's NBT (acquired from vendor immediately and in the next session) with `data entity get @s SelectedItem` and it's identical to the point of symbols I can see in console, so it seems there is some hidden data which breaks the comparison. Previously there was an issue with 'Damage' tag, might it reappear? It also doesn't reproduce for every item, but can't see the pattern. It's (I think) less likely to break the trade on items that do not stack originally, which is not directly related to the issue. I can confirm that it has to do with `display` tag, as any common item works perfectly even with custom (hidden) NBT, like {currency:"Coin"} and matches correctly, but custom named items definetely have some comparison issues, and it seems that it has to do with villager trade particularly, as `clear` command and other command-based interactions work perfectly.  Also spawning the villager from scratch during the same session seems to fix the first trade, but not the following ones. I haven't found any way to debug this further, but there are like 10 different threads on reddit regarding that issue, and anecdotal evidence suggests that certain scenarios like that we working until 1.14 but collapsed afterwards. I believe that helps and the issue should be reopened 

P.S. And yes, we shouldn't be comparing items by names, but how else we let the player know which item the villager wants?