94 lines
5.1 KiB
Diff
94 lines
5.1 KiB
Diff
--- a/net/minecraft/world/entity/boss/wither/EntityWither.java
|
|
+++ b/net/minecraft/world/entity/boss/wither/EntityWither.java
|
|
@@ -54,6 +54,17 @@
|
|
import net.minecraft.world.level.block.state.IBlockData;
|
|
import net.minecraft.world.phys.Vec3D;
|
|
|
|
+// CraftBukkit start
|
|
+import net.minecraft.network.protocol.game.PacketPlayOutWorldEvent;
|
|
+import net.minecraft.server.MinecraftServer;
|
|
+import net.minecraft.server.level.WorldServer;
|
|
+import net.minecraft.world.level.block.Blocks;
|
|
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
|
+import org.bukkit.event.entity.EntityRegainHealthEvent;
|
|
+import org.bukkit.event.entity.EntityTargetEvent;
|
|
+import org.bukkit.event.entity.ExplosionPrimeEvent;
|
|
+// CraftBukkit end
|
|
+
|
|
public class EntityWither extends EntityMonster implements PowerableMob, IRangedEntity {
|
|
|
|
private static final DataWatcherObject<Integer> DATA_TARGET_A = DataWatcher.a(EntityWither.class, DataWatcherRegistry.INT);
|
|
@@ -238,16 +249,40 @@
|
|
this.bossEvent.setProgress(1.0F - (float) i / 220.0F);
|
|
if (i <= 0) {
|
|
Explosion.Effect explosion_effect = this.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) ? Explosion.Effect.DESTROY : Explosion.Effect.NONE;
|
|
+ // CraftBukkit start
|
|
+ // this.world.createExplosion(this, this.locX(), this.getHeadY(), this.locZ(), 7.0F, false, explosion_effect);
|
|
+ ExplosionPrimeEvent event = new ExplosionPrimeEvent(this.getBukkitEntity(), 7.0F, false);
|
|
+ this.level.getServer().getPluginManager().callEvent(event);
|
|
+
|
|
+ if (!event.isCancelled()) {
|
|
+ this.level.createExplosion(this, this.locX(), this.getHeadY(), this.locZ(), event.getRadius(), event.getFire(), explosion_effect);
|
|
+ }
|
|
+ // CraftBukkit end
|
|
|
|
- this.level.createExplosion(this, this.locX(), this.getHeadY(), this.locZ(), 7.0F, false, explosion_effect);
|
|
if (!this.isSilent()) {
|
|
- this.level.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.level).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.connection.sendPacket(new PacketPlayOutWorldEvent(1023, new BlockPosition((int) relativeX, (int) this.locY(), (int) relativeZ), 0, true));
|
|
+ } else {
|
|
+ player.connection.sendPacket(new PacketPlayOutWorldEvent(1023, this.getChunkCoordinates(), 0, true));
|
|
+ }
|
|
+ }
|
|
+ // CraftBukkit end
|
|
}
|
|
}
|
|
|
|
this.setInvul(i);
|
|
if (this.tickCount % 10 == 0) {
|
|
- this.heal(10.0F);
|
|
+ this.heal(10.0F, EntityRegainHealthEvent.RegainReason.WITHER_SPAWN); // CraftBukkit
|
|
}
|
|
|
|
} else {
|
|
@@ -292,6 +327,7 @@
|
|
if (!list.isEmpty()) {
|
|
EntityLiving entityliving1 = (EntityLiving) list.get(this.random.nextInt(list.size()));
|
|
|
|
+ if (CraftEventFactory.callEntityTargetLivingEvent(this, entityliving1, EntityTargetEvent.TargetReason.CLOSEST_ENTITY).isCancelled()) continue; // CraftBukkit
|
|
this.setHeadTarget(i, entityliving1.getId());
|
|
}
|
|
}
|
|
@@ -322,6 +358,11 @@
|
|
IBlockData iblockdata = this.level.getType(blockposition);
|
|
|
|
if (c(iblockdata)) {
|
|
+ // CraftBukkit start
|
|
+ if (CraftEventFactory.callEntityChangeBlockEvent(this, blockposition, Blocks.AIR.getBlockData()).isCancelled()) {
|
|
+ continue;
|
|
+ }
|
|
+ // CraftBukkit end
|
|
flag = this.level.a(blockposition, true, this) || flag;
|
|
}
|
|
}
|
|
@@ -335,7 +376,7 @@
|
|
}
|
|
|
|
if (this.tickCount % 20 == 0) {
|
|
- this.heal(1.0F);
|
|
+ this.heal(1.0F, EntityRegainHealthEvent.RegainReason.REGEN); // CraftBukkit
|
|
}
|
|
|
|
this.bossEvent.setProgress(this.getHealth() / this.getMaxHealth());
|