Search in sources :

Example 1 with FishHook

use of org.bukkit.entity.FishHook in project Glowstone by GlowstoneMC.

the class ItemFishingRod method rightClickAir.

@Override
public void rightClickAir(GlowPlayer player, ItemStack holding) {
    if (player.getCurrentFishingHook() == null) {
        Location location = calculateSpawnLocation(player);
        FishHook fishHook = new GlowFishingHook(location, holding, player);
        fishHook.setShooter(player);
        player.setCurrentFishingHook((GlowFishingHook) fishHook);
    } else {
        player.getCurrentFishingHook().reelIn();
        player.setCurrentFishingHook(null);
    }
}
Also used : GlowFishingHook(net.glowstone.entity.passive.GlowFishingHook) FishHook(org.bukkit.entity.FishHook) Location(org.bukkit.Location)

Example 2 with FishHook

use of org.bukkit.entity.FishHook in project Denizen-For-Bukkit by DenizenScript.

the class FishingHelperImpl method spawnHook.

@Override
public FishHook spawnHook(Location location, Player player) {
    ServerLevel nmsWorld = ((CraftWorld) location.getWorld()).getHandle();
    FishingHook hook = new FishingHook(((CraftPlayer) player).getHandle(), nmsWorld, 0, 0);
    nmsWorld.addEntity(hook, CreatureSpawnEvent.SpawnReason.CUSTOM);
    return (FishHook) hook.getBukkitEntity();
}
Also used : ServerLevel(net.minecraft.server.level.ServerLevel) FishHook(org.bukkit.entity.FishHook) CraftFishHook(org.bukkit.craftbukkit.v1_17_R1.entity.CraftFishHook) FishingHook(net.minecraft.world.entity.projectile.FishingHook) CraftWorld(org.bukkit.craftbukkit.v1_17_R1.CraftWorld)

Example 3 with FishHook

use of org.bukkit.entity.FishHook in project Citizens2 by CitizensDev.

the class EventListen method onProjectileHit.

@EventHandler(ignoreCancelled = true)
public void onProjectileHit(final ProjectileHitEvent event) {
    if (!(event.getEntity() instanceof FishHook))
        return;
    NMS.removeHookIfNecessary(npcRegistry, (FishHook) event.getEntity());
    new BukkitRunnable() {

        int n = 0;

        @Override
        public void run() {
            if (n++ > 5) {
                cancel();
            }
            NMS.removeHookIfNecessary(npcRegistry, (FishHook) event.getEntity());
        }
    }.runTaskTimer(CitizensAPI.getPlugin(), 0, 1);
}
Also used : FishHook(org.bukkit.entity.FishHook) BukkitRunnable(org.bukkit.scheduler.BukkitRunnable) EventHandler(org.bukkit.event.EventHandler)

Example 4 with FishHook

use of org.bukkit.entity.FishHook in project Denizen-For-Bukkit by DenizenScript.

the class FishingHelperImpl method spawnHook.

@Override
public FishHook spawnHook(Location location, Player player) {
    ServerLevel nmsWorld = ((CraftWorld) location.getWorld()).getHandle();
    FishingHook hook = new FishingHook(((CraftPlayer) player).getHandle(), nmsWorld, 0, 0);
    nmsWorld.addFreshEntity(hook, CreatureSpawnEvent.SpawnReason.CUSTOM);
    return (FishHook) hook.getBukkitEntity();
}
Also used : ServerLevel(net.minecraft.server.level.ServerLevel) CraftFishHook(org.bukkit.craftbukkit.v1_18_R1.entity.CraftFishHook) FishHook(org.bukkit.entity.FishHook) FishingHook(net.minecraft.world.entity.projectile.FishingHook) CraftWorld(org.bukkit.craftbukkit.v1_18_R1.CraftWorld)

Aggregations

FishHook (org.bukkit.entity.FishHook)4 ServerLevel (net.minecraft.server.level.ServerLevel)2 FishingHook (net.minecraft.world.entity.projectile.FishingHook)2 GlowFishingHook (net.glowstone.entity.passive.GlowFishingHook)1 Location (org.bukkit.Location)1 CraftWorld (org.bukkit.craftbukkit.v1_17_R1.CraftWorld)1 CraftFishHook (org.bukkit.craftbukkit.v1_17_R1.entity.CraftFishHook)1 CraftWorld (org.bukkit.craftbukkit.v1_18_R1.CraftWorld)1 CraftFishHook (org.bukkit.craftbukkit.v1_18_R1.entity.CraftFishHook)1 EventHandler (org.bukkit.event.EventHandler)1 BukkitRunnable (org.bukkit.scheduler.BukkitRunnable)1