Skip to content

Instantly share code, notes, and snippets.

View GizmoTheMoonPig's full-sized avatar
🕷️
Squashing Bugs

GizmoTheMoonPig

🕷️
Squashing Bugs
  • United States
  • 02:15 (UTC -06:00)
View GitHub Profile
@GizmoTheMoonPig
GizmoTheMoonPig / damagetypes.md
Last active June 16, 2023 02:20
DamageType Conversion

DamageSource changes:

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

Registering your own DamageTypes and calling them:

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:

@GizmoTheMoonPig
GizmoTheMoonPig / Materials.md
Last active April 19, 2024 00:36
Materials: where did they go?

Starting in 1.20, the Material class has completely disappeared and has been replaced with a series of properties that are chained to BlockBehavior.Properties.of. This list exists so you can easily figure out which propeties to use to replace the old materials.

Every Material here gives its default MapColor (previously known as MaterialColor), regardless of if it had one or not. It also defines which properties to use to replicate the exact behavior used previously.

The very bottom of this file defines the more complicated replacements to certain material properties.

  • AIR - No MapColor, replaceable
  • STRUCTURAL_AIR - No MapColor, replaceable
  • PORTAL - No MapColor, PushReaction.BLOCK
  • CLOTH_DECORATION - MapColor.WOOL, ignitedByLava