Skip to content

Commit

Permalink
Fix canteens playing the right click animation when the player is not…
Browse files Browse the repository at this point in the history
… hungry
  • Loading branch information
pupnewfster committed Aug 20, 2024
1 parent 374ab4b commit 8a49089
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/main/java/mekanism/common/item/gear/ItemCanteen.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import mekanism.common.registration.impl.CreativeTabDeferredRegister.ICustomCreativeTabContents;
import mekanism.common.registries.MekanismFluids;
import mekanism.common.util.FluidUtils;
import mekanism.common.util.MekanismUtils;
import mekanism.common.util.StorageUtils;
import net.minecraft.network.chat.Component;
import net.minecraft.world.InteractionHand;
Expand Down Expand Up @@ -95,10 +96,15 @@ private FluidStack getFluid(ItemStack stack) {

@NotNull
@Override
public InteractionResultHolder<ItemStack> use(@NotNull Level worldIn, Player playerIn, @NotNull InteractionHand handIn) {
if (!playerIn.isCreative() && playerIn.canEat(false) && getFluid(playerIn.getItemInHand(handIn)).getAmount() >= 50) {
playerIn.startUsingItem(handIn);
public InteractionResultHolder<ItemStack> use(@NotNull Level worldIn, Player player, @NotNull InteractionHand hand) {
ItemStack item = player.getItemInHand(hand);
if (!MekanismUtils.isPlayingMode(player)) {
return InteractionResultHolder.pass(item);
}
return InteractionResultHolder.success(playerIn.getItemInHand(handIn));
if (player.canEat(false) && getFluid(item).getAmount() >= 50) {
player.startUsingItem(hand);
return InteractionResultHolder.consume(item);
}
return InteractionResultHolder.fail(item);
}
}

0 comments on commit 8a49089

Please sign in to comment.