How put a invisible shield into the second hand of the player?

Started by zorualeloupsolitaire on

Topic category: Help with Minecraft modding (Java Edition)

Joined Nov 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
How put a invisible shield into the second hand of the player?

Hello,

I'd like to improve my mod's combat system, and for defense, I had the idea of adding an invisible enchanted shield as soon as the player presses a key, G for example (although right-clicking would be better).

This invisible shield would withdraw as soon as the player stopped pressing the button.
But I don't know how to get Mcreator to add a shield to the player's second hand.

Thanks in advance!

Joined Jan 2025
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Helo,   You should probably…
Tue, 01/07/2025 - 19:59

Helo,

 

You should probably have a global itemstack variable on player lifetime ex. name: off-hand-item

You could do a procedure "WhenKey(Key)Pressed" do

Set itemstack global: (off-hand-item) to (item in off-hand of (Entity))

Set item in off-hand of (Entity) to (1) (invisible shield)

And procedure "WhenKeyReleased" do

Set item in off-hand of (Entity) to (get number of items(global:(off-hand-item))) (global:(off-hand-item)))

Joined Nov 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Good evening! I'd like to…
Wed, 01/08/2025 - 19:51

Good evening!

I'd like to thank you for your help, but I'm having trouble understanding what you've done for the part where you release the key.

Could you go into more detail?