SpectralArrow .java

net.minecraft.world.entity.projectile.arrow.SpectralArrow (class, 67 lines): members: pickupItemStack, doPostHurtEffects, DEFAULT_DURATION, duration, tick.

net.minecraft.world.entity.projectile.arrowclass67 linescommonextends AbstractArrow2.3 KB

API Surface (5)

void tick()
void doPostHurtEffects(final LivingEntity mob)
void readAdditionalSaveData(final ValueInput input)
void addAdditionalSaveData(final ValueOutput output)
ItemStack getDefaultPickupItem()

Fields & Constants (3)

DEFAULT_DURATION
duration
pickupItemStack

String literals (1)

"Duration"

Full Source

SpectralArrow.java67 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.world.entity.projectile.arrow;
2
3
import net.minecraft.core.particles.ParticleTypes;
4
import net.minecraft.core.particles.SpellParticleOption;
5
import net.minecraft.world.effect.MobEffectInstance;
6
import net.minecraft.world.effect.MobEffects;
7
import net.minecraft.world.entity.EntityType;
8
import net.minecraft.world.entity.EntityTypes;
9
import net.minecraft.world.entity.LivingEntity;
10
import net.minecraft.world.item.ItemStack;
11
import net.minecraft.world.item.Items;
12
import net.minecraft.world.level.Level;
13
import net.minecraft.world.level.storage.ValueInput;
14
import net.minecraft.world.level.storage.ValueOutput;
15
import org.jspecify.annotations.Nullable;
16
17
public class SpectralArrow extends AbstractArrow {
18
	private static final int DEFAULT_DURATION = 200;
19
	private int duration = 200;
20
21
	public SpectralArrow(final EntityType<? extends SpectralArrow> type, final Level level) {
22
		super(type, level);
23
	}
24
25
	public SpectralArrow(final Level level, final LivingEntity owner, final ItemStack pickupItemStack, final @Nullable ItemStack firedFromWeapon) {
26
		super(EntityTypes.SPECTRAL_ARROW, owner, level, pickupItemStack, firedFromWeapon);
27
	}
28
29
	public SpectralArrow(
30
		final Level level, final double x, final double y, final double z, final ItemStack pickupItemStack, final @Nullable ItemStack firedFromWeapon
31
	) {
32
		super(EntityTypes.SPECTRAL_ARROW, x, y, z, level, pickupItemStack, firedFromWeapon);
33
	}
34
35
	@Override
36
	public void tick() {
37
		super.tick();
38
		if (this.level().isClientSide() && !this.isInGround()) {
39
			this.level().addParticle(SpellParticleOption.create(ParticleTypes.EFFECT, -1, 1.0F), this.getX(), this.getY(), this.getZ(), 0.0, 0.0, 0.0);
40
		}
41
	}
42
43
	@Override
44
	protected void doPostHurtEffects(final LivingEntity mob) {
45
		super.doPostHurtEffects(mob);
46
		MobEffectInstance effect = new MobEffectInstance(MobEffects.GLOWING, this.duration, 0);
47
		mob.addEffect(effect, this.getEffectSource());
48
	}
49
50
	@Override
51
	protected void readAdditionalSaveData(final ValueInput input) {
52
		super.readAdditionalSaveData(input);
53
		this.duration = input.getIntOr("Duration", 200);
54
	}
55
56
	@Override
57
	protected void addAdditionalSaveData(final ValueOutput output) {
58
		super.addAdditionalSaveData(output);
59
		output.putInt("Duration", this.duration);
60
	}
61
62
	@Override
63
	protected ItemStack getDefaultPickupItem() {
64
		return new ItemStack(Items.SPECTRAL_ARROW);
65
	}
66
}
67

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