Paper/src/main/java/net/minecraft/server/PathfinderGoalBreakDoor.java

60 Zeilen
1.9 KiB
Java

package net.minecraft.server;
public class PathfinderGoalBreakDoor extends PathfinderGoalDoorInteract {
private int i;
2012-07-29 09:33:13 +02:00
private int j = -1;
2013-07-01 13:03:00 +02:00
public PathfinderGoalBreakDoor(EntityInsentient entityinsentient) {
super(entityinsentient);
}
public boolean a() {
2013-11-04 14:07:38 +01:00
return !super.a() ? false : (!this.a.world.getGameRules().getBoolean("mobGriefing") ? false : !this.e.f((IBlockAccess) this.a.world, this.b, this.c, this.d)); // CraftBukkit - Fix decompilation issue by casting world to IBlockAccess
}
public void c() {
super.c();
2012-07-29 09:33:13 +02:00
this.i = 0;
}
public boolean b() {
double d0 = this.a.e((double) this.b, (double) this.c, (double) this.d);
2013-11-04 14:07:38 +01:00
return this.i <= 240 && !this.e.f((IBlockAccess) this.a.world, this.b, this.c, this.d) && d0 < 4.0D; // CraftBukkit - Fix decompilation issue by casting world to IBlockAccess
}
2012-07-29 09:33:13 +02:00
public void d() {
super.d();
2013-11-04 14:07:38 +01:00
this.a.world.d(this.a.getId(), this.b, this.c, this.d, -1);
}
public void e() {
super.e();
2014-03-21 05:26:30 +01:00
if (this.a.aH().nextInt(20) == 0) {
this.a.world.triggerEffect(1010, this.b, this.c, this.d, 0);
}
2012-07-29 09:33:13 +02:00
++this.i;
int i = (int) ((float) this.i / 240.0F * 10.0F);
if (i != this.j) {
2013-11-04 14:07:38 +01:00
this.a.world.d(this.a.getId(), this.b, this.c, this.d, i);
2012-07-29 09:33:13 +02:00
this.j = i;
}
2013-11-04 14:07:38 +01:00
if (this.i == 240 && this.a.world.difficulty == EnumDifficulty.HARD) {
// CraftBukkit start
if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityBreakDoorEvent(this.a, this.b, this.c, this.d).isCancelled()) {
this.c();
return;
}
// CraftBukkit end
2012-07-29 09:33:13 +02:00
2013-03-13 23:33:27 +01:00
this.a.world.setAir(this.b, this.c, this.d);
this.a.world.triggerEffect(1012, this.b, this.c, this.d, 0);
2013-11-04 14:07:38 +01:00
this.a.world.triggerEffect(2001, this.b, this.c, this.d, Block.b((Block) this.e));
}
}
}