DamageSources .java

net.minecraft.world.damagesource.DamageSources (class): members: badRespawnPointExplosion, fallingStalactite, noAggroMobAttack, fellOutOfWorld, lava, spit.

net.minecraft.world.damagesourceclass294 linescommon8.9 KB

API Surface (51)

DamageSource source(final ResourceKey<DamageType> key)
DamageSource source(final ResourceKey<DamageType> key, final @Nullable Entity cause)
DamageSource source(final ResourceKey<DamageType> key, final @Nullable Entity directEntity, final @Nullable Entity causingEntity)
DamageSource inFire()
DamageSource campfire()
DamageSource lightningBolt()
DamageSource onFire()
DamageSource lava()
DamageSource hotFloor()
DamageSource inWall()
DamageSource cramming()
DamageSource drown()
DamageSource starve()
DamageSource cactus()
DamageSource fall()
DamageSource enderPearl()
DamageSource flyIntoWall()
DamageSource fellOutOfWorld()
DamageSource generic()
DamageSource magic()
DamageSource wither()
DamageSource dragonBreath()
DamageSource dryOut()
DamageSource sweetBerryBush()
DamageSource freeze()
DamageSource stalagmite()
DamageSource fallingBlock(final Entity entity)
DamageSource anvil(final Entity entity)
DamageSource fallingStalactite(final Entity entity)
DamageSource sting(final LivingEntity mob)
DamageSource mobAttack(final LivingEntity mob)
DamageSource noAggroMobAttack(final LivingEntity mob)
DamageSource playerAttack(final Player player)
DamageSource arrow(final AbstractArrow arrow, final @Nullable Entity owner)
DamageSource trident(final Entity trident, final @Nullable Entity owner)
DamageSource mobProjectile(final Entity entity, final @Nullable LivingEntity mob)
DamageSource spit(final Entity entity, final @Nullable LivingEntity mob)
DamageSource windCharge(final Entity entity, final @Nullable LivingEntity mob)
DamageSource fireworks(final FireworkRocketEntity rocket, final @Nullable Entity owner)
DamageSource fireball(final Fireball fireball, final @Nullable Entity owner)
DamageSource witherSkull(final WitherSkull witherSkull, final Entity owner)
DamageSource thrown(final Entity entity, final @Nullable Entity owner)
DamageSource indirectMagic(final Entity entity, final @Nullable Entity owner)
DamageSource thorns(final Entity source)
DamageSource explosion(final @Nullable Explosion explosion)
DamageSource explosion(final @Nullable Entity entity, final @Nullable Entity cause)
DamageSource sonicBoom(final Entity entity)
DamageSource badRespawnPointExplosion(final Vec3 boomPos)
DamageSource outOfBorder()
DamageSource genericKill()
DamageSource mace(final Entity owner)

Fields & Constants (26)

damageTypes
inFire
campfire
lightningBolt
onFire
lava
hotFloor
inWall
cramming
drown
starve
cactus
fall
enderPearl
flyIntoWall
fellOutOfWorld
generic
magic
wither
dragonBreath
dryOut
sweetBerryBush
freeze
stalagmite

…and 2 more (see full source).

Full Source

DamageSources.java294 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.world.damagesource;
2
3
import net.minecraft.core.Registry;
4
import net.minecraft.core.RegistryAccess;
5
import net.minecraft.core.registries.Registries;
6
import net.minecraft.resources.ResourceKey;
7
import net.minecraft.world.entity.Entity;
8
import net.minecraft.world.entity.LivingEntity;
9
import net.minecraft.world.entity.player.Player;
10
import net.minecraft.world.entity.projectile.FireworkRocketEntity;
11
import net.minecraft.world.entity.projectile.arrow.AbstractArrow;
12
import net.minecraft.world.entity.projectile.hurtingprojectile.Fireball;
13
import net.minecraft.world.entity.projectile.hurtingprojectile.WitherSkull;
14
import net.minecraft.world.level.Explosion;
15
import net.minecraft.world.phys.Vec3;
16
import org.jspecify.annotations.Nullable;
17
18
/**
19
 * Access widened by fabric-transitive-access-wideners-v1 to accessible
20
 */
