Search in sources :

Example 6 with FishingBobberEntity

use of net.minecraft.entity.projectile.FishingBobberEntity in project LoliServer by Loli-Server.

the class CraftFishHook method setMaxWaitTime.

@Override
public void setMaxWaitTime(int maxWaitTime) {
    FishingBobberEntity hook = getHandle();
    Validate.isTrue(maxWaitTime >= 0 && maxWaitTime >= this.getMinWaitTime(), "The maximum wait time should be higher than or equal to 0 and the minimum wait time.");
    hook.maxWaitTime = maxWaitTime;
}
Also used : FishingBobberEntity(net.minecraft.entity.projectile.FishingBobberEntity)

Example 7 with FishingBobberEntity

use of net.minecraft.entity.projectile.FishingBobberEntity in project LoliServer by Loli-Server.

the class CraftFishHook method setMinWaitTime.

@Override
public void setMinWaitTime(int minWaitTime) {
    FishingBobberEntity hook = getHandle();
    Validate.isTrue(minWaitTime >= 0 && minWaitTime <= this.getMaxWaitTime(), "The minimum wait time should be between 0 and the maximum wait time.");
    hook.minWaitTime = minWaitTime;
}
Also used : FishingBobberEntity(net.minecraft.entity.projectile.FishingBobberEntity)

Example 8 with FishingBobberEntity

use of net.minecraft.entity.projectile.FishingBobberEntity in project Arclight by IzzelAliz.

the class FishingRodItemMixin method onItemRightClick.

/**
 * @author IzzelAliz
 * @reason
 */
@Overwrite
public ActionResult<ItemStack> onItemRightClick(World worldIn, PlayerEntity playerIn, Hand handIn) {
    ItemStack itemstack = playerIn.getHeldItem(handIn);
    if (playerIn.fishingBobber != null) {
        if (!worldIn.isRemote) {
            int i = playerIn.fishingBobber.handleHookRetraction(itemstack);
            itemstack.damageItem(i, playerIn, (p_220000_1_) -> {
                p_220000_1_.sendBreakAnimation(handIn);
            });
        }
        playerIn.swingArm(handIn);
        worldIn.playSound(null, playerIn.posX, playerIn.posY, playerIn.posZ, SoundEvents.ENTITY_FISHING_BOBBER_RETRIEVE, SoundCategory.NEUTRAL, 1.0F, 0.4F / (random.nextFloat() * 0.4F + 0.8F));
    } else {
        if (!worldIn.isRemote) {
            int k = EnchantmentHelper.getFishingSpeedBonus(itemstack);
            int j = EnchantmentHelper.getFishingLuckBonus(itemstack);
            FishingBobberEntity hook = new FishingBobberEntity(playerIn, worldIn, j, k);
            PlayerFishEvent playerFishEvent = new PlayerFishEvent(((ServerPlayerEntityBridge) playerIn).bridge$getBukkitEntity(), null, (FishHook) ((EntityBridge) hook).bridge$getBukkitEntity(), PlayerFishEvent.State.FISHING);
            Bukkit.getPluginManager().callEvent(playerFishEvent);
            if (playerFishEvent.isCancelled()) {
                playerIn.fishingBobber = null;
                return new ActionResult<>(ActionResultType.PASS, itemstack);
            }
            worldIn.playSound(null, playerIn.posX, playerIn.posY, playerIn.posZ, SoundEvents.ENTITY_FISHING_BOBBER_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (random.nextFloat() * 0.4F + 0.8F));
            worldIn.addEntity(new FishingBobberEntity(playerIn, worldIn, j, k));
        }
        // playerIn.swingArm(handIn);
        playerIn.addStat(Stats.ITEM_USED.get(this));
    }
    return new ActionResult<>(ActionResultType.SUCCESS, itemstack);
}
Also used : FishingBobberEntity(net.minecraft.entity.projectile.FishingBobberEntity) ActionResult(net.minecraft.util.ActionResult) PlayerFishEvent(org.bukkit.event.player.PlayerFishEvent) ItemStack(net.minecraft.item.ItemStack) ServerPlayerEntityBridge(io.izzel.arclight.common.bridge.entity.player.ServerPlayerEntityBridge) EntityBridge(io.izzel.arclight.common.bridge.entity.EntityBridge) Overwrite(org.spongepowered.asm.mixin.Overwrite)

Example 9 with FishingBobberEntity

use of net.minecraft.entity.projectile.FishingBobberEntity in project Arclight by IzzelAliz.

the class FishingBobberEntityMixin method handleHookRetraction.

