@@ -504,32 +504,20 @@ public void setSelectedTool(int slot, ItemStack stack) {
504504 @ NotNull BlockPos pos , @ NotNull EnumFacing side , float hitX ,
505505 float hitY , float hitZ , @ NotNull EnumHand hand ) {
506506 EnumActionResult result = IDyeableItem .super .onItemUseFirst (player , world , pos , side , hitX , hitY , hitZ , hand );
507- if (result == EnumActionResult .PASS ) {
508- ItemStack stack = player .getHeldItem (hand );
509- ToolStackHandler handler = getHandler (stack );
510- if (handler .getSelectedStack ().isEmpty () &&
511- world .getTileEntity (pos ) instanceof MetaTileEntityHolder holder &&
512- holder .getMetaTileEntity () instanceof MetaTileEntityMaintenanceHatch maintenance ) {
513- maintenance .fixMaintenanceProblemsWithToolbelt (player , this , stack );
514- return EnumActionResult .SUCCESS ;
515- }
516- return super .onItemUseFirst (player , world , pos , side , hitX , hitY , hitZ , hand );
517- } else return result ;
518- }
507+ if (result != EnumActionResult .PASS ) return result ;
519508
520- @ Override
521- public @ NotNull EnumActionResult onItemUse (@ NotNull EntityPlayer player , @ NotNull World world ,
522- @ NotNull BlockPos pos , @ NotNull EnumHand hand ,
523- @ NotNull EnumFacing facing , float hitX , float hitY , float hitZ ) {
524- ToolStackHandler handler = getHandler (player .getHeldItem (hand ));
525- ItemStack selected = handler .getSelectedStack ();
526- if (!selected .isEmpty ()) {
527- EnumActionResult result = AbstractSprayBehavior .handleExternalSpray (player , world , pos , facing , selected );
528- if (result != EnumActionResult .PASS ) {
529- return result ;
530- }
509+ ItemStack thisToolBelt = player .getHeldItem (hand );
510+ ToolStackHandler handler = getHandler (thisToolBelt );
511+ ItemStack selectedToolBeltStack = handler .getSelectedStack ();
512+ if (selectedToolBeltStack .isEmpty () && world .getTileEntity (pos ) instanceof MetaTileEntityHolder holder &&
513+ holder .getMetaTileEntity () instanceof MetaTileEntityMaintenanceHatch maintenance ) {
514+ maintenance .fixMaintenanceProblemsWithToolbelt (player , this , thisToolBelt );
515+ return EnumActionResult .SUCCESS ;
516+ } else if (AbstractSprayBehavior .isSprayCan (selectedToolBeltStack )) {
517+ return AbstractSprayBehavior .handleExternalSpray (player , world , pos , side , selectedToolBeltStack );
531518 }
532- return super .onItemUse (player , world , pos , hand , facing , hitX , hitY , hitZ );
519+
520+ return super .onItemUseFirst (player , world , pos , side , hitX , hitY , hitZ , hand );
533521 }
534522
535523 @ Override
0 commit comments