diff --git a/src/main/java/com/atsuishio/superbwarfare/item/ArtilleryIndicator.java b/src/main/java/com/atsuishio/superbwarfare/item/ArtilleryIndicator.java index 4b9009a45..20fe64dfc 100644 --- a/src/main/java/com/atsuishio/superbwarfare/item/ArtilleryIndicator.java +++ b/src/main/java/com/atsuishio/superbwarfare/item/ArtilleryIndicator.java @@ -1,6 +1,18 @@ package com.atsuishio.superbwarfare.item; +import net.minecraft.sounds.SoundEvents; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.InteractionResultHolder; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.ItemUtils; +import net.minecraft.world.item.UseAnim; +import net.minecraft.world.level.Level; +import org.jetbrains.annotations.NotNull; + +import javax.annotation.ParametersAreNonnullByDefault; public class ArtilleryIndicator extends Item { @@ -8,6 +20,42 @@ public class ArtilleryIndicator extends Item { super(new Properties().stacksTo(1)); } + @Override + @ParametersAreNonnullByDefault + public int getUseDuration(ItemStack stack, LivingEntity entity) { + return 1200; + } + + @Override + public @NotNull UseAnim getUseAnimation(@NotNull ItemStack stack) { + return UseAnim.SPYGLASS; + } + + @Override + @ParametersAreNonnullByDefault + public @NotNull InteractionResultHolder use(Level worldIn, Player playerIn, InteractionHand handIn) { + ItemStack stack = playerIn.getItemInHand(handIn); + playerIn.playSound(SoundEvents.SPYGLASS_USE, 1.0F, 1.0F); + return ItemUtils.startUsingInstantly(worldIn, playerIn, handIn); + } + + @Override + @ParametersAreNonnullByDefault + public @NotNull ItemStack finishUsingItem(ItemStack pStack, Level pLevel, LivingEntity pLivingEntity) { + this.stopUsing(pLivingEntity); + return pStack; + } + + @Override + @ParametersAreNonnullByDefault + public void releaseUsing(ItemStack pStack, Level pLevel, LivingEntity pLivingEntity, int pTimeCharged) { + this.stopUsing(pLivingEntity); + } + + private void stopUsing(LivingEntity pUser) { + pUser.playSound(SoundEvents.SPYGLASS_STOP_USING, 1.0F, 1.0F); + } + // @Override // public @NotNull InteractionResult useOn(UseOnContext pContext) { // ItemStack stack = pContext.getItemInHand();