3737import net .minecraft .sounds .SoundEvent ;
3838import net .minecraft .sounds .SoundEvents ;
3939import net .minecraft .sounds .SoundSource ;
40+ import net .minecraft .tags .BlockTags ;
4041import net .minecraft .util .ByIdMap ;
4142import net .minecraft .util .StringRepresentable ;
4243import net .minecraft .world .InteractionResult ;
5253import net .minecraft .world .phys .AABB ;
5354import net .minecraft .world .phys .BlockHitResult ;
5455import net .minecraft .world .phys .Vec3 ;
55- import net .neoforged .neoforge .common .IPlantable ;
56- import net .neoforged .neoforge .common .ToolAction ;
57- import net .neoforged .neoforge .common .ToolActions ;
56+ import net .neoforged .neoforge .common .ItemAbilities ;
57+ import net .neoforged .neoforge .common .ItemAbility ;
5858import net .neoforged .neoforge .common .util .Lazy ;
5959import org .jetbrains .annotations .NotNull ;
6060import org .jetbrains .annotations .Nullable ;
@@ -91,9 +91,9 @@ public InteractionResult onItemUse(IModule<ModuleFarmingUnit> module, UseOnConte
9191 Lazy <BlockState > lazyClickedState = Lazy .of (() -> context .getLevel ().getBlockState (context .getClickedPos ()));
9292 return MekanismUtils .performActions (
9393 //First try to use the disassembler as an axe
94- useAxeAOE (context , lazyClickedState , energyContainer , diameter , ToolActions .AXE_STRIP , SoundEvents .AXE_STRIP , -1 ),
95- () -> useAxeAOE (context , lazyClickedState , energyContainer , diameter , ToolActions .AXE_SCRAPE , SoundEvents .AXE_SCRAPE , LevelEvent .PARTICLES_SCRAPE ),
96- () -> useAxeAOE (context , lazyClickedState , energyContainer , diameter , ToolActions .AXE_WAX_OFF , SoundEvents .AXE_WAX_OFF , LevelEvent .PARTICLES_WAX_OFF ),
94+ useAxeAOE (context , lazyClickedState , energyContainer , diameter , ItemAbilities .AXE_STRIP , SoundEvents .AXE_STRIP , -1 ),
95+ () -> useAxeAOE (context , lazyClickedState , energyContainer , diameter , ItemAbilities .AXE_SCRAPE , SoundEvents .AXE_SCRAPE , LevelEvent .PARTICLES_SCRAPE ),
96+ () -> useAxeAOE (context , lazyClickedState , energyContainer , diameter , ItemAbilities .AXE_WAX_OFF , SoundEvents .AXE_WAX_OFF , LevelEvent .PARTICLES_WAX_OFF ),
9797 //Then as a shovel
9898 () -> flattenAOE (context , lazyClickedState , energyContainer , diameter ),
9999 () -> dowseCampfire (context , lazyClickedState , energyContainer ),
@@ -103,18 +103,18 @@ public InteractionResult onItemUse(IModule<ModuleFarmingUnit> module, UseOnConte
103103 }
104104
105105 @ Override
106- public boolean canPerformAction (IModule <ModuleFarmingUnit > module , IModuleContainer moduleContainer , ItemStack stack , ToolAction action ) {
107- if (action == ToolActions .AXE_STRIP || action == ToolActions .AXE_SCRAPE || action == ToolActions .AXE_WAX_OFF ) {
106+ public boolean canPerformAction (IModule <ModuleFarmingUnit > module , IModuleContainer moduleContainer , ItemStack stack , ItemAbility action ) {
107+ if (action == ItemAbilities .AXE_STRIP || action == ItemAbilities .AXE_SCRAPE || action == ItemAbilities .AXE_WAX_OFF ) {
108108 return module .hasEnoughEnergy (stack , MekanismConfig .gear .mekaToolEnergyUsageAxe );
109- } else if (action == ToolActions .SHOVEL_FLATTEN ) {
109+ } else if (action == ItemAbilities .SHOVEL_FLATTEN ) {
110110 return module .hasEnoughEnergy (stack , MekanismConfig .gear .mekaToolEnergyUsageShovel );
111- } else if (action == ToolActions .HOE_TILL ) {
111+ } else if (action == ItemAbilities .HOE_TILL ) {
112112 return module .hasEnoughEnergy (stack , MekanismConfig .gear .mekaToolEnergyUsageHoe );
113113 }
114114 //Note: In general when we get here there will be no tool actions known unless mods add more default tool actions
115115 // This is because we special case the known vanilla types above and the dig variants are already handled by the Meka-Tool itself before
116116 // it even checks the installed modules
117- return ToolActions .DEFAULT_AXE_ACTIONS .contains (action ) || ToolActions .DEFAULT_SHOVEL_ACTIONS .contains (action ) || ToolActions .DEFAULT_HOE_ACTIONS .contains (action );
117+ return ItemAbilities .DEFAULT_AXE_ACTIONS .contains (action ) || ItemAbilities .DEFAULT_SHOVEL_ACTIONS .contains (action ) || ItemAbilities .DEFAULT_HOE_ACTIONS .contains (action );
118118 }
119119
120120 @ NothingNullByDefault
@@ -179,7 +179,7 @@ private InteractionResult dowseCampfire(UseOnContext context, Lazy<BlockState> l
179179 }
180180
181181 private InteractionResult tillAOE (UseOnContext context , Lazy <BlockState > lazyClickedState , IEnergyContainer energyContainer , int diameter ) {
182- return useAOE (context , lazyClickedState , energyContainer , diameter , ToolActions .HOE_TILL , SoundEvents .HOE_TILL , -1 ,
182+ return useAOE (context , lazyClickedState , energyContainer , diameter , ItemAbilities .HOE_TILL , SoundEvents .HOE_TILL , -1 ,
183183 MekanismConfig .gear .mekaToolEnergyUsageHoe .get (), new HoeToolAOEData ());
184184 }
185185
@@ -189,17 +189,17 @@ private InteractionResult flattenAOE(UseOnContext context, Lazy<BlockState> lazy
189189 //Don't allow flattening a block from underneath
190190 return InteractionResult .PASS ;
191191 }
192- return useAOE (context , lazyClickedState , energyContainer , diameter , ToolActions .SHOVEL_FLATTEN , SoundEvents .SHOVEL_FLATTEN , -1 ,
192+ return useAOE (context , lazyClickedState , energyContainer , diameter , ItemAbilities .SHOVEL_FLATTEN , SoundEvents .SHOVEL_FLATTEN , -1 ,
193193 MekanismConfig .gear .mekaToolEnergyUsageShovel .get (), new ShovelToolAOEData ());
194194 }
195195
196- private InteractionResult useAxeAOE (UseOnContext context , Lazy <BlockState > lazyClickedState , IEnergyContainer energyContainer , int diameter , ToolAction action ,
196+ private InteractionResult useAxeAOE (UseOnContext context , Lazy <BlockState > lazyClickedState , IEnergyContainer energyContainer , int diameter , ItemAbility action ,
197197 SoundEvent sound , int particle ) {
198198 return useAOE (context , lazyClickedState , energyContainer , diameter , action , sound , particle , MekanismConfig .gear .mekaToolEnergyUsageAxe .get (),
199199 new AxeToolAOEData ());
200200 }
201201
202- private InteractionResult useAOE (UseOnContext context , Lazy <BlockState > lazyClickedState , IEnergyContainer energyContainer , int diameter , ToolAction action ,
202+ private InteractionResult useAOE (UseOnContext context , Lazy <BlockState > lazyClickedState , IEnergyContainer energyContainer , int diameter , ItemAbility action ,
203203 SoundEvent sound , int particle , FloatingLong energyUsage , IToolAOEData toolAOEData ) {
204204 FloatingLong energy = energyContainer .getEnergy ();
205205 if (energy .smallerThan (energyUsage )) {
@@ -326,7 +326,8 @@ public boolean isValid(Level level, BlockPos pos, BlockState state) {
326326 }
327327 //Or it is a replaceable plant that is also not solid (such as tall grass)
328328 //Note: This may not be the most optimal way of checking this, but it gives a decent enough estimate of it
329- if (aboveState .is (MekanismTags .Blocks .FARMING_OVERRIDE ) || aboveState .canBeReplaced () && aboveState .getBlock () instanceof IPlantable ) {
329+ //TODO - 1.21: Do we want to try and come up with a better tag or check for if it is a replaceable plant?
330+ if (aboveState .is (MekanismTags .Blocks .FARMING_OVERRIDE ) || aboveState .canBeReplaced () && aboveState .is (BlockTags .REPLACEABLE_BY_TREES )) {
330331 return aboveState .getFluidState ().isEmpty () && !aboveState .isSolidRender (level , abovePos );
331332 }
332333 return false ;
0 commit comments