Advertisement
Guest User

LeviathanAxe

a guest
Apr 5th, 2024
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.25 KB | None | 0 0
  1. public class LeviathanAxe extends TridentItem {
  2.  
  3.     private final Effect[] NEGATIVE_EFFECTS = {
  4.             Effects.SLOWNESS
  5.     };
  6.  
  7.     public LeviathanAxe(Properties builderIn) {
  8.         super(builderIn);
  9.     }
  10.  
  11.     @Override
  12.     public UseAction getUseAction(ItemStack stack) {
  13.         return UseAction.SPEAR;
  14.     }
  15.  
  16.     @Override
  17.     public int getUseDuration(ItemStack stack) {
  18.         return 72000;
  19.     }
  20.  
  21.     @Override
  22.     public void onPlayerStoppedUsing(ItemStack stack, World worldIn, LivingEntity entityLiving, int timeLeft) {
  23.         if (entityLiving instanceof PlayerEntity) {
  24.             PlayerEntity playerentity = (PlayerEntity)entityLiving;
  25.             int i = this.getUseDuration(stack) - timeLeft;
  26.             if (i >= 10) {
  27.                 if (!worldIn.isRemote) {
  28.                     LeviathanAxeEntity leviathanAxeEntity = new LeviathanAxeEntity(worldIn, playerentity, stack);
  29.                     leviathanAxeEntity.setDirectionAndMovement(playerentity, playerentity.rotationPitch, playerentity.rotationYaw, 0.0F, 3.0F, 1.0F);
  30.                     if (playerentity.abilities.isCreativeMode) {
  31.                         leviathanAxeEntity.pickupStatus = AbstractArrowEntity.PickupStatus.CREATIVE_ONLY;
  32.                     }
  33.  
  34.                     worldIn.addEntity(leviathanAxeEntity);
  35.                     worldIn.playMovingSound((PlayerEntity)null, leviathanAxeEntity, SoundEvents.ITEM_TRIDENT_THROW, SoundCategory.PLAYERS, 1.0F, 1.0F);
  36.                     if (!playerentity.abilities.isCreativeMode) {
  37.                         playerentity.inventory.deleteStack(stack);
  38.                     }
  39.                 }
  40.             }
  41.             playerentity.addStat(Stats.ITEM_USED.get(this));
  42.         }
  43.     }
  44.  
  45.     @Override
  46.     public ActionResult<ItemStack> onItemRightClick(World worldIn, PlayerEntity playerIn, Hand handIn) {
  47.         ItemStack itemstack = playerIn.getHeldItem(handIn);
  48.         playerIn.setActiveHand(handIn);
  49.         return ActionResult.resultConsume(itemstack);
  50.     }
  51.  
  52.     @Override
  53.     public boolean hitEntity(ItemStack stack, LivingEntity target, LivingEntity attacker) {
  54.         FirestoneBlock.gainPotionEffects(target, NEGATIVE_EFFECTS, 40, 0);
  55.  
  56.         return super.hitEntity(stack, target, attacker);
  57.     }
  58. }
  59.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement