mirror of
https://github.com/Dreeam-qwq/Gale.git
synced 2026-01-04 15:31:45 +00:00
62 lines
3.4 KiB
Diff
62 lines
3.4 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Martijn Muijsers <martijnmuijsers@live.nl>
|
|
Date: Mon, 7 Aug 2023 22:02:38 +0200
|
|
Subject: [PATCH] Dragon respawn end crystal proximity check
|
|
|
|
License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
|
Gale - https://galemc.org
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/item/EndCrystalItem.java b/src/main/java/net/minecraft/world/item/EndCrystalItem.java
|
|
index ca1edc083847b47bb450b291723aca778a5912dc..428eed6ad35b59bdf293ca727fa3e81520a8bf0b 100644
|
|
--- a/src/main/java/net/minecraft/world/item/EndCrystalItem.java
|
|
+++ b/src/main/java/net/minecraft/world/item/EndCrystalItem.java
|
|
@@ -56,7 +56,7 @@ public class EndCrystalItem extends Item {
|
|
EndDragonFight enderdragonbattle = ((ServerLevel) world).getDragonFight();
|
|
|
|
if (enderdragonbattle != null) {
|
|
- enderdragonbattle.tryRespawn();
|
|
+ enderdragonbattle.tryRespawn(blockposition1); // Gale - check placed end crystal to portal proximity before attempting to respawn dragon
|
|
}
|
|
}
|
|
|
|
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 02d5a5b799bfe90993bc6868369d31f43d5b7fd6..9cb6a36ac210574a3d62202b16058e9fdc94691e 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
|
|
@@ -535,6 +535,12 @@ public class EndDragonFight {
|
|
}
|
|
|
|
public boolean tryRespawn() { // CraftBukkit - return boolean
|
|
+ // Gale start - check placed end crystal to portal proximity before attempting to respawn dragon
|
|
+ return this.tryRespawn(null);
|
|
+ }
|
|
+
|
|
+ public boolean tryRespawn(@Nullable BlockPos placedEndCrystalBlockPos) { // CraftBukkit - return boolean
|
|
+ // Gale end - check placed end crystal to portal proximity before attempting to respawn dragon
|
|
if (this.dragonKilled && this.respawnStage == null) {
|
|
BlockPos blockposition = this.portalLocation;
|
|
|
|
@@ -552,6 +558,22 @@ public class EndDragonFight {
|
|
blockposition = this.portalLocation;
|
|
}
|
|
|
|
+ // Gale start - check placed end crystal to portal proximity before attempting to respawn dragon
|
|
+ if (placedEndCrystalBlockPos != null) {
|
|
+ // The end crystal must be 0 or 1 higher than the portal origin
|
|
+ int dy = placedEndCrystalBlockPos.getY() - blockposition.getY();
|
|
+ if (dy != 0 && dy != 1) {
|
|
+ return false;
|
|
+ }
|
|
+ // The end crystal must be within a distance of 1 in one planar direction, and 3 in the other
|
|
+ int dx = placedEndCrystalBlockPos.getX() - blockposition.getX();
|
|
+ int dz = placedEndCrystalBlockPos.getZ() - blockposition.getZ();
|
|
+ if (!((dx >= -1 && dx <= 1 && dz >= -3 && dz <= 3) || (dx >= -3 && dx <= 3 && dz >= -1 && dz <= 1))) {
|
|
+ return false;
|
|
+ }
|
|
+ }
|
|
+ // Gale end - check placed end crystal to portal proximity before attempting to respawn dragon
|
|
+
|
|
List<EndCrystal> list = Lists.newArrayList();
|
|
BlockPos blockposition1 = blockposition.above(1);
|
|
Iterator iterator = Direction.Plane.HORIZONTAL.iterator();
|