21
public class DamageSources {
22
	/**
23
	 * Access widened by fabric-transitive-access-wideners-v1 to accessible
24
	 */
25
	public final Registry<DamageType> damageTypes;
26
	private final DamageSource inFire;
27
	private final DamageSource campfire;
28
	private final DamageSource lightningBolt;
29
	private final DamageSource onFire;
30
	private final DamageSource lava;
31
	private final DamageSource hotFloor;
32
	private final DamageSource inWall;
33
	private final DamageSource cramming;
34
	private final DamageSource drown;
35
	private final DamageSource starve;
36
	private final DamageSource cactus;
37
	private final DamageSource fall;
38
	private final DamageSource enderPearl;
39
	private final DamageSource flyIntoWall;
40
	private final DamageSource fellOutOfWorld;
41
	private final DamageSource generic;
42
	private final DamageSource magic;
43
	private final DamageSource wither;
44
	private final DamageSource dragonBreath;
45
	private final DamageSource dryOut;
46
	private final DamageSource sweetBerryBush;
47
	private final DamageSource freeze;
48
	private final DamageSource stalagmite;
49
	private final DamageSource outsideBorder;
50
	private final DamageSource genericKill;
51
52
	public DamageSources(final RegistryAccess registries) {
53
		this.damageTypes = registries.lookupOrThrow(Registries.DAMAGE_TYPE);
54
		this.inFire = this.source(DamageTypes.IN_FIRE);
55
		this.campfire = this.source(DamageTypes.CAMPFIRE);
56
		this.lightningBolt = this.source(DamageTypes.LIGHTNING_BOLT);
57
		this.onFire = this.source(DamageTypes.ON_FIRE);
58
		this.lava = this.source(DamageTypes.LAVA);
59
		this.hotFloor = this.source(DamageTypes.HOT_FLOOR);
60
		this.inWall = this.source(DamageTypes.IN_WALL);
61
		this.cramming = this.source(DamageTypes.CRAMMING);
62
		this.drown = this.source(DamageTypes.DROWN);
63
		this.starve = this.source(DamageTypes.STARVE);
64
		this.cactus = this.source(DamageTypes.CACTUS);
65
		this.fall = this.source(DamageTypes.FALL);
66
		this.enderPearl = this.source(DamageTypes.ENDER_PEARL);
67
		this.flyIntoWall = this.source(DamageTypes.FLY_INTO_WALL);
68
		this.fellOutOfWorld = this.source(DamageTypes.FELL_OUT_OF_WORLD);
69
		this.generic = this.source(DamageTypes.GENERIC);
70
		this.magic = this.source(DamageTypes.MAGIC);
71
		this.wither = this.source(DamageTypes.WITHER);
72
		this.dragonBreath = this.source(DamageTypes.DRAGON_BREATH);
73
		this.dryOut = this.source(DamageTypes.DRY_OUT);
74
		this.sweetBerryBush = this.source(DamageTypes.SWEET_BERRY_BUSH);
75
		this.freeze = this.source(DamageTypes.FREEZE);
76
		this.stalagmite = this.source(DamageTypes.STALAGMITE);
77
		this.outsideBorder = this.source(DamageTypes.OUTSIDE_BORDER);
78
		this.genericKill = this.source(DamageTypes.GENERIC_KILL);
79
	}
80
81
	/**
82
	 * Access widened by fabric-transitive-access-wideners-v1 to accessible
83
	 */
84
	public final DamageSource source(final ResourceKey<DamageType> key) {
85
		return new DamageSource(this.damageTypes.getOrThrow(key));
86
	}
87
88
	/**
89
	 * Access widened by fabric-transitive-access-wideners-v1 to accessible
90
	 */
91
	public final DamageSource source(final ResourceKey<DamageType> key, final @Nullable Entity cause) {
92
		return new DamageSource(this.damageTypes.getOrThrow(key), cause);
93
	}
94
95
	/**
96
	 * Access widened by fabric-transitive-access-wideners-v1 to accessible
97
	 */
98
	public final DamageSource source(final ResourceKey<DamageType> key, final @Nullable Entity directEntity, final @Nullable Entity causingEntity) {
99
		return new DamageSource(this.damageTypes.getOrThrow(key), directEntity, causingEntity);
100
	}
101
102
	public DamageSource inFire() {
103
		return this.inFire;
104
	}
105
106
	public DamageSource campfire() {
107
		return this.campfire;
108
	}
109
110
	public DamageSource lightningBolt() {
111
		return this.lightningBolt;
112
	}
113
114
	public DamageSource onFire() {
115
		return this.onFire;
116
	}
117
118
	public DamageSource lava() {
119
		return this.lava;
120
	}
121
122
	public DamageSource hotFloor() {
123
		return this.hotFloor;
124
	}
125
126
	public DamageSource inWall() {
127
		return this.inWall;
128
	}
129
130
	public DamageSource cramming() {
131
		return this.cramming;
132
	}
133
134
	public DamageSource drown() {
135
		return this.drown;
136
	}
137
138
	public DamageSource starve() {
139
		return this.starve;
140
	}
141
142
	public DamageSource cactus() {
143
		return this.cactus;
144
	}
145
146
	public DamageSource fall() {
147
		return this.fall;
148
	}
149
150
	public DamageSource enderPearl() {
151
		return this.enderPearl;
152
	}
153
154
	public DamageSource flyIntoWall() {
155
		return this.flyIntoWall;
156
	}
157
158
	public DamageSource fellOutOfWorld() {
159
		return this.fellOutOfWorld;
160
	}
161
162
	public DamageSource generic() {
163
		return this.generic;
164
	}
165
166
	public DamageSource magic() {
167
		return this.magic;
168
	}
169
170
	public DamageSource wither() {
171
		return this.wither;
172
	}
173
174
	public DamageSource dragonBreath() {
175
		return this.dragonBreath;
176
	}
177
178
	public DamageSource dryOut() {
179
		return this.dryOut;
180
	}
181
182
	public DamageSource sweetBerryBush() {
183
		return this.sweetBerryBush;
184
	}
185
186
	public DamageSource freeze() {
187
		return this.freeze;
188
	}
189
190
	public DamageSource stalagmite() {
191
		return this.stalagmite;
192
	}
193
194
	public DamageSource fallingBlock(final Entity entity) {
195
		return this.source(DamageTypes.FALLING_BLOCK, entity);
196
	}
197
198
	public DamageSource anvil(final Entity entity) {
199
		return this.source(DamageTypes.FALLING_ANVIL, entity);
200
	}
201
202
	public DamageSource fallingStalactite(final Entity entity) {
203
		return this.source(DamageTypes.FALLING_STALACTITE, entity);
204
	}
205
206
	public DamageSource sting(final LivingEntity mob) {
207
		return this.source(DamageTypes.STING, mob);
208
	}
209
210
	public DamageSource mobAttack(final LivingEntity mob) {
211
		return this.source(DamageTypes.MOB_ATTACK, mob);
212
	}
213
214
	public DamageSource noAggroMobAttack(final LivingEntity mob) {
215
		return this.source(DamageTypes.MOB_ATTACK_NO_AGGRO, mob);
216
	}
217
218
	public DamageSource playerAttack(final Player player) {
219
		return this.source(DamageTypes.PLAYER_ATTACK, player);
220
	}
221
222
	public DamageSource arrow(final AbstractArrow arrow, final @Nullable Entity owner) {
223
		return this.source(DamageTypes.ARROW, arrow, owner);
224
	}
225
226
	public DamageSource trident(final Entity trident, final @Nullable Entity owner) {
227
		return this.source(DamageTypes.TRIDENT, trident, owner);
228
	}
229
230
	public DamageSource mobProjectile(final Entity entity, final @Nullable LivingEntity mob) {
231
		return this.source(DamageTypes.MOB_PROJECTILE, entity, mob);
232
	}
233
234
	public DamageSource spit(final Entity entity, final @Nullable LivingEntity mob) {
235
		return this.source(DamageTypes.SPIT, entity, mob);
236
	}
237
238
	public DamageSource windCharge(final Entity entity, final @Nullable LivingEntity mob) {
239
		return this.source(DamageTypes.WIND_CHARGE, entity, mob);
240
	}
241
242
	public DamageSource fireworks(final FireworkRocketEntity rocket, final @Nullable Entity owner) {
243
		return this.source(DamageTypes.FIREWORKS, rocket, owner);
244
	}
245
246
	public DamageSource fireball(final Fireball fireball, final @Nullable Entity owner) {
247
		return owner == null ? this.source(DamageTypes.UNATTRIBUTED_FIREBALL, fireball) : this.source(DamageTypes.FIREBALL, fireball, owner);
248
	}
249
250
	public DamageSource witherSkull(final WitherSkull witherSkull, final Entity owner) {
251
		return this.source(DamageTypes.WITHER_SKULL, witherSkull, owner);
252
	}
253
254
	public DamageSource thrown(final Entity entity, final @Nullable Entity owner) {
255
		return this.source(DamageTypes.THROWN, entity, owner);
256
	}
257
258
	public DamageSource indirectMagic(final Entity entity, final @Nullable Entity owner) {
259
		return this.source(DamageTypes.INDIRECT_MAGIC, entity, owner);
260
	}
261
262
	public DamageSource thorns(final Entity source) {
263
		return this.source(DamageTypes.THORNS, source);
264
	}
265
266
	public DamageSource explosion(final @Nullable Explosion explosion) {
267
		return explosion != null ? this.explosion(explosion.getDirectSourceEntity(), explosion.getIndirectSourceEntity()) : this.explosion(null, null);
268
	}
269
270
	public DamageSource explosion(final @Nullable Entity entity, final @Nullable Entity cause) {
271
		return this.source(cause != null && entity != null ? DamageTypes.PLAYER_EXPLOSION : DamageTypes.EXPLOSION, entity, cause);
272
	}
273
274
	public DamageSource sonicBoom(final Entity entity) {
275
		return this.source(DamageTypes.SONIC_BOOM, entity);
276
	}
277
278
	public DamageSource badRespawnPointExplosion(final Vec3 boomPos) {
279
		return new DamageSource(this.damageTypes.getOrThrow(DamageTypes.BAD_RESPAWN_POINT), boomPos);
280
	}
281
282
	public DamageSource outOfBorder() {
283
		return this.outsideBorder;
284
	}
285
286
	public DamageSource genericKill() {
287
		return this.genericKill;
288
	}
289
290
	public DamageSource mace(final Entity owner) {
291
		return this.source(DamageTypes.MACE_SMASH, owner);
292
	}
293
}
294

Decompiled Minecraft 26.3 source of DamageSources (net/minecraft/world/damagesource/DamageSources.java) with Mojang official mappings, stored verbatim on the site.