Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
MinecraftForge
GitHub Repository: MinecraftForge/MinecraftForge
Path: blob/1.21.x/src/main/java/net/minecraftforge/common/ToolActions.java
7393 views
1
/*
2
* Copyright (c) Forge Development LLC and contributors
3
* SPDX-License-Identifier: LGPL-2.1-only
4
*/
5
6
package net.minecraftforge.common;
7
8
import com.google.common.collect.Sets;
9
import net.minecraftforge.common.extensions.IForgeBlock;
10
import net.minecraftforge.common.extensions.IForgeItem;
11
12
import java.util.Set;
13
import java.util.stream.Collectors;
14
import java.util.stream.Stream;
15
16
public class ToolActions
17
{
18
/**
19
* Exposed by axes to allow querying tool behaviours
20
*/
21
public static final ToolAction AXE_DIG = ToolAction.get("axe_dig");
22
23
/**
24
* Exposed by pickaxes to allow querying tool behaviours
25
*/
26
public static final ToolAction PICKAXE_DIG = ToolAction.get("pickaxe_dig");
27
28
/**
29
* Exposed by shovels to allow querying tool behaviours
30
*/
31
public static final ToolAction SHOVEL_DIG = ToolAction.get("shovel_dig");
32
33
/**
34
* Exposed by hoes to allow querying tool behaviours
35
*/
36
public static final ToolAction HOE_DIG = ToolAction.get("hoe_dig");
37
38
/**
39
* Exposed by swords to allow querying tool behaviours
40
*/
41
public static final ToolAction SWORD_DIG = ToolAction.get("sword_dig");
42
43
/**
44
* Exposed by shears to allow querying tool behaviours
45
*/
46
public static final ToolAction SHEARS_DIG = ToolAction.get("shears_dig");
47
48
/**
49
* Passed onto {@link IForgeBlock#getToolModifiedState} when an axe wants to strip a log
50
*/
51
public static final ToolAction AXE_STRIP = ToolAction.get("axe_strip");
52
53
/**
54
* Passed onto {@link IForgeBlock#getToolModifiedState} when an axe wants to scrape oxidization off copper
55
*/
56
public static final ToolAction AXE_SCRAPE = ToolAction.get("axe_scrape");
57
58
/**
59
* Passed onto {@link IForgeBlock#getToolModifiedState} when an axe wants to remove wax out of copper
60
*/
61
public static final ToolAction AXE_WAX_OFF = ToolAction.get("axe_wax_off");
62
63
/**
64
* Passed onto {@link IForgeBlock#getToolModifiedState} when a shovel wants to turn dirt into path
65
*/
66
public static final ToolAction SHOVEL_FLATTEN = ToolAction.get("shovel_flatten");
67
68
/**
69
* Used during player attack to figure out if a sweep attack should be performed
70
*
71
* @see IForgeItem#getSweepHitBox
72
*/
73
public static final ToolAction SWORD_SWEEP = ToolAction.get("sword_sweep");
74
75
/**
76
* This action is exposed by shears and corresponds to a harvest action that is triggered with a right click on a block that supports such behaviour.
77
* Example: Right click with shears on a beehive with honey level 5 to harvest it
78
*/
79
public static final ToolAction SHEARS_HARVEST = ToolAction.get("shears_harvest");
80
81
/**
82
* This action is exposed by shears and corresponds to a carve action that is triggered with a right click on a block that supports such behaviour.
83
* Example: Right click with shears o a pumpkin to carve it
84
*/
85
public static final ToolAction SHEARS_CARVE = ToolAction.get("shears_carve");
86
87
/**
88
* This action is exposed by shears and corresponds to a disarm action that is triggered by breaking a block that supports such behaviour.
89
* Example: Breaking a trip wire with shears to disarm it.
90
*/
91
public static final ToolAction SHEARS_DISARM = ToolAction.get("shears_disarm");
92
93
/**
94
* Passed onto {@link IForgeBlock#getToolModifiedState} when a hoe wants to turn dirt into soil
95
*/
96
public static final ToolAction HOE_TILL = ToolAction.get("till");
97
98
/**
99
* A tool action corresponding to the 'block' action of shields.
100
*
101
* @deprecated Completely overshadowed by {@link net.minecraft.core.component.DataComponents#BLOCKS_ATTACKS}
102
*/
103
@Deprecated(forRemoval = true, since = "1.21.5")
104
public static final ToolAction SHIELD_BLOCK = ToolAction.get("shield_block");
105
106
/**
107
* This action corresponds to right-clicking the fishing rod.
108
*/
109
public static final ToolAction FISHING_ROD_CAST = ToolAction.get("fishing_rod_cast");
110
111
// Default actions supported by each tool type
112
public static final Set<ToolAction> DEFAULT_AXE_ACTIONS = of(AXE_DIG, AXE_STRIP, AXE_SCRAPE, AXE_WAX_OFF);
113
public static final Set<ToolAction> DEFAULT_HOE_ACTIONS = of(HOE_DIG, HOE_TILL);
114
public static final Set<ToolAction> DEFAULT_SHOVEL_ACTIONS = of(SHOVEL_DIG, SHOVEL_FLATTEN);
115
@Deprecated(since = "1.21.5")
116
public static final Set<ToolAction> DEFAULT_PICKAXE_ACTIONS = of(PICKAXE_DIG);
117
@Deprecated(since = "1.21.5")
118
public static final Set<ToolAction> DEFAULT_SWORD_ACTIONS = of(SWORD_DIG, SWORD_SWEEP);
119
public static final Set<ToolAction> DEFAULT_SHEARS_ACTIONS = of(SHEARS_DIG, SHEARS_HARVEST, SHEARS_CARVE, SHEARS_DISARM);
120
@Deprecated(since = "1.21.5")
121
public static final Set<ToolAction> DEFAULT_SHIELD_ACTIONS = of(SHIELD_BLOCK);
122
public static final Set<ToolAction> DEFAULT_FISHING_ROD_ACTIONS = of(FISHING_ROD_CAST);
123
124
private static Set<ToolAction> of(ToolAction... actions) {
125
return Stream.of(actions).collect(Collectors.toCollection(Sets::newIdentityHashSet));
126
}
127
}
128
129