修复注册bug
This commit is contained in:
parent
813bd7eeb8
commit
d6fcd7a101
1 changed files with 48 additions and 0 deletions
|
@ -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();
|
||||
|
|
Loading…
Add table
Reference in a new issue