修复注册bug

This commit is contained in:
Atsuishio 2025-07-08 21:59:16 +08:00 committed by Light_Quanta
parent 813bd7eeb8
commit d6fcd7a101
No known key found for this signature in database
GPG key ID: 11A39A1B8C890959

View file

@ -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<ItemStack> 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();