CrossbowAttackMob .java

net.minecraft.world.entity.monster.CrossbowAttackMob (interface, 28 lines): members: performCrossbowAttack, onCrossbowAttackPerformed, setChargingCrossbow.

net.minecraft.world.entity.monsterinterface28 linescommonextends RangedAttackMob1.0 KB

API Surface (0)

No public/protected methods detected (fields or constants only).

Code Graph: Dependencies (7)

Edges (calls / imports / inherits / references) resolved by graphify from the AST. Every chip opens the class source.

Full Source

CrossbowAttackMob.java28 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.world.entity.monster;
2
3
import net.minecraft.world.InteractionHand;
4
import net.minecraft.world.entity.LivingEntity;
5
import net.minecraft.world.entity.projectile.ProjectileUtil;
6
import net.minecraft.world.item.CrossbowItem;
7
import net.minecraft.world.item.ItemStack;
8
import net.minecraft.world.item.Items;
9
import org.jspecify.annotations.Nullable;
10
11
public interface CrossbowAttackMob extends RangedAttackMob {
12
	void setChargingCrossbow(final boolean isCharging);
13
14
	@Nullable LivingEntity getTarget();
15
16
	void onCrossbowAttackPerformed();
17
18
	default void performCrossbowAttack(final LivingEntity body, final float crossbowPower) {
19
		InteractionHand hand = ProjectileUtil.getWeaponHoldingHand(body, Items.CROSSBOW);
20
		ItemStack usedItem = body.getItemInHand(hand);
21
		if (usedItem.getItem() instanceof CrossbowItem crossbow) {
22
			crossbow.performShooting(body.level(), body, hand, usedItem, crossbowPower, this.rangedAttackUncertainty(body.level()), this.getTarget());
23
		}
24
25
		this.onCrossbowAttackPerformed();
26
	}
27
}
28

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