2012-03-09 20:25:44 +01:00
|
|
|
package net.minecraft.server;
|
|
|
|
|
2012-03-09 20:36:21 +01:00
|
|
|
// CraftBukkit start
|
|
|
|
import org.bukkit.craftbukkit.event.CraftEventFactory;
|
|
|
|
import org.bukkit.Material;
|
|
|
|
// CraftBukkit end
|
|
|
|
|
2012-03-09 20:25:44 +01:00
|
|
|
public class PathfinderGoalEatTile extends PathfinderGoal {
|
|
|
|
|
2013-07-01 13:03:00 +02:00
|
|
|
private EntityInsentient b;
|
2012-03-09 20:25:44 +01:00
|
|
|
private World c;
|
2013-07-01 13:03:00 +02:00
|
|
|
int a;
|
2012-03-09 20:25:44 +01:00
|
|
|
|
2013-07-01 13:03:00 +02:00
|
|
|
public PathfinderGoalEatTile(EntityInsentient entityinsentient) {
|
|
|
|
this.b = entityinsentient;
|
|
|
|
this.c = entityinsentient.world;
|
2012-03-09 20:25:44 +01:00
|
|
|
this.a(7);
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean a() {
|
2013-07-09 01:43:37 +02:00
|
|
|
if (this.b.aC().nextInt(this.b.isBaby() ? 50 : 1000) != 0) {
|
2012-03-09 20:25:44 +01:00
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
int i = MathHelper.floor(this.b.locX);
|
|
|
|
int j = MathHelper.floor(this.b.locY);
|
|
|
|
int k = MathHelper.floor(this.b.locZ);
|
|
|
|
|
|
|
|
return this.c.getTypeId(i, j, k) == Block.LONG_GRASS.id && this.c.getData(i, j, k) == 1 ? true : this.c.getTypeId(i, j - 1, k) == Block.GRASS.id;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
public void c() {
|
2012-03-09 20:25:44 +01:00
|
|
|
this.a = 40;
|
|
|
|
this.c.broadcastEntityEffect(this.b, (byte) 10);
|
2013-07-01 13:03:00 +02:00
|
|
|
this.b.getNavigation().h();
|
2012-03-09 20:25:44 +01:00
|
|
|
}
|
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
public void d() {
|
2012-03-09 20:25:44 +01:00
|
|
|
this.a = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean b() {
|
|
|
|
return this.a > 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int f() {
|
|
|
|
return this.a;
|
|
|
|
}
|
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
public void e() {
|
2012-03-09 20:25:44 +01:00
|
|
|
this.a = Math.max(0, this.a - 1);
|
|
|
|
if (this.a == 4) {
|
|
|
|
int i = MathHelper.floor(this.b.locX);
|
|
|
|
int j = MathHelper.floor(this.b.locY);
|
|
|
|
int k = MathHelper.floor(this.b.locZ);
|
|
|
|
|
|
|
|
if (this.c.getTypeId(i, j, k) == Block.LONG_GRASS.id) {
|
2012-03-09 20:36:21 +01:00
|
|
|
// CraftBukkit start
|
|
|
|
if (!CraftEventFactory.callEntityChangeBlockEvent(this.b.getBukkitEntity(), this.b.world.getWorld().getBlockAt(i, j, k), Material.AIR).isCancelled()) {
|
2013-03-13 23:33:27 +01:00
|
|
|
this.c.setAir(i, j, k, false);
|
2013-07-02 20:00:57 +02:00
|
|
|
this.b.n();
|
2012-03-09 20:36:21 +01:00
|
|
|
}
|
|
|
|
// CraftBukkit end
|
2012-03-09 20:25:44 +01:00
|
|
|
} else if (this.c.getTypeId(i, j - 1, k) == Block.GRASS.id) {
|
2012-03-09 20:36:21 +01:00
|
|
|
// CraftBukkit start
|
|
|
|
if (!CraftEventFactory.callEntityChangeBlockEvent(this.b.getBukkitEntity(), this.b.world.getWorld().getBlockAt(i, j - 1, k), Material.DIRT).isCancelled()) {
|
|
|
|
this.c.triggerEffect(2001, i, j - 1, k, Block.GRASS.id);
|
2013-03-13 23:33:27 +01:00
|
|
|
this.c.setTypeIdAndData(i, j - 1, k, Block.DIRT.id, 0, 2);
|
2013-07-02 20:00:57 +02:00
|
|
|
this.b.n();
|
2012-03-09 20:36:21 +01:00
|
|
|
}
|
|
|
|
// CraftBukkit end
|
2012-03-09 20:25:44 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-07-22 08:18:00 +02:00
|
|
|
}
|