How to enchant all items in player's inventory?

Started by DJSlimeball on

Topic category: Help with Minecraft modding (Java Edition)

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.

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

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.

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

 

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.

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++
}
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?

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. 

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

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