WindCharge .java

net.minecraft.world.entity.projectile.hurtingprojectile.windcharge.WindCharge (class): members: noDeflectTicks, deflectingEntity, byAttack, newOwner, tick.

net.minecraft.world.entity.projectile.hurtingprojectile.windchargeclass87 linescommonextends AbstractWindCharge2.9 KB

API Surface (4)

void tick()
boolean deflect(final ProjectileDeflection deflection, final @Nullable Entity deflectingEntity, final @Nullable EntityReference<Entity> newOwner, final boolean byAttack, final Vec3 power)
void explode(final Vec3 position)
boolean shouldRenderAtSqrDistance(final double distance)

Fields & Constants (9)

EXPLOSION_DAMAGE_CALCULATOR
RADIUS
MIN_CAMERA_DISTANCE_SQUARED
false
noDeflectTicks
deflection
deflectingEntity
newOwner
byAttack

Full Source

WindCharge.java87 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.world.entity.projectile.hurtingprojectile.windcharge;
2
3
import java.util.Optional;
4
import java.util.function.Function;
5
import net.minecraft.core.particles.ParticleTypes;
6
import net.minecraft.core.registries.BuiltInRegistries;
7
import net.minecraft.sounds.SoundEvents;
8
import net.minecraft.tags.BlockTags;
9
import net.minecraft.util.Mth;
10
import net.minecraft.util.random.WeightedList;
11
import net.minecraft.world.entity.Entity;
12
import net.minecraft.world.entity.EntityReference;
13
import net.minecraft.world.entity.EntityType;
14
import net.minecraft.world.entity.EntityTypes;
15
import net.minecraft.world.entity.player.Player;
16
import net.minecraft.world.entity.projectile.ProjectileDeflection;
17
import net.minecraft.world.level.ExplosionDamageCalculator;
18
import net.minecraft.world.level.Level;
19
import net.minecraft.world.level.SimpleExplosionDamageCalculator;
20
import net.minecraft.world.phys.Vec3;
21
import org.jspecify.annotations.Nullable;
22
23
public class WindCharge extends AbstractWindCharge {
24
	private static final ExplosionDamageCalculator EXPLOSION_DAMAGE_CALCULATOR = new SimpleExplosionDamageCalculator(
25
		true, false, Optional.of(1.22F), BuiltInRegistries.BLOCK.get(BlockTags.BLOCKS_WIND_CHARGE_EXPLOSIONS).map(Function.identity())
26
	);
27
	private static final float RADIUS = 1.2F;
28
	private static final float MIN_CAMERA_DISTANCE_SQUARED = Mth.square(3.5F);
29
	private int noDeflectTicks = 5;
30
31
	public WindCharge(final EntityType<? extends AbstractWindCharge> type, final Level level) {
32
		super(type, level);
33
	}
34
35
	public WindCharge(final Player player, final Level level, final double x, final double y, final double z) {
36
		super(EntityTypes.WIND_CHARGE, level, player, x, y, z);
37
	}
38
39
	public WindCharge(final Level level, final double x, final double y, final double z, final Vec3 direction) {
40
		super(EntityTypes.WIND_CHARGE, x, y, z, direction, level);
41
	}
42
43
	@Override
44
	public void tick() {
45
		super.tick();
46
		if (this.noDeflectTicks > 0) {
47
			this.noDeflectTicks--;
48
		}
49
	}
50
51
	@Override
52
	public boolean deflect(
53
		final ProjectileDeflection deflection,
54
		final @Nullable Entity deflectingEntity,
55
		final @Nullable EntityReference<Entity> newOwner,
56
		final boolean byAttack,
57
		final Vec3 power
58
	) {
59
		return this.noDeflectTicks > 0 ? false : super.deflect(deflection, deflectingEntity, newOwner, byAttack, power);
60
	}
61
62
	@Override
63
	protected void explode(final Vec3 position) {
64
		this.level()
65
			.explode(
66
				this,
67
				null,
68
				EXPLOSION_DAMAGE_CALCULATOR,
69
				position.x(),
70
				position.y(),
71
				position.z(),
72
				1.2F,
73
				false,
74
				Level.ExplosionInteraction.TRIGGER,
75
				ParticleTypes.GUST_EMITTER_SMALL,
76
				ParticleTypes.GUST_EMITTER_LARGE,
77
				WeightedList.of(),
78
				SoundEvents.WIND_CHARGE_BURST
79
			);
80
	}
81
82
	@Override
83
	public boolean shouldRenderAtSqrDistance(final double distance) {
84
		return this.tickCount < 2 && distance < MIN_CAMERA_DISTANCE_SQUARED ? false : super.shouldRenderAtSqrDistance(distance);
85
	}
86
}
87

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