Prevent item from duplicating

Started by GendarmyY on Sun, 03/28/2021 - 15:45

Topic category: Help with modding (Java Edition)

Last seen on 17:25, 19. Apr 2021
Joined May 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
Prevent item from duplicating
Sun, 03/28/2021 - 15:45

Hey, so I'm making an armor leggings that basically when you put them on it gives you a sword. Problem is, I didn't think about the fact if you drop the sword it directly gives you another sword and you can get back the sword you dropped and by that you can duplicate it. The procedure that I made is basically when the player as the leggings, if he does not have a sword, give him a sword. It's the only way I found to prevent from having infinite swords spawning in the player's inventory. Is there any way to prevent that duplication by maybe making the sword unable to be dropped ?

Actually, you can also duplicate it by putting the sword in a chest or basically by taking it off the inventory so prevent the sword from being dropped is useless. I thought maybe I can do a procedure that detects when there's more than 1 sword in the player's inventory and if so it deletes the amount of sword so that there's only one left, but I didn't see anything that can count the amount of a certain item in the inventory so... :/ need help idk what to do

Any help is really appreciated !

Last seen on 23:33, 5. May 2021
Joined Apr 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
Just use a LOGIC variable to…
Mon, 03/29/2021 - 03:32

Just use a LOGIC variable to check if the player has obtained the sword, once they have, set it to TRUE, that way when they equip or unequip the pants it will check the LOGIC variable and determine wether its been obtained or not.

 

> Here < is a example screenshot

Last seen on 17:25, 19. Apr 2021
Joined May 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
It's been sometime since…
Mon, 04/19/2021 - 12:36

It's been sometime since this post but thank you !! I actually didn't think about doing it like this 👍