Search in sources :

Example 1 with CraftFishHook

use of org.bukkit.craftbukkit.v1_16_R3.entity.CraftFishHook in project Denizen-For-Bukkit by DenizenScript.

the class FishingHelperImpl method getResult.

@Override
public org.bukkit.inventory.ItemStack getResult(FishHook fishHook, CatchType catchType) {
    ItemStack result = null;
    EntityFishingHook nmsHook = ((CraftFishHook) fishHook).getHandle();
    if (catchType == CatchType.DEFAULT) {
        float f = ((CraftWorld) fishHook.getWorld()).getHandle().random.nextFloat();
        int i = EnchantmentManager.g((EntityHuman) nmsHook.getShooter());
        int j = EnchantmentManager.a(Enchantments.LURE, (EntityHuman) nmsHook.getShooter());
        float f1 = 0.1F - (float) i * 0.025F - (float) j * 0.01F;
        float f2 = 0.05F + (float) i * 0.01F - (float) j * 0.01F;
        f1 = MathHelper.a(f1, 0.0F, 1.0F);
        f2 = MathHelper.a(f2, 0.0F, 1.0F);
        if (f < f1) {
            result = catchRandomJunk(nmsHook);
        } else {
            f -= f1;
            if (f < f2) {
                result = catchRandomTreasure(nmsHook);
            } else {
                result = catchRandomFish(nmsHook);
            }
        }
    } else if (catchType == CatchType.JUNK) {
        result = catchRandomJunk(nmsHook);
    } else if (catchType == CatchType.TREASURE) {
        result = catchRandomTreasure(nmsHook);
    } else if (catchType == CatchType.FISH) {
        result = catchRandomFish(nmsHook);
    }
    if (result != null) {
        return CraftItemStack.asBukkitCopy(result);
    } else {
        return null;
    }
}
Also used : CraftFishHook(org.bukkit.craftbukkit.v1_16_R3.entity.CraftFishHook) CraftItemStack(org.bukkit.craftbukkit.v1_16_R3.inventory.CraftItemStack) CraftWorld(org.bukkit.craftbukkit.v1_16_R3.CraftWorld)

Example 2 with CraftFishHook

use of org.bukkit.craftbukkit.v1_16_R3.entity.CraftFishHook in project Denizen-For-Bukkit by DenizenScript.

the class FishingHelperImpl method getResult.

@Override
public org.bukkit.inventory.ItemStack getResult(FishHook fishHook, CatchType catchType) {
    ItemStack result = null;
    FishingHook nmsHook = ((CraftFishHook) fishHook).getHandle();
    if (catchType == CatchType.DEFAULT) {
        float f = ((CraftWorld) fishHook.getWorld()).getHandle().random.nextFloat();
        int i = EnchantmentHelper.getMobLooting(nmsHook.getPlayerOwner());
        int j = EnchantmentHelper.getEnchantmentLevel(Enchantments.FISHING_LUCK, nmsHook.getPlayerOwner());
        float f1 = 0.1F - (float) i * 0.025F - (float) j * 0.01F;
        float f2 = 0.05F + (float) i * 0.01F - (float) j * 0.01F;
        f1 = Mth.clamp(f1, 0.0F, 1.0F);
        f2 = Mth.clamp(f2, 0.0F, 1.0F);
        if (f < f1) {
            result = catchRandomJunk(nmsHook);
        } else {
            f -= f1;
            if (f < f2) {
                result = catchRandomTreasure(nmsHook);
            } else {
                result = catchRandomFish(nmsHook);
            }
        }
    } else if (catchType == CatchType.JUNK) {
        result = catchRandomJunk(nmsHook);
    } else if (catchType == CatchType.TREASURE) {
        result = catchRandomTreasure(nmsHook);
    } else if (catchType == CatchType.FISH) {
        result = catchRandomFish(nmsHook);
    }
    if (result != null) {
        return CraftItemStack.asBukkitCopy(result);
    } else {
        return null;
    }
}
Also used : CraftFishHook(org.bukkit.craftbukkit.v1_17_R1.entity.CraftFishHook) ItemStack(net.minecraft.world.item.ItemStack) CraftItemStack(org.bukkit.craftbukkit.v1_17_R1.inventory.CraftItemStack) FishingHook(net.minecraft.world.entity.projectile.FishingHook) CraftWorld(org.bukkit.craftbukkit.v1_17_R1.CraftWorld)

