
ExprItemsIn always prefers ItemType
TheLimeGlass opened this issue ยท 1 comments
Skript/Server Version
2.12.1
MC 1.21.5
Bug Description
When using loop items in player's inventory
Then using any kind of Skript reflection for itemstack syntax %itemstack% will cause an issue of converting from ItemType to a newly created ItemStack. (ItemType#getRandom)
This is problematic, because when looping the items, I want whatever I change to affect the ItemStack and not a newly created copy of an ItemType that essentially does nothing because it doesn't affect the original ItemStack.
Expected Behavior
Convert InventorySlot to an ItemStack for ItemStack syntaxes.
The looping of the items in expression should convert the slot to an ItemStack not to an ItemType. The ItemStack has always been the requirement for expression returns where the context is not literal.
This allows for proper manipulation of the items.
This also is the requirement because Skript can easily handle ItemStack to ItemType comparisons.
Steps to Reproduce
command /test:
trigger:
loop items in player's inventory:
loop-item.getType() is Material.DIAMOND
broadcast "failure"
No matching non-static method: InventorySlot#getType called without arguments
Other
Solution is to just avoid Skript's syntax all together to get what you want.
loop ...player.getInventory().getContents():
Self note if I end up fixing this;
loop-itemstack is also not possible, where this should be allowed to give context clues to Skript for the correct type to be using here.
Agreement
- I have read the guidelines above and affirm I am following them with this report.
I don't believe skript-reflect converts objects like that. ExprLoopValue doesn't use converters for determining whether to allow loop-X
, which is why loop-itemstack
doesn't work. loop-item
is allowed by ExprItemsIn. Since ExprItemsIn returns a Slot, you'll need to manually grab the ItemStack using .getItem()