3

I want to make a datapack where if you touch lime glass, you get damaged 2.5 hearts. I don't want the commands to work for just this specific value. Instead, I want to be able to specify the amount of damage. I can't use the instant damage effect because it's not controllable.

9
  • I am working on something that should be done either today or tomorrow. It requires a data pack for ease of use and for multiplayer friendliness although is not required. Would a data pack work? Commented Dec 8, 2020 at 20:48
  • yes datapack would work
    – panda
    Commented Dec 9, 2020 at 5:59
  • you finish the datapack? if you finished send a link or something
    – panda
    Commented Dec 12, 2020 at 9:37
  • sorry, I ran into a few bugs when transferring it to a function, and all I have to do is make it more multiplayer friendly. It also currently doesn’t work with any attribute modifiers. If you don’t want multiplayer friendliness or to use it with attribute modifiers, then I could give it to you soon. FYI, my damaging system takes 3 ticks to run. It isn’t instant, but should be instant enough. Commented Dec 12, 2020 at 15:42
  • OK I will wait and it istant enough for me
    – panda
    Commented Dec 12, 2020 at 19:14

2 Answers 2

2

1.16+

Note: This data pack is in beta, and is in the works. If you have any bugs please let me know, and I'll add it to the known bugs list. Also, this is not tested in any version other then 1.16.4

I created a data pack that allows you to set health and deal damage to a player(for mobs use data modify instead). First off, you can get the data pack here. After installing it, make sure it says in chat that it was installed.

How To Use

Dealing Damage

To damage a player, set that player's damage scoreboard to how much damage you want to apply(negatives heal players), then run the function editor:deal_damage as the player you want to damage and you are done.

Setting Health

To set the health of a player, set that player's sethealth scoreboard to what health you want that player to have, then run the function editor:set_health as the player you want to edit health and you are done.

Remember: 1 heart is 2 HP, and a half a heart is 1 HP, default max health is 20 HP(10 hearts)

The Commands

To damage players:

scoreboard players set <selector> damage <value>
execute as <selector> run function editor:deal_damage

To set player health:

scoreboard players set <selector> sethealth <value>
execute as <selector> run function editor:set_health

How It Works

What the data pack does is set the max health of the player to what health you want to set, and gives the player the instant health effect so it will update the player health, setting the player's health to max, then it sets the max health to be what it originally was.

Known Bugs

  • A bug that shows the player as dead, even though they are not. (Its a Minecraft bug)
  • A bug that ignores absorption hearts, and skips to the base hearts.

Incompatibilities

All Incompatibilities are being worked on to be compatible

  • An existing helmet/item in the helmet slot with the max health attribute

Finding Bugs/Issues

Bugs

If you find any bugs, please report it. Also add how you found the bug, so I can recreate it, and fix it, videos/screenshots of bugs are preferred.

Issues

If you have any performance issues while running the data pack, please report it. Also add what performance issues you are getting, low tps, low fps, etc. Videos/screenshots and computer specs do help!

Where to report

To report bugs/issues, use either comments on this answer, or the issues page on the GitHub download link.

Terms of Use

If you use this in a data pack to publish, I would like for you to put the GitHub link to the data pack somewhere for others who may want it, Thanks. You are welcome to edit the data pack to whatever you want, just don't break it! :)

5
  • I don't know how to send a private message to you so I do here I want to take the datapack for my datapack and of course, I want to give you big credit so what to write or link how to call you
    – panda
    Commented Dec 24, 2020 at 14:28
  • @panda you can just add either at the download link for your data pack or in a tellraw command on reload the following. Some of this data pack was made using randomuser922's <link around here>health editor<put a link around here> add a link to my data pack download. Commented Dec 24, 2020 at 15:19
  • Ok I will also write your name (randomuser922) and "Made the damage system"
    – panda
    Commented Dec 24, 2020 at 15:21
  • @panda I gave a suggestion for what to do, and don't forget to link the download page. Commented Dec 24, 2020 at 15:23
  • I know I will do it
    – panda
    Commented Dec 24, 2020 at 15:25
3

use the wither effect for a specific amount of time to lower ones health controllably, as it lowers players health by .5 hp per second, or 1 heart every 4 seconds. Wither II drains one heart every two seconds, or 1 hp per second, which is most likely what you would want.
this command will drain the player of 2.5 hearts: /effect give @p minecraft:wither 5 2

sources:
Commands/Effect
Wither (status effect)

4
  • but with this the player "need to wait"
    – panda
    Commented Dec 5, 2020 at 17:39
  • there's no way to directly deal damage to the player, other than instant damage,which they specifically mention that they don't want to use Commented Dec 6, 2020 at 0:30
  • i don't want to use instant damage because I can't fully control the damage that it will deal
    – panda
    Commented Dec 6, 2020 at 14:53
  • Actually you can deal a specific amount of damage to a player. I'm working on something right now that does this. I'm not finished but it will be done soon. Commented Dec 8, 2020 at 18:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.