mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-04 22:14:40 +01:00
116 lines
5.9 KiB
Diff
116 lines
5.9 KiB
Diff
--- a/net/minecraft/server/EntityEnderDragon.java
|
|
+++ b/net/minecraft/server/EntityEnderDragon.java
|
|
@@ -6,7 +6,13 @@
|
|
import javax.annotation.Nullable;
|
|
import org.apache.logging.log4j.LogManager;
|
|
import org.apache.logging.log4j.Logger;
|
|
+// CraftBukkit start
|
|
+import org.bukkit.craftbukkit.block.CraftBlock;
|
|
+import org.bukkit.event.entity.EntityExplodeEvent;
|
|
+import org.bukkit.event.entity.EntityRegainHealthEvent;
|
|
+// CraftBukkit end
|
|
|
|
+// PAIL: Fixme
|
|
public class EntityEnderDragon extends EntityInsentient implements IMonster {
|
|
|
|
private static final Logger bN = LogManager.getLogger();
|
|
@@ -35,6 +41,7 @@
|
|
private final PathPoint[] bT = new PathPoint[24];
|
|
private final int[] bU = new int[24];
|
|
private final Path bV = new Path();
|
|
+ private Explosion explosionSource = new Explosion(null, this, Double.NaN, Double.NaN, Double.NaN, Float.NaN, true, Explosion.Effect.DESTROY); // CraftBukkit - reusable source for CraftTNTPrimed.getSource()
|
|
|
|
public EntityEnderDragon(EntityTypes<? extends EntityEnderDragon> entitytypes, World world) {
|
|
super(EntityTypes.ENDER_DRAGON, world);
|
|
@@ -173,7 +180,7 @@
|
|
|
|
Vec3D vec3d1 = idragoncontroller.g();
|
|
|
|
- if (vec3d1 != null) {
|
|
+ if (vec3d1 != null && idragoncontroller.getControllerPhase() != DragonControllerPhase.HOVER) { // CraftBukkit - Don't move when hovering
|
|
d0 = vec3d1.x - this.locX;
|
|
d1 = vec3d1.y - this.locY;
|
|
d2 = vec3d1.z - this.locZ;
|
|
@@ -315,7 +322,14 @@
|
|
if (this.currentEnderCrystal.dead) {
|
|
this.currentEnderCrystal = null;
|
|
} else if (this.ticksLived % 10 == 0 && this.getHealth() < this.getMaxHealth()) {
|
|
- this.setHealth(this.getHealth() + 1.0F);
|
|
+ // CraftBukkit start
|
|
+ EntityRegainHealthEvent event = new EntityRegainHealthEvent(this.getBukkitEntity(), 1.0F, EntityRegainHealthEvent.RegainReason.ENDER_CRYSTAL);
|
|
+ this.world.getServer().getPluginManager().callEvent(event);
|
|
+
|
|
+ if (!event.isCancelled()) {
|
|
+ this.setHealth((float) (this.getHealth() + event.getAmount()));
|
|
+ }
|
|
+ // CraftBukkit end
|
|
}
|
|
}
|
|
|
|
@@ -388,6 +402,9 @@
|
|
int j1 = MathHelper.floor(axisalignedbb.maxZ);
|
|
boolean flag = false;
|
|
boolean flag1 = false;
|
|
+ // CraftBukkit start - Create a list to hold all the destroyed blocks
|
|
+ List<org.bukkit.block.Block> destroyedBlocks = new java.util.ArrayList<org.bukkit.block.Block>();
|
|
+ // CraftBukkit end
|
|
|
|
for (int k1 = i; k1 <= l; ++k1) {
|
|
for (int l1 = j; l1 <= i1; ++l1) {
|
|
@@ -398,7 +415,11 @@
|
|
|
|
if (!iblockdata.isAir() && iblockdata.getMaterial() != Material.FIRE) {
|
|
if (this.world.getGameRules().getBoolean("mobGriefing") && !TagsBlock.DRAGON_IMMUNE.isTagged(block)) {
|
|
- flag1 = this.world.a(blockposition, false) || flag1;
|
|
+ // CraftBukkit start - Add blocks to list rather than destroying them
|
|
+ // flag1 = this.world.a(blockposition, false) || flag1;
|
|
+ flag1 = true;
|
|
+ destroyedBlocks.add(CraftBlock.at(world, blockposition));
|
|
+ // CraftBukkit end
|
|
} else {
|
|
flag = true;
|
|
}
|
|
@@ -407,6 +428,43 @@
|
|
}
|
|
}
|
|
|
|
+ // CraftBukkit start - Set off an EntityExplodeEvent for the dragon exploding all these blocks
|
|
+ org.bukkit.entity.Entity bukkitEntity = this.getBukkitEntity();
|
|
+ EntityExplodeEvent event = new EntityExplodeEvent(bukkitEntity, bukkitEntity.getLocation(), destroyedBlocks, 0F);
|
|
+ bukkitEntity.getServer().getPluginManager().callEvent(event);
|
|
+ if (event.isCancelled()) {
|
|
+ // This flag literally means 'Dragon hit something hard' (Obsidian, White Stone or Bedrock) and will cause the dragon to slow down.
|
|
+ // We should consider adding an event extension for it, or perhaps returning true if the event is cancelled.
|
|
+ return flag;
|
|
+ } else if (event.getYield() == 0F) {
|
|
+ // Yield zero ==> no drops
|
|
+ for (org.bukkit.block.Block block : event.blockList()) {
|
|
+ this.world.a(new BlockPosition(block.getX(), block.getY(), block.getZ()), false);
|
|
+ }
|
|
+ } else {
|
|
+ for (org.bukkit.block.Block block : event.blockList()) {
|
|
+ org.bukkit.Material blockId = block.getType();
|
|
+ if (blockId == org.bukkit.Material.AIR) {
|
|
+ continue;
|
|
+ }
|
|
+
|
|
+ CraftBlock craftBlock = ((CraftBlock) block);
|
|
+ BlockPosition blockposition = craftBlock.getPosition();
|
|
+
|
|
+ Block nmsBlock = craftBlock.getNMS().getBlock();
|
|
+ if (nmsBlock.a(explosionSource)) {
|
|
+ TileEntity tileentity = nmsBlock.isTileEntity() ? this.world.getTileEntity(blockposition) : null;
|
|
+ LootTableInfo.Builder loottableinfo_builder = (new LootTableInfo.Builder((WorldServer) this.world)).a(this.world.random).set(LootContextParameters.POSITION, blockposition).set(LootContextParameters.TOOL, ItemStack.a).set(LootContextParameters.EXPLOSION_RADIUS, 1.0F / event.getYield()).setOptional(LootContextParameters.BLOCK_ENTITY, tileentity);
|
|
+
|
|
+ Block.b(craftBlock.getNMS(), loottableinfo_builder);
|
|
+ }
|
|
+ nmsBlock.wasExploded(world, blockposition, explosionSource);
|
|
+
|
|
+ this.world.a(blockposition, false);
|
|
+ }
|
|
+ }
|
|
+ // CraftBukkit end
|
|
+
|
|
if (flag1) {
|
|
BlockPosition blockposition1 = new BlockPosition(i + this.random.nextInt(l - i + 1), j + this.random.nextInt(i1 - j + 1), k + this.random.nextInt(j1 - k + 1));
|
|
|