mirror of
https://github.com/PaperMC/Paper.git
synced 2025-03-12 14:50:03 +01:00
#783: Expand the FishHook API
By: Parker Hawke <hawkeboyz2@hotmail.com>
This commit is contained in:
parent
f6f717ebe7
commit
9a6f2ccb6b
@ -5,6 +5,7 @@ import net.minecraft.server.EntityFishingHook;
|
|||||||
import net.minecraft.server.MathHelper;
|
import net.minecraft.server.MathHelper;
|
||||||
import org.apache.commons.lang.Validate;
|
import org.apache.commons.lang.Validate;
|
||||||
import org.bukkit.craftbukkit.CraftServer;
|
import org.bukkit.craftbukkit.CraftServer;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.FishHook;
|
import org.bukkit.entity.FishHook;
|
||||||
|
|
||||||
@ -82,4 +83,39 @@ public class CraftFishHook extends CraftProjectile implements FishHook {
|
|||||||
Validate.isTrue(chance >= 0 && chance <= 1, "The bite chance must be between 0 and 1.");
|
Validate.isTrue(chance >= 0 && chance <= 1, "The bite chance must be between 0 and 1.");
|
||||||
this.biteChance = chance;
|
this.biteChance = chance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isInOpenWater() {
|
||||||
|
return getHandle().isInOpenWater();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Entity getHookedEntity() {
|
||||||
|
net.minecraft.server.Entity hooked = getHandle().hooked;
|
||||||
|
return (hooked != null) ? hooked.getBukkitEntity() : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setHookedEntity(Entity entity) {
|
||||||
|
EntityFishingHook hook = getHandle();
|
||||||
|
|
||||||
|
hook.hooked = (entity != null) ? ((CraftEntity) entity).getHandle() : null;
|
||||||
|
hook.getDataWatcher().set(EntityFishingHook.HOOKED_ENTITY, hook.hooked != null ? hook.hooked.getId() + 1 : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean pullHookedEntity() {
|
||||||
|
EntityFishingHook hook = getHandle();
|
||||||
|
if (hook.hooked == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
hook.reel();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HookState getState() {
|
||||||
|
return HookState.values()[getHandle().hookState.ordinal()];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user