friendlyhj/ZenUtils

[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).

image

The problem, is that i cant know what item result i would get after right-clicking.

As i got it right, i should

  1. Detect item Goose holding
  2. Make fake player
  3. Simulate right-click by player with item goose holding
  4. This would open "fur ball" and drop items into fake player inventory
  5. 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).

image

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!