PluginBugs / Issues-ItemsAdder

Repository used to keep track of issues of my plugin ItemsAdder
https://itemsadder.devs.beer
54 stars 21 forks source link

Destroy Item after Command #2585

Closed 00Hrtz closed 1 year ago

00Hrtz commented 1 year ago

Terms

Discord tag (optional)

No response

Describe the solution you'd like

I have an item that when clicked in hand, runs a command but i'd like the item to be removed/destroyed from the players hand after the commands run.

I'd prefer not to have to make the item a tool just to use the durability destroy item way if i could.

Hoping you could do it so that we could use a disappear_after_command_run: true action instead.

Is your feature request related to a problem?

Yes, unable to use the disappear action without having to use a tool for durability.

Describe alternatives you've considered

No alternatives as wish to do it with itemsadder rather than add more plugins to my already large list of plugins.

Additional context

No response

LoneDev6 commented 1 year ago

You can try using:

        decrement_amount:
          amount: 1
00Hrtz commented 1 year ago

I've tried different combinations and can't get it to disappear after first use, i've tried before without using a tool with durability as the material and it didn't work back then either.


info:
  namespace: customitems
items:
  pouch_of_plunder:
    display_name: Pouch of Plunder
    permission: pouch.of.plunder
    resource:
      material: STICK
      generate: true
      textures:
      - item/bags/medium_sack_of_holding.png
    events_cooldown: 150 ########### <-- EXAMPLE 60 seconds      
    events:
      interact:
        right:
          play_sound:
            name: minecraft:entity.pillager.celebrate
            volume: 1
            pitch: 1
          execute_commands:
            first_cmd:
              as_console: false
              command: 'eco give {player} 50'             
        durability: 
          max_custom_durability: 1          
          custom_durability: 1  
          disappear_when_broken: true 
          usages: 1 
        decrement_amount:     
          amount: 1

I tried this first 

info:
  namespace: customitems
items:
  pouch_of_plunder:
    display_name: Pouch of Plunder
    permission: pouch.of.plunder
    resource:
      material: STICK
      generate: true
      textures:
      - item/bags/medium_sack_of_holding.png
    events_cooldown: 150 ########### <-- EXAMPLE 60 seconds      
    events:
      interact:
        right:
          play_sound:
            name: minecraft:entity.pillager.celebrate
            volume: 1
            pitch: 1
          execute_commands:
            first_cmd:
              as_console: false
              command: 'eco give {player} 50'             
        decrement_amount:     
          amount: 1
00Hrtz commented 1 year ago

I've tried all different combinations of decrement durability, usage and amount and still unable to make the item disappear after right clicking in hand. I also can't seem to find an appropriate decrement trigger either.

00Hrtz commented 1 year ago

I just don't understand what the decrement is decrementing when there's nothing to decrement from seeing as i'm using STICK, i.e. why i mentioned at the start that i did not wish to use a vanilla tool.

Maybe i'll try execute command with /iaremove instead as this decrement way isn't working and the wiki is very vague on decrement.

00Hrtz commented 1 year ago

/iaremove with a 1 tick delay works fine.

LoneDev6 commented 1 year ago

I don't see how the decrement logic is vague. It decrements the amount of the current custom item. 1-1 = 0. You have an item that you want to be destroyed on use.

/iaremove with a 1 tick delay works fine.

It opens your server to duplication glitches as people can spamclick Q to drop the item right before the /iaremore command is executed.


Also I still don't know why after 3 years of using Itemsadder you still edit your files without using the extension to check if properties exist or not while writing them down. No idea why you put durability here for 2 reasons:

info:
  namespace: customitems
items:
  pouch_of_plunder:
    display_name: Pouch of Plunder
    permission: pouch.of.plunder
    resource:
      material: STICK
      generate: true
      textures:
      - item/bags/medium_sack_of_holding.png
    events_cooldown: 150 ########### <-- EXAMPLE 60 seconds      
    events:
      interact:
        right:
          play_sound:
            name: minecraft:entity.pillager.celebrate
            volume: 1
            pitch: 1
          execute_commands:
            first_cmd:
              as_console: false
              command: 'eco give {player} 50'             
        durability: # ???????????????????
          max_custom_durability: 1          
          custom_durability: 1  
          disappear_when_broken: true 
          usages: 1 
        decrement_amount:     
          amount: 1

Also why did you put the decrement_amount under interact and not interact->right? Obviously it won't do anything ingame, it's in the wrong place. Please stop editing your files without using the configurations extension and start reading its suggestions. You have to press CTRL+SPACE to get suggestions while writing down.

I fixed your configuration.

info:
  namespace: customitems
items:
  pouch_of_plunder:
    display_name: Pouch of Plunder
    permission: pouch.of.plunder
    resource:
      material: STICK
      generate: true
      textures:
      - item/bags/medium_sack_of_holding.png
    events_cooldown: 150 ########### <-- EXAMPLE 60 seconds      
    events:
      interact:
        right:
          play_sound:
            name: minecraft:entity.pillager.celebrate
            volume: 1
            pitch: 1
          execute_commands:
            first_cmd:
              as_console: false
              command: 'eco give {player} 50'             
          decrement_amount:     
            amount: 1
00Hrtz commented 1 year ago

https://itemsadder.devs.beer/plugin-usage/adding-content/item-properties/events/actions

You have no #description for the decrements actions, nothing on how it works under each one.

If by extension you mean the item editor, i've been using it from the moment you created the website editor.

If you look at the second config i provided you above, i did put decrement under interact right, don't know where you got that i didn't.

You're fix is literally a copy of the second configuration i provided above and it didn't work, the only difference is that you've moved it along a few spaces, when i placed it in your editor site it did not tell me the decrement was incorrectly indented. If it did i wouldn't be here asking why it doesn't work.

LoneDev6 commented 1 year ago

You're fix is literally a copy of the second configuration i provided above and it didn't work,the only difference is that you've moved it along a few spaces,

It's not "the only difference". It's a fix. You cannot expect things to work even if they were misplaced. Indentation is important in yml configurations for ANY plugin/software.

If by extension you mean the item editor, i've been using it from the moment you created the website editor.

I mean the new vscode extension. The web editor is deprecated since May 2022 and will be removed from the website in the next months because it was limited, slow and hard to maintain. https://itemsadder.devs.beer/plugin-usage/files-editor

00Hrtz commented 1 year ago

I don't expect anything to work if it's incorrectly indented, my point was the editor didn't tell me it was incorrectly indented so i assumed it was correctly indented. I wasn't aware of this new extension until now.

Thanks for updating me on this new vscode extension, i'm assuming i need to download visual studio to use it so will go ahead and check it out.