From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Trigary Date: Mon, 25 Jan 2021 14:53:57 +0100 Subject: [PATCH] add DragonEggFormEvent diff --git a/src/main/java/net/minecraft/world/level/dimension/end/EnderDragonBattle.java b/src/main/java/net/minecraft/world/level/dimension/end/EnderDragonBattle.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/level/dimension/end/EnderDragonBattle.java +++ b/src/main/java/net/minecraft/world/level/dimension/end/EnderDragonBattle.java @@ -0,0 +0,0 @@ import net.minecraft.world.level.levelgen.feature.configurations.WorldGenFeature import net.minecraft.world.phys.AxisAlignedBB; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import io.papermc.paper.event.block.DragonEggFormEvent; // Paper - DragonEggFormEvent public class EnderDragonBattle { @@ -0,0 +0,0 @@ public class EnderDragonBattle { this.bossBattle.setVisible(false); this.generateExitPortal(true); this.n(); + // Paper start - DragonEggFormEvent + BlockPosition eggPosition = this.world.getHighestBlockYAt(HeightMap.Type.MOTION_BLOCKING, WorldGenEndTrophy.getPosition()); + org.bukkit.craftbukkit.block.CraftBlock eggBlock = org.bukkit.craftbukkit.block.CraftBlock.at(this.world, eggPosition); + org.bukkit.craftbukkit.block.CraftBlockState eggState = new org.bukkit.craftbukkit.block.CraftBlockState(eggBlock); + eggState.setData(Blocks.DRAGON_EGG.getBlockData()); + DragonEggFormEvent eggEvent = new DragonEggFormEvent(eggBlock, eggState, + new org.bukkit.craftbukkit.boss.CraftDragonBattle(this)); + // Paper end - DragonEggFormEvent if (this.world.paperConfig.enderDragonsDeathAlwaysPlacesDragonEgg || !this.previouslyKilled) { // Paper - always place dragon egg - this.world.setTypeUpdate(this.world.getHighestBlockYAt(HeightMap.Type.MOTION_BLOCKING, WorldGenEndTrophy.a), Blocks.DRAGON_EGG.getBlockData()); + // Paper start - DragonEggFormEvent + //this.world.setTypeUpdate(this.world.getHighestBlockYAt(HeightMap.Type.MOTION_BLOCKING, WorldGenEndTrophy.a), Blocks.DRAGON_EGG.getBlockData()); + } else { + eggEvent.setCancelled(true); + } + if (eggEvent.callEvent()) { + eggEvent.getNewState().update(true); } + // Paper end - DragonEggFormEvent this.previouslyKilled = true; this.dragonKilled = true; diff --git a/src/main/java/net/minecraft/world/level/levelgen/feature/WorldGenEndTrophy.java b/src/main/java/net/minecraft/world/level/levelgen/feature/WorldGenEndTrophy.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/level/levelgen/feature/WorldGenEndTrophy.java +++ b/src/main/java/net/minecraft/world/level/levelgen/feature/WorldGenEndTrophy.java @@ -0,0 +0,0 @@ import net.minecraft.world.level.levelgen.feature.configurations.WorldGenFeature public class WorldGenEndTrophy extends WorldGenerator { - public static final BlockPosition a = BlockPosition.ZERO; + public static final BlockPosition a = BlockPosition.ZERO; public static BlockPosition getPosition() { return a; } // Paper - OBFHELPER private final boolean ab; public WorldGenEndTrophy(boolean flag) { @@ -0,0 +0,0 @@ public class WorldGenEndTrophy extends WorldGenerator