Damage item every second

Started by myxical on

Topic category: Help with Minecraft modding (Java Edition)

Joined May 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Damage item every second

each second damage custom item in inventory

Use tick ervent for this. I…
Sat, 05/22/2021 - 16:21

Use tick ervent for this.

I suggest you check our tutorials collection playlist on our YouTube channel which contains many examples and tutorials that can help you get started with MCreator: https://www.youtube.com/playlist?list=PLAeL-oIFIEngE6jRgFYeFMfuj8WQsO3Ei

Joined May 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I cannot find anything in…
Sun, 05/23/2021 - 16:48

I cannot find anything in your playlist that can help me.

Joined Dec 2017
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Alright, this is a fairly…
Wed, 01/08/2025 - 20:49

Alright, this is a fairly old post, but still a thing. Here is a bit of information

I am sure there is a video in the playlist Klemen shared that does explain this, however, figuring out which video does would require you to watch all of them until you find it, which nobody wants to do.

IF You understand how to make a procedure, specify variables, etc. on mcreator, then this should be no issue, if you are fairly new or do NOT quite understand how proceduress work or what a tick is on minecraft, you should probably go learn and play around with procedures and ticks before attempting stuff like this.

On Tick Update: This procedure triggers every tick, which, a single tick is 1/20th of a second, 20 ticks = 1 second. If you don't want this procedure to do 20+ damage per second, you will have to do a lot of stuff to change that.
How to begin:

  • What you may need: If-Then blocks, while blocks, wait blocks, and a local timer variable
  • Create your timer variable as a number variable
    • This will need to be set at the start of your procedure
      • Set to 0 for an instant application followed by a timer
      • Set to 20 for a 1 second delay followed by a timer
      • Set higher for a higher delay
  • Create a While block
    • While: [condition required for event to take place]
    • Using an IF statement would result in the procedure ending after the action is completed, this could cause your timer variable to be useless.
  • Wait function
    • This ensures that anything this procedure does waits a certain amount of time before proceeding, preventing an immediate action such as damage on first tick.
    • You CAN skip this if you do not need to delay the rest of your procedure
    • You can also avoid using this by setting your timer to less than 0 at the start of your procedure
  • If : Else If
    • Here is where you insert your timer
    • If Timer = 0 Do: preform action
      Else if Timer > 0 Do: set Timer to: Get Timer - 1
  • Simple Blockly Setup for item in main hand damage
    • Instant Apply with a 1 second timer
    • Will only repeat while the stated condition is true
Set number variable [Timer] to [0]
While: [item in maind-hand of [event/target entity]] = [customItem]
do:
	If: Get number variable [Timer] = [0]
	do: 
		deal [1] damage to [event/target entity] with custom damage type: [generic]
		Set number variable [Timer] to: [20]
	Else If: Get number variable [Timer] > [0] 
	do: 
		Set number variable [Timer] to: Get number variable [Timer] - [1]
  • Alternative if you do NOT want your procedure to immediately take effect
    • Take effect after 10 seconds with a repeating timer of 1 second
    • Same procedure, different starting point
Set number variable [Timer] to: [200]
While: [Item in main-hand of: [event/target entity]] = [customItem]
do:
	If: Get number variable [Timer] = [0]
	do:
		deal [1] damage to [event/target entity] with custom damage type: [generic]
		Set number variable [Timer] to: [20]
	Else if: Get number variable [Timer] > [0]
	do:
		Set number variable [Timer] to: Get number variable [Timer] - [1]

Notes:

  • Any/All items in Brackets are changeable variables in the event that this is used for other things.
  • I will NOT make a tutorial for making timers for other things such as entities, enchantments, potion effects, etc, as this coves most simple timer-based procedures, you will have to learn to alter this and troubleshoot this on your own
  • This is a theoretical procedure construct, I've not yet tested this, but I will shortly and will make tweaks/changes where needed.
Joined Dec 2017
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Do NOT do what I stated it…
Wed, 01/08/2025 - 20:55

Do NOT do what I stated it will crash your game.