DragonEggPlaceEvent

This commit is contained in:
William Blake Galbreath
2020-07-30 18:16:41 -05:00
parent 9bd6e71f22
commit c543151676
2 changed files with 84 additions and 0 deletions

View File

@@ -0,0 +1,59 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: William Blake Galbreath <Blake.Galbreath@GMail.com>
Date: Thu, 30 Jul 2020 18:15:04 -0500
Subject: [PATCH] DragonEggPlaceEvent
diff --git a/src/main/java/net/pl3x/purpur/event/block/DragonEggPlaceEvent.java b/src/main/java/net/pl3x/purpur/event/block/DragonEggPlaceEvent.java
new file mode 100644
index 000000000..bdabfd2b5
--- /dev/null
+++ b/src/main/java/net/pl3x/purpur/event/block/DragonEggPlaceEvent.java
@@ -0,0 +1,47 @@
+package net.pl3x.purpur.event.block;
+
+import org.bukkit.Location;
+import org.bukkit.event.Cancellable;
+import org.bukkit.event.Event;
+import org.bukkit.event.HandlerList;
+import org.jetbrains.annotations.NotNull;
+
+public class DragonEggPlaceEvent extends Event implements Cancellable {
+ private static final HandlerList handlers = new HandlerList();
+ private Location location;
+ private boolean cancelled;
+
+ public DragonEggPlaceEvent(@NotNull Location location) {
+ this.location = location;
+ }
+
+ @NotNull
+ public Location getLocation() {
+ return location;
+ }
+
+ public void setLocation(@NotNull Location location) {
+ this.location = location;
+ }
+
+ @Override
+ public boolean isCancelled() {
+ return cancelled;
+ }
+
+ @Override
+ public void setCancelled(boolean cancel) {
+ cancelled = cancel;
+ }
+
+ @Override
+ @NotNull
+ public HandlerList getHandlers() {
+ return handlers;
+ }
+
+ @NotNull
+ public static HandlerList getHandlerList() {
+ return handlers;
+ }
+}

View File

@@ -0,0 +1,25 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: William Blake Galbreath <Blake.Galbreath@GMail.com>
Date: Thu, 30 Jul 2020 18:15:13 -0500
Subject: [PATCH] DragonEggPlaceEvent
diff --git a/src/main/java/net/minecraft/server/EnderDragonBattle.java b/src/main/java/net/minecraft/server/EnderDragonBattle.java
index ecd6af04d4..1cdfedde58 100644
--- a/src/main/java/net/minecraft/server/EnderDragonBattle.java
+++ b/src/main/java/net/minecraft/server/EnderDragonBattle.java
@@ -359,7 +359,13 @@ public class EnderDragonBattle {
this.a(true);
this.n();
if (this.world.purpurConfig.enderDragonAlwaysDropsEggBlock || !this.previouslyKilled) { // Purpur - always place dragon egg
- this.world.setTypeUpdate(this.world.getHighestBlockYAt(HeightMap.Type.MOTION_BLOCKING, WorldGenEndTrophy.a), Blocks.DRAGON_EGG.getBlockData());
+ // Purpur start
+ BlockPosition pos = this.world.getHighestBlockYAt(HeightMap.Type.MOTION_BLOCKING, WorldGenEndTrophy.a);
+ net.pl3x.purpur.event.block.DragonEggPlaceEvent event = new net.pl3x.purpur.event.block.DragonEggPlaceEvent(MCUtil.toLocation(world, pos));
+ if (event.callEvent()) {
+ this.world.setTypeUpdate(MCUtil.toBlockPosition(event.getLocation()), Blocks.DRAGON_EGG.getBlockData());
+ }
+ // Purpur end
}
this.previouslyKilled = true;