2011-01-12 06:48:19 +01:00
|
|
|
package net.minecraft.server;
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
import java.util.Iterator;
|
2011-01-12 06:48:19 +01:00
|
|
|
import java.util.List;
|
|
|
|
|
2012-07-22 08:18:00 +02:00
|
|
|
// CraftBukkit start
|
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
import org.bukkit.event.player.PlayerFishEvent;
|
|
|
|
// CraftBukkit end
|
2011-01-12 06:48:19 +01:00
|
|
|
|
2011-09-24 23:03:31 +02:00
|
|
|
public class EntityFishingHook extends Entity {
|
2011-01-12 06:48:19 +01:00
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
private int d = -1;
|
|
|
|
private int e = -1;
|
|
|
|
private int f = -1;
|
2011-02-23 03:37:56 +01:00
|
|
|
private int g = 0;
|
|
|
|
private boolean h = false;
|
2011-01-29 22:50:29 +01:00
|
|
|
public int a = 0;
|
2011-04-20 19:05:14 +02:00
|
|
|
public EntityHuman owner;
|
2011-02-23 03:37:56 +01:00
|
|
|
private int i;
|
|
|
|
private int j = 0;
|
2012-07-29 09:33:13 +02:00
|
|
|
private int an = 0;
|
2012-01-14 21:03:48 +01:00
|
|
|
public Entity hooked = null;
|
2012-07-29 09:33:13 +02:00
|
|
|
private int ao;
|
|
|
|
private double ap;
|
|
|
|
private double aq;
|
|
|
|
private double ar;
|
|
|
|
private double as;
|
|
|
|
private double at;
|
2011-01-12 06:48:19 +01:00
|
|
|
|
2011-09-24 23:03:31 +02:00
|
|
|
public EntityFishingHook(World world) {
|
2011-01-12 06:48:19 +01:00
|
|
|
super(world);
|
2012-07-29 09:33:13 +02:00
|
|
|
this.a(0.25F, 0.25F);
|
|
|
|
this.ak = true;
|
2011-01-12 06:48:19 +01:00
|
|
|
}
|
|
|
|
|
2011-09-24 23:03:31 +02:00
|
|
|
public EntityFishingHook(World world, EntityHuman entityhuman) {
|
2011-01-30 16:15:17 +01:00
|
|
|
super(world);
|
2012-07-29 09:33:13 +02:00
|
|
|
this.ak = true;
|
2011-04-20 19:05:14 +02:00
|
|
|
this.owner = entityhuman;
|
|
|
|
this.owner.hookedFish = this;
|
2012-07-29 09:33:13 +02:00
|
|
|
this.a(0.25F, 0.25F);
|
2011-04-20 19:05:14 +02:00
|
|
|
this.setPositionRotation(entityhuman.locX, entityhuman.locY + 1.62D - (double) entityhuman.height, entityhuman.locZ, entityhuman.yaw, entityhuman.pitch);
|
|
|
|
this.locX -= (double) (MathHelper.cos(this.yaw / 180.0F * 3.1415927F) * 0.16F);
|
2011-01-29 22:50:29 +01:00
|
|
|
this.locY -= 0.10000000149011612D;
|
2011-04-20 19:05:14 +02:00
|
|
|
this.locZ -= (double) (MathHelper.sin(this.yaw / 180.0F * 3.1415927F) * 0.16F);
|
|
|
|
this.setPosition(this.locX, this.locY, this.locZ);
|
2011-01-29 22:50:29 +01:00
|
|
|
this.height = 0.0F;
|
|
|
|
float f = 0.4F;
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
this.motX = (double) (-MathHelper.sin(this.yaw / 180.0F * 3.1415927F) * MathHelper.cos(this.pitch / 180.0F * 3.1415927F) * f);
|
|
|
|
this.motZ = (double) (MathHelper.cos(this.yaw / 180.0F * 3.1415927F) * MathHelper.cos(this.pitch / 180.0F * 3.1415927F) * f);
|
|
|
|
this.motY = (double) (-MathHelper.sin(this.pitch / 180.0F * 3.1415927F) * f);
|
2012-07-29 09:33:13 +02:00
|
|
|
this.c(this.motX, this.motY, this.motZ, 1.5F, 1.0F);
|
2011-01-12 06:48:19 +01:00
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
protected void a() {}
|
2011-05-26 14:48:22 +02:00
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
public void c(double d0, double d1, double d2, float f, float f1) {
|
2012-01-14 21:03:48 +01:00
|
|
|
float f2 = MathHelper.sqrt(d0 * d0 + d1 * d1 + d2 * d2);
|
2011-01-29 22:50:29 +01:00
|
|
|
|
|
|
|
d0 /= (double) f2;
|
|
|
|
d1 /= (double) f2;
|
|
|
|
d2 /= (double) f2;
|
|
|
|
d0 += this.random.nextGaussian() * 0.007499999832361937D * (double) f1;
|
|
|
|
d1 += this.random.nextGaussian() * 0.007499999832361937D * (double) f1;
|
|
|
|
d2 += this.random.nextGaussian() * 0.007499999832361937D * (double) f1;
|
|
|
|
d0 *= (double) f;
|
|
|
|
d1 *= (double) f;
|
|
|
|
d2 *= (double) f;
|
|
|
|
this.motX = d0;
|
|
|
|
this.motY = d1;
|
|
|
|
this.motZ = d2;
|
2012-01-14 21:03:48 +01:00
|
|
|
float f3 = MathHelper.sqrt(d0 * d0 + d2 * d2);
|
2011-01-29 22:50:29 +01:00
|
|
|
|
|
|
|
this.lastYaw = this.yaw = (float) (Math.atan2(d0, d2) * 180.0D / 3.1415927410125732D);
|
|
|
|
this.lastPitch = this.pitch = (float) (Math.atan2(d1, (double) f3) * 180.0D / 3.1415927410125732D);
|
2011-02-23 03:37:56 +01:00
|
|
|
this.i = 0;
|
2011-01-12 06:48:19 +01:00
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
public void h_() {
|
|
|
|
super.h_();
|
|
|
|
if (this.ao > 0) {
|
|
|
|
double d0 = this.locX + (this.ap - this.locX) / (double) this.ao;
|
|
|
|
double d1 = this.locY + (this.aq - this.locY) / (double) this.ao;
|
|
|
|
double d2 = this.locZ + (this.ar - this.locZ) / (double) this.ao;
|
|
|
|
double d3 = MathHelper.g(this.as - (double) this.yaw);
|
|
|
|
|
|
|
|
this.yaw = (float) ((double) this.yaw + d3 / (double) this.ao);
|
|
|
|
this.pitch = (float) ((double) this.pitch + (this.at - (double) this.pitch) / (double) this.ao);
|
|
|
|
--this.ao;
|
2011-04-20 19:05:14 +02:00
|
|
|
this.setPosition(d0, d1, d2);
|
2012-07-29 09:33:13 +02:00
|
|
|
this.b(this.yaw, this.pitch);
|
2011-01-29 22:50:29 +01:00
|
|
|
} else {
|
|
|
|
if (!this.world.isStatic) {
|
2012-07-29 09:33:13 +02:00
|
|
|
ItemStack itemstack = this.owner.bC();
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
if (this.owner.dead || !this.owner.isAlive() || itemstack == null || itemstack.getItem() != Item.FISHING_ROD || this.e(this.owner) > 1024.0D) {
|
2011-04-20 19:05:14 +02:00
|
|
|
this.die();
|
|
|
|
this.owner.hookedFish = null;
|
2011-01-12 06:48:19 +01:00
|
|
|
return;
|
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2012-01-14 21:03:48 +01:00
|
|
|
if (this.hooked != null) {
|
|
|
|
if (!this.hooked.dead) {
|
|
|
|
this.locX = this.hooked.locX;
|
|
|
|
this.locY = this.hooked.boundingBox.b + (double) this.hooked.length * 0.8D;
|
|
|
|
this.locZ = this.hooked.locZ;
|
2011-01-29 22:50:29 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-01-14 21:03:48 +01:00
|
|
|
this.hooked = null;
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
2011-01-12 06:48:19 +01:00
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
|
|
|
if (this.a > 0) {
|
|
|
|
--this.a;
|
|
|
|
}
|
|
|
|
|
2011-02-23 03:37:56 +01:00
|
|
|
if (this.h) {
|
2011-01-29 22:50:29 +01:00
|
|
|
int i = this.world.getTypeId(this.d, this.e, this.f);
|
|
|
|
|
2011-02-23 03:37:56 +01:00
|
|
|
if (i == this.g) {
|
|
|
|
++this.i;
|
|
|
|
if (this.i == 1200) {
|
2011-04-20 19:05:14 +02:00
|
|
|
this.die();
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
2011-01-12 06:48:19 +01:00
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2011-02-23 03:37:56 +01:00
|
|
|
this.h = false;
|
2011-01-29 22:50:29 +01:00
|
|
|
this.motX *= (double) (this.random.nextFloat() * 0.2F);
|
|
|
|
this.motY *= (double) (this.random.nextFloat() * 0.2F);
|
|
|
|
this.motZ *= (double) (this.random.nextFloat() * 0.2F);
|
2011-02-23 03:37:56 +01:00
|
|
|
this.i = 0;
|
|
|
|
this.j = 0;
|
2011-01-29 22:50:29 +01:00
|
|
|
} else {
|
2011-02-23 03:37:56 +01:00
|
|
|
++this.j;
|
2011-01-12 06:48:19 +01:00
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
Vec3D vec3d = Vec3D.a().create(this.locX, this.locY, this.locZ);
|
|
|
|
Vec3D vec3d1 = Vec3D.a().create(this.locX + this.motX, this.locY + this.motY, this.locZ + this.motZ);
|
2011-01-29 22:50:29 +01:00
|
|
|
MovingObjectPosition movingobjectposition = this.world.a(vec3d, vec3d1);
|
2011-01-12 06:48:19 +01:00
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
vec3d = Vec3D.a().create(this.locX, this.locY, this.locZ);
|
|
|
|
vec3d1 = Vec3D.a().create(this.locX + this.motX, this.locY + this.motY, this.locZ + this.motZ);
|
2011-01-29 22:50:29 +01:00
|
|
|
if (movingobjectposition != null) {
|
2012-07-29 09:33:13 +02:00
|
|
|
vec3d1 = Vec3D.a().create(movingobjectposition.pos.a, movingobjectposition.pos.b, movingobjectposition.pos.c);
|
2011-01-12 06:48:19 +01:00
|
|
|
}
|
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
Entity entity = null;
|
2012-01-12 16:27:39 +01:00
|
|
|
List list = this.world.getEntities(this, this.boundingBox.a(this.motX, this.motY, this.motZ).grow(1.0D, 1.0D, 1.0D));
|
2011-01-29 22:50:29 +01:00
|
|
|
double d4 = 0.0D;
|
2012-07-29 09:33:13 +02:00
|
|
|
Iterator iterator = list.iterator();
|
2011-01-29 22:50:29 +01:00
|
|
|
|
|
|
|
double d5;
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
while (iterator.hasNext()) {
|
|
|
|
Entity entity1 = (Entity) iterator.next();
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
if (entity1.L() && (entity1 != this.owner || this.j >= 5)) {
|
2011-01-29 22:50:29 +01:00
|
|
|
float f = 0.3F;
|
2012-01-12 16:27:39 +01:00
|
|
|
AxisAlignedBB axisalignedbb = entity1.boundingBox.grow((double) f, (double) f, (double) f);
|
2011-01-29 22:50:29 +01:00
|
|
|
MovingObjectPosition movingobjectposition1 = axisalignedbb.a(vec3d, vec3d1);
|
|
|
|
|
|
|
|
if (movingobjectposition1 != null) {
|
2012-02-29 22:31:04 +01:00
|
|
|
d5 = vec3d.distanceSquared(movingobjectposition1.pos); // CraftBukkit - distance efficiency
|
2011-01-29 22:50:29 +01:00
|
|
|
if (d5 < d4 || d4 == 0.0D) {
|
|
|
|
entity = entity1;
|
|
|
|
d4 = d5;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-01-12 06:48:19 +01:00
|
|
|
}
|
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
if (entity != null) {
|
|
|
|
movingobjectposition = new MovingObjectPosition(entity);
|
2011-01-12 06:48:19 +01:00
|
|
|
}
|
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
if (movingobjectposition != null) {
|
2011-04-20 19:05:14 +02:00
|
|
|
if (movingobjectposition.entity != null) {
|
2012-03-12 23:55:02 +01:00
|
|
|
if (movingobjectposition.entity.damageEntity(DamageSource.projectile(this, this.owner), 0)) {
|
2012-01-14 21:03:48 +01:00
|
|
|
this.hooked = movingobjectposition.entity;
|
2011-01-12 06:48:19 +01:00
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
} else {
|
2011-02-23 03:37:56 +01:00
|
|
|
this.h = true;
|
2011-01-12 06:48:19 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-02-23 03:37:56 +01:00
|
|
|
if (!this.h) {
|
2011-04-20 19:05:14 +02:00
|
|
|
this.move(this.motX, this.motY, this.motZ);
|
2012-01-14 21:03:48 +01:00
|
|
|
float f1 = MathHelper.sqrt(this.motX * this.motX + this.motZ * this.motZ);
|
2011-01-12 06:48:19 +01:00
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
this.yaw = (float) (Math.atan2(this.motX, this.motZ) * 180.0D / 3.1415927410125732D);
|
2011-01-12 06:48:19 +01:00
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
for (this.pitch = (float) (Math.atan2(this.motY, (double) f1) * 180.0D / 3.1415927410125732D); this.pitch - this.lastPitch < -180.0F; this.lastPitch -= 360.0F) {
|
|
|
|
;
|
|
|
|
}
|
2011-01-12 06:48:19 +01:00
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
while (this.pitch - this.lastPitch >= 180.0F) {
|
|
|
|
this.lastPitch += 360.0F;
|
|
|
|
}
|
2011-01-12 06:48:19 +01:00
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
while (this.yaw - this.lastYaw < -180.0F) {
|
|
|
|
this.lastYaw -= 360.0F;
|
|
|
|
}
|
2011-01-12 06:48:19 +01:00
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
while (this.yaw - this.lastYaw >= 180.0F) {
|
|
|
|
this.lastYaw += 360.0F;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.pitch = this.lastPitch + (this.pitch - this.lastPitch) * 0.2F;
|
|
|
|
this.yaw = this.lastYaw + (this.yaw - this.lastYaw) * 0.2F;
|
|
|
|
float f2 = 0.92F;
|
2011-01-12 06:48:19 +01:00
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
if (this.onGround || this.positionChanged) {
|
2011-01-29 22:50:29 +01:00
|
|
|
f2 = 0.5F;
|
2011-01-12 06:48:19 +01:00
|
|
|
}
|
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
byte b0 = 5;
|
|
|
|
double d6 = 0.0D;
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
for (int j = 0; j < b0; ++j) {
|
|
|
|
double d7 = this.boundingBox.b + (this.boundingBox.e - this.boundingBox.b) * (double) (j + 0) / (double) b0 - 0.125D + 0.125D;
|
|
|
|
double d8 = this.boundingBox.b + (this.boundingBox.e - this.boundingBox.b) * (double) (j + 1) / (double) b0 - 0.125D + 0.125D;
|
|
|
|
AxisAlignedBB axisalignedbb1 = AxisAlignedBB.a().a(this.boundingBox.a, d7, this.boundingBox.c, this.boundingBox.d, d8, this.boundingBox.f);
|
2011-01-12 06:48:19 +01:00
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
if (this.world.b(axisalignedbb1, Material.WATER)) {
|
|
|
|
d6 += 1.0D / (double) b0;
|
|
|
|
}
|
2011-01-12 06:48:19 +01:00
|
|
|
}
|
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
if (d6 > 0.0D) {
|
2012-07-29 09:33:13 +02:00
|
|
|
if (this.an > 0) {
|
|
|
|
--this.an;
|
2011-04-20 22:47:26 +02:00
|
|
|
} else {
|
|
|
|
short short1 = 500;
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
if (this.world.B(MathHelper.floor(this.locX), MathHelper.floor(this.locY) + 1, MathHelper.floor(this.locZ))) {
|
2011-04-20 22:47:26 +02:00
|
|
|
short1 = 300;
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
|
|
|
|
2011-04-20 22:47:26 +02:00
|
|
|
if (this.random.nextInt(short1) == 0) {
|
2012-07-29 09:33:13 +02:00
|
|
|
this.an = this.random.nextInt(30) + 10;
|
2011-04-20 22:47:26 +02:00
|
|
|
this.motY -= 0.20000000298023224D;
|
|
|
|
this.world.makeSound(this, "random.splash", 0.25F, 1.0F + (this.random.nextFloat() - this.random.nextFloat()) * 0.4F);
|
|
|
|
float f3 = (float) MathHelper.floor(this.boundingBox.b);
|
|
|
|
|
|
|
|
float f4;
|
2012-07-29 09:33:13 +02:00
|
|
|
int k;
|
2011-04-20 22:47:26 +02:00
|
|
|
float f5;
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
for (k = 0; (float) k < 1.0F + this.width * 20.0F; ++k) {
|
2011-11-30 00:17:43 +01:00
|
|
|
f5 = (this.random.nextFloat() * 2.0F - 1.0F) * this.width;
|
|
|
|
f4 = (this.random.nextFloat() * 2.0F - 1.0F) * this.width;
|
2011-04-20 22:47:26 +02:00
|
|
|
this.world.a("bubble", this.locX + (double) f5, (double) (f3 + 1.0F), this.locZ + (double) f4, this.motX, this.motY - (double) (this.random.nextFloat() * 0.2F), this.motZ);
|
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
for (k = 0; (float) k < 1.0F + this.width * 20.0F; ++k) {
|
2011-11-30 00:17:43 +01:00
|
|
|
f5 = (this.random.nextFloat() * 2.0F - 1.0F) * this.width;
|
|
|
|
f4 = (this.random.nextFloat() * 2.0F - 1.0F) * this.width;
|
2011-04-20 22:47:26 +02:00
|
|
|
this.world.a("splash", this.locX + (double) f5, (double) (f3 + 1.0F), this.locZ + (double) f4, this.motX, this.motY, this.motZ);
|
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
if (this.an > 0) {
|
2011-01-29 22:50:29 +01:00
|
|
|
this.motY -= (double) (this.random.nextFloat() * this.random.nextFloat() * this.random.nextFloat()) * 0.2D;
|
|
|
|
}
|
|
|
|
|
|
|
|
d5 = d6 * 2.0D - 1.0D;
|
|
|
|
this.motY += 0.03999999910593033D * d5;
|
|
|
|
if (d6 > 0.0D) {
|
|
|
|
f2 = (float) ((double) f2 * 0.9D);
|
|
|
|
this.motY *= 0.8D;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.motX *= (double) f2;
|
|
|
|
this.motY *= (double) f2;
|
|
|
|
this.motZ *= (double) f2;
|
2011-04-20 19:05:14 +02:00
|
|
|
this.setPosition(this.locX, this.locY, this.locZ);
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
2011-01-12 06:48:19 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-20 22:47:26 +02:00
|
|
|
public void b(NBTTagCompound nbttagcompound) {
|
2011-11-30 00:17:43 +01:00
|
|
|
nbttagcompound.setShort("xTile", (short) this.d);
|
|
|
|
nbttagcompound.setShort("yTile", (short) this.e);
|
|
|
|
nbttagcompound.setShort("zTile", (short) this.f);
|
|
|
|
nbttagcompound.setByte("inTile", (byte) this.g);
|
|
|
|
nbttagcompound.setByte("shake", (byte) this.a);
|
|
|
|
nbttagcompound.setByte("inGround", (byte) (this.h ? 1 : 0));
|
2011-01-12 06:48:19 +01:00
|
|
|
}
|
|
|
|
|
2011-04-20 22:47:26 +02:00
|
|
|
public void a(NBTTagCompound nbttagcompound) {
|
2011-11-30 00:17:43 +01:00
|
|
|
this.d = nbttagcompound.getShort("xTile");
|
|
|
|
this.e = nbttagcompound.getShort("yTile");
|
|
|
|
this.f = nbttagcompound.getShort("zTile");
|
|
|
|
this.g = nbttagcompound.getByte("inTile") & 255;
|
|
|
|
this.a = nbttagcompound.getByte("shake") & 255;
|
|
|
|
this.h = nbttagcompound.getByte("inGround") == 1;
|
2011-01-12 06:48:19 +01:00
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
public int d() {
|
|
|
|
if (this.world.isStatic) {
|
|
|
|
return 0;
|
|
|
|
} else {
|
|
|
|
byte b0 = 0;
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
if (this.hooked != null) {
|
|
|
|
// CraftBukkit start
|
|
|
|
PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) this.owner.getBukkitEntity(), this.hooked.getBukkitEntity(), PlayerFishEvent.State.CAUGHT_ENTITY);
|
|
|
|
this.world.getServer().getPluginManager().callEvent(playerFishEvent);
|
2011-07-03 06:28:29 +02:00
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
if (playerFishEvent.isCancelled()) {
|
|
|
|
this.die();
|
|
|
|
this.owner.hookedFish = null;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
// CraftBukkit end
|
|
|
|
|
|
|
|
double d0 = this.owner.locX - this.locX;
|
|
|
|
double d1 = this.owner.locY - this.locY;
|
|
|
|
double d2 = this.owner.locZ - this.locZ;
|
|
|
|
double d3 = (double) MathHelper.sqrt(d0 * d0 + d1 * d1 + d2 * d2);
|
|
|
|
double d4 = 0.1D;
|
|
|
|
|
|
|
|
this.hooked.motX += d0 * d4;
|
|
|
|
this.hooked.motY += d1 * d4 + (double) MathHelper.sqrt(d3) * 0.08D;
|
|
|
|
this.hooked.motZ += d2 * d4;
|
|
|
|
b0 = 3;
|
|
|
|
} else if (this.an > 0) {
|
|
|
|
EntityItem entityitem = new EntityItem(this.world, this.locX, this.locY, this.locZ, new ItemStack(Item.RAW_FISH));
|
|
|
|
// CraftBukkit start
|
|
|
|
PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) this.owner.getBukkitEntity(), entityitem.getBukkitEntity(), PlayerFishEvent.State.CAUGHT_FISH);
|
|
|
|
this.world.getServer().getPluginManager().callEvent(playerFishEvent);
|
|
|
|
|
|
|
|
if (playerFishEvent.isCancelled()) {
|
|
|
|
this.die();
|
|
|
|
this.owner.hookedFish = null;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
// CraftBukkit end
|
|
|
|
|
|
|
|
double d5 = this.owner.locX - this.locX;
|
|
|
|
double d6 = this.owner.locY - this.locY;
|
|
|
|
double d7 = this.owner.locZ - this.locZ;
|
|
|
|
double d8 = (double) MathHelper.sqrt(d5 * d5 + d6 * d6 + d7 * d7);
|
|
|
|
double d9 = 0.1D;
|
|
|
|
|
|
|
|
entityitem.motX = d5 * d9;
|
|
|
|
entityitem.motY = d6 * d9 + (double) MathHelper.sqrt(d8) * 0.08D;
|
|
|
|
entityitem.motZ = d7 * d9;
|
|
|
|
this.world.addEntity(entityitem);
|
|
|
|
this.owner.a(StatisticList.B, 1);
|
|
|
|
b0 = 1;
|
2011-07-03 06:28:29 +02:00
|
|
|
}
|
2011-11-20 09:01:14 +01:00
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
if (this.h) {
|
|
|
|
// CraftBukkit start
|
|
|
|
PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) this.owner.getBukkitEntity(), null, PlayerFishEvent.State.IN_GROUND);
|
|
|
|
this.world.getServer().getPluginManager().callEvent(playerFishEvent);
|
2011-07-03 06:28:29 +02:00
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
if (playerFishEvent.isCancelled()) {
|
|
|
|
this.die();
|
|
|
|
this.owner.hookedFish = null;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
// CraftBukkit end
|
2011-11-20 09:01:14 +01:00
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
b0 = 2;
|
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2011-07-03 06:28:29 +02:00
|
|
|
// CraftBukkit start
|
2012-07-29 09:33:13 +02:00
|
|
|
if (b0 == 0) {
|
|
|
|
PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) this.owner.getBukkitEntity(), null, PlayerFishEvent.State.FAILED_ATTEMPT);
|
|
|
|
this.world.getServer().getPluginManager().callEvent(playerFishEvent);
|
2011-07-03 06:28:29 +02:00
|
|
|
}
|
|
|
|
// CraftBukkit end
|
2012-07-29 09:33:13 +02:00
|
|
|
|
|
|
|
this.die();
|
|
|
|
this.owner.hookedFish = null;
|
|
|
|
return b0;
|
2011-01-12 06:48:19 +01:00
|
|
|
}
|
2012-07-29 09:33:13 +02:00
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
public void die() {
|
|
|
|
super.die();
|
|
|
|
if (this.owner != null) {
|
|
|
|
this.owner.hookedFish = null;
|
2011-07-03 06:28:29 +02:00
|
|
|
}
|
2011-01-12 06:48:19 +01:00
|
|
|
}
|
|
|
|
}
|