Example 3 with CraftFishHook

use of org.bukkit.craftbukkit.v1_16_R3.entity.CraftFishHook in project Denizen-For-Bukkit by DenizenScript.

the class FishingHelperImpl method getResult.

@Override
public org.bukkit.inventory.ItemStack getResult(FishHook fishHook, CatchType catchType) {
    ItemStack result = null;
    FishingHook nmsHook = ((CraftFishHook) fishHook).getHandle();
    if (catchType == CatchType.DEFAULT) {
        float f = ((CraftWorld) fishHook.getWorld()).getHandle().random.nextFloat();
        int i = EnchantmentHelper.getMobLooting(nmsHook.getPlayerOwner());
        int j = EnchantmentHelper.getEnchantmentLevel(Enchantments.FISHING_LUCK, nmsHook.getPlayerOwner());
        float f1 = 0.1F - (float) i * 0.025F - (float) j * 0.01F;
        float f2 = 0.05F + (float) i * 0.01F - (float) j * 0.01F;
        f1 = Mth.clamp(f1, 0.0F, 1.0F);
        f2 = Mth.clamp(f2, 0.0F, 1.0F);
        if (f < f1) {
            result = catchRandomJunk(nmsHook);
        } else {
            f -= f1;
            if (f < f2) {
                result = catchRandomTreasure(nmsHook);
            } else {
                result = catchRandomFish(nmsHook);
            }
        }
    } else if (catchType == CatchType.JUNK) {
        result = catchRandomJunk(nmsHook);
    } else if (catchType == CatchType.TREASURE) {
        result = catchRandomTreasure(nmsHook);
    } else if (catchType == CatchType.FISH) {
        result = catchRandomFish(nmsHook);
    }
    if (result != null) {
        return CraftItemStack.asBukkitCopy(result);
    } else {
        return null;
    }
}
Also used : CraftFishHook(org.bukkit.craftbukkit.v1_18_R1.entity.CraftFishHook) CraftItemStack(org.bukkit.craftbukkit.v1_18_R1.inventory.CraftItemStack) ItemStack(net.minecraft.world.item.ItemStack) FishingHook(net.minecraft.world.entity.projectile.FishingHook) CraftWorld(org.bukkit.craftbukkit.v1_18_R1.CraftWorld)

Aggregations

FishingHook (net.minecraft.world.entity.projectile.FishingHook)2 ItemStack (net.minecraft.world.item.ItemStack)2 CraftWorld (org.bukkit.craftbukkit.v1_16_R3.CraftWorld)1 CraftFishHook (org.bukkit.craftbukkit.v1_16_R3.entity.CraftFishHook)1 CraftItemStack (org.bukkit.craftbukkit.v1_16_R3.inventory.CraftItemStack)1 CraftWorld (org.bukkit.craftbukkit.v1_17_R1.CraftWorld)1 CraftFishHook (org.bukkit.craftbukkit.v1_17_R1.entity.CraftFishHook)1 CraftItemStack (org.bukkit.craftbukkit.v1_17_R1.inventory.CraftItemStack)1 CraftWorld (org.bukkit.craftbukkit.v1_18_R1.CraftWorld)1 CraftFishHook (org.bukkit.craftbukkit.v1_18_R1.entity.CraftFishHook)1 CraftItemStack (org.bukkit.craftbukkit.v1_18_R1.inventory.CraftItemStack)1