diff options
author | Andre LeBlanc <andre@norcode.com> | 2013-03-20 11:48:35 -0400 |
---|---|---|
committer | GJ <gjmcferrin@gmail.com> | 2013-03-25 14:45:24 -0400 |
commit | 18d7bc7ca3ff8fa5a183b9bb6bbab8ae388a8835 (patch) | |
tree | cdc0953ab3b6a0ce43c19338df8484c77bde5071 /src/main/java/org | |
parent | 96ba65d506641ef37fbefc5f9a6c65a4ccec5d23 (diff) | |
download | craftbukkit-18d7bc7ca3ff8fa5a183b9bb6bbab8ae388a8835.tar craftbukkit-18d7bc7ca3ff8fa5a183b9bb6bbab8ae388a8835.tar.gz craftbukkit-18d7bc7ca3ff8fa5a183b9bb6bbab8ae388a8835.tar.lz craftbukkit-18d7bc7ca3ff8fa5a183b9bb6bbab8ae388a8835.tar.xz craftbukkit-18d7bc7ca3ff8fa5a183b9bb6bbab8ae388a8835.zip |
Allow fishing success rate to be adjustable. Adds BUKKIT-3837
Diffstat (limited to 'src/main/java/org')
-rw-r--r-- | src/main/java/org/bukkit/craftbukkit/entity/CraftFish.java | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftFish.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftFish.java index 1e432ca0..7504bd50 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftFish.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftFish.java @@ -2,13 +2,17 @@ package org.bukkit.craftbukkit.entity; import net.minecraft.server.EntityFishingHook; import net.minecraft.server.EntityHuman; +import net.minecraft.server.MathHelper; +import org.apache.commons.lang.Validate; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.entity.EntityType; import org.bukkit.entity.Fish; import org.bukkit.entity.LivingEntity; public class CraftFish extends AbstractProjectile implements Fish { + private double biteChance = -1; + public CraftFish(CraftServer server, EntityFishingHook entity) { super(server, entity); } @@ -40,4 +44,21 @@ public class CraftFish extends AbstractProjectile implements Fish { public EntityType getType() { return EntityType.FISHING_HOOK; } + + public double getBiteChance() { + EntityFishingHook hook = getHandle(); + + if (this.biteChance == -1) { + if (hook.world.F(MathHelper.floor(hook.locX), MathHelper.floor(hook.locY) + 1, MathHelper.floor(hook.locZ))) { + return 1/300.0; + } + return 1/500.0; + } + return this.biteChance; + } + + public void setBiteChance(double chance) { + Validate.isTrue(chance >= 0 && chance <= 1, "The bite chance must be between 0 and 1."); + this.biteChance = chance; + } } |