Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class LeviathanAxe extends TridentItem {
- private final Effect[] NEGATIVE_EFFECTS = {
- Effects.SLOWNESS
- };
- public LeviathanAxe(Properties builderIn) {
- super(builderIn);
- }
- @Override
- public UseAction getUseAction(ItemStack stack) {
- return UseAction.SPEAR;
- }
- @Override
- public int getUseDuration(ItemStack stack) {
- return 72000;
- }
- @Override
- public void onPlayerStoppedUsing(ItemStack stack, World worldIn, LivingEntity entityLiving, int timeLeft) {
- if (entityLiving instanceof PlayerEntity) {
- PlayerEntity playerentity = (PlayerEntity)entityLiving;
- int i = this.getUseDuration(stack) - timeLeft;
- if (i >= 10) {
- if (!worldIn.isRemote) {
- LeviathanAxeEntity leviathanAxeEntity = new LeviathanAxeEntity(worldIn, playerentity, stack);
- leviathanAxeEntity.setDirectionAndMovement(playerentity, playerentity.rotationPitch, playerentity.rotationYaw, 0.0F, 3.0F, 1.0F);
- if (playerentity.abilities.isCreativeMode) {
- leviathanAxeEntity.pickupStatus = AbstractArrowEntity.PickupStatus.CREATIVE_ONLY;
- }
- worldIn.addEntity(leviathanAxeEntity);
- worldIn.playMovingSound((PlayerEntity)null, leviathanAxeEntity, SoundEvents.ITEM_TRIDENT_THROW, SoundCategory.PLAYERS, 1.0F, 1.0F);
- if (!playerentity.abilities.isCreativeMode) {
- playerentity.inventory.deleteStack(stack);
- }
- }
- }
- playerentity.addStat(Stats.ITEM_USED.get(this));
- }
- }
- @Override
- public ActionResult<ItemStack> onItemRightClick(World worldIn, PlayerEntity playerIn, Hand handIn) {
- ItemStack itemstack = playerIn.getHeldItem(handIn);
- playerIn.setActiveHand(handIn);
- return ActionResult.resultConsume(itemstack);
- }
- @Override
- public boolean hitEntity(ItemStack stack, LivingEntity target, LivingEntity attacker) {
- FirestoneBlock.gainPotionEffects(target, NEGATIVE_EFFECTS, 40, 0);
- return super.hitEntity(stack, target, attacker);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement