ItemActivation .java

net.minecraft.client.player.ItemActivation (class, 58 lines): members: ANIMATION_LENGTH, offX, offY, activate, isActive, reset, item, ticks, tick.

net.minecraft.client.playerclass58 linesclient1.1 KB

API Surface (8)

void tick()
void reset()
void activate(final ItemStack itemStack, final RandomSource random)
boolean isActive()
ItemStack item()
int ticks()
float offX()
float offY()

Fields & Constants (5)

ANIMATION_LENGTH
item
ticks
offX
offY

Code Graph: Dependencies (2)

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

Full Source

ItemActivation.java58 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.client.player;
2
3
import net.fabricmc.api.EnvType;
4
import net.fabricmc.api.Environment;
5
import net.minecraft.util.RandomSource;
6
import net.minecraft.world.item.ItemStack;
7
import org.jspecify.annotations.Nullable;
8
9
@Environment(EnvType.CLIENT)
10
public class ItemActivation {
11
	public static final int ANIMATION_LENGTH = 40;
12
	private @Nullable ItemStack item;
13
	private int ticks;
14
	private float offX;
15
	private float offY;
16
17
	public void tick() {
18
		if (this.ticks > 0) {
19
			this.ticks--;
20
			if (this.ticks == 0) {
21
				this.item = null;
22
			}
23
		}
24
	}
25
26
	public void reset() {
27
		this.item = null;
28
		this.ticks = 0;
29
	}
30
31
	public void activate(final ItemStack itemStack, final RandomSource random) {
32
		this.item = itemStack.copy();
33
		this.ticks = 40;
34
		this.offX = random.nextFloat() * 2.0F - 1.0F;
35
		this.offY = random.nextFloat() * 2.0F - 1.0F;
36
	}
37
38
	public boolean isActive() {
39
		return this.item != null && this.ticks > 0;
40
	}
41
42
	public ItemStack item() {
43
		return this.item;
44
	}
45
46
	public int ticks() {
47
		return this.ticks;
48
	}
49
50
	public float offX() {
51
		return this.offX;
52
	}
53
54
	public float offY() {
55
		return this.offY;
56
	}
57
}
58

Decompiled Minecraft 26.3 source of ItemActivation (net/minecraft/client/player/ItemActivation.java) with Mojang official mappings, stored verbatim on the site.