[Feature request] optional `item` in simulate functions
Closed this issue · 2 comments
I want to simulate right-click for opening "loot box" by the entity.
In my case its Goose holding Fur Ball (fur ball dropping items on right click).
The problem, is that i cant know what item result i would get after right-clicking.
As i got it right, i should
- Detect item Goose holding
- Make fake player
- Simulate right-click by player with item goose holding
- This would open "fur ball" and drop items into fake player inventory
- Drop inventory of fake player in world like it was Goose
The problem is that i want any item be used this way. Like, maybe gun? Or giant sword. In this case i need to know not only the result of usage simulation but item transformation (like reducing durability).
If in functions like player.simulateRightClickItem(item, hand);
i could assume that item
is thing holded in hand
, actual item would be used from fake player inventory and transformed, so u could read result after.
I can't make item arg as optional, since null value should be considered as empty hand.
Added result item for your problem.
val result = world.fakePlayer.simulateRightClickEntity(target, <minecraft:shears>);
// for sheep, it will print <minecraft:shears:1>
print(result.item.commandString);
Great! Thank you for the fix!