Skip to content

Commit 8a49089

Browse files
committed
Fix canteens playing the right click animation when the player is not hungry
1 parent 374ab4b commit 8a49089

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/main/java/mekanism/common/item/gear/ItemCanteen.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import mekanism.common.registration.impl.CreativeTabDeferredRegister.ICustomCreativeTabContents;
99
import mekanism.common.registries.MekanismFluids;
1010
import mekanism.common.util.FluidUtils;
11+
import mekanism.common.util.MekanismUtils;
1112
import mekanism.common.util.StorageUtils;
1213
import net.minecraft.network.chat.Component;
1314
import net.minecraft.world.InteractionHand;
@@ -95,10 +96,15 @@ private FluidStack getFluid(ItemStack stack) {
9596

9697
@NotNull
9798
@Override
98-
public InteractionResultHolder<ItemStack> use(@NotNull Level worldIn, Player playerIn, @NotNull InteractionHand handIn) {
99-
if (!playerIn.isCreative() && playerIn.canEat(false) && getFluid(playerIn.getItemInHand(handIn)).getAmount() >= 50) {
100-
playerIn.startUsingItem(handIn);
99+
public InteractionResultHolder<ItemStack> use(@NotNull Level worldIn, Player player, @NotNull InteractionHand hand) {
100+
ItemStack item = player.getItemInHand(hand);
101+
if (!MekanismUtils.isPlayingMode(player)) {
102+
return InteractionResultHolder.pass(item);
101103
}
102-
return InteractionResultHolder.success(playerIn.getItemInHand(handIn));
104+
if (player.canEat(false) && getFluid(item).getAmount() >= 50) {
105+
player.startUsingItem(hand);
106+
return InteractionResultHolder.consume(item);
107+
}
108+
return InteractionResultHolder.fail(item);
103109
}
104110
}

0 commit comments

Comments
 (0)