@@ -0,0 +1,51 @@
|
||||
--- a/net/minecraft/server/EntityEnderCrystal.java
|
||||
+++ b/net/minecraft/server/EntityEnderCrystal.java
|
||||
@@ -3,6 +3,11 @@
|
||||
import java.util.Optional;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||
+import org.bukkit.event.entity.ExplosionPrimeEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class EntityEnderCrystal extends Entity {
|
||||
|
||||
private static final DataWatcherObject<Optional<BlockPosition>> c = DataWatcher.a(EntityEnderCrystal.class, DataWatcherRegistry.m);
|
||||
@@ -38,7 +43,11 @@
|
||||
BlockPosition blockposition = this.getChunkCoordinates();
|
||||
|
||||
if (((WorldServer) this.world).getDragonBattle() != null && this.world.getType(blockposition).isAir()) {
|
||||
- this.world.setTypeUpdate(blockposition, BlockFireAbstract.a((IBlockAccess) this.world, blockposition));
|
||||
+ // CraftBukkit start
|
||||
+ if (!CraftEventFactory.callBlockIgniteEvent(this.world, blockposition, this).isCancelled()) {
|
||||
+ this.world.setTypeUpdate(blockposition, BlockFireAbstract.a((IBlockAccess) this.world, blockposition));
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,9 +87,22 @@
|
||||
return false;
|
||||
} else {
|
||||
if (!this.dead && !this.world.isClientSide) {
|
||||
+ // CraftBukkit start - All non-living entities need this
|
||||
+ if (CraftEventFactory.handleNonLivingEntityDamageEvent(this, damagesource, f, false)) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.die();
|
||||
if (!damagesource.isExplosion()) {
|
||||
- this.world.explode((Entity) null, this.locX(), this.locY(), this.locZ(), 6.0F, Explosion.Effect.DESTROY);
|
||||
+ // CraftBukkit start
|
||||
+ ExplosionPrimeEvent event = new ExplosionPrimeEvent(this.getBukkitEntity(), 6.0F, false);
|
||||
+ this.world.getServer().getPluginManager().callEvent(event);
|
||||
+ if (event.isCancelled()) {
|
||||
+ this.dead = false;
|
||||
+ return false;
|
||||
+ }
|
||||
+ this.world.createExplosion(this, this.locX(), this.locY(), this.locZ(), event.getRadius(), event.getFire(), Explosion.Effect.DESTROY);
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
this.a(damagesource);
|
||||
@@ -0,0 +1,123 @@
|
||||
--- a/net/minecraft/server/EntityEnderDragon.java
|
||||
+++ b/net/minecraft/server/EntityEnderDragon.java
|
||||
@@ -7,6 +7,12 @@
|
||||
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
|
||||
+
|
||||
public class EntityEnderDragon extends EntityInsentient implements IMonster {
|
||||
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
@@ -38,6 +44,7 @@
|
||||
private final PathPoint[] bJ = new PathPoint[24];
|
||||
private final int[] bK = new int[24];
|
||||
private final Path bL = new Path();
|
||||
+ private Explosion explosionSource = new Explosion(null, this, null, null, 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);
|
||||
@@ -175,7 +182,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();
|
||||
@@ -313,7 +320,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(GameRules.MOB_GRIEFING) && !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,51 @@
|
||||
}
|
||||
}
|
||||
|
||||
+ // CraftBukkit start - Set off an EntityExplodeEvent for the dragon exploding all these blocks
|
||||
+ // SPIGOT-4882: don't fire event if nothing hit
|
||||
+ if (!flag1) {
|
||||
+ return flag;
|
||||
+ }
|
||||
+
|
||||
+ 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.isAir()) {
|
||||
+ 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.ORIGIN, Vec3D.a(blockposition)).set(LootContextParameters.TOOL, ItemStack.b).set(LootContextParameters.EXPLOSION_RADIUS, 1.0F / event.getYield()).setOptional(LootContextParameters.BLOCK_ENTITY, tileentity);
|
||||
+
|
||||
+ craftBlock.getNMS().a(loottableinfo_builder).forEach((itemstack) -> {
|
||||
+ Block.a(world, blockposition, itemstack);
|
||||
+ });
|
||||
+ craftBlock.getNMS().dropNaturally((WorldServer) world, blockposition, ItemStack.b);
|
||||
+ }
|
||||
+ 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));
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
--- a/net/minecraft/server/DragonControllerManager.java
|
||||
+++ b/net/minecraft/server/DragonControllerManager.java
|
||||
@@ -3,6 +3,11 @@
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.craftbukkit.entity.CraftEnderDragon;
|
||||
+import org.bukkit.event.entity.EnderDragonChangePhaseEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class DragonControllerManager {
|
||||
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
@@ -21,6 +26,19 @@
|
||||
this.currentDragonController.e();
|
||||
}
|
||||
|
||||
+ // CraftBukkit start - Call EnderDragonChangePhaseEvent
|
||||
+ EnderDragonChangePhaseEvent event = new EnderDragonChangePhaseEvent(
|
||||
+ (CraftEnderDragon) this.enderDragon.getBukkitEntity(),
|
||||
+ (this.currentDragonController == null) ? null : CraftEnderDragon.getBukkitPhase(this.currentDragonController.getControllerPhase()),
|
||||
+ CraftEnderDragon.getBukkitPhase(dragoncontrollerphase)
|
||||
+ );
|
||||
+ this.enderDragon.world.getServer().getPluginManager().callEvent(event);
|
||||
+ if (event.isCancelled()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ dragoncontrollerphase = CraftEnderDragon.getMinecraftPhase(event.getNewPhase());
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
this.currentDragonController = this.b(dragoncontrollerphase);
|
||||
if (!this.enderDragon.world.isClientSide) {
|
||||
this.enderDragon.getDataWatcher().set(EntityEnderDragon.PHASE, dragoncontrollerphase.b());
|
||||
@@ -42,6 +60,6 @@
|
||||
this.dragonControllers[i] = dragoncontrollerphase.a(this.enderDragon);
|
||||
}
|
||||
|
||||
- return this.dragonControllers[i];
|
||||
+ return (T) this.dragonControllers[i]; // CraftBukkit - decompile error
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user