From fd2db108bf26c31942c87ecfc99845d3a59ff632 Mon Sep 17 00:00:00 2001 From: TelepathicGrunt <40846040+TelepathicGrunt@users.noreply.github.com> Date: Wed, 26 Jun 2024 19:17:07 -0400 Subject: [PATCH] Rename ToolActions to ItemAbilities (#1148) Co-authored-by: Matyrobbrt <65940752+Matyrobbrt@users.noreply.github.com> --- .../entity/FishingHookRenderer.java.patch | 2 +- .../world/entity/LivingEntity.java.patch | 2 +- ...opHoldingItemIfNoLongerAdmiring.java.patch | 2 +- .../world/entity/player/Player.java.patch | 4 +- .../entity/projectile/FishingHook.java.patch | 4 +- .../minecraft/world/item/AxeItem.java.patch | 10 +-- .../minecraft/world/item/BrushItem.java.patch | 4 +- .../world/item/FishingRodItem.java.patch | 4 +- .../minecraft/world/item/HoeItem.java.patch | 8 +-- .../net/minecraft/world/item/Item.java.patch | 2 +- .../world/item/PickaxeItem.java.patch | 4 +- .../world/item/ShearsItem.java.patch | 4 +- .../world/item/ShieldItem.java.patch | 4 +- .../world/item/ShovelItem.java.patch | 6 +- .../minecraft/world/item/SwordItem.java.patch | 4 +- .../world/item/TridentItem.java.patch | 4 +- .../level/block/BambooSaplingBlock.java.patch | 2 +- .../level/block/BambooStalkBlock.java.patch | 2 +- .../world/level/block/BeehiveBlock.java.patch | 2 +- .../world/level/block/PumpkinBlock.java.patch | 2 +- .../level/block/TripWireBlock.java.patch | 2 +- .../advancement/adventure/lighten_up.json | 2 +- .../advancement/husbandry/wax_off.json | 2 +- .../loot_table/blocks/acacia_leaves.json | 8 +-- .../loot_table/blocks/azalea_leaves.json | 8 +-- .../loot_table/blocks/birch_leaves.json | 8 +-- .../loot_table/blocks/cherry_leaves.json | 8 +-- .../minecraft/loot_table/blocks/cobweb.json | 4 +- .../loot_table/blocks/dark_oak_leaves.json | 12 ++-- .../loot_table/blocks/dead_bush.json | 4 +- .../minecraft/loot_table/blocks/fern.json | 4 +- .../blocks/flowering_azalea_leaves.json | 8 +-- .../loot_table/blocks/glow_lichen.json | 4 +- .../loot_table/blocks/hanging_roots.json | 4 +- .../loot_table/blocks/jungle_leaves.json | 8 +-- .../loot_table/blocks/large_fern.json | 8 +-- .../loot_table/blocks/mangrove_leaves.json | 4 +- .../loot_table/blocks/nether_sprouts.json | 4 +- .../loot_table/blocks/oak_leaves.json | 12 ++-- .../minecraft/loot_table/blocks/seagrass.json | 4 +- .../loot_table/blocks/short_grass.json | 4 +- .../loot_table/blocks/small_dripleaf.json | 4 +- .../loot_table/blocks/spruce_leaves.json | 8 +-- .../loot_table/blocks/tall_grass.json | 8 +-- .../loot_table/blocks/tall_seagrass.json | 4 +- .../loot_table/blocks/twisting_vines.json | 4 +- .../blocks/twisting_vines_plant.json | 4 +- .../minecraft/loot_table/blocks/vine.json | 4 +- .../loot_table/blocks/weeping_vines.json | 4 +- .../blocks/weeping_vines_plant.json | 4 +- .../{ToolActions.java => ItemAbilities.java} | 68 +++++++++---------- .../{ToolAction.java => ItemAbility.java} | 22 +++--- .../neoforge/common/NeoForgeMod.java | 8 +-- .../net/neoforged/neoforge/common/Tags.java | 48 ++++++------- ...edicate.java => ItemAbilityPredicate.java} | 8 +-- .../internal/NeoForgeAdvancementProvider.java | 12 ++-- .../internal/NeoForgeLootTableProvider.java | 8 +-- .../common/extensions/IBlockExtension.java | 30 ++++---- .../extensions/IBlockStateExtension.java | 20 +++--- .../common/extensions/IItemExtension.java | 12 ++-- .../extensions/IItemStackExtension.java | 12 ++-- ...Action.java => CanItemPerformAbility.java} | 24 +++---- .../neoforged/neoforge/event/EventHooks.java | 6 +- .../neoforge/event/level/BlockEvent.java | 24 +++---- .../neoforge/debug/block/BlockEventTests.java | 4 +- .../oldtest/item/CustomShieldTest.java | 8 +-- 66 files changed, 278 insertions(+), 278 deletions(-) rename src/main/java/net/neoforged/neoforge/common/{ToolActions.java => ItemAbilities.java} (51%) rename src/main/java/net/neoforged/neoforge/common/{ToolAction.java => ItemAbility.java} (56%) rename src/main/java/net/neoforged/neoforge/common/advancements/critereon/{ToolActionItemPredicate.java => ItemAbilityPredicate.java} (51%) rename src/main/java/net/neoforged/neoforge/common/loot/{CanToolPerformAction.java => CanItemPerformAbility.java} (63%) diff --git a/patches/net/minecraft/client/renderer/entity/FishingHookRenderer.java.patch b/patches/net/minecraft/client/renderer/entity/FishingHookRenderer.java.patch index ca780ed783..77ce7e708d 100644 --- a/patches/net/minecraft/client/renderer/entity/FishingHookRenderer.java.patch +++ b/patches/net/minecraft/client/renderer/entity/FishingHookRenderer.java.patch @@ -5,7 +5,7 @@ int i = p_340935_.getMainArm() == HumanoidArm.RIGHT ? 1 : -1; ItemStack itemstack = p_340935_.getMainHandItem(); - if (!itemstack.is(Items.FISHING_ROD)) { -+ if (!itemstack.canPerformAction(net.neoforged.neoforge.common.ToolActions.FISHING_ROD_CAST)) { ++ if (!itemstack.canPerformAction(net.neoforged.neoforge.common.ItemAbilities.FISHING_ROD_CAST)) { i = -i; } diff --git a/patches/net/minecraft/world/entity/LivingEntity.java.patch b/patches/net/minecraft/world/entity/LivingEntity.java.patch index d666afcb68..7823a78f2a 100644 --- a/patches/net/minecraft/world/entity/LivingEntity.java.patch +++ b/patches/net/minecraft/world/entity/LivingEntity.java.patch @@ -645,7 +645,7 @@ if (this.isUsingItem() && !this.useItem.isEmpty()) { Item item = this.useItem.getItem(); - return item.getUseAnimation(this.useItem) != UseAnim.BLOCK ? false : item.getUseDuration(this.useItem, this) - this.useItemRemaining >= 5; -+ return !this.useItem.canPerformAction(net.neoforged.neoforge.common.ToolActions.SHIELD_BLOCK) ? false : item.getUseDuration(this.useItem, this) - this.useItemRemaining >= 5; ++ return !this.useItem.canPerformAction(net.neoforged.neoforge.common.ItemAbilities.SHIELD_BLOCK) ? false : item.getUseDuration(this.useItem, this) - this.useItemRemaining >= 5; } else { return false; } diff --git a/patches/net/minecraft/world/entity/monster/piglin/StopHoldingItemIfNoLongerAdmiring.java.patch b/patches/net/minecraft/world/entity/monster/piglin/StopHoldingItemIfNoLongerAdmiring.java.patch index 1023c54c1d..29b127e428 100644 --- a/patches/net/minecraft/world/entity/monster/piglin/StopHoldingItemIfNoLongerAdmiring.java.patch +++ b/patches/net/minecraft/world/entity/monster/piglin/StopHoldingItemIfNoLongerAdmiring.java.patch @@ -5,7 +5,7 @@ return BehaviorBuilder.create( p_259197_ -> p_259197_.group(p_259197_.absent(MemoryModuleType.ADMIRING_ITEM)).apply(p_259197_, p_259512_ -> (p_352826_, p_352827_, p_352828_) -> { - if (!p_352827_.getOffhandItem().isEmpty() && !p_352827_.getOffhandItem().is(Items.SHIELD)) { -+ if (!p_352827_.getOffhandItem().isEmpty() && !p_352827_.getOffhandItem().canPerformAction(net.neoforged.neoforge.common.ToolActions.SHIELD_BLOCK)) { ++ if (!p_352827_.getOffhandItem().isEmpty() && !p_352827_.getOffhandItem().canPerformAction(net.neoforged.neoforge.common.ItemAbilities.SHIELD_BLOCK)) { PiglinAi.stopHoldingOffHandItem(p_352827_, true); return true; } else { diff --git a/patches/net/minecraft/world/entity/player/Player.java.patch b/patches/net/minecraft/world/entity/player/Player.java.patch index c28d275637..bbe5252e8b 100644 --- a/patches/net/minecraft/world/entity/player/Player.java.patch +++ b/patches/net/minecraft/world/entity/player/Player.java.patch @@ -132,7 +132,7 @@ @Override protected void hurtCurrentlyUsedShield(float p_36383_) { - if (this.useItem.is(Items.SHIELD)) { -+ if (this.useItem.canPerformAction(net.neoforged.neoforge.common.ToolActions.SHIELD_BLOCK)) { ++ if (this.useItem.canPerformAction(net.neoforged.neoforge.common.ItemAbilities.SHIELD_BLOCK)) { if (!this.level().isClientSide) { this.awardStat(Stats.ITEM_USED.get(this.useItem.getItem())); } @@ -261,7 +261,7 @@ - if (itemstack1.getItem() instanceof SwordItem) { - flag2 = true; - } -+ flag2 = itemstack1.canPerformAction(net.neoforged.neoforge.common.ToolActions.SWORD_SWEEP); ++ flag2 = itemstack1.canPerformAction(net.neoforged.neoforge.common.ItemAbilities.SWORD_SWEEP); } float f6 = 0.0F; diff --git a/patches/net/minecraft/world/entity/projectile/FishingHook.java.patch b/patches/net/minecraft/world/entity/projectile/FishingHook.java.patch index 46cece1391..aadfd8768b 100644 --- a/patches/net/minecraft/world/entity/projectile/FishingHook.java.patch +++ b/patches/net/minecraft/world/entity/projectile/FishingHook.java.patch @@ -6,8 +6,8 @@ ItemStack itemstack1 = p_37137_.getOffhandItem(); - boolean flag = itemstack.is(Items.FISHING_ROD); - boolean flag1 = itemstack1.is(Items.FISHING_ROD); -+ boolean flag = itemstack.canPerformAction(net.neoforged.neoforge.common.ToolActions.FISHING_ROD_CAST); -+ boolean flag1 = itemstack1.canPerformAction(net.neoforged.neoforge.common.ToolActions.FISHING_ROD_CAST); ++ boolean flag = itemstack.canPerformAction(net.neoforged.neoforge.common.ItemAbilities.FISHING_ROD_CAST); ++ boolean flag1 = itemstack1.canPerformAction(net.neoforged.neoforge.common.ItemAbilities.FISHING_ROD_CAST); if (!p_37137_.isRemoved() && p_37137_.isAlive() && (flag || flag1) && !(this.distanceToSqr(p_37137_) > 1024.0)) { return false; } else { diff --git a/patches/net/minecraft/world/item/AxeItem.java.patch b/patches/net/minecraft/world/item/AxeItem.java.patch index ff11c8ad3a..9f9732d1ac 100644 --- a/patches/net/minecraft/world/item/AxeItem.java.patch +++ b/patches/net/minecraft/world/item/AxeItem.java.patch @@ -16,13 +16,13 @@ - private Optional evaluateNewBlockState(Level p_308922_, BlockPos p_308899_, @Nullable Player p_309192_, BlockState p_308900_) { - Optional optional = this.getStripped(p_308900_); + private Optional evaluateNewBlockState(Level p_308922_, BlockPos p_308899_, @Nullable Player p_309192_, BlockState p_308900_, UseOnContext p_40529_) { -+ Optional optional = Optional.ofNullable(p_308900_.getToolModifiedState(p_40529_, net.neoforged.neoforge.common.ToolActions.AXE_STRIP, false)); ++ Optional optional = Optional.ofNullable(p_308900_.getToolModifiedState(p_40529_, net.neoforged.neoforge.common.ItemAbilities.AXE_STRIP, false)); if (optional.isPresent()) { p_308922_.playSound(p_309192_, p_308899_, SoundEvents.AXE_STRIP, SoundSource.BLOCKS, 1.0F, 1.0F); return optional; } else { - Optional optional1 = WeatheringCopper.getPrevious(p_308900_); -+ Optional optional1 = Optional.ofNullable(p_308900_.getToolModifiedState(p_40529_, net.neoforged.neoforge.common.ToolActions.AXE_SCRAPE, false)); ++ Optional optional1 = Optional.ofNullable(p_308900_.getToolModifiedState(p_40529_, net.neoforged.neoforge.common.ItemAbilities.AXE_SCRAPE, false)); if (optional1.isPresent()) { p_308922_.playSound(p_309192_, p_308899_, SoundEvents.AXE_SCRAPE, SoundSource.BLOCKS, 1.0F, 1.0F); p_308922_.levelEvent(p_309192_, 3005, p_308899_, 0); @@ -30,7 +30,7 @@ } else { - Optional optional2 = Optional.ofNullable(HoneycombItem.WAX_OFF_BY_BLOCK.get().get(p_308900_.getBlock())) - .map(p_150694_ -> p_150694_.withPropertiesOf(p_308900_)); -+ Optional optional2 = Optional.ofNullable(p_308900_.getToolModifiedState(p_40529_, net.neoforged.neoforge.common.ToolActions.AXE_WAX_OFF, false)); ++ Optional optional2 = Optional.ofNullable(p_308900_.getToolModifiedState(p_40529_, net.neoforged.neoforge.common.ItemAbilities.AXE_WAX_OFF, false)); if (optional2.isPresent()) { p_308922_.playSound(p_309192_, p_308899_, SoundEvents.AXE_WAX_OFF, SoundSource.BLOCKS, 1.0F, 1.0F); p_308922_.levelEvent(p_309192_, 3004, p_308899_, 0); @@ -50,7 +50,7 @@ + } + + @Override -+ public boolean canPerformAction(ItemStack stack, net.neoforged.neoforge.common.ToolAction toolAction) { -+ return net.neoforged.neoforge.common.ToolActions.DEFAULT_AXE_ACTIONS.contains(toolAction); ++ public boolean canPerformAction(ItemStack stack, net.neoforged.neoforge.common.ItemAbility itemAbility) { ++ return net.neoforged.neoforge.common.ItemAbilities.DEFAULT_AXE_ACTIONS.contains(itemAbility); } } diff --git a/patches/net/minecraft/world/item/BrushItem.java.patch b/patches/net/minecraft/world/item/BrushItem.java.patch index 500b92816b..34e228180c 100644 --- a/patches/net/minecraft/world/item/BrushItem.java.patch +++ b/patches/net/minecraft/world/item/BrushItem.java.patch @@ -6,7 +6,7 @@ } + + @Override -+ public boolean canPerformAction(ItemStack stack, net.neoforged.neoforge.common.ToolAction toolAction) { -+ return net.neoforged.neoforge.common.ToolActions.DEFAULT_BRUSH_ACTIONS.contains(toolAction); ++ public boolean canPerformAction(ItemStack stack, net.neoforged.neoforge.common.ItemAbility itemAbility) { ++ return net.neoforged.neoforge.common.ItemAbilities.DEFAULT_BRUSH_ACTIONS.contains(itemAbility); + } } diff --git a/patches/net/minecraft/world/item/FishingRodItem.java.patch b/patches/net/minecraft/world/item/FishingRodItem.java.patch index 4e708db190..1a36fc3955 100644 --- a/patches/net/minecraft/world/item/FishingRodItem.java.patch +++ b/patches/net/minecraft/world/item/FishingRodItem.java.patch @@ -21,7 +21,7 @@ + /* ******************** FORGE START ******************** */ + + @Override -+ public boolean canPerformAction(ItemStack stack, net.neoforged.neoforge.common.ToolAction toolAction) { -+ return net.neoforged.neoforge.common.ToolActions.DEFAULT_FISHING_ROD_ACTIONS.contains(toolAction); ++ public boolean canPerformAction(ItemStack stack, net.neoforged.neoforge.common.ItemAbility itemAbility) { ++ return net.neoforged.neoforge.common.ItemAbilities.DEFAULT_FISHING_ROD_ACTIONS.contains(itemAbility); } } diff --git a/patches/net/minecraft/world/item/HoeItem.java.patch b/patches/net/minecraft/world/item/HoeItem.java.patch index 685c8b7c01..06b66cf47b 100644 --- a/patches/net/minecraft/world/item/HoeItem.java.patch +++ b/patches/net/minecraft/world/item/HoeItem.java.patch @@ -7,7 +7,7 @@ + /** + * @deprecated Forge: This map is patched out of vanilla code. + * Listen to {@link net.neoforged.neoforge.event.level.BlockEvent.BlockToolModificationEvent} -+ * or override {@link net.neoforged.neoforge.common.extensions.IBlockExtension#getToolModifiedState(BlockState, UseOnContext, net.neoforged.neoforge.common.ToolAction, boolean)}. ++ * or override {@link net.neoforged.neoforge.common.extensions.IBlockExtension#getToolModifiedState(BlockState, UseOnContext, net.neoforged.neoforge.common.ItemAbility, boolean)}. + */ + @Deprecated protected static final Map, Consumer>> TILLABLES = Maps.newHashMap( @@ -18,7 +18,7 @@ Level level = p_41341_.getLevel(); BlockPos blockpos = p_41341_.getClickedPos(); - Pair, Consumer> pair = TILLABLES.get(level.getBlockState(blockpos).getBlock()); -+ BlockState toolModifiedState = level.getBlockState(blockpos).getToolModifiedState(p_41341_, net.neoforged.neoforge.common.ToolActions.HOE_TILL, false); ++ BlockState toolModifiedState = level.getBlockState(blockpos).getToolModifiedState(p_41341_, net.neoforged.neoforge.common.ItemAbilities.HOE_TILL, false); + Pair, Consumer> pair = toolModifiedState == null ? null : Pair.of(ctx -> true, changeIntoState(toolModifiedState)); if (pair == null) { return InteractionResult.PASS; @@ -30,7 +30,7 @@ + } + + @Override -+ public boolean canPerformAction(ItemStack stack, net.neoforged.neoforge.common.ToolAction toolAction) { -+ return net.neoforged.neoforge.common.ToolActions.DEFAULT_HOE_ACTIONS.contains(toolAction); ++ public boolean canPerformAction(ItemStack stack, net.neoforged.neoforge.common.ItemAbility itemAbility) { ++ return net.neoforged.neoforge.common.ItemAbilities.DEFAULT_HOE_ACTIONS.contains(itemAbility); } } diff --git a/patches/net/minecraft/world/item/Item.java.patch b/patches/net/minecraft/world/item/Item.java.patch index f6cdede428..2ed1826529 100644 --- a/patches/net/minecraft/world/item/Item.java.patch +++ b/patches/net/minecraft/world/item/Item.java.patch @@ -48,7 +48,7 @@ public void onUseTick(Level p_41428_, LivingEntity p_41429_, ItemStack p_41430_, int p_41431_) { } -+ /** @deprecated Forge: {@link IItemExtension#onDestroyed(ItemEntity, DamageSource) Use damage source sensitive version} */ ++ /** @deprecated Forge: {@link net.neoforged.neoforge.common.extensions.IItemExtension#onDestroyed(ItemEntity, DamageSource) Use damage source sensitive version} */ + @Deprecated public void onDestroyed(ItemEntity p_150887_) { } diff --git a/patches/net/minecraft/world/item/PickaxeItem.java.patch b/patches/net/minecraft/world/item/PickaxeItem.java.patch index 9b4d5c6b71..f6f3418534 100644 --- a/patches/net/minecraft/world/item/PickaxeItem.java.patch +++ b/patches/net/minecraft/world/item/PickaxeItem.java.patch @@ -6,7 +6,7 @@ } + + @Override -+ public boolean canPerformAction(ItemStack stack, net.neoforged.neoforge.common.ToolAction toolAction) { -+ return net.neoforged.neoforge.common.ToolActions.DEFAULT_PICKAXE_ACTIONS.contains(toolAction); ++ public boolean canPerformAction(ItemStack stack, net.neoforged.neoforge.common.ItemAbility itemAbility) { ++ return net.neoforged.neoforge.common.ItemAbilities.DEFAULT_PICKAXE_ACTIONS.contains(itemAbility); + } } diff --git a/patches/net/minecraft/world/item/ShearsItem.java.patch b/patches/net/minecraft/world/item/ShearsItem.java.patch index 038829eaf4..f1dd49f96c 100644 --- a/patches/net/minecraft/world/item/ShearsItem.java.patch +++ b/patches/net/minecraft/world/item/ShearsItem.java.patch @@ -20,8 +20,8 @@ + } + + @Override -+ public boolean canPerformAction(ItemStack stack, net.neoforged.neoforge.common.ToolAction toolAction) { -+ return net.neoforged.neoforge.common.ToolActions.DEFAULT_SHEARS_ACTIONS.contains(toolAction); ++ public boolean canPerformAction(ItemStack stack, net.neoforged.neoforge.common.ItemAbility itemAbility) { ++ return net.neoforged.neoforge.common.ItemAbilities.DEFAULT_SHEARS_ACTIONS.contains(itemAbility); + } + + @Override diff --git a/patches/net/minecraft/world/item/ShieldItem.java.patch b/patches/net/minecraft/world/item/ShieldItem.java.patch index c0a5dc3b16..77f5c32148 100644 --- a/patches/net/minecraft/world/item/ShieldItem.java.patch +++ b/patches/net/minecraft/world/item/ShieldItem.java.patch @@ -7,8 +7,8 @@ + /* ******************** FORGE START ******************** */ + + @Override -+ public boolean canPerformAction(ItemStack stack, net.neoforged.neoforge.common.ToolAction toolAction) { -+ return net.neoforged.neoforge.common.ToolActions.DEFAULT_SHIELD_ACTIONS.contains(toolAction); ++ public boolean canPerformAction(ItemStack stack, net.neoforged.neoforge.common.ItemAbility itemAbility) { ++ return net.neoforged.neoforge.common.ItemAbilities.DEFAULT_SHIELD_ACTIONS.contains(itemAbility); + } + @Override diff --git a/patches/net/minecraft/world/item/ShovelItem.java.patch b/patches/net/minecraft/world/item/ShovelItem.java.patch index f42a9820f7..0723dbe878 100644 --- a/patches/net/minecraft/world/item/ShovelItem.java.patch +++ b/patches/net/minecraft/world/item/ShovelItem.java.patch @@ -5,7 +5,7 @@ } else { Player player = p_43119_.getPlayer(); - BlockState blockstate1 = FLATTENABLES.get(blockstate.getBlock()); -+ BlockState blockstate1 = blockstate.getToolModifiedState(p_43119_, net.neoforged.neoforge.common.ToolActions.SHOVEL_FLATTEN, false); ++ BlockState blockstate1 = blockstate.getToolModifiedState(p_43119_, net.neoforged.neoforge.common.ItemAbilities.SHOVEL_FLATTEN, false); BlockState blockstate2 = null; if (blockstate1 != null && level.getBlockState(blockpos.above()).isAir()) { level.playSound(player, blockpos, SoundEvents.SHOVEL_FLATTEN, SoundSource.BLOCKS, 1.0F, 1.0F); @@ -21,7 +21,7 @@ + } + + @Override -+ public boolean canPerformAction(ItemStack stack, net.neoforged.neoforge.common.ToolAction toolAction) { -+ return net.neoforged.neoforge.common.ToolActions.DEFAULT_SHOVEL_ACTIONS.contains(toolAction); ++ public boolean canPerformAction(ItemStack stack, net.neoforged.neoforge.common.ItemAbility itemAbility) { ++ return net.neoforged.neoforge.common.ItemAbilities.DEFAULT_SHOVEL_ACTIONS.contains(itemAbility); } } diff --git a/patches/net/minecraft/world/item/SwordItem.java.patch b/patches/net/minecraft/world/item/SwordItem.java.patch index 1549f174cf..bcff559cf7 100644 --- a/patches/net/minecraft/world/item/SwordItem.java.patch +++ b/patches/net/minecraft/world/item/SwordItem.java.patch @@ -33,7 +33,7 @@ + } + + @Override -+ public boolean canPerformAction(ItemStack stack, net.neoforged.neoforge.common.ToolAction toolAction) { -+ return net.neoforged.neoforge.common.ToolActions.DEFAULT_SWORD_ACTIONS.contains(toolAction); ++ public boolean canPerformAction(ItemStack stack, net.neoforged.neoforge.common.ItemAbility itemAbility) { ++ return net.neoforged.neoforge.common.ItemAbilities.DEFAULT_SWORD_ACTIONS.contains(itemAbility); } } diff --git a/patches/net/minecraft/world/item/TridentItem.java.patch b/patches/net/minecraft/world/item/TridentItem.java.patch index 26e3ad362f..1f32d6ec83 100644 --- a/patches/net/minecraft/world/item/TridentItem.java.patch +++ b/patches/net/minecraft/world/item/TridentItem.java.patch @@ -6,7 +6,7 @@ } + + @Override -+ public boolean canPerformAction(ItemStack stack, net.neoforged.neoforge.common.ToolAction toolAction) { -+ return net.neoforged.neoforge.common.ToolActions.DEFAULT_TRIDENT_ACTIONS.contains(toolAction); ++ public boolean canPerformAction(ItemStack stack, net.neoforged.neoforge.common.ItemAbility itemAbility) { ++ return net.neoforged.neoforge.common.ItemAbilities.DEFAULT_TRIDENT_ACTIONS.contains(itemAbility); + } } diff --git a/patches/net/minecraft/world/level/block/BambooSaplingBlock.java.patch b/patches/net/minecraft/world/level/block/BambooSaplingBlock.java.patch index a097d379e0..cce4907ae0 100644 --- a/patches/net/minecraft/world/level/block/BambooSaplingBlock.java.patch +++ b/patches/net/minecraft/world/level/block/BambooSaplingBlock.java.patch @@ -14,7 +14,7 @@ @Override protected float getDestroyProgress(BlockState p_48981_, Player p_48982_, BlockGetter p_48983_, BlockPos p_48984_) { - return p_48982_.getMainHandItem().getItem() instanceof SwordItem ? 1.0F : super.getDestroyProgress(p_48981_, p_48982_, p_48983_, p_48984_); -+ return p_48982_.getMainHandItem().canPerformAction(net.neoforged.neoforge.common.ToolActions.SWORD_DIG) ? 1.0F : super.getDestroyProgress(p_48981_, p_48982_, p_48983_, p_48984_); ++ return p_48982_.getMainHandItem().canPerformAction(net.neoforged.neoforge.common.ItemAbilities.SWORD_DIG) ? 1.0F : super.getDestroyProgress(p_48981_, p_48982_, p_48983_, p_48984_); } protected void growBamboo(Level p_48973_, BlockPos p_48974_) { diff --git a/patches/net/minecraft/world/level/block/BambooStalkBlock.java.patch b/patches/net/minecraft/world/level/block/BambooStalkBlock.java.patch index 55616552f9..efaeb2b815 100644 --- a/patches/net/minecraft/world/level/block/BambooStalkBlock.java.patch +++ b/patches/net/minecraft/world/level/block/BambooStalkBlock.java.patch @@ -38,7 +38,7 @@ @Override protected float getDestroyProgress(BlockState p_261691_, Player p_262171_, BlockGetter p_261621_, BlockPos p_261500_) { - return p_262171_.getMainHandItem().getItem() instanceof SwordItem ? 1.0F : super.getDestroyProgress(p_261691_, p_262171_, p_261621_, p_261500_); -+ return p_262171_.getMainHandItem().canPerformAction(net.neoforged.neoforge.common.ToolActions.SWORD_DIG) ? 1.0F : super.getDestroyProgress(p_261691_, p_262171_, p_261621_, p_261500_); ++ return p_262171_.getMainHandItem().canPerformAction(net.neoforged.neoforge.common.ItemAbilities.SWORD_DIG) ? 1.0F : super.getDestroyProgress(p_261691_, p_262171_, p_261621_, p_261500_); } protected void growBamboo(BlockState p_261855_, Level p_262076_, BlockPos p_262109_, RandomSource p_261633_, int p_261759_) { diff --git a/patches/net/minecraft/world/level/block/BeehiveBlock.java.patch b/patches/net/minecraft/world/level/block/BeehiveBlock.java.patch index 46dc3cac7f..5e59b85a4c 100644 --- a/patches/net/minecraft/world/level/block/BeehiveBlock.java.patch +++ b/patches/net/minecraft/world/level/block/BeehiveBlock.java.patch @@ -5,7 +5,7 @@ if (i >= 5) { Item item = p_316844_.getItem(); - if (p_316844_.is(Items.SHEARS)) { -+ if (p_316844_.canPerformAction(net.neoforged.neoforge.common.ToolActions.SHEARS_HARVEST)) { ++ if (p_316844_.canPerformAction(net.neoforged.neoforge.common.ItemAbilities.SHEARS_HARVEST)) { p_316306_.playSound(p_316824_, p_316824_.getX(), p_316824_.getY(), p_316824_.getZ(), SoundEvents.BEEHIVE_SHEAR, SoundSource.BLOCKS, 1.0F, 1.0F); dropHoneycomb(p_316306_, p_316497_); p_316844_.hurtAndBreak(1, p_316824_, LivingEntity.getSlotForHand(p_316436_)); diff --git a/patches/net/minecraft/world/level/block/PumpkinBlock.java.patch b/patches/net/minecraft/world/level/block/PumpkinBlock.java.patch index 961523813d..64546ae9af 100644 --- a/patches/net/minecraft/world/level/block/PumpkinBlock.java.patch +++ b/patches/net/minecraft/world/level/block/PumpkinBlock.java.patch @@ -5,7 +5,7 @@ ItemStack p_316383_, BlockState p_316676_, Level p_316272_, BlockPos p_316484_, Player p_316367_, InteractionHand p_316216_, BlockHitResult p_316827_ ) { - if (!p_316383_.is(Items.SHEARS)) { -+ if (!p_316383_.canPerformAction(net.neoforged.neoforge.common.ToolActions.SHEARS_CARVE)) { ++ if (!p_316383_.canPerformAction(net.neoforged.neoforge.common.ItemAbilities.SHEARS_CARVE)) { return super.useItemOn(p_316383_, p_316676_, p_316272_, p_316484_, p_316367_, p_316216_, p_316827_); } else if (p_316272_.isClientSide) { return ItemInteractionResult.sidedSuccess(p_316272_.isClientSide); diff --git a/patches/net/minecraft/world/level/block/TripWireBlock.java.patch b/patches/net/minecraft/world/level/block/TripWireBlock.java.patch index 3a879e54ff..1d1fd55985 100644 --- a/patches/net/minecraft/world/level/block/TripWireBlock.java.patch +++ b/patches/net/minecraft/world/level/block/TripWireBlock.java.patch @@ -5,7 +5,7 @@ @Override public BlockState playerWillDestroy(Level p_57615_, BlockPos p_57616_, BlockState p_57617_, Player p_57618_) { - if (!p_57615_.isClientSide && !p_57618_.getMainHandItem().isEmpty() && p_57618_.getMainHandItem().is(Items.SHEARS)) { -+ if (!p_57615_.isClientSide && !p_57618_.getMainHandItem().isEmpty() && p_57618_.getMainHandItem().canPerformAction(net.neoforged.neoforge.common.ToolActions.SHEARS_DISARM)) { ++ if (!p_57615_.isClientSide && !p_57618_.getMainHandItem().isEmpty() && p_57618_.getMainHandItem().canPerformAction(net.neoforged.neoforge.common.ItemAbilities.SHEARS_DISARM)) { p_57615_.setBlock(p_57616_, p_57617_.setValue(DISARMED, Boolean.valueOf(true)), 4); p_57615_.gameEvent(p_57618_, GameEvent.SHEAR, p_57616_); } diff --git a/src/generated/resources/data/minecraft/advancement/adventure/lighten_up.json b/src/generated/resources/data/minecraft/advancement/adventure/lighten_up.json index 83fad4c56b..e0bffbfecd 100644 --- a/src/generated/resources/data/minecraft/advancement/adventure/lighten_up.json +++ b/src/generated/resources/data/minecraft/advancement/adventure/lighten_up.json @@ -26,7 +26,7 @@ "condition": "minecraft:match_tool", "predicate": { "predicates": { - "neoforge:tool_action": "axe_wax_off" + "neoforge:item_ability": "axe_wax_off" } } } diff --git a/src/generated/resources/data/minecraft/advancement/husbandry/wax_off.json b/src/generated/resources/data/minecraft/advancement/husbandry/wax_off.json index 6b4c17a11d..1de6c8abf9 100644 --- a/src/generated/resources/data/minecraft/advancement/husbandry/wax_off.json +++ b/src/generated/resources/data/minecraft/advancement/husbandry/wax_off.json @@ -53,7 +53,7 @@ "condition": "minecraft:match_tool", "predicate": { "predicates": { - "neoforge:tool_action": "axe_wax_off" + "neoforge:item_ability": "axe_wax_off" } } } diff --git a/src/generated/resources/data/minecraft/loot_table/blocks/acacia_leaves.json b/src/generated/resources/data/minecraft/loot_table/blocks/acacia_leaves.json index 7c711bcc6e..a024d76585 100644 --- a/src/generated/resources/data/minecraft/loot_table/blocks/acacia_leaves.json +++ b/src/generated/resources/data/minecraft/loot_table/blocks/acacia_leaves.json @@ -14,8 +14,8 @@ "condition": "minecraft:any_of", "terms": [ { - "action": "shears_dig", - "condition": "neoforge:can_tool_perform_action" + "ability": "shears_dig", + "condition": "neoforge:can_item_perform_ability" }, { "condition": "minecraft:match_tool", @@ -70,8 +70,8 @@ "condition": "minecraft:any_of", "terms": [ { - "action": "shears_dig", - "condition": "neoforge:can_tool_perform_action" + "ability": "shears_dig", + "condition": "neoforge:can_item_perform_ability" }, { "condition": "minecraft:match_tool", diff --git a/src/generated/resources/data/minecraft/loot_table/blocks/azalea_leaves.json b/src/generated/resources/data/minecraft/loot_table/blocks/azalea_leaves.json index 06e77fb200..5b2f5139a8 100644 --- a/src/generated/resources/data/minecraft/loot_table/blocks/azalea_leaves.json +++ b/src/generated/resources/data/minecraft/loot_table/blocks/azalea_leaves.json @@ -14,8 +14,8 @@ "condition": "minecraft:any_of", "terms": [ { - "action": "shears_dig", - "condition": "neoforge:can_tool_perform_action" + "ability": "shears_dig", + "condition": "neoforge:can_item_perform_ability" }, { "condition": "minecraft:match_tool", @@ -70,8 +70,8 @@ "condition": "minecraft:any_of", "terms": [ { - "action": "shears_dig", - "condition": "neoforge:can_tool_perform_action" + "ability": "shears_dig", + "condition": "neoforge:can_item_perform_ability" }, { "condition": "minecraft:match_tool", diff --git a/src/generated/resources/data/minecraft/loot_table/blocks/birch_leaves.json b/src/generated/resources/data/minecraft/loot_table/blocks/birch_leaves.json index 18d6d70cbf..13979a6680 100644 --- a/src/generated/resources/data/minecraft/loot_table/blocks/birch_leaves.json +++ b/src/generated/resources/data/minecraft/loot_table/blocks/birch_leaves.json @@ -14,8 +14,8 @@ "condition": "minecraft:any_of", "terms": [ { - "action": "shears_dig", - "condition": "neoforge:can_tool_perform_action" + "ability": "shears_dig", + "condition": "neoforge:can_item_perform_ability" }, { "condition": "minecraft:match_tool", @@ -70,8 +70,8 @@ "condition": "minecraft:any_of", "terms": [ { - "action": "shears_dig", - "condition": "neoforge:can_tool_perform_action" + "ability": "shears_dig", + "condition": "neoforge:can_item_perform_ability" }, { "condition": "minecraft:match_tool", diff --git a/src/generated/resources/data/minecraft/loot_table/blocks/cherry_leaves.json b/src/generated/resources/data/minecraft/loot_table/blocks/cherry_leaves.json index 7363ad0653..e812d9ed25 100644 --- a/src/generated/resources/data/minecraft/loot_table/blocks/cherry_leaves.json +++ b/src/generated/resources/data/minecraft/loot_table/blocks/cherry_leaves.json @@ -14,8 +14,8 @@ "condition": "minecraft:any_of", "terms": [ { - "action": "shears_dig", - "condition": "neoforge:can_tool_perform_action" + "ability": "shears_dig", + "condition": "neoforge:can_item_perform_ability" }, { "condition": "minecraft:match_tool", @@ -70,8 +70,8 @@ "condition": "minecraft:any_of", "terms": [ { - "action": "shears_dig", - "condition": "neoforge:can_tool_perform_action" + "ability": "shears_dig", + "condition": "neoforge:can_item_perform_ability" }, { "condition": "minecraft:match_tool", diff --git a/src/generated/resources/data/minecraft/loot_table/blocks/cobweb.json b/src/generated/resources/data/minecraft/loot_table/blocks/cobweb.json index 10bfb8de71..8aea3bf802 100644 --- a/src/generated/resources/data/minecraft/loot_table/blocks/cobweb.json +++ b/src/generated/resources/data/minecraft/loot_table/blocks/cobweb.json @@ -14,8 +14,8 @@ "condition": "minecraft:any_of", "terms": [ { - "action": "shears_dig", - "condition": "neoforge:can_tool_perform_action" + "ability": "shears_dig", + "condition": "neoforge:can_item_perform_ability" }, { "condition": "minecraft:match_tool", diff --git a/src/generated/resources/data/minecraft/loot_table/blocks/dark_oak_leaves.json b/src/generated/resources/data/minecraft/loot_table/blocks/dark_oak_leaves.json index ffe9ac8146..a54ac6c737 100644 --- a/src/generated/resources/data/minecraft/loot_table/blocks/dark_oak_leaves.json +++ b/src/generated/resources/data/minecraft/loot_table/blocks/dark_oak_leaves.json @@ -14,8 +14,8 @@ "condition": "minecraft:any_of", "terms": [ { - "action": "shears_dig", - "condition": "neoforge:can_tool_perform_action" + "ability": "shears_dig", + "condition": "neoforge:can_item_perform_ability" }, { "condition": "minecraft:match_tool", @@ -70,8 +70,8 @@ "condition": "minecraft:any_of", "terms": [ { - "action": "shears_dig", - "condition": "neoforge:can_tool_perform_action" + "ability": "shears_dig", + "condition": "neoforge:can_item_perform_ability" }, { "condition": "minecraft:match_tool", @@ -136,8 +136,8 @@ "condition": "minecraft:any_of", "terms": [ { - "action": "shears_dig", - "condition": "neoforge:can_tool_perform_action" + "ability": "shears_dig", + "condition": "neoforge:can_item_perform_ability" }, { "condition": "minecraft:match_tool", diff --git a/src/generated/resources/data/minecraft/loot_table/blocks/dead_bush.json b/src/generated/resources/data/minecraft/loot_table/blocks/dead_bush.json index c5b3c4ae7c..1d9bf29db3 100644 --- a/src/generated/resources/data/minecraft/loot_table/blocks/dead_bush.json +++ b/src/generated/resources/data/minecraft/loot_table/blocks/dead_bush.json @@ -11,8 +11,8 @@ "type": "minecraft:item", "conditions": [ { - "action": "shears_dig", - "condition": "neoforge:can_tool_perform_action" + "ability": "shears_dig", + "condition": "neoforge:can_item_perform_ability" } ], "name": "minecraft:dead_bush" diff --git a/src/generated/resources/data/minecraft/loot_table/blocks/fern.json b/src/generated/resources/data/minecraft/loot_table/blocks/fern.json index 4e7a4a3aef..bad2f02f4c 100644 --- a/src/generated/resources/data/minecraft/loot_table/blocks/fern.json +++ b/src/generated/resources/data/minecraft/loot_table/blocks/fern.json @@ -11,8 +11,8 @@ "type": "minecraft:item", "conditions": [ { - "action": "shears_dig", - "condition": "neoforge:can_tool_perform_action" + "ability": "shears_dig", + "condition": "neoforge:can_item_perform_ability" } ], "name": "minecraft:fern" diff --git a/src/generated/resources/data/minecraft/loot_table/blocks/flowering_azalea_leaves.json b/src/generated/resources/data/minecraft/loot_table/blocks/flowering_azalea_leaves.json index d38bbf1c99..eade82b767 100644 --- a/src/generated/resources/data/minecraft/loot_table/blocks/flowering_azalea_leaves.json +++ b/src/generated/resources/data/minecraft/loot_table/blocks/flowering_azalea_leaves.json @@ -14,8 +14,8 @@ "condition": "minecraft:any_of", "terms": [ { - "action": "shears_dig", - "condition": "neoforge:can_tool_perform_action" + "ability": "shears_dig", + "condition": "neoforge:can_item_perform_ability" }, { "condition": "minecraft:match_tool", @@ -70,8 +70,8 @@ "condition": "minecraft:any_of", "terms": [ { - "action": "shears_dig", - "condition": "neoforge:can_tool_perform_action" + "ability": "shears_dig", + "condition": "neoforge:can_item_perform_ability" }, { "condition": "minecraft:match_tool", diff --git a/src/generated/resources/data/minecraft/loot_table/blocks/glow_lichen.json b/src/generated/resources/data/minecraft/loot_table/blocks/glow_lichen.json index b051d0889f..3a5478d926 100644 --- a/src/generated/resources/data/minecraft/loot_table/blocks/glow_lichen.json +++ b/src/generated/resources/data/minecraft/loot_table/blocks/glow_lichen.json @@ -8,8 +8,8 @@ "type": "minecraft:item", "conditions": [ { - "action": "shears_dig", - "condition": "neoforge:can_tool_perform_action" + "ability": "shears_dig", + "condition": "neoforge:can_item_perform_ability" } ], "functions": [ diff --git a/src/generated/resources/data/minecraft/loot_table/blocks/hanging_roots.json b/src/generated/resources/data/minecraft/loot_table/blocks/hanging_roots.json index 931e0838e8..49f30a4a64 100644 --- a/src/generated/resources/data/minecraft/loot_table/blocks/hanging_roots.json +++ b/src/generated/resources/data/minecraft/loot_table/blocks/hanging_roots.json @@ -5,8 +5,8 @@ "bonus_rolls": 0.0, "conditions": [ { - "action": "shears_dig", - "condition": "neoforge:can_tool_perform_action" + "ability": "shears_dig", + "condition": "neoforge:can_item_perform_ability" } ], "entries": [ diff --git a/src/generated/resources/data/minecraft/loot_table/blocks/jungle_leaves.json b/src/generated/resources/data/minecraft/loot_table/blocks/jungle_leaves.json index 75d0086e61..9d96d216dc 100644 --- a/src/generated/resources/data/minecraft/loot_table/blocks/jungle_leaves.json +++ b/src/generated/resources/data/minecraft/loot_table/blocks/jungle_leaves.json @@ -14,8 +14,8 @@ "condition": "minecraft:any_of", "terms": [ { - "action": "shears_dig", - "condition": "neoforge:can_tool_perform_action" + "ability": "shears_dig", + "condition": "neoforge:can_item_perform_ability" }, { "condition": "minecraft:match_tool", @@ -71,8 +71,8 @@ "condition": "minecraft:any_of", "terms": [ { - "action": "shears_dig", - "condition": "neoforge:can_tool_perform_action" + "ability": "shears_dig", + "condition": "neoforge:can_item_perform_ability" }, { "condition": "minecraft:match_tool", diff --git a/src/generated/resources/data/minecraft/loot_table/blocks/large_fern.json b/src/generated/resources/data/minecraft/loot_table/blocks/large_fern.json index 891c482253..f19a347877 100644 --- a/src/generated/resources/data/minecraft/loot_table/blocks/large_fern.json +++ b/src/generated/resources/data/minecraft/loot_table/blocks/large_fern.json @@ -32,8 +32,8 @@ "type": "minecraft:item", "conditions": [ { - "action": "shears_dig", - "condition": "neoforge:can_tool_perform_action" + "ability": "shears_dig", + "condition": "neoforge:can_item_perform_ability" } ], "functions": [ @@ -94,8 +94,8 @@ "type": "minecraft:item", "conditions": [ { - "action": "shears_dig", - "condition": "neoforge:can_tool_perform_action" + "ability": "shears_dig", + "condition": "neoforge:can_item_perform_ability" } ], "functions": [ diff --git a/src/generated/resources/data/minecraft/loot_table/blocks/mangrove_leaves.json b/src/generated/resources/data/minecraft/loot_table/blocks/mangrove_leaves.json index 6be01be9f3..e958cc76e2 100644 --- a/src/generated/resources/data/minecraft/loot_table/blocks/mangrove_leaves.json +++ b/src/generated/resources/data/minecraft/loot_table/blocks/mangrove_leaves.json @@ -14,8 +14,8 @@ "condition": "minecraft:any_of", "terms": [ { - "action": "shears_dig", - "condition": "neoforge:can_tool_perform_action" + "ability": "shears_dig", + "condition": "neoforge:can_item_perform_ability" }, { "condition": "minecraft:match_tool", diff --git a/src/generated/resources/data/minecraft/loot_table/blocks/nether_sprouts.json b/src/generated/resources/data/minecraft/loot_table/blocks/nether_sprouts.json index 4532fa2413..4e75140de7 100644 --- a/src/generated/resources/data/minecraft/loot_table/blocks/nether_sprouts.json +++ b/src/generated/resources/data/minecraft/loot_table/blocks/nether_sprouts.json @@ -5,8 +5,8 @@ "bonus_rolls": 0.0, "conditions": [ { - "action": "shears_dig", - "condition": "neoforge:can_tool_perform_action" + "ability": "shears_dig", + "condition": "neoforge:can_item_perform_ability" } ], "entries": [ diff --git a/src/generated/resources/data/minecraft/loot_table/blocks/oak_leaves.json b/src/generated/resources/data/minecraft/loot_table/blocks/oak_leaves.json index 3724dbee29..5980a594ba 100644 --- a/src/generated/resources/data/minecraft/loot_table/blocks/oak_leaves.json +++ b/src/generated/resources/data/minecraft/loot_table/blocks/oak_leaves.json @@ -14,8 +14,8 @@ "condition": "minecraft:any_of", "terms": [ { - "action": "shears_dig", - "condition": "neoforge:can_tool_perform_action" + "ability": "shears_dig", + "condition": "neoforge:can_item_perform_ability" }, { "condition": "minecraft:match_tool", @@ -70,8 +70,8 @@ "condition": "minecraft:any_of", "terms": [ { - "action": "shears_dig", - "condition": "neoforge:can_tool_perform_action" + "ability": "shears_dig", + "condition": "neoforge:can_item_perform_ability" }, { "condition": "minecraft:match_tool", @@ -136,8 +136,8 @@ "condition": "minecraft:any_of", "terms": [ { - "action": "shears_dig", - "condition": "neoforge:can_tool_perform_action" + "ability": "shears_dig", + "condition": "neoforge:can_item_perform_ability" }, { "condition": "minecraft:match_tool", diff --git a/src/generated/resources/data/minecraft/loot_table/blocks/seagrass.json b/src/generated/resources/data/minecraft/loot_table/blocks/seagrass.json index e18b278621..6c3d72d9e7 100644 --- a/src/generated/resources/data/minecraft/loot_table/blocks/seagrass.json +++ b/src/generated/resources/data/minecraft/loot_table/blocks/seagrass.json @@ -5,8 +5,8 @@ "bonus_rolls": 0.0, "conditions": [ { - "action": "shears_dig", - "condition": "neoforge:can_tool_perform_action" + "ability": "shears_dig", + "condition": "neoforge:can_item_perform_ability" } ], "entries": [ diff --git a/src/generated/resources/data/minecraft/loot_table/blocks/short_grass.json b/src/generated/resources/data/minecraft/loot_table/blocks/short_grass.json index 39d253d3db..119413291a 100644 --- a/src/generated/resources/data/minecraft/loot_table/blocks/short_grass.json +++ b/src/generated/resources/data/minecraft/loot_table/blocks/short_grass.json @@ -11,8 +11,8 @@ "type": "minecraft:item", "conditions": [ { - "action": "shears_dig", - "condition": "neoforge:can_tool_perform_action" + "ability": "shears_dig", + "condition": "neoforge:can_item_perform_ability" } ], "name": "minecraft:short_grass" diff --git a/src/generated/resources/data/minecraft/loot_table/blocks/small_dripleaf.json b/src/generated/resources/data/minecraft/loot_table/blocks/small_dripleaf.json index 82270c0e8f..bb6c912e82 100644 --- a/src/generated/resources/data/minecraft/loot_table/blocks/small_dripleaf.json +++ b/src/generated/resources/data/minecraft/loot_table/blocks/small_dripleaf.json @@ -5,8 +5,8 @@ "bonus_rolls": 0.0, "conditions": [ { - "action": "shears_dig", - "condition": "neoforge:can_tool_perform_action" + "ability": "shears_dig", + "condition": "neoforge:can_item_perform_ability" } ], "entries": [ diff --git a/src/generated/resources/data/minecraft/loot_table/blocks/spruce_leaves.json b/src/generated/resources/data/minecraft/loot_table/blocks/spruce_leaves.json index 82caea152e..b0cc677ad1 100644 --- a/src/generated/resources/data/minecraft/loot_table/blocks/spruce_leaves.json +++ b/src/generated/resources/data/minecraft/loot_table/blocks/spruce_leaves.json @@ -14,8 +14,8 @@ "condition": "minecraft:any_of", "terms": [ { - "action": "shears_dig", - "condition": "neoforge:can_tool_perform_action" + "ability": "shears_dig", + "condition": "neoforge:can_item_perform_ability" }, { "condition": "minecraft:match_tool", @@ -70,8 +70,8 @@ "condition": "minecraft:any_of", "terms": [ { - "action": "shears_dig", - "condition": "neoforge:can_tool_perform_action" + "ability": "shears_dig", + "condition": "neoforge:can_item_perform_ability" }, { "condition": "minecraft:match_tool", diff --git a/src/generated/resources/data/minecraft/loot_table/blocks/tall_grass.json b/src/generated/resources/data/minecraft/loot_table/blocks/tall_grass.json index d71351c438..58259f0266 100644 --- a/src/generated/resources/data/minecraft/loot_table/blocks/tall_grass.json +++ b/src/generated/resources/data/minecraft/loot_table/blocks/tall_grass.json @@ -32,8 +32,8 @@ "type": "minecraft:item", "conditions": [ { - "action": "shears_dig", - "condition": "neoforge:can_tool_perform_action" + "ability": "shears_dig", + "condition": "neoforge:can_item_perform_ability" } ], "functions": [ @@ -94,8 +94,8 @@ "type": "minecraft:item", "conditions": [ { - "action": "shears_dig", - "condition": "neoforge:can_tool_perform_action" + "ability": "shears_dig", + "condition": "neoforge:can_item_perform_ability" } ], "functions": [ diff --git a/src/generated/resources/data/minecraft/loot_table/blocks/tall_seagrass.json b/src/generated/resources/data/minecraft/loot_table/blocks/tall_seagrass.json index d2588b98fa..7b4e30ba1d 100644 --- a/src/generated/resources/data/minecraft/loot_table/blocks/tall_seagrass.json +++ b/src/generated/resources/data/minecraft/loot_table/blocks/tall_seagrass.json @@ -5,8 +5,8 @@ "bonus_rolls": 0.0, "conditions": [ { - "action": "shears_dig", - "condition": "neoforge:can_tool_perform_action" + "ability": "shears_dig", + "condition": "neoforge:can_item_perform_ability" } ], "entries": [ diff --git a/src/generated/resources/data/minecraft/loot_table/blocks/twisting_vines.json b/src/generated/resources/data/minecraft/loot_table/blocks/twisting_vines.json index bd58174df4..b6b335b984 100644 --- a/src/generated/resources/data/minecraft/loot_table/blocks/twisting_vines.json +++ b/src/generated/resources/data/minecraft/loot_table/blocks/twisting_vines.json @@ -14,8 +14,8 @@ "condition": "minecraft:any_of", "terms": [ { - "action": "shears_dig", - "condition": "neoforge:can_tool_perform_action" + "ability": "shears_dig", + "condition": "neoforge:can_item_perform_ability" }, { "condition": "minecraft:match_tool", diff --git a/src/generated/resources/data/minecraft/loot_table/blocks/twisting_vines_plant.json b/src/generated/resources/data/minecraft/loot_table/blocks/twisting_vines_plant.json index 71d151ce2c..6a0abeb056 100644 --- a/src/generated/resources/data/minecraft/loot_table/blocks/twisting_vines_plant.json +++ b/src/generated/resources/data/minecraft/loot_table/blocks/twisting_vines_plant.json @@ -14,8 +14,8 @@ "condition": "minecraft:any_of", "terms": [ { - "action": "shears_dig", - "condition": "neoforge:can_tool_perform_action" + "ability": "shears_dig", + "condition": "neoforge:can_item_perform_ability" }, { "condition": "minecraft:match_tool", diff --git a/src/generated/resources/data/minecraft/loot_table/blocks/vine.json b/src/generated/resources/data/minecraft/loot_table/blocks/vine.json index 2bb35878d4..1040c82281 100644 --- a/src/generated/resources/data/minecraft/loot_table/blocks/vine.json +++ b/src/generated/resources/data/minecraft/loot_table/blocks/vine.json @@ -5,8 +5,8 @@ "bonus_rolls": 0.0, "conditions": [ { - "action": "shears_dig", - "condition": "neoforge:can_tool_perform_action" + "ability": "shears_dig", + "condition": "neoforge:can_item_perform_ability" } ], "entries": [ diff --git a/src/generated/resources/data/minecraft/loot_table/blocks/weeping_vines.json b/src/generated/resources/data/minecraft/loot_table/blocks/weeping_vines.json index 8f71803a44..fbb21c4970 100644 --- a/src/generated/resources/data/minecraft/loot_table/blocks/weeping_vines.json +++ b/src/generated/resources/data/minecraft/loot_table/blocks/weeping_vines.json @@ -14,8 +14,8 @@ "condition": "minecraft:any_of", "terms": [ { - "action": "shears_dig", - "condition": "neoforge:can_tool_perform_action" + "ability": "shears_dig", + "condition": "neoforge:can_item_perform_ability" }, { "condition": "minecraft:match_tool", diff --git a/src/generated/resources/data/minecraft/loot_table/blocks/weeping_vines_plant.json b/src/generated/resources/data/minecraft/loot_table/blocks/weeping_vines_plant.json index 80301d5cdc..624cb5305a 100644 --- a/src/generated/resources/data/minecraft/loot_table/blocks/weeping_vines_plant.json +++ b/src/generated/resources/data/minecraft/loot_table/blocks/weeping_vines_plant.json @@ -14,8 +14,8 @@ "condition": "minecraft:any_of", "terms": [ { - "action": "shears_dig", - "condition": "neoforge:can_tool_perform_action" + "ability": "shears_dig", + "condition": "neoforge:can_item_perform_ability" }, { "condition": "minecraft:match_tool", diff --git a/src/main/java/net/neoforged/neoforge/common/ToolActions.java b/src/main/java/net/neoforged/neoforge/common/ItemAbilities.java similarity index 51% rename from src/main/java/net/neoforged/neoforge/common/ToolActions.java rename to src/main/java/net/neoforged/neoforge/common/ItemAbilities.java index 1a8d47b2a4..f1069d9f0f 100644 --- a/src/main/java/net/neoforged/neoforge/common/ToolActions.java +++ b/src/main/java/net/neoforged/neoforge/common/ItemAbilities.java @@ -12,122 +12,122 @@ import net.neoforged.neoforge.common.extensions.IBlockExtension; import net.neoforged.neoforge.common.extensions.IItemExtension; -public class ToolActions { +public class ItemAbilities { /** * Exposed by axes to allow querying tool behaviours */ - public static final ToolAction AXE_DIG = ToolAction.get("axe_dig"); + public static final ItemAbility AXE_DIG = ItemAbility.get("axe_dig"); /** * Exposed by pickaxes to allow querying tool behaviours */ - public static final ToolAction PICKAXE_DIG = ToolAction.get("pickaxe_dig"); + public static final ItemAbility PICKAXE_DIG = ItemAbility.get("pickaxe_dig"); /** * Exposed by shovels to allow querying tool behaviours */ - public static final ToolAction SHOVEL_DIG = ToolAction.get("shovel_dig"); + public static final ItemAbility SHOVEL_DIG = ItemAbility.get("shovel_dig"); /** * Exposed by hoes to allow querying tool behaviours */ - public static final ToolAction HOE_DIG = ToolAction.get("hoe_dig"); + public static final ItemAbility HOE_DIG = ItemAbility.get("hoe_dig"); /** * Exposed by swords to allow querying tool behaviours */ - public static final ToolAction SWORD_DIG = ToolAction.get("sword_dig"); + public static final ItemAbility SWORD_DIG = ItemAbility.get("sword_dig"); /** * Exposed by shears to allow querying tool behaviours */ - public static final ToolAction SHEARS_DIG = ToolAction.get("shears_dig"); + public static final ItemAbility SHEARS_DIG = ItemAbility.get("shears_dig"); /** * Passed onto {@link IBlockExtension#getToolModifiedState} when an axe wants to strip a log */ - public static final ToolAction AXE_STRIP = ToolAction.get("axe_strip"); + public static final ItemAbility AXE_STRIP = ItemAbility.get("axe_strip"); /** * Passed onto {@link IBlockExtension#getToolModifiedState} when an axe wants to scrape oxidization off copper */ - public static final ToolAction AXE_SCRAPE = ToolAction.get("axe_scrape"); + public static final ItemAbility AXE_SCRAPE = ItemAbility.get("axe_scrape"); /** * Passed onto {@link IBlockExtension#getToolModifiedState} when an axe wants to remove wax out of copper */ - public static final ToolAction AXE_WAX_OFF = ToolAction.get("axe_wax_off"); + public static final ItemAbility AXE_WAX_OFF = ItemAbility.get("axe_wax_off"); /** * Passed onto {@link IBlockExtension#getToolModifiedState} when a shovel wants to turn dirt into path */ - public static final ToolAction SHOVEL_FLATTEN = ToolAction.get("shovel_flatten"); + public static final ItemAbility SHOVEL_FLATTEN = ItemAbility.get("shovel_flatten"); /** * Used during player attack to figure out if a sweep attack should be performed * * @see IItemExtension#getSweepHitBox */ - public static final ToolAction SWORD_SWEEP = ToolAction.get("sword_sweep"); + public static final ItemAbility SWORD_SWEEP = ItemAbility.get("sword_sweep"); /** * 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. * Example: Right click with shears on a beehive with honey level 5 to harvest it */ - public static final ToolAction SHEARS_HARVEST = ToolAction.get("shears_harvest"); + public static final ItemAbility SHEARS_HARVEST = ItemAbility.get("shears_harvest"); /** * 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. * Example: Right click with shears o a pumpkin to carve it */ - public static final ToolAction SHEARS_CARVE = ToolAction.get("shears_carve"); + public static final ItemAbility SHEARS_CARVE = ItemAbility.get("shears_carve"); /** * This action is exposed by shears and corresponds to a disarm action that is triggered by breaking a block that supports such behaviour. * Example: Breaking a trip wire with shears to disarm it. */ - public static final ToolAction SHEARS_DISARM = ToolAction.get("shears_disarm"); + public static final ItemAbility SHEARS_DISARM = ItemAbility.get("shears_disarm"); /** * Passed onto {@link IBlockExtension#getToolModifiedState} when a hoe wants to turn dirt into soil */ - public static final ToolAction HOE_TILL = ToolAction.get("till"); + public static final ItemAbility HOE_TILL = ItemAbility.get("till"); /** - * A tool action corresponding to the 'block' action of shields. - * Items should expose this tool action in order to enable damage blocking when the item is being "used". + * An item ability corresponding to the 'block' action of shields. + * Items should expose this item ability in order to enable damage blocking when the item is being "used". */ - public static final ToolAction SHIELD_BLOCK = ToolAction.get("shield_block"); + public static final ItemAbility SHIELD_BLOCK = ItemAbility.get("shield_block"); /** * This action corresponds to right-clicking the fishing rod to reel it in after earlier casting. * Needed for modded fishing rods so that the FishingHook entity can properly function. */ - public static final ToolAction FISHING_ROD_CAST = ToolAction.get("fishing_rod_cast"); + public static final ItemAbility FISHING_ROD_CAST = ItemAbility.get("fishing_rod_cast"); /** * Exposed by trident-like items to allow querying tool behaviours for items that can be thrown like Tridents. */ - public static final ToolAction TRIDENT_THROW = ToolAction.get("trident_throw"); + public static final ItemAbility TRIDENT_THROW = ItemAbility.get("trident_throw"); /** * Exposed by brushes to allow querying tool behaviours for items that can brush Suspicious Blocks. */ - public static final ToolAction BRUSH_BRUSH = ToolAction.get("brush_brush"); + public static final ItemAbility BRUSH_BRUSH = ItemAbility.get("brush_brush"); // Default actions supported by each tool type - public static final Set DEFAULT_AXE_ACTIONS = of(AXE_DIG, AXE_STRIP, AXE_SCRAPE, AXE_WAX_OFF); - public static final Set DEFAULT_HOE_ACTIONS = of(HOE_DIG, HOE_TILL); - public static final Set DEFAULT_SHOVEL_ACTIONS = of(SHOVEL_DIG, SHOVEL_FLATTEN); - public static final Set DEFAULT_PICKAXE_ACTIONS = of(PICKAXE_DIG); - public static final Set DEFAULT_SWORD_ACTIONS = of(SWORD_DIG, SWORD_SWEEP); - public static final Set DEFAULT_SHEARS_ACTIONS = of(SHEARS_DIG, SHEARS_HARVEST, SHEARS_CARVE, SHEARS_DISARM); - public static final Set DEFAULT_SHIELD_ACTIONS = of(SHIELD_BLOCK); - public static final Set DEFAULT_FISHING_ROD_ACTIONS = of(FISHING_ROD_CAST); - public static final Set DEFAULT_TRIDENT_ACTIONS = of(TRIDENT_THROW); - public static final Set DEFAULT_BRUSH_ACTIONS = of(BRUSH_BRUSH); - - private static Set of(ToolAction... actions) { + public static final Set DEFAULT_AXE_ACTIONS = of(AXE_DIG, AXE_STRIP, AXE_SCRAPE, AXE_WAX_OFF); + public static final Set DEFAULT_HOE_ACTIONS = of(HOE_DIG, HOE_TILL); + public static final Set DEFAULT_SHOVEL_ACTIONS = of(SHOVEL_DIG, SHOVEL_FLATTEN); + public static final Set DEFAULT_PICKAXE_ACTIONS = of(PICKAXE_DIG); + public static final Set DEFAULT_SWORD_ACTIONS = of(SWORD_DIG, SWORD_SWEEP); + public static final Set DEFAULT_SHEARS_ACTIONS = of(SHEARS_DIG, SHEARS_HARVEST, SHEARS_CARVE, SHEARS_DISARM); + public static final Set DEFAULT_SHIELD_ACTIONS = of(SHIELD_BLOCK); + public static final Set DEFAULT_FISHING_ROD_ACTIONS = of(FISHING_ROD_CAST); + public static final Set DEFAULT_TRIDENT_ACTIONS = of(TRIDENT_THROW); + public static final Set DEFAULT_BRUSH_ACTIONS = of(BRUSH_BRUSH); + + private static Set of(ItemAbility... actions) { return Stream.of(actions).collect(Collectors.toCollection(Sets::newIdentityHashSet)); } } diff --git a/src/main/java/net/neoforged/neoforge/common/ToolAction.java b/src/main/java/net/neoforged/neoforge/common/ItemAbility.java similarity index 56% rename from src/main/java/net/neoforged/neoforge/common/ToolAction.java rename to src/main/java/net/neoforged/neoforge/common/ItemAbility.java index c96b6defb8..befe2fb494 100644 --- a/src/main/java/net/neoforged/neoforge/common/ToolAction.java +++ b/src/main/java/net/neoforged/neoforge/common/ItemAbility.java @@ -11,29 +11,29 @@ import java.util.Map; import java.util.concurrent.ConcurrentHashMap; -public final class ToolAction { - private static final Map actions = new ConcurrentHashMap<>(); +public final class ItemAbility { + private static final Map actions = new ConcurrentHashMap<>(); - public static Codec CODEC = Codec.STRING.xmap(ToolAction::get, ToolAction::name); + public static Codec CODEC = Codec.STRING.xmap(ItemAbility::get, ItemAbility::name); /** * Returns all registered actions. * This collection can be kept around, and will update itself in response to changes to the map. * See {@link ConcurrentHashMap#values()} for details. */ - public static Collection getActions() { + public static Collection getActions() { return Collections.unmodifiableCollection(actions.values()); } /** - * Gets or creates a new ToolAction for the given name. + * Gets or creates a new ItemAbility for the given name. */ - public static ToolAction get(String name) { - return actions.computeIfAbsent(name, ToolAction::new); + public static ItemAbility get(String name) { + return actions.computeIfAbsent(name, ItemAbility::new); } /** - * Returns the name of this tool action + * Returns the name of this item ability */ public String name() { return name; @@ -41,15 +41,15 @@ public String name() { @Override public String toString() { - return "ToolAction[" + name + "]"; + return "ItemAbility[" + name + "]"; } private final String name; /** - * Use {@link #get(String)} to get or create a ToolAction + * Use {@link #get(String)} to get or create a ItemAbility */ - private ToolAction(String name) { + private ItemAbility(String name) { this.name = name; } } diff --git a/src/main/java/net/neoforged/neoforge/common/NeoForgeMod.java b/src/main/java/net/neoforged/neoforge/common/NeoForgeMod.java index 71861b234a..f4252d5547 100644 --- a/src/main/java/net/neoforged/neoforge/common/NeoForgeMod.java +++ b/src/main/java/net/neoforged/neoforge/common/NeoForgeMod.java @@ -86,9 +86,9 @@ import net.neoforged.fml.loading.progress.StartupNotificationManager; import net.neoforged.neoforge.capabilities.CapabilityHooks; import net.neoforged.neoforge.client.extensions.common.IClientFluidTypeExtensions; +import net.neoforged.neoforge.common.advancements.critereon.ItemAbilityPredicate; import net.neoforged.neoforge.common.advancements.critereon.PiglinCurrencyItemPredicate; import net.neoforged.neoforge.common.advancements.critereon.PiglinNeutralArmorEntityPredicate; -import net.neoforged.neoforge.common.advancements.critereon.ToolActionItemPredicate; import net.neoforged.neoforge.common.conditions.AndCondition; import net.neoforged.neoforge.common.conditions.FalseCondition; import net.neoforged.neoforge.common.conditions.ICondition; @@ -122,7 +122,7 @@ import net.neoforged.neoforge.common.data.internal.NeoForgeStructureTagsProvider; import net.neoforged.neoforge.common.data.internal.VanillaSoundDefinitionsProvider; import net.neoforged.neoforge.common.loot.AddTableLootModifier; -import net.neoforged.neoforge.common.loot.CanToolPerformAction; +import net.neoforged.neoforge.common.loot.CanItemPerformAbility; import net.neoforged.neoforge.common.loot.IGlobalLootModifier; import net.neoforged.neoforge.common.loot.LootTableIdCondition; import net.neoforged.neoforge.common.world.BiomeModifier; @@ -396,7 +396,7 @@ public class NeoForgeMod { public static final DeferredHolder, MapCodec> PIGLIN_NEUTRAL_ARMOR_PREDICATE = ENTITY_PREDICATE_CODECS.register("piglin_neutral_armor", () -> PiglinNeutralArmorEntityPredicate.CODEC); private static final DeferredRegister> ITEM_SUB_PREDICATES = DeferredRegister.create(Registries.ITEM_SUB_PREDICATE_TYPE, NeoForgeVersion.MOD_ID); - public static final DeferredHolder, ItemSubPredicate.Type> TOOL_ACTION_PREDICATE = ITEM_SUB_PREDICATES.register("tool_action", () -> ToolActionItemPredicate.TYPE); + public static final DeferredHolder, ItemSubPredicate.Type> ITEM_ABILITY_PREDICATE = ITEM_SUB_PREDICATES.register("item_ability", () -> ItemAbilityPredicate.TYPE); public static final DeferredHolder, ItemSubPredicate.Type> PIGLIN_CURRENCY_PREDICATE = ITEM_SUB_PREDICATES.register("piglin_currency", () -> PiglinCurrencyItemPredicate.TYPE); private static final DeferredRegister VANILLA_FLUID_TYPES = DeferredRegister.create(NeoForgeRegistries.Keys.FLUID_TYPES, "minecraft"); @@ -726,7 +726,7 @@ public void registerLootData(RegisterEvent event) { return; event.register(Registries.LOOT_CONDITION_TYPE, ResourceLocation.fromNamespaceAndPath("neoforge", "loot_table_id"), () -> LootTableIdCondition.LOOT_TABLE_ID); - event.register(Registries.LOOT_CONDITION_TYPE, ResourceLocation.fromNamespaceAndPath("neoforge", "can_tool_perform_action"), () -> CanToolPerformAction.LOOT_CONDITION_TYPE); + event.register(Registries.LOOT_CONDITION_TYPE, ResourceLocation.fromNamespaceAndPath("neoforge", "can_item_perform_ability"), () -> CanItemPerformAbility.LOOT_CONDITION_TYPE); } public static final PermissionNode USE_SELECTORS_PERMISSION = new PermissionNode<>(NeoForgeVersion.MOD_ID, "use_entity_selectors", diff --git a/src/main/java/net/neoforged/neoforge/common/Tags.java b/src/main/java/net/neoforged/neoforge/common/Tags.java index d065ddcc27..51d16de953 100644 --- a/src/main/java/net/neoforged/neoforge/common/Tags.java +++ b/src/main/java/net/neoforged/neoforge/common/Tags.java @@ -586,68 +586,68 @@ public static class Items { // Tools and Armors /** * A tag containing all existing tools. Do not use this tag for determining a tool's behavior. - * Please use {@link net.neoforged.neoforge.common.ToolActions} instead for what action a tool can do. + * Please use {@link ItemAbilities} instead for what action a tool can do. * - * @see ToolAction - * @see ToolActions + * @see ItemAbility + * @see ItemAbilities */ public static final TagKey TOOLS = tag("tools"); /** * A tag containing all existing shields. Do not use this tag for determining a tool's behavior. - * Please use {@link net.neoforged.neoforge.common.ToolActions} instead for what action a tool can do. + * Please use {@link ItemAbilities} instead for what action a tool can do. * - * @see ToolAction - * @see ToolActions + * @see ItemAbility + * @see ItemAbilities */ public static final TagKey TOOLS_SHIELD = tag("tools/shield"); /** * A tag containing all existing bows. Do not use this tag for determining a tool's behavior. - * Please use {@link net.neoforged.neoforge.common.ToolActions} instead for what action a tool can do. + * Please use {@link ItemAbilities} instead for what action a tool can do. * - * @see ToolAction - * @see ToolActions + * @see ItemAbility + * @see ItemAbilities */ public static final TagKey TOOLS_BOW = tag("tools/bow"); /** * A tag containing all existing crossbows. Do not use this tag for determining a tool's behavior. - * Please use {@link net.neoforged.neoforge.common.ToolActions} instead for what action a tool can do. + * Please use {@link ItemAbilities} instead for what action a tool can do. * - * @see net.neoforged.neoforge.common.ToolAction - * @see net.neoforged.neoforge.common.ToolActions + * @see ItemAbility + * @see ItemAbilities */ public static final TagKey TOOLS_CROSSBOW = tag("tools/crossbow"); /** * A tag containing all existing fishing rods. Do not use this tag for determining a tool's behavior. - * Please use {@link net.neoforged.neoforge.common.ToolActions} instead for what action a tool can do. + * Please use {@link ItemAbilities} instead for what action a tool can do. * - * @see net.neoforged.neoforge.common.ToolAction - * @see net.neoforged.neoforge.common.ToolActions + * @see ItemAbility + * @see ItemAbilities */ public static final TagKey TOOLS_FISHING_ROD = tag("tools/fishing_rod"); /** * A tag containing all existing spears. Other tools such as throwing knives or boomerangs * should not be put into this tag and should be put into their own tool tags. * Do not use this tag for determining a tool's behavior. - * Please use {@link net.neoforged.neoforge.common.ToolActions} instead for what action a tool can do. + * Please use {@link ItemAbilities} instead for what action a tool can do. * - * @see ToolAction - * @see ToolActions + * @see ItemAbility + * @see ItemAbilities */ public static final TagKey TOOLS_SPEAR = tag("tools/spear"); /** * A tag containing all existing shears. Do not use this tag for determining a tool's behavior. - * Please use {@link net.neoforged.neoforge.common.ToolActions} instead for what action a tool can do. + * Please use {@link ItemAbilities} instead for what action a tool can do. * - * @see ToolAction - * @see ToolActions + * @see ItemAbility + * @see ItemAbilities */ public static final TagKey TOOLS_SHEAR = tag("tools/shear"); /** * A tag containing all existing brushes. Do not use this tag for determining a tool's behavior. - * Please use {@link net.neoforged.neoforge.common.ToolActions} instead for what action a tool can do. + * Please use {@link ItemAbilities} instead for what action a tool can do. * - * @see ToolAction - * @see ToolActions + * @see ItemAbility + * @see ItemAbilities */ public static final TagKey TOOLS_BRUSH = tag("tools/brush"); /** diff --git a/src/main/java/net/neoforged/neoforge/common/advancements/critereon/ToolActionItemPredicate.java b/src/main/java/net/neoforged/neoforge/common/advancements/critereon/ItemAbilityPredicate.java similarity index 51% rename from src/main/java/net/neoforged/neoforge/common/advancements/critereon/ToolActionItemPredicate.java rename to src/main/java/net/neoforged/neoforge/common/advancements/critereon/ItemAbilityPredicate.java index 879aee9485..59a56b0fb7 100644 --- a/src/main/java/net/neoforged/neoforge/common/advancements/critereon/ToolActionItemPredicate.java +++ b/src/main/java/net/neoforged/neoforge/common/advancements/critereon/ItemAbilityPredicate.java @@ -8,11 +8,11 @@ import com.mojang.serialization.Codec; import net.minecraft.advancements.critereon.ItemSubPredicate; import net.minecraft.world.item.ItemStack; -import net.neoforged.neoforge.common.ToolAction; +import net.neoforged.neoforge.common.ItemAbility; -public record ToolActionItemPredicate(ToolAction action) implements ItemSubPredicate { - public static final Codec CODEC = ToolAction.CODEC.xmap(ToolActionItemPredicate::new, ToolActionItemPredicate::action); - public static final Type TYPE = new Type<>(ToolActionItemPredicate.CODEC); +public record ItemAbilityPredicate(ItemAbility action) implements ItemSubPredicate { + public static final Codec CODEC = ItemAbility.CODEC.xmap(ItemAbilityPredicate::new, ItemAbilityPredicate::action); + public static final Type TYPE = new Type<>(ItemAbilityPredicate.CODEC); @Override public boolean matches(ItemStack stack) { diff --git a/src/main/java/net/neoforged/neoforge/common/data/internal/NeoForgeAdvancementProvider.java b/src/main/java/net/neoforged/neoforge/common/data/internal/NeoForgeAdvancementProvider.java index 613c6833f4..675fb1281a 100644 --- a/src/main/java/net/neoforged/neoforge/common/data/internal/NeoForgeAdvancementProvider.java +++ b/src/main/java/net/neoforged/neoforge/common/data/internal/NeoForgeAdvancementProvider.java @@ -44,11 +44,11 @@ import net.minecraft.world.level.storage.loot.predicates.LootItemEntityPropertyCondition; import net.minecraft.world.level.storage.loot.predicates.MatchTool; import net.neoforged.fml.util.ObfuscationReflectionHelper; -import net.neoforged.neoforge.common.ToolAction; -import net.neoforged.neoforge.common.ToolActions; +import net.neoforged.neoforge.common.ItemAbilities; +import net.neoforged.neoforge.common.ItemAbility; +import net.neoforged.neoforge.common.advancements.critereon.ItemAbilityPredicate; import net.neoforged.neoforge.common.advancements.critereon.PiglinCurrencyItemPredicate; import net.neoforged.neoforge.common.advancements.critereon.PiglinNeutralArmorEntityPredicate; -import net.neoforged.neoforge.common.advancements.critereon.ToolActionItemPredicate; import net.neoforged.neoforge.common.data.AdvancementProvider; import net.neoforged.neoforge.common.data.ExistingFileHelper; import org.jetbrains.annotations.Nullable; @@ -60,7 +60,7 @@ public NeoForgeAdvancementProvider(PackOutput output, CompletableFuture getVanillaAdvancementProviders(PackOutput output, CompletableFuture registries) { List, HolderLookup.Provider, Criterion>> criteriaReplacers = new ArrayList<>(); - criteriaReplacers.add(replaceMatchToolCriteria(ToolActions.AXE_WAX_OFF, getPrivateValue(VanillaHusbandryAdvancements.class, null, "WAX_SCRAPING_TOOLS"))); + criteriaReplacers.add(replaceMatchToolCriteria(ItemAbilities.AXE_WAX_OFF, getPrivateValue(VanillaHusbandryAdvancements.class, null, "WAX_SCRAPING_TOOLS"))); criteriaReplacers.add(replaceInteractCriteria(ItemPredicate.Builder.item().withSubPredicate(PiglinCurrencyItemPredicate.TYPE, PiglinCurrencyItemPredicate.INSTANCE).build(), PiglinAi.BARTERING_ITEM)); criteriaReplacers.add(replaceWearingPredicate(EntityPredicate.Builder.entity().subPredicate(PiglinNeutralArmorEntityPredicate.INSTANCE).build(), predicate -> { if (predicate.head().filter(item -> predicateMatches(item, Items.GOLDEN_HELMET)).isPresent()) { @@ -79,10 +79,10 @@ private static List getVanillaAdvancementProviders(PackOut .toList(); } - private static BiFunction, HolderLookup.Provider, Criterion> replaceMatchToolCriteria(ToolAction toolAction, ItemLike... targetItem) { + private static BiFunction, HolderLookup.Provider, Criterion> replaceMatchToolCriteria(ItemAbility itemAbility, ItemLike... targetItem) { UnaryOperator replacer = condition -> { if (condition instanceof MatchTool toolMatch && toolMatch.predicate().filter(predicate -> predicateMatches(predicate, targetItem)).isPresent()) { - return new MatchTool(Optional.of(ItemPredicate.Builder.item().withSubPredicate(ToolActionItemPredicate.TYPE, new ToolActionItemPredicate(toolAction)).build())); + return new MatchTool(Optional.of(ItemPredicate.Builder.item().withSubPredicate(ItemAbilityPredicate.TYPE, new ItemAbilityPredicate(itemAbility)).build())); } return null; }; diff --git a/src/main/java/net/neoforged/neoforge/common/data/internal/NeoForgeLootTableProvider.java b/src/main/java/net/neoforged/neoforge/common/data/internal/NeoForgeLootTableProvider.java index 3fb866b21f..0198966892 100644 --- a/src/main/java/net/neoforged/neoforge/common/data/internal/NeoForgeLootTableProvider.java +++ b/src/main/java/net/neoforged/neoforge/common/data/internal/NeoForgeLootTableProvider.java @@ -50,12 +50,12 @@ import net.minecraft.world.level.storage.loot.predicates.LootItemCondition; import net.minecraft.world.level.storage.loot.predicates.MatchTool; import net.neoforged.fml.util.ObfuscationReflectionHelper; -import net.neoforged.neoforge.common.ToolActions; -import net.neoforged.neoforge.common.loot.CanToolPerformAction; +import net.neoforged.neoforge.common.ItemAbilities; +import net.neoforged.neoforge.common.loot.CanItemPerformAbility; import org.jetbrains.annotations.Nullable; /** - * Currently used only for replacing shears item to shears_dig tool action + * Currently used only for replacing shears item to shears_dig item ability */ public final class NeoForgeLootTableProvider extends LootTableProvider { private final List> conditionReplacers = new ArrayList<>(); @@ -73,7 +73,7 @@ protected void validate(WritableRegistry writableregistry, Validation public List getTables() { replaceLootItemCondition(condition -> { if (condition instanceof MatchTool matchTool && checkMatchTool(matchTool, Items.SHEARS)) { - return CanToolPerformAction.canToolPerformAction(ToolActions.SHEARS_DIG); + return CanItemPerformAbility.canItemPerformAbility(ItemAbilities.SHEARS_DIG); } return null; }); diff --git a/src/main/java/net/neoforged/neoforge/common/extensions/IBlockExtension.java b/src/main/java/net/neoforged/neoforge/common/extensions/IBlockExtension.java index 982171cfec..e720d04eb6 100644 --- a/src/main/java/net/neoforged/neoforge/common/extensions/IBlockExtension.java +++ b/src/main/java/net/neoforged/neoforge/common/extensions/IBlockExtension.java @@ -73,8 +73,8 @@ import net.neoforged.neoforge.capabilities.BlockCapabilityCache; import net.neoforged.neoforge.client.ClientHooks; import net.neoforged.neoforge.client.model.data.ModelData; -import net.neoforged.neoforge.common.ToolAction; -import net.neoforged.neoforge.common.ToolActions; +import net.neoforged.neoforge.common.ItemAbilities; +import net.neoforged.neoforge.common.ItemAbility; import net.neoforged.neoforge.common.enums.BubbleColumnDirection; import net.neoforged.neoforge.common.util.TriState; import net.neoforged.neoforge.common.world.AuxiliaryLightManager; @@ -744,31 +744,31 @@ default boolean shouldDisplayFluidOverlay(BlockState state, BlockAndTintGetter l /** * Returns the state that this block should transform into when right-clicked by a tool. - * For example: Used to determine if {@link ToolActions#AXE_STRIP an axe can strip}, - * {@link ToolActions#SHOVEL_FLATTEN a shovel can path}, or {@link ToolActions#HOE_TILL a hoe can till}. + * For example: Used to determine if {@link ItemAbilities#AXE_STRIP an axe can strip}, + * {@link ItemAbilities#SHOVEL_FLATTEN a shovel can path}, or {@link ItemAbilities#HOE_TILL a hoe can till}. * Returns {@code null} if nothing should happen. * - * @param state The current state - * @param context The use on context that the action was performed in - * @param toolAction The action being performed by the tool - * @param simulate If {@code true}, no actions that modify the world in any way should be performed. If {@code false}, the world may be modified. + * @param state The current state + * @param context The use on context that the action was performed in + * @param itemAbility The action being performed by the tool + * @param simulate If {@code true}, no actions that modify the world in any way should be performed. If {@code false}, the world may be modified. * @return The resulting state after the action has been performed */ @Nullable - default BlockState getToolModifiedState(BlockState state, UseOnContext context, ToolAction toolAction, boolean simulate) { + default BlockState getToolModifiedState(BlockState state, UseOnContext context, ItemAbility itemAbility, boolean simulate) { ItemStack itemStack = context.getItemInHand(); - if (!itemStack.canPerformAction(toolAction)) + if (!itemStack.canPerformAction(itemAbility)) return null; - if (ToolActions.AXE_STRIP == toolAction) { + if (ItemAbilities.AXE_STRIP == itemAbility) { return AxeItem.getAxeStrippingState(state); - } else if (ToolActions.AXE_SCRAPE == toolAction) { + } else if (ItemAbilities.AXE_SCRAPE == itemAbility) { return WeatheringCopper.getPrevious(state).orElse(null); - } else if (ToolActions.AXE_WAX_OFF == toolAction) { + } else if (ItemAbilities.AXE_WAX_OFF == itemAbility) { return Optional.ofNullable(HoneycombItem.WAX_OFF_BY_BLOCK.get().get(state.getBlock())).map(block -> block.withPropertiesOf(state)).orElse(null); - } else if (ToolActions.SHOVEL_FLATTEN == toolAction) { + } else if (ItemAbilities.SHOVEL_FLATTEN == itemAbility) { return ShovelItem.getShovelPathingState(state); - } else if (ToolActions.HOE_TILL == toolAction) { + } else if (ItemAbilities.HOE_TILL == itemAbility) { // Logic copied from HoeItem#TILLABLES; needs to be kept in sync during updating Block block = state.getBlock(); if (block == Blocks.ROOTED_DIRT) { diff --git a/src/main/java/net/neoforged/neoforge/common/extensions/IBlockStateExtension.java b/src/main/java/net/neoforged/neoforge/common/extensions/IBlockStateExtension.java index d359d99d4d..f8668a7f47 100644 --- a/src/main/java/net/neoforged/neoforge/common/extensions/IBlockStateExtension.java +++ b/src/main/java/net/neoforged/neoforge/common/extensions/IBlockStateExtension.java @@ -42,8 +42,8 @@ import net.minecraft.world.phys.HitResult; import net.minecraft.world.phys.Vec3; import net.neoforged.neoforge.capabilities.BlockCapabilityCache; -import net.neoforged.neoforge.common.ToolAction; -import net.neoforged.neoforge.common.ToolActions; +import net.neoforged.neoforge.common.ItemAbilities; +import net.neoforged.neoforge.common.ItemAbility; import net.neoforged.neoforge.common.enums.BubbleColumnDirection; import net.neoforged.neoforge.common.util.TriState; import net.neoforged.neoforge.common.world.AuxiliaryLightManager; @@ -622,19 +622,19 @@ default boolean shouldDisplayFluidOverlay(BlockAndTintGetter level, BlockPos pos /** * Returns the state that this block should transform into when right-clicked by a tool. - * For example: Used to determine if {@link ToolActions#AXE_STRIP an axe can strip}, - * {@link ToolActions#SHOVEL_FLATTEN a shovel can path}, or {@link ToolActions#HOE_TILL a hoe can till}. + * For example: Used to determine if {@link ItemAbilities#AXE_STRIP an axe can strip}, + * {@link ItemAbilities#SHOVEL_FLATTEN a shovel can path}, or {@link ItemAbilities#HOE_TILL a hoe can till}. * Returns {@code null} if nothing should happen. * - * @param context The use on context that the action was performed in - * @param toolAction The action being performed by the tool - * @param simulate If {@code true}, no actions that modify the world in any way should be performed. If {@code false}, the world may be modified. + * @param context The use on context that the action was performed in + * @param itemAbility The action being performed by the tool + * @param simulate If {@code true}, no actions that modify the world in any way should be performed. If {@code false}, the world may be modified. * @return The resulting state after the action has been performed */ @Nullable - default BlockState getToolModifiedState(UseOnContext context, ToolAction toolAction, boolean simulate) { - BlockState eventState = EventHooks.onToolUse(self(), context, toolAction, simulate); - return eventState != self() ? eventState : self().getBlock().getToolModifiedState(self(), context, toolAction, simulate); + default BlockState getToolModifiedState(UseOnContext context, ItemAbility itemAbility, boolean simulate) { + BlockState eventState = EventHooks.onToolUse(self(), context, itemAbility, simulate); + return eventState != self() ? eventState : self().getBlock().getToolModifiedState(self(), context, itemAbility, simulate); } /** diff --git a/src/main/java/net/neoforged/neoforge/common/extensions/IItemExtension.java b/src/main/java/net/neoforged/neoforge/common/extensions/IItemExtension.java index 574e660d0e..21b3f6cdb5 100644 --- a/src/main/java/net/neoforged/neoforge/common/extensions/IItemExtension.java +++ b/src/main/java/net/neoforged/neoforge/common/extensions/IItemExtension.java @@ -49,8 +49,8 @@ import net.minecraft.world.level.block.Blocks; import net.minecraft.world.phys.AABB; import net.neoforged.neoforge.common.CommonHooks; -import net.neoforged.neoforge.common.ToolAction; -import net.neoforged.neoforge.common.ToolActions; +import net.neoforged.neoforge.common.ItemAbilities; +import net.neoforged.neoforge.common.ItemAbility; import net.neoforged.neoforge.registries.datamaps.builtin.FurnaceFuel; import net.neoforged.neoforge.registries.datamaps.builtin.NeoForgeDataMaps; import org.jetbrains.annotations.ApiStatus; @@ -383,13 +383,13 @@ default void setDamage(ItemStack stack, int damage) { /** * Queries if an item can perform the given action. - * See {@link ToolActions} for a description of each stock action + * See {@link ItemAbilities} for a description of each stock action * - * @param stack The stack being used - * @param toolAction The action being queried + * @param stack The stack being used + * @param itemAbility The action being queried * @return True if the stack can perform the action */ - default boolean canPerformAction(ItemStack stack, ToolAction toolAction) { + default boolean canPerformAction(ItemStack stack, ItemAbility itemAbility) { return false; } diff --git a/src/main/java/net/neoforged/neoforge/common/extensions/IItemStackExtension.java b/src/main/java/net/neoforged/neoforge/common/extensions/IItemStackExtension.java index 46ca619634..bb1f2adfa2 100644 --- a/src/main/java/net/neoforged/neoforge/common/extensions/IItemStackExtension.java +++ b/src/main/java/net/neoforged/neoforge/common/extensions/IItemStackExtension.java @@ -40,8 +40,8 @@ import net.minecraft.world.phys.AABB; import net.neoforged.neoforge.capabilities.ItemCapability; import net.neoforged.neoforge.common.CommonHooks; -import net.neoforged.neoforge.common.ToolAction; -import net.neoforged.neoforge.common.ToolActions; +import net.neoforged.neoforge.common.ItemAbilities; +import net.neoforged.neoforge.common.ItemAbility; import net.neoforged.neoforge.event.EventHooks; import org.jetbrains.annotations.Nullable; @@ -113,13 +113,13 @@ default InteractionResult onItemUseFirst(UseOnContext context) { /** * Queries if an item can perform the given action. - * See {@link ToolActions} for a description of each stock action + * See {@link ItemAbilities} for a description of each stock action * - * @param toolAction The action being queried + * @param itemAbility The action being queried * @return True if the stack can perform the action */ - default boolean canPerformAction(ToolAction toolAction) { - return self().getItem().canPerformAction(self(), toolAction); + default boolean canPerformAction(ItemAbility itemAbility) { + return self().getItem().canPerformAction(self(), itemAbility); } /** diff --git a/src/main/java/net/neoforged/neoforge/common/loot/CanToolPerformAction.java b/src/main/java/net/neoforged/neoforge/common/loot/CanItemPerformAbility.java similarity index 63% rename from src/main/java/net/neoforged/neoforge/common/loot/CanToolPerformAction.java rename to src/main/java/net/neoforged/neoforge/common/loot/CanItemPerformAbility.java index 70e22d3666..09841307c2 100644 --- a/src/main/java/net/neoforged/neoforge/common/loot/CanToolPerformAction.java +++ b/src/main/java/net/neoforged/neoforge/common/loot/CanItemPerformAbility.java @@ -15,24 +15,24 @@ import net.minecraft.world.level.storage.loot.parameters.LootContextParams; import net.minecraft.world.level.storage.loot.predicates.LootItemCondition; import net.minecraft.world.level.storage.loot.predicates.LootItemConditionType; -import net.neoforged.neoforge.common.ToolAction; +import net.neoforged.neoforge.common.ItemAbility; /** - * This LootItemCondition "neoforge:can_tool_perform_action" can be used to check if a tool can perform a given ToolAction. + * This LootItemCondition "neoforge:can_item_perform_ability" can be used to check if an item can perform a given ItemAbility. */ -public class CanToolPerformAction implements LootItemCondition { - public static MapCodec CODEC = RecordCodecBuilder.mapCodec( +public class CanItemPerformAbility implements LootItemCondition { + public static MapCodec CODEC = RecordCodecBuilder.mapCodec( builder -> builder .group( - ToolAction.CODEC.fieldOf("action").forGetter(action -> action.action)) - .apply(builder, CanToolPerformAction::new)); + ItemAbility.CODEC.fieldOf("ability").forGetter(action -> action.ability)) + .apply(builder, CanItemPerformAbility::new)); public static final LootItemConditionType LOOT_CONDITION_TYPE = new LootItemConditionType(CODEC); - final ToolAction action; + final ItemAbility ability; - public CanToolPerformAction(ToolAction action) { - this.action = action; + public CanItemPerformAbility(ItemAbility ability) { + this.ability = ability; } public LootItemConditionType getType() { @@ -45,10 +45,10 @@ public Set> getReferencedContextParams() { public boolean test(LootContext lootContext) { ItemStack itemstack = lootContext.getParamOrNull(LootContextParams.TOOL); - return itemstack != null && itemstack.canPerformAction(this.action); + return itemstack != null && itemstack.canPerformAction(this.ability); } - public static LootItemCondition.Builder canToolPerformAction(ToolAction action) { - return () -> new CanToolPerformAction(action); + public static LootItemCondition.Builder canItemPerformAbility(ItemAbility action) { + return () -> new CanItemPerformAbility(action); } } diff --git a/src/main/java/net/neoforged/neoforge/event/EventHooks.java b/src/main/java/net/neoforged/neoforge/event/EventHooks.java index 7975551521..760e395aa0 100644 --- a/src/main/java/net/neoforged/neoforge/event/EventHooks.java +++ b/src/main/java/net/neoforged/neoforge/event/EventHooks.java @@ -107,8 +107,8 @@ import net.minecraft.world.phys.Vec3; import net.neoforged.fml.ModLoader; import net.neoforged.neoforge.common.EffectCure; +import net.neoforged.neoforge.common.ItemAbility; import net.neoforged.neoforge.common.NeoForge; -import net.neoforged.neoforge.common.ToolAction; import net.neoforged.neoforge.common.extensions.IFluidStateExtension; import net.neoforged.neoforge.common.extensions.IOwnedSpawner; import net.neoforged.neoforge.common.util.BlockSnapshot; @@ -485,8 +485,8 @@ public static void firePlayerLoadingEvent(Player player, PlayerDataStorage playe } @Nullable - public static BlockState onToolUse(BlockState originalState, UseOnContext context, ToolAction toolAction, boolean simulate) { - BlockToolModificationEvent event = new BlockToolModificationEvent(originalState, context, toolAction, simulate); + public static BlockState onToolUse(BlockState originalState, UseOnContext context, ItemAbility itemAbility, boolean simulate) { + BlockToolModificationEvent event = new BlockToolModificationEvent(originalState, context, itemAbility, simulate); return NeoForge.EVENT_BUS.post(event).isCanceled() ? null : event.getFinalState(); } diff --git a/src/main/java/net/neoforged/neoforge/event/level/BlockEvent.java b/src/main/java/net/neoforged/neoforge/event/level/BlockEvent.java index 9a5b90f972..d0697ddb04 100644 --- a/src/main/java/net/neoforged/neoforge/event/level/BlockEvent.java +++ b/src/main/java/net/neoforged/neoforge/event/level/BlockEvent.java @@ -23,8 +23,8 @@ import net.minecraft.world.level.portal.PortalShape; import net.neoforged.bus.api.Event; import net.neoforged.bus.api.ICancellableEvent; -import net.neoforged.neoforge.common.ToolAction; -import net.neoforged.neoforge.common.ToolActions; +import net.neoforged.neoforge.common.ItemAbilities; +import net.neoforged.neoforge.common.ItemAbility; import net.neoforged.neoforge.common.util.BlockSnapshot; import org.jetbrains.annotations.Nullable; @@ -284,8 +284,8 @@ public PortalShape getPortalSize() { /** * Fired when a block is right-clicked by a tool to change its state. - * For example: Used to determine if {@link ToolActions#AXE_STRIP an axe can strip}, - * {@link ToolActions#SHOVEL_FLATTEN a shovel can path}, or {@link ToolActions#HOE_TILL a hoe can till}. + * For example: Used to determine if {@link ItemAbilities#AXE_STRIP an axe can strip}, + * {@link ItemAbilities#SHOVEL_FLATTEN a shovel can path}, or {@link ItemAbilities#HOE_TILL a hoe can till}. *

* Care must be taken to ensure level-modifying events are only performed if {@link #isSimulated()} returns {@code false}. *

@@ -294,15 +294,15 @@ public PortalShape getPortalSize() { */ public static class BlockToolModificationEvent extends BlockEvent implements ICancellableEvent { private final UseOnContext context; - private final ToolAction toolAction; + private final ItemAbility itemAbility; private final boolean simulate; private BlockState state; - public BlockToolModificationEvent(BlockState originalState, UseOnContext context, ToolAction toolAction, boolean simulate) { + public BlockToolModificationEvent(BlockState originalState, UseOnContext context, ItemAbility itemAbility, boolean simulate) { super(context.getLevel(), context.getClickedPos(), originalState); this.context = context; this.state = originalState; - this.toolAction = toolAction; + this.itemAbility = itemAbility; this.simulate = simulate; } @@ -323,10 +323,10 @@ public ItemStack getHeldItemStack() { } /** - * @return the action being performed + * @return the ability being performed */ - public ToolAction getToolAction() { - return this.toolAction; + public ItemAbility getItemAbility() { + return this.itemAbility; } /** @@ -360,9 +360,9 @@ public void setFinalState(@Nullable BlockState finalState) { } /** - * Returns the state to transform the block into after tool use. + * Returns the state to transform the block into after item ability use. * If {@link #setFinalState(BlockState)} is not called, this will return the original state. - * If {@link #isCanceled()} is {@code true}, this value will be ignored and the tool action will be canceled. + * If {@link #isCanceled()} is {@code true}, this value will be ignored and the item ability will be canceled. * * @return the state to transform the block into after tool use */ diff --git a/tests/src/main/java/net/neoforged/neoforge/debug/block/BlockEventTests.java b/tests/src/main/java/net/neoforged/neoforge/debug/block/BlockEventTests.java index e77bf870bc..74b938c1b3 100644 --- a/tests/src/main/java/net/neoforged/neoforge/debug/block/BlockEventTests.java +++ b/tests/src/main/java/net/neoforged/neoforge/debug/block/BlockEventTests.java @@ -20,7 +20,7 @@ import net.minecraft.world.level.block.RedstoneLampBlock; import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.Vec3; -import net.neoforged.neoforge.common.ToolActions; +import net.neoforged.neoforge.common.ItemAbilities; import net.neoforged.neoforge.event.level.BlockDropsEvent; import net.neoforged.neoforge.event.level.BlockEvent; import net.neoforged.testframework.DynamicTest; @@ -150,7 +150,7 @@ public static void entityPlacedEvent(final DynamicTest test) { @TestHolder(description = "Tests if the block modification event is fired") public static void blockModificationEvent(final DynamicTest test) { test.eventListeners().forge().addListener((final BlockEvent.BlockToolModificationEvent event) -> { - if (event.getToolAction() == ToolActions.AXE_STRIP) { + if (event.getItemAbility() == ItemAbilities.AXE_STRIP) { if (event.getLevel().getBlockState(event.getContext().getClickedPos()).is(Blocks.ACACIA_LOG)) { event.setCanceled(true); } else if (event.getFinalState().is(Blocks.DIAMOND_BLOCK) && event.getContext().getClickedFace() == Direction.UP) { diff --git a/tests/src/main/java/net/neoforged/neoforge/oldtest/item/CustomShieldTest.java b/tests/src/main/java/net/neoforged/neoforge/oldtest/item/CustomShieldTest.java index 7410430dc0..71c3487004 100644 --- a/tests/src/main/java/net/neoforged/neoforge/oldtest/item/CustomShieldTest.java +++ b/tests/src/main/java/net/neoforged/neoforge/oldtest/item/CustomShieldTest.java @@ -16,8 +16,8 @@ import net.minecraft.world.level.Level; import net.neoforged.bus.api.IEventBus; import net.neoforged.fml.common.Mod; -import net.neoforged.neoforge.common.ToolAction; -import net.neoforged.neoforge.common.ToolActions; +import net.neoforged.neoforge.common.ItemAbilities; +import net.neoforged.neoforge.common.ItemAbility; import net.neoforged.neoforge.event.BuildCreativeModeTabContentsEvent; import net.neoforged.neoforge.registries.DeferredItem; import net.neoforged.neoforge.registries.DeferredRegister; @@ -62,8 +62,8 @@ public InteractionResultHolder use(Level world, Player player, Intera } @Override - public boolean canPerformAction(ItemStack stack, ToolAction toolAction) { - return toolAction == ToolActions.SHIELD_BLOCK; + public boolean canPerformAction(ItemStack stack, ItemAbility itemAbility) { + return itemAbility == ItemAbilities.SHIELD_BLOCK; } } }