2015-05-25 12:37:24 +02:00
|
|
|
--- a/net/minecraft/server/EntityWither.java
|
|
|
|
+++ b/net/minecraft/server/EntityWither.java
|
2017-05-14 04:00:00 +02:00
|
|
|
@@ -5,6 +5,12 @@
|
2018-07-15 02:00:00 +02:00
|
|
|
import java.util.function.Predicate;
|
2016-05-10 13:47:39 +02:00
|
|
|
import javax.annotation.Nullable;
|
2014-11-25 22:32:16 +01:00
|
|
|
|
|
|
|
+// CraftBukkit start
|
|
|
|
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
|
|
|
+import org.bukkit.event.entity.EntityRegainHealthEvent;
|
|
|
|
+import org.bukkit.event.entity.ExplosionPrimeEvent;
|
|
|
|
+// CraftBukkit end
|
|
|
|
+
|
|
|
|
public class EntityWither extends EntityMonster implements IRangedEntity {
|
|
|
|
|
2016-02-29 22:32:46 +01:00
|
|
|
private static final DataWatcherObject<Integer> a = DataWatcher.a(EntityWither.class, DataWatcherRegistry.b);
|
2018-07-15 02:00:00 +02:00
|
|
|
@@ -181,13 +187,38 @@
|
2018-08-26 04:00:00 +02:00
|
|
|
if (this.dz() > 0) {
|
|
|
|
i = this.dz() - 1;
|
2014-11-25 22:32:16 +01:00
|
|
|
if (i <= 0) {
|
|
|
|
- this.world.createExplosion(this, this.locX, this.locY + (double) this.getHeadHeight(), this.locZ, 7.0F, false, this.world.getGameRules().getBoolean("mobGriefing"));
|
2016-02-29 22:32:46 +01:00
|
|
|
- this.world.a(1023, new BlockPosition(this), 0);
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // CraftBukkit start
|
|
|
|
+ // this.world.createExplosion(this, this.locX, this.locY + (double) this.getHeadHeight(), this.locZ, 7.0F, false, this.world.getGameRules().getBoolean("mobGriefing"));
|
|
|
|
+ ExplosionPrimeEvent event = new ExplosionPrimeEvent(this.getBukkitEntity(), 7.0F, false);
|
|
|
|
+ this.world.getServer().getPluginManager().callEvent(event);
|
|
|
|
+
|
|
|
|
+ if (!event.isCancelled()) {
|
|
|
|
+ this.world.createExplosion(this, this.locX, this.locY + (double) this.getHeadHeight(), this.locZ, event.getRadius(), event.getFire(), this.world.getGameRules().getBoolean("mobGriefing"));
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
2015-02-26 23:41:06 +01:00
|
|
|
+
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // CraftBukkit start - Use relative location for far away sounds
|
2016-02-29 22:32:46 +01:00
|
|
|
+ // this.world.a(1023, new BlockPosition(this), 0);
|
2014-11-25 22:32:16 +01:00
|
|
|
+ int viewDistance = ((WorldServer) this.world).getServer().getViewDistance() * 16;
|
2015-03-07 16:02:53 +01:00
|
|
|
+ for (EntityPlayer player : (List<EntityPlayer>) MinecraftServer.getServer().getPlayerList().players) {
|
2014-11-25 22:32:16 +01:00
|
|
|
+ double deltaX = this.locX - player.locX;
|
|
|
|
+ double deltaZ = this.locZ - player.locZ;
|
|
|
|
+ double distanceSquared = deltaX * deltaX + deltaZ * deltaZ;
|
|
|
|
+ if (distanceSquared > viewDistance * viewDistance) {
|
|
|
|
+ double deltaLength = Math.sqrt(distanceSquared);
|
|
|
|
+ double relativeX = player.locX + (deltaX / deltaLength) * viewDistance;
|
|
|
|
+ double relativeZ = player.locZ + (deltaZ / deltaLength) * viewDistance;
|
2016-11-17 22:41:21 +01:00
|
|
|
+ player.playerConnection.sendPacket(new PacketPlayOutWorldEvent(1023, new BlockPosition((int) relativeX, (int) this.locY, (int) relativeZ), 0, true));
|
2014-11-25 22:32:16 +01:00
|
|
|
+ } else {
|
2016-11-17 22:41:21 +01:00
|
|
|
+ player.playerConnection.sendPacket(new PacketPlayOutWorldEvent(1023, new BlockPosition((int) this.locX, (int) this.locY, (int) this.locZ), 0, true));
|
2014-11-25 22:32:16 +01:00
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
|
|
|
}
|
|
|
|
|
2018-08-26 04:00:00 +02:00
|
|
|
this.d(i);
|
2014-11-25 22:32:16 +01:00
|
|
|
if (this.ticksLived % 10 == 0) {
|
|
|
|
- this.heal(10.0F);
|
|
|
|
+ this.heal(10.0F, EntityRegainHealthEvent.RegainReason.WITHER_SPAWN); // CraftBukkit
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
2018-07-15 02:00:00 +02:00
|
|
|
@@ -278,6 +309,11 @@
|
2016-02-29 22:32:46 +01:00
|
|
|
Block block = iblockdata.getBlock();
|
2014-11-25 22:32:16 +01:00
|
|
|
|
2018-07-15 02:00:00 +02:00
|
|
|
if (!iblockdata.isAir() && a(block)) {
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // CraftBukkit start
|
2018-07-15 02:00:00 +02:00
|
|
|
+ if (CraftEventFactory.callEntityChangeBlockEvent(this, blockposition, Blocks.AIR.getBlockData()).isCancelled()) {
|
2014-11-25 22:32:16 +01:00
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
2015-02-26 23:41:06 +01:00
|
|
|
flag = this.world.setAir(blockposition, true) || flag;
|
2014-11-25 22:32:16 +01:00
|
|
|
}
|
|
|
|
}
|
2018-07-15 02:00:00 +02:00
|
|
|
@@ -291,7 +327,7 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (this.ticksLived % 20 == 0) {
|
|
|
|
- this.heal(1.0F);
|
|
|
|
+ this.heal(1.0F, EntityRegainHealthEvent.RegainReason.REGEN); // CraftBukkit
|
|
|
|
}
|
|
|
|
|
2018-07-15 02:00:00 +02:00
|
|
|
this.bL.setProgress(this.getHealth() / this.getMaxHealth());
|