Starting in 1.19.4, damage sources have been removed and replaced with a new system called DamageTypes. Damage Types are now a datapack registry, meaning they are no longer hardcoded. There are now also DamageType tags. To fetch DamageTypes, you will need to be able to use RegistryAccess.
There are 2 ways to fetch vanilla DamageTypes: use level.damageSources()
or entity.damageSources()
. Theres a method for each vanilla type, such as .fall()
for fall damage, .mobAttack()
for mob attacks, and so on. You can find all the ones you can use in DamageSources
. Here's how to call vanilla sources: https://github.com/TeamTwilight/twilightforest/blob/1.19.x/src/main/java/twilightforest/entity/projectile/SlimeProjectile.java#L66
As an example, I will be walking through how to register a DamageType called thrown_block
.
First, create a ResourceKey for the damage like so: