How to enchant all items in player's inventory?

Started by DJSlimeball on

Topic category: Help with modding (Java Edition)

Last seen on 06:04, 14. May 2023
Joined Apr 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
How to enchant all items in player's inventory?

I think the title should be pretty self-explanatory. Please help.

Last seen on 16:39, 2. Sep 2023
Joined Mar 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
You Can't (Probably) Enchant…
Wed, 03/22/2023 - 16:56

You Can't (Probably) Enchant All Items In Inventory, You Can Try Using This:
Add enchantment (Enchantment Here) with level (Level Here) to Provided itemstack

Last seen on 06:04, 14. May 2023
Joined Apr 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I don't want to enchant the…
Thu, 03/23/2023 - 01:07

I don't want to enchant the currently held item at all, just literally everything else.

Last seen on 00:04, 29. Mar 2024
Joined Apr 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I have a solution: Step 1:…
Wed, 04/05/2023 - 17:15

I have a solution:

Step 1: create a local number variable(vslot).

Step 2:  Add this procedure code

"(Set (vslot) to: (0))

(Repeat (36) times)

          (If (Is (get a copy of item from slot (vslot) of (event/target entity) if it has inventory) enchantable))

                    (add enchantment (enchantment) to (get a copy of item from slot (vslot) of (event/target entity) if it has inventory))

          (Set (vslot) to: ((vslot) + (1)))

 

Last seen on 00:04, 29. Mar 2024
Joined Apr 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Sorry, I just realized that…
Wed, 04/05/2023 - 17:19

Sorry, I just realized that doesn't work.  I should have tested beforehand.

I will try to give you a working solution later today.

Last seen on 05:13, 9. Nov 2023
Joined Mar 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
That does not work since you…
Wed, 04/05/2023 - 18:33

That does not work since you're getting a copy of the item from the slot, so applying the enchant is putting the enchant on the copy that is then being dropped into the void.

Instead it would go like this:

Set i to 0
While i <= 36 {
    If is enchantable item {
    	Set "current_item" to copy of item from slot i
   		Add enchantment to "current_item"
    	Set inventory slot i to "current_item"
    }
  	i++
}
Last seen on 06:04, 14. May 2023
Joined Apr 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Can you specify more please?
Wed, 04/05/2023 - 22:48

Can you specify more please?

Last seen on 05:13, 9. Nov 2023
Joined Mar 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Well here it is in code…
Thu, 04/06/2023 - 10:27

Well here it is in code blocks. 

Last seen on 06:04, 14. May 2023
Joined Apr 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I can't put "Event/target…
Mon, 04/10/2023 - 01:00

I can't put "Event/target entity" in the "Get a copy" block...

Last seen on 23:14, 17. Apr 2023
Joined Mar 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
does not work you can not do…
Mon, 04/10/2023 - 08:44

does not work you can not do this