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/EndDragonFight.java b/src/main/java/net/minecraft/world/level/dimension/end/EndDragonFight.java index e2f784b771b12bd646d519938c33b1c86cc2686d..f32e2c71929a73258e4eb521c160c247690744d2 100644 --- a/src/main/java/net/minecraft/world/level/dimension/end/EndDragonFight.java +++ b/src/main/java/net/minecraft/world/level/dimension/end/EndDragonFight.java @@ -57,6 +57,7 @@ import net.minecraft.world.level.levelgen.feature.configurations.FeatureConfigur import net.minecraft.world.phys.AABB; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import io.papermc.paper.event.block.DragonEggFormEvent; // Paper - DragonEggFormEvent public class EndDragonFight { @@ -396,9 +397,24 @@ public class EndDragonFight { this.dragonEvent.setVisible(false); this.spawnExitPortal(true); this.spawnNewGateway(); + // Paper start - DragonEggFormEvent + BlockPos eggPosition = this.level.getHeightmapPos(Heightmap.Types.MOTION_BLOCKING, EndPodiumFeature.getPosition()); + org.bukkit.craftbukkit.block.CraftBlock eggBlock = org.bukkit.craftbukkit.block.CraftBlock.at(this.level, eggPosition); + org.bukkit.craftbukkit.block.CraftBlockState eggState = new org.bukkit.craftbukkit.block.CraftBlockState(eggBlock); + eggState.setData(Blocks.DRAGON_EGG.defaultBlockState()); + DragonEggFormEvent eggEvent = new DragonEggFormEvent(eggBlock, eggState, + new org.bukkit.craftbukkit.boss.CraftDragonBattle(this)); + // Paper end - DragonEggFormEvent if (this.level.paperConfig.enderDragonsDeathAlwaysPlacesDragonEgg || !this.previouslyKilled) { // Paper - always place dragon egg - this.level.setBlockAndUpdate(this.level.getHeightmapPos(Heightmap.Types.MOTION_BLOCKING, EndPodiumFeature.END_PODIUM_LOCATION), Blocks.DRAGON_EGG.defaultBlockState()); + // 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/EndPodiumFeature.java b/src/main/java/net/minecraft/world/level/levelgen/feature/EndPodiumFeature.java index cd24e9db1e9a490117716d4883376bb6b59c7c67..e085607f4033476e80b7dcd7b026449c12a47cf6 100644 --- a/src/main/java/net/minecraft/world/level/levelgen/feature/EndPodiumFeature.java +++ b/src/main/java/net/minecraft/world/level/levelgen/feature/EndPodiumFeature.java @@ -14,7 +14,7 @@ import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConf public class EndPodiumFeature extends Feature { - public static final BlockPos END_PODIUM_LOCATION = BlockPos.ZERO; + public static final BlockPos END_PODIUM_LOCATION = BlockPos.ZERO; public static BlockPos getPosition() { return END_PODIUM_LOCATION; } // Paper - OBFHELPER private final boolean active; public EndPodiumFeature(boolean open) { @@ -22,43 +22,43 @@ public class EndPodiumFeature extends Feature { this.active = open; } - public boolean place(WorldGenLevel world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, NoneFeatureConfiguration config) { - Iterator iterator = BlockPos.betweenClosed(new BlockPos(pos.getX() - 4, pos.getY() - 1, pos.getZ() - 4), new BlockPos(pos.getX() + 4, pos.getY() + 32, pos.getZ() + 4)).iterator(); + public boolean generate(WorldGenLevel generatoraccessseed, ChunkGenerator chunkgenerator, Random random, BlockPos blockposition, NoneFeatureConfiguration worldgenfeatureemptyconfiguration) { // Paper - decompile fix + Iterator iterator = BlockPos.betweenClosed(new BlockPos(blockposition.getX() - 4, blockposition.getY() - 1, blockposition.getZ() - 4), new BlockPos(blockposition.getX() + 4, blockposition.getY() + 32, blockposition.getZ() + 4)).iterator(); while (iterator.hasNext()) { BlockPos blockposition1 = (BlockPos) iterator.next(); - boolean flag = blockposition1.closerThan((Vec3i) pos, 2.5D); + boolean flag = blockposition1.closerThan((Vec3i) blockposition, 2.5D); - if (flag || blockposition1.closerThan((Vec3i) pos, 3.5D)) { - if (blockposition1.getY() < pos.getY()) { + if (flag || blockposition1.closerThan((Vec3i) blockposition, 3.5D)) { + if (blockposition1.getY() < blockposition.getY()) { if (flag) { - this.setBlock(world, blockposition1, Blocks.BEDROCK.defaultBlockState()); - } else if (blockposition1.getY() < pos.getY()) { - this.setBlock(world, blockposition1, Blocks.END_STONE.defaultBlockState()); + this.setBlock(generatoraccessseed, blockposition1, Blocks.BEDROCK.defaultBlockState()); + } else if (blockposition1.getY() < blockposition.getY()) { + this.setBlock(generatoraccessseed, blockposition1, Blocks.END_STONE.defaultBlockState()); } - } else if (blockposition1.getY() > pos.getY()) { - this.setBlock(world, blockposition1, Blocks.AIR.defaultBlockState()); + } else if (blockposition1.getY() > blockposition.getY()) { + this.setBlock(generatoraccessseed, blockposition1, Blocks.AIR.defaultBlockState()); } else if (!flag) { - this.setBlock(world, blockposition1, Blocks.BEDROCK.defaultBlockState()); + this.setBlock(generatoraccessseed, blockposition1, Blocks.BEDROCK.defaultBlockState()); } else if (this.active) { - this.setBlock(world, new BlockPos(blockposition1), Blocks.END_PORTAL.defaultBlockState()); + this.setBlock(generatoraccessseed, new BlockPos(blockposition1), Blocks.END_PORTAL.defaultBlockState()); } else { - this.setBlock(world, new BlockPos(blockposition1), Blocks.AIR.defaultBlockState()); + this.setBlock(generatoraccessseed, new BlockPos(blockposition1), Blocks.AIR.defaultBlockState()); } } } for (int i = 0; i < 4; ++i) { - this.setBlock(world, pos.above(i), Blocks.BEDROCK.defaultBlockState()); + this.setBlock(generatoraccessseed, blockposition.above(i), Blocks.BEDROCK.defaultBlockState()); } - BlockPos blockposition2 = pos.above(2); + BlockPos blockposition2 = blockposition.above(2); Iterator iterator1 = Direction.Plane.HORIZONTAL.iterator(); while (iterator1.hasNext()) { Direction enumdirection = (Direction) iterator1.next(); - this.setBlock(world, blockposition2.relative(enumdirection), (BlockState) Blocks.WALL_TORCH.defaultBlockState().setValue(WallTorchBlock.FACING, enumdirection)); + this.setBlock(generatoraccessseed, blockposition2.relative(enumdirection), (BlockState) Blocks.WALL_TORCH.defaultBlockState().setValue(WallTorchBlock.FACING, enumdirection)); } return true;