TriggerReactor

TriggerReactor

24.6k Downloads

Improve #GIVE

gerzytet opened this issue ยท 3 comments

commented

currently there are 2 areas where #GIVE falls short:

  1. When the player has items that could stack with the given item, the items go to a different stack instead
  2. When the player's inventory is full, the items are lost.

To solve these issues, I suggest we make this executor behave like minecraft's /give command:

  1. Given items will stack with items in the player's inventory
  2. If there is no space, excess items are dropped on the ground

However, we need to decide what to do with the old #GIVE executor, some users may have taken advantage of the old executor, so changing it would break their scripts.

commented

Or perhaps we can add a new executor with a different name?

an optional argument is possible too. #GIVE item() true false

the first boolean is for allow stacking and second is for drop if full

commented

@gerzytet @wysohn Please check whether I understood correctly.
#GIVE in published version:

  • throws error if inventory is full
  • if not full, item can be stackable (because of Inventory#firstEmpty()'s behavior)
  • if empty spaces have been filled with #GIVE and there's no enough space to give it more
    (e.g. one slot left and no same item in inventory. then #GIVE item("ITEM", 65). )
    it disappears.
  • if empty spaces have been filled with #GIVE and there's enough space to give it more
    (e.g. one slot left and there's same 62-stacked item in inventory. then #GIVE item("ITEM, 66)
    it actually can give all 66 pieces of the item.

#GIVE in future version(when this issue has been completed)

  • when received only ItemStack
    • (e.g. #GIVE item("ITEM", 3))

      same as usual.

  • when received two more arguments, 'stackable and dropable'
    • (e.g. #GIVE item("ITEM", 3), false, false)

      act same as #GIVE item("ITEM", 3)

    • (e.g. #GIVE item("ITEM", 3), true, false)

      this will give 3 ITEM item. but if there's no space(firstEmpty() == -1), check if there's same item which can stack gived item and stack as much as possible.
      if still not enough, then the item left will be disappear.

    • (e.g. #GIVE item("ITEM", 3), false, true)

      this will give 3 ITEM item. but if there's no space(firstEmpty() == -1), does not check if there's same item that can stack the given item, and drops all the item in front of the player.

    • (e.g. #GIVE item("ITEM", 3), true, true)

      this will give 3 ITEM item. but if there's no space(firstEmpty() == -1), check if there's same item which can stack gived item and stack as much as possible. if still not enough, drops all the item left in front of the player.

commented

@rkdrns4747
#GIVE in future version(when this issue has been completed)

  • when received two more arguments, 'stackable and dropable'
    • (e.g. #GIVE item("ITEM", 3), true, false)

      That works too, but it wouldn't be natural. For example, in vanilla Minecraft, if a player picks an item up, the items will be stacked until the amount reaches the limit (64 mostly), and then it will start to use next slot (which is returned by firstEmpty())

    • (e.g. #GIVE item("ITEM", 3), true, true)

      Same idea as above, yet mostly correct.