mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-25 09:41:29 +01:00
Allow fishing success rate to be adjustable. Adds BUKKIT-3837
By: Andre LeBlanc <andre@norcode.com>
This commit is contained in:
parent
afa8771324
commit
10245ce119
@ -2,13 +2,17 @@ package org.bukkit.craftbukkit.entity;
|
|||||||
|
|
||||||
import net.minecraft.server.EntityFishingHook;
|
import net.minecraft.server.EntityFishingHook;
|
||||||
import net.minecraft.server.EntityHuman;
|
import net.minecraft.server.EntityHuman;
|
||||||
|
import net.minecraft.server.MathHelper;
|
||||||
|
|
||||||
|
import org.apache.commons.lang.Validate;
|
||||||
import org.bukkit.craftbukkit.CraftServer;
|
import org.bukkit.craftbukkit.CraftServer;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.Fish;
|
import org.bukkit.entity.Fish;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
|
|
||||||
public class CraftFish extends AbstractProjectile implements Fish {
|
public class CraftFish extends AbstractProjectile implements Fish {
|
||||||
|
private double biteChance = -1;
|
||||||
|
|
||||||
public CraftFish(CraftServer server, EntityFishingHook entity) {
|
public CraftFish(CraftServer server, EntityFishingHook entity) {
|
||||||
super(server, entity);
|
super(server, entity);
|
||||||
}
|
}
|
||||||
@ -40,4 +44,21 @@ public class CraftFish extends AbstractProjectile implements Fish {
|
|||||||
public EntityType getType() {
|
public EntityType getType() {
|
||||||
return EntityType.FISHING_HOOK;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user