CrossbowPull .java

net.minecraft.client.renderer.item.properties.numeric.CrossbowPull (class): members: get, MAP_CODEC, type. imports: CrossbowItem, ItemOwner, ClientLevel.

net.minecraft.client.renderer.item.properties.numericclass37 linesclient1.2 KB

Implements

API Surface (2)

float get(final ItemStack itemStack, final @Nullable ClientLevel level, final @Nullable ItemOwner owner, final int seed)
MapCodec<CrossbowPull> type()

Fields & Constants (1)

MAP_CODEC

Code Graph: Dependencies (7)

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

Full Source

CrossbowPull.java37 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.client.renderer.item.properties.numeric;
2
3
import com.mojang.serialization.MapCodec;
4
import net.fabricmc.api.EnvType;
5
import net.fabricmc.api.Environment;
6
import net.minecraft.client.multiplayer.ClientLevel;
7
import net.minecraft.world.entity.ItemOwner;
8
import net.minecraft.world.entity.LivingEntity;
9
import net.minecraft.world.item.CrossbowItem;
10
import net.minecraft.world.item.ItemStack;
11
import org.jspecify.annotations.Nullable;
12
13
@Environment(EnvType.CLIENT)
14
public class CrossbowPull implements RangeSelectItemModelProperty {
15
	public static final MapCodec<CrossbowPull> MAP_CODEC = MapCodec.unit(new CrossbowPull());
16
17
	@Override
18
	public float get(final ItemStack itemStack, final @Nullable ClientLevel level, final @Nullable ItemOwner owner, final int seed) {
19
		LivingEntity entity = owner == null ? null : owner.asLivingEntity();
20
		if (entity == null) {
21
			return 0.0F;
22
		}
23
24
		if (CrossbowItem.isCharged(itemStack)) {
25
			return 0.0F;
26
		}
27
28
		int chargeDuration = CrossbowItem.getChargeDuration(itemStack, entity);
29
		return (float)UseDuration.useDuration(itemStack, entity) / chargeDuration;
30
	}
31
32
	@Override
33
	public MapCodec<CrossbowPull> type() {
34
		return MAP_CODEC;
35
	}
36
}
37

Decompiled Minecraft 26.3 source of CrossbowPull (net/minecraft/client/renderer/item/properties/numeric/CrossbowPull.java) with Mojang official mappings, stored verbatim on the site.