mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-11 09:23:42 +01:00
67 lines
4.1 KiB
Diff
67 lines
4.1 KiB
Diff
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||
|
From: Trigary <trigary0@gmail.com>
|
||
|
Date: Mon, 25 Jan 2021 14:53:57 +0100
|
||
|
Subject: [PATCH] add DragonEggFormEvent
|
||
|
|
||
|
|
||
|
diff --git a/src/main/java/net/minecraft/server/EnderDragonBattle.java b/src/main/java/net/minecraft/server/EnderDragonBattle.java
|
||
|
index 7f11adbc5d8527b50f7657d46459516a471017b3..0d8fba494ed11ad79201dfd1c7f3ad5b288ca0ca 100644
|
||
|
--- a/src/main/java/net/minecraft/server/EnderDragonBattle.java
|
||
|
+++ b/src/main/java/net/minecraft/server/EnderDragonBattle.java
|
||
|
@@ -15,6 +15,7 @@ import java.util.function.Predicate;
|
||
|
import javax.annotation.Nullable;
|
||
|
import org.apache.logging.log4j.LogManager;
|
||
|
import org.apache.logging.log4j.Logger;
|
||
|
+import io.papermc.paper.event.block.DragonEggFormEvent; // Paper - DragonEggFormEvent
|
||
|
|
||
|
public class EnderDragonBattle {
|
||
|
|
||
|
@@ -358,9 +359,24 @@ 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/server/WorldGenEndTrophy.java b/src/main/java/net/minecraft/server/WorldGenEndTrophy.java
|
||
|
index dde3c2553adf29b6c97aa9a17b666f2e8ad4d2e6..441f3b6d57f128644ad952ab7f2d090d2140bd0c 100644
|
||
|
--- a/src/main/java/net/minecraft/server/WorldGenEndTrophy.java
|
||
|
+++ b/src/main/java/net/minecraft/server/WorldGenEndTrophy.java
|
||
|
@@ -5,7 +5,7 @@ import java.util.Random;
|
||
|
|
||
|
public class WorldGenEndTrophy extends WorldGenerator<WorldGenFeatureEmptyConfiguration> {
|
||
|
|
||
|
- 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) {
|
||
|
@@ -13,7 +13,7 @@ public class WorldGenEndTrophy extends WorldGenerator<WorldGenFeatureEmptyConfig
|
||
|
this.ab = flag;
|
||
|
}
|
||
|
|
||
|
- public boolean a(GeneratorAccessSeed generatoraccessseed, ChunkGenerator chunkgenerator, Random random, BlockPosition blockposition, WorldGenFeatureEmptyConfiguration worldgenfeatureemptyconfiguration) {
|
||
|
+ public boolean generate(GeneratorAccessSeed generatoraccessseed, ChunkGenerator chunkgenerator, Random random, BlockPosition blockposition, WorldGenFeatureEmptyConfiguration worldgenfeatureemptyconfiguration) { // Paper - decompile fix
|
||
|
Iterator iterator = BlockPosition.a(new BlockPosition(blockposition.getX() - 4, blockposition.getY() - 1, blockposition.getZ() - 4), new BlockPosition(blockposition.getX() + 4, blockposition.getY() + 32, blockposition.getZ() + 4)).iterator();
|
||
|
|
||
|
while (iterator.hasNext()) {
|