LargeFireball .java

net.minecraft.world.entity.projectile.hurtingprojectile.LargeFireball (class): members: DEFAULT_EXPLOSION_POWER, explosionPower, onHitEntity, onHit.

net.minecraft.world.entity.projectile.hurtingprojectileclass65 linescommonextends Fireball2.4 KB

API Surface (4)

void onHit(final HitResult hitResult)
void onHitEntity(final EntityHitResult hitResult)
void addAdditionalSaveData(final ValueOutput output)
void readAdditionalSaveData(final ValueInput input)

Fields & Constants (2)

DEFAULT_EXPLOSION_POWER
explosionPower

String literals (1)

"ExplosionPower"

Full Source

LargeFireball.java65 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.world.entity.projectile.hurtingprojectile;
2
3
import net.minecraft.server.level.ServerLevel;
4
import net.minecraft.world.damagesource.DamageSource;
5
import net.minecraft.world.entity.Entity;
6
import net.minecraft.world.entity.EntityType;
7
import net.minecraft.world.entity.EntityTypes;
8
import net.minecraft.world.entity.LivingEntity;
9
import net.minecraft.world.item.enchantment.EnchantmentHelper;
10
import net.minecraft.world.level.Level;
11
import net.minecraft.world.level.gamerules.GameRules;
12
import net.minecraft.world.level.storage.ValueInput;
13
import net.minecraft.world.level.storage.ValueOutput;
14
import net.minecraft.world.phys.EntityHitResult;
15
import net.minecraft.world.phys.HitResult;
16
import net.minecraft.world.phys.Vec3;
17
18
public class LargeFireball extends Fireball {
19
	private static final byte DEFAULT_EXPLOSION_POWER = 1;
20
	private int explosionPower = 1;
21
22
	public LargeFireball(final EntityType<? extends LargeFireball> type, final Level level) {
23
		super(type, level);
24
	}
25
26
	public LargeFireball(final Level level, final LivingEntity mob, final Vec3 direction, final int explosionPower) {
27
		super(EntityTypes.FIREBALL, mob, direction, level);
28
		this.explosionPower = explosionPower;
29
	}
30
31
	@Override
32
	protected void onHit(final HitResult hitResult) {
33
		super.onHit(hitResult);
34
		if (this.level() instanceof ServerLevel serverLevel) {
35
			boolean grief = serverLevel.getGameRules().get(GameRules.MOB_GRIEFING);
36
			this.level().explode(this, this.getX(), this.getY(), this.getZ(), this.explosionPower, grief, Level.ExplosionInteraction.MOB);
37
			this.discard();
38
		}
39
	}
40
41
	@Override
42
	protected void onHitEntity(final EntityHitResult hitResult) {
43
		super.onHitEntity(hitResult);
44
		if (this.level() instanceof ServerLevel serverLevel) {
45
			Entity var6 = hitResult.getEntity();
46
			Entity owner = this.getOwner();
47
			DamageSource damageSource = this.damageSources().fireball(this, owner);
48
			var6.hurtServer(serverLevel, damageSource, 6.0F);
49
			EnchantmentHelper.doPostAttackEffects(serverLevel, var6, damageSource);
50
		}
51
	}
52
53
	@Override
54
	protected void addAdditionalSaveData(final ValueOutput output) {
55
		super.addAdditionalSaveData(output);
56
		output.putByte("ExplosionPower", (byte)this.explosionPower);
57
	}
58
59
	@Override
60
	protected void readAdditionalSaveData(final ValueInput input) {
61
		super.readAdditionalSaveData(input);
62
		this.explosionPower = input.getByteOr("ExplosionPower", (byte)1);
63
	}
64
}
65

Decompiled Minecraft 26.3 source of LargeFireball (net/minecraft/world/entity/projectile/hurtingprojectile/LargeFireball.java) with Mojang official mappings, stored verbatim on the site.