Path: blob/1.21.x/src/main/java/net/minecraftforge/common/ToolActions.java
7393 views
/*1* Copyright (c) Forge Development LLC and contributors2* SPDX-License-Identifier: LGPL-2.1-only3*/45package net.minecraftforge.common;67import com.google.common.collect.Sets;8import net.minecraftforge.common.extensions.IForgeBlock;9import net.minecraftforge.common.extensions.IForgeItem;1011import java.util.Set;12import java.util.stream.Collectors;13import java.util.stream.Stream;1415public class ToolActions16{17/**18* Exposed by axes to allow querying tool behaviours19*/20public static final ToolAction AXE_DIG = ToolAction.get("axe_dig");2122/**23* Exposed by pickaxes to allow querying tool behaviours24*/25public static final ToolAction PICKAXE_DIG = ToolAction.get("pickaxe_dig");2627/**28* Exposed by shovels to allow querying tool behaviours29*/30public static final ToolAction SHOVEL_DIG = ToolAction.get("shovel_dig");3132/**33* Exposed by hoes to allow querying tool behaviours34*/35public static final ToolAction HOE_DIG = ToolAction.get("hoe_dig");3637/**38* Exposed by swords to allow querying tool behaviours39*/40public static final ToolAction SWORD_DIG = ToolAction.get("sword_dig");4142/**43* Exposed by shears to allow querying tool behaviours44*/45public static final ToolAction SHEARS_DIG = ToolAction.get("shears_dig");4647/**48* Passed onto {@link IForgeBlock#getToolModifiedState} when an axe wants to strip a log49*/50public static final ToolAction AXE_STRIP = ToolAction.get("axe_strip");5152/**53* Passed onto {@link IForgeBlock#getToolModifiedState} when an axe wants to scrape oxidization off copper54*/55public static final ToolAction AXE_SCRAPE = ToolAction.get("axe_scrape");5657/**58* Passed onto {@link IForgeBlock#getToolModifiedState} when an axe wants to remove wax out of copper59*/60public static final ToolAction AXE_WAX_OFF = ToolAction.get("axe_wax_off");6162/**63* Passed onto {@link IForgeBlock#getToolModifiedState} when a shovel wants to turn dirt into path64*/65public static final ToolAction SHOVEL_FLATTEN = ToolAction.get("shovel_flatten");6667/**68* Used during player attack to figure out if a sweep attack should be performed69*70* @see IForgeItem#getSweepHitBox71*/72public static final ToolAction SWORD_SWEEP = ToolAction.get("sword_sweep");7374/**75* 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.76* Example: Right click with shears on a beehive with honey level 5 to harvest it77*/78public static final ToolAction SHEARS_HARVEST = ToolAction.get("shears_harvest");7980/**81* 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.82* Example: Right click with shears o a pumpkin to carve it83*/84public static final ToolAction SHEARS_CARVE = ToolAction.get("shears_carve");8586/**87* This action is exposed by shears and corresponds to a disarm action that is triggered by breaking a block that supports such behaviour.88* Example: Breaking a trip wire with shears to disarm it.89*/90public static final ToolAction SHEARS_DISARM = ToolAction.get("shears_disarm");9192/**93* Passed onto {@link IForgeBlock#getToolModifiedState} when a hoe wants to turn dirt into soil94*/95public static final ToolAction HOE_TILL = ToolAction.get("till");9697/**98* A tool action corresponding to the 'block' action of shields.99*100* @deprecated Completely overshadowed by {@link net.minecraft.core.component.DataComponents#BLOCKS_ATTACKS}101*/102@Deprecated(forRemoval = true, since = "1.21.5")103public static final ToolAction SHIELD_BLOCK = ToolAction.get("shield_block");104105/**106* This action corresponds to right-clicking the fishing rod.107*/108public static final ToolAction FISHING_ROD_CAST = ToolAction.get("fishing_rod_cast");109110// Default actions supported by each tool type111public static final Set<ToolAction> DEFAULT_AXE_ACTIONS = of(AXE_DIG, AXE_STRIP, AXE_SCRAPE, AXE_WAX_OFF);112public static final Set<ToolAction> DEFAULT_HOE_ACTIONS = of(HOE_DIG, HOE_TILL);113public static final Set<ToolAction> DEFAULT_SHOVEL_ACTIONS = of(SHOVEL_DIG, SHOVEL_FLATTEN);114@Deprecated(since = "1.21.5")115public static final Set<ToolAction> DEFAULT_PICKAXE_ACTIONS = of(PICKAXE_DIG);116@Deprecated(since = "1.21.5")117public static final Set<ToolAction> DEFAULT_SWORD_ACTIONS = of(SWORD_DIG, SWORD_SWEEP);118public static final Set<ToolAction> DEFAULT_SHEARS_ACTIONS = of(SHEARS_DIG, SHEARS_HARVEST, SHEARS_CARVE, SHEARS_DISARM);119@Deprecated(since = "1.21.5")120public static final Set<ToolAction> DEFAULT_SHIELD_ACTIONS = of(SHIELD_BLOCK);121public static final Set<ToolAction> DEFAULT_FISHING_ROD_ACTIONS = of(FISHING_ROD_CAST);122123private static Set<ToolAction> of(ToolAction... actions) {124return Stream.of(actions).collect(Collectors.toCollection(Sets::newIdentityHashSet));125}126}127128129