/**
 * @author IzzelAliz
 * @reason
 */
@Overwrite
public int handleHookRetraction(ItemStack p_146034_1_) {
    if (!this.world.isRemote && this.angler != null) {
        int i = 0;
        ItemFishedEvent event = null;
        if (this.caughtEntity != null) {
            PlayerFishEvent fishEvent = new PlayerFishEvent(((ServerPlayerEntityBridge) this.angler).bridge$getBukkitEntity(), ((EntityBridge) this.caughtEntity).bridge$getBukkitEntity(), (FishHook) this.getBukkitEntity(), PlayerFishEvent.State.CAUGHT_ENTITY);
            Bukkit.getPluginManager().callEvent(fishEvent);
            if (fishEvent.isCancelled()) {
                return 0;
            }
            this.bringInHookedEntity();
            CriteriaTriggers.FISHING_ROD_HOOKED.trigger((ServerPlayerEntity) this.angler, p_146034_1_, (FishingBobberEntity) (Object) this, Collections.emptyList());
            this.world.setEntityState((FishingBobberEntity) (Object) this, (byte) 31);
            i = this.caughtEntity instanceof ItemEntity ? 3 : 5;
        } else if (this.ticksCatchable > 0) {
            LootContext.Builder lootcontext$builder = (new LootContext.Builder((ServerWorld) this.world)).withParameter(LootParameters.POSITION, new BlockPos((FishingBobberEntity) (Object) this)).withParameter(LootParameters.TOOL, p_146034_1_).withRandom(this.rand).withLuck((float) this.luck + this.angler.getLuck());
            lootcontext$builder.withParameter(LootParameters.KILLER_ENTITY, this.angler).withParameter(LootParameters.THIS_ENTITY, (FishingBobberEntity) (Object) this);
            LootTable loottable = this.world.getServer().getLootTableManager().getLootTableFromLocation(LootTables.GAMEPLAY_FISHING);
            List<ItemStack> list = loottable.generate(lootcontext$builder.build(LootParameterSets.FISHING));
            event = new ItemFishedEvent(list, this.inGround ? 2 : 1, (FishingBobberEntity) (Object) this);
            MinecraftForge.EVENT_BUS.post(event);
            if (event.isCanceled()) {
                this.remove();
                return event.getRodDamage();
            }
            CriteriaTriggers.FISHING_ROD_HOOKED.trigger((ServerPlayerEntity) this.angler, p_146034_1_, (FishingBobberEntity) (Object) this, list);
            for (ItemStack itemstack : list) {
                ItemEntity itementity = new ItemEntity(this.world, this.posX, this.posY, this.posZ, itemstack);
                PlayerFishEvent playerFishEvent = new PlayerFishEvent(((ServerPlayerEntityBridge) this.angler).bridge$getBukkitEntity(), ((EntityBridge) itementity).bridge$getBukkitEntity(), (FishHook) this.getBukkitEntity(), PlayerFishEvent.State.CAUGHT_FISH);
                playerFishEvent.setExpToDrop(this.rand.nextInt(6) + 1);
                Bukkit.getPluginManager().callEvent(playerFishEvent);
                if (playerFishEvent.isCancelled()) {
                    return 0;
                }
                double d0 = this.angler.posX - this.posX;
                double d1 = this.angler.posY - this.posY;
                double d2 = this.angler.posZ - this.posZ;
                double d3 = 0.1D;
                itementity.setMotion(d0 * 0.1D, d1 * 0.1D + Math.sqrt(Math.sqrt(d0 * d0 + d1 * d1 + d2 * d2)) * 0.08D, d2 * 0.1D);
                this.world.addEntity(itementity);
                if (playerFishEvent.getExpToDrop() > 0) {
                    this.angler.world.addEntity(new ExperienceOrbEntity(this.angler.world, this.angler.posX, this.angler.posY + 0.5D, this.angler.posZ + 0.5D, playerFishEvent.getExpToDrop()));
                }
                if (itemstack.getItem().isIn(ItemTags.FISHES)) {
                    this.angler.addStat(Stats.FISH_CAUGHT, 1);
                }
            }
            i = 1;
        }
        if (this.inGround) {
            PlayerFishEvent playerFishEvent = new PlayerFishEvent(((ServerPlayerEntityBridge) this.angler).bridge$getBukkitEntity(), null, (FishHook) this.getBukkitEntity(), PlayerFishEvent.State.IN_GROUND);
            Bukkit.getPluginManager().callEvent(playerFishEvent);
            if (playerFishEvent.isCancelled()) {
                return 0;
            }
            i = 2;
        }
        if (i == 0) {
            PlayerFishEvent playerFishEvent = new PlayerFishEvent(((ServerPlayerEntityBridge) this.angler).bridge$getBukkitEntity(), null, (FishHook) this.getBukkitEntity(), PlayerFishEvent.State.REEL_IN);
            Bukkit.getPluginManager().callEvent(playerFishEvent);
            if (playerFishEvent.isCancelled()) {
                return 0;
            }
        }
        this.remove();
        return event == null ? i : event.getRodDamage();
    } else {
        return 0;
    }
}
Also used : LootTable(net.minecraft.world.storage.loot.LootTable) FishingBobberEntity(net.minecraft.entity.projectile.FishingBobberEntity) ItemEntity(net.minecraft.entity.item.ItemEntity) FishHook(org.bukkit.entity.FishHook) PlayerFishEvent(org.bukkit.event.player.PlayerFishEvent) ServerPlayerEntity(net.minecraft.entity.player.ServerPlayerEntity) ExperienceOrbEntity(net.minecraft.entity.item.ExperienceOrbEntity) ServerPlayerEntityBridge(io.izzel.arclight.common.bridge.entity.player.ServerPlayerEntityBridge) ItemFishedEvent(net.minecraftforge.event.entity.player.ItemFishedEvent) BlockPos(net.minecraft.util.math.BlockPos) List(java.util.List) ItemStack(net.minecraft.item.ItemStack) ServerPlayerEntityBridge(io.izzel.arclight.common.bridge.entity.player.ServerPlayerEntityBridge) EntityBridge(io.izzel.arclight.common.bridge.entity.EntityBridge) Overwrite(org.spongepowered.asm.mixin.Overwrite)

Example 10 with FishingBobberEntity

use of net.minecraft.entity.projectile.FishingBobberEntity in project Client by MatHax.

the class AutoFish method onPlaySound.

@EventHandler
private void onPlaySound(PlaySoundEvent event) {
    SoundInstance p = event.sound;
    FishingBobberEntity b = mc.player.fishHook;
    if (p.getId().getPath().equals("entity.fishing_bobber.splash")) {
        if (!splashDetectionRangeEnabled.get() || Utils.distance(b.getX(), b.getY(), b.getZ(), p.getX(), p.getY(), p.getZ()) <= splashDetectionRange.get()) {
            ticksEnabled = true;
            ticksToRightClick = ticksCatch.get();
            ticksData = 0;
        }
    }
}
Also used : FishingBobberEntity(net.minecraft.entity.projectile.FishingBobberEntity) SoundInstance(net.minecraft.client.sound.SoundInstance) EventHandler(mathax.client.eventbus.EventHandler)

Aggregations

FishingBobberEntity (net.minecraft.entity.projectile.FishingBobberEntity)14 FishHook (org.bukkit.entity.FishHook)3 EntityBridge (io.izzel.arclight.common.bridge.entity.EntityBridge)2 ServerPlayerEntityBridge (io.izzel.arclight.common.bridge.entity.player.ServerPlayerEntityBridge)2 SoundInstance (net.minecraft.client.sound.SoundInstance)2 EnderPearlEntity (net.minecraft.entity.item.EnderPearlEntity)2 ExperienceBottleEntity (net.minecraft.entity.item.ExperienceBottleEntity)2 PlayerEntity (net.minecraft.entity.player.PlayerEntity)2 AbstractArrowEntity (net.minecraft.entity.projectile.AbstractArrowEntity)2 ArrowEntity (net.minecraft.entity.projectile.ArrowEntity)2 DamagingProjectileEntity (net.minecraft.entity.projectile.DamagingProjectileEntity)2 DragonFireballEntity (net.minecraft.entity.projectile.DragonFireballEntity)2 EggEntity (net.minecraft.entity.projectile.EggEntity)2 FireballEntity (net.minecraft.entity.projectile.FireballEntity)2 FireworkRocketEntity (net.minecraft.entity.projectile.FireworkRocketEntity)2 LlamaSpitEntity (net.minecraft.entity.projectile.LlamaSpitEntity)2 PotionEntity (net.minecraft.entity.projectile.PotionEntity)2 ShulkerBulletEntity (net.minecraft.entity.projectile.ShulkerBulletEntity)2 SmallFireballEntity (net.minecraft.entity.projectile.SmallFireballEntity)2 SnowballEntity (net.minecraft.entity.projectile.SnowballEntity)2