2015-05-25 12:37:24 +02:00
|
|
|
--- a/net/minecraft/server/EntityWither.java
|
|
|
|
+++ b/net/minecraft/server/EntityWither.java
|
2019-04-23 04:00:00 +02:00
|
|
|
@@ -6,6 +6,13 @@
|
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;
|
2019-02-10 00:32:24 +01:00
|
|
|
+import org.bukkit.event.entity.EntityTargetEvent;
|
2014-11-25 22:32:16 +01:00
|
|
|
+import org.bukkit.event.entity.ExplosionPrimeEvent;
|
|
|
|
+// CraftBukkit end
|
|
|
|
+
|
|
|
|
public class EntityWither extends EntityMonster implements IRangedEntity {
|
|
|
|
|
2019-04-23 04:00:00 +02:00
|
|
|
private static final DataWatcherObject<Integer> b = DataWatcher.a(EntityWither.class, DataWatcherRegistry.b);
|
2020-06-25 02:00:00 +02:00
|
|
|
@@ -188,16 +195,40 @@
|
|
|
|
i = this.getInvul() - 1;
|
2014-11-25 22:32:16 +01:00
|
|
|
if (i <= 0) {
|
2019-06-21 12:00:00 +02:00
|
|
|
Explosion.Effect explosion_effect = this.world.getGameRules().getBoolean(GameRules.MOB_GRIEFING) ? Explosion.Effect.DESTROY : Explosion.Effect.NONE;
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // CraftBukkit start
|
2019-12-10 23:00:00 +01:00
|
|
|
+ // this.world.createExplosion(this, this.locX(), this.getHeadY(), this.locZ(), 7.0F, false, explosion_effect);
|
2014-11-25 22:32:16 +01:00
|
|
|
+ ExplosionPrimeEvent event = new ExplosionPrimeEvent(this.getBukkitEntity(), 7.0F, false);
|
|
|
|
+ this.world.getServer().getPluginManager().callEvent(event);
|
|
|
|
+
|
|
|
|
+ if (!event.isCancelled()) {
|
2019-12-10 23:00:00 +01:00
|
|
|
+ this.world.createExplosion(this, this.locX(), this.getHeadY(), this.locZ(), event.getRadius(), event.getFire(), explosion_effect);
|
2014-11-25 22:32:16 +01:00
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
2019-04-23 04:00:00 +02:00
|
|
|
|
2019-12-10 23:00:00 +01:00
|
|
|
- this.world.createExplosion(this, this.locX(), this.getHeadY(), this.locZ(), 7.0F, false, explosion_effect);
|
2020-06-25 02:00:00 +02:00
|
|
|
if (!this.isSilent()) {
|
|
|
|
- this.world.b(1023, this.getChunkCoordinates(), 0);
|
|
|
|
+ // CraftBukkit start - Use relative location for far away sounds
|
|
|
|
+ // this.world.b(1023, new BlockPosition(this), 0);
|
|
|
|
+ int viewDistance = ((WorldServer) this.world).getServer().getViewDistance() * 16;
|
|
|
|
+ for (EntityPlayer player : (List<EntityPlayer>) MinecraftServer.getServer().getPlayerList().players) {
|
|
|
|
+ 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;
|
|
|
|
+ player.playerConnection.sendPacket(new PacketPlayOutWorldEvent(1023, new BlockPosition((int) relativeX, (int) this.locY(), (int) relativeZ), 0, true));
|
|
|
|
+ } else {
|
|
|
|
+ player.playerConnection.sendPacket(new PacketPlayOutWorldEvent(1023, this.getChunkCoordinates(), 0, true));
|
|
|
|
+ }
|
2014-11-25 22:32:16 +01:00
|
|
|
+ }
|
2020-06-25 02:00:00 +02:00
|
|
|
+ // CraftBukkit end
|
|
|
|
}
|
2014-11-25 22:32:16 +01:00
|
|
|
}
|
|
|
|
|
2020-06-25 02:00:00 +02:00
|
|
|
this.setInvul(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 {
|
2020-06-25 02:00:00 +02:00
|
|
|
@@ -249,9 +280,11 @@
|
2019-02-10 00:32:24 +01:00
|
|
|
if (entityliving != this && entityliving.isAlive() && this.hasLineOfSight(entityliving)) {
|
|
|
|
if (entityliving instanceof EntityHuman) {
|
|
|
|
if (!((EntityHuman) entityliving).abilities.isInvulnerable) {
|
|
|
|
+ if (CraftEventFactory.callEntityTargetLivingEvent(this, entityliving, EntityTargetEvent.TargetReason.CLOSEST_PLAYER).isCancelled()) continue; // CraftBukkit
|
2019-04-23 04:00:00 +02:00
|
|
|
this.setHeadTarget(i, entityliving.getId());
|
2019-02-10 00:32:24 +01:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
+ if (CraftEventFactory.callEntityTargetLivingEvent(this, entityliving, EntityTargetEvent.TargetReason.CLOSEST_ENTITY).isCancelled()) continue; // CraftBukkit
|
2019-04-23 04:00:00 +02:00
|
|
|
this.setHeadTarget(i, entityliving.getId());
|
2019-02-10 00:32:24 +01:00
|
|
|
}
|
|
|
|
break;
|
2020-06-25 02:00:00 +02:00
|
|
|
@@ -287,6 +320,11 @@
|
2019-04-23 04:00:00 +02:00
|
|
|
IBlockData iblockdata = this.world.getType(blockposition);
|
2014-11-25 22:32:16 +01:00
|
|
|
|
2020-06-25 02:00:00 +02:00
|
|
|
if (c(iblockdata)) {
|
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
|
2019-12-10 23:00:00 +01:00
|
|
|
flag = this.world.a(blockposition, true, this) || flag;
|
2014-11-25 22:32:16 +01:00
|
|
|
}
|
|
|
|
}
|
2020-06-25 02:00:00 +02:00
|
|
|
@@ -300,7 +338,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-12-06 00:00:00 +01:00
|
|
|
this.bossBattle.setProgress(this.getHealth() / this.getMaxHealth());
|