mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-17 16:37:43 +01:00
106 lines
5.5 KiB
Diff
106 lines
5.5 KiB
Diff
From 8cd2f55a5d205378ff704811df327682f4cd1546 Mon Sep 17 00:00:00 2001
|
|
From: William Blake Galbreath <blake.galbreath@gmail.com>
|
|
Date: Sat, 19 Oct 2019 03:53:54 -0500
|
|
Subject: [PATCH] Add back EntityCreatePortalEvent for EnderDragon
|
|
|
|
---
|
|
.../minecraft/server/EnderDragonBattle.java | 57 ++++++++++++++++---
|
|
1 file changed, 49 insertions(+), 8 deletions(-)
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/EnderDragonBattle.java b/src/main/java/net/minecraft/server/EnderDragonBattle.java
|
|
index cfc059c00f..a2cb2693a4 100644
|
|
--- a/src/main/java/net/minecraft/server/EnderDragonBattle.java
|
|
+++ b/src/main/java/net/minecraft/server/EnderDragonBattle.java
|
|
@@ -21,8 +21,8 @@ public class EnderDragonBattle {
|
|
private static final Logger LOGGER = LogManager.getLogger();
|
|
private static final Predicate<Entity> b = IEntitySelector.a.and(IEntitySelector.a(0.0D, 128.0D, 0.0D, 192.0D));
|
|
public final BossBattleServer bossBattle;
|
|
- private final WorldServer d;
|
|
- private final List<Integer> e;
|
|
+ private final WorldServer d; public WorldServer getWorld() { return d; } // Purpur - OBFHELPER
|
|
+ private final List<Integer> e; public List<Integer> getGateways() { return e; } // Purpur - OBFHELPER
|
|
private final ShapeDetector f;
|
|
private int g;
|
|
private int h;
|
|
@@ -356,8 +356,8 @@ public class EnderDragonBattle {
|
|
if (entityenderdragon.getUniqueID().equals(this.m)) {
|
|
this.bossBattle.setProgress(0.0F);
|
|
this.bossBattle.setVisible(false);
|
|
- this.a(true);
|
|
- this.n();
|
|
+ spawnExitPortal(entityenderdragon); // Purpur
|
|
+ spawnGateway(entityenderdragon); // Purpur
|
|
if (net.pl3x.purpur.PurpurConfig.enderDragonAlwaysDropsEggBlock || !this.l) { // Purpur - always place dragon egg
|
|
this.d.setTypeUpdate(this.d.getHighestBlockYAt(HeightMap.Type.MOTION_BLOCKING, WorldGenEndTrophy.a), Blocks.DRAGON_EGG.getBlockData());
|
|
}
|
|
@@ -368,21 +368,62 @@ public class EnderDragonBattle {
|
|
|
|
}
|
|
|
|
- private void n() {
|
|
- if (!this.e.isEmpty()) {
|
|
- int i = (Integer) this.e.remove(this.e.size() - 1);
|
|
+ // Purpur start
|
|
+ private void spawnGateway(EntityEnderDragon dragon) { n(dragon); } // Purpur - OBFHELPER
|
|
+ private void n(EntityEnderDragon entityenderdragon) {
|
|
+ if (!getGateways().isEmpty()) {
|
|
+ int i = getGateways().remove(getGateways().size() - 1);
|
|
+ // Purpur end
|
|
int j = MathHelper.floor(96.0D * Math.cos(2.0D * (-3.141592653589793D + 0.15707963267948966D * (double) i)));
|
|
int k = MathHelper.floor(96.0D * Math.sin(2.0D * (-3.141592653589793D + 0.15707963267948966D * (double) i)));
|
|
|
|
- this.a(new BlockPosition(j, 75, k));
|
|
+ // Purpur start
|
|
+ getWorld().captureBlockStates = true;
|
|
+ generateGateway(new BlockPosition(j, 75, k));
|
|
+ getWorld().captureBlockStates = false;
|
|
+ if (getWorld().capturedBlockStates.size() > 0) {
|
|
+ org.bukkit.event.entity.EntityCreatePortalEvent event = new org.bukkit.event.entity.EntityCreatePortalEvent(entityenderdragon.getBukkitLivingEntity(), getWorld().capturedBlockStates.stream().map(state -> org.bukkit.craftbukkit.block.CraftBlockState.getBlockState(getWorld(), state.getPosition())).collect(java.util.stream.Collectors.toList()), org.bukkit.PortalType.END_GATEWAY);
|
|
+ if (!event.callEvent()) {
|
|
+ // put the gateway back into queue
|
|
+ getGateways().add(i);
|
|
+ // revert captured blocks
|
|
+ for (org.bukkit.craftbukkit.block.CraftBlockState state : getWorld().capturedBlockStates) {
|
|
+ state.update(true, false);
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+ getWorld().capturedTileEntities.clear();
|
|
+ getWorld().capturedBlockStates.clear();
|
|
+ // Purpur end
|
|
}
|
|
}
|
|
|
|
+ private void generateGateway(BlockPosition blockPosition) { a(blockPosition); } // Purpur - OBFHELPER
|
|
private void a(BlockPosition blockposition) {
|
|
this.d.triggerEffect(3000, blockposition, 0);
|
|
WorldGenerator.END_GATEWAY.b(WorldGenEndGatewayConfiguration.a()).a(this.d, this.d.getChunkProvider().getChunkGenerator(), new Random(), blockposition); // Paper - decompile fix
|
|
}
|
|
|
|
+ // Purpur start
|
|
+ private void spawnExitPortal(EntityEnderDragon dragon) {
|
|
+ getWorld().captureBlockStates = true;
|
|
+ generateExitPortal(true);
|
|
+ getWorld().captureBlockStates = false;
|
|
+ if (getWorld().capturedBlockStates.size() > 0) {
|
|
+ org.bukkit.event.entity.EntityCreatePortalEvent event = new org.bukkit.event.entity.EntityCreatePortalEvent(dragon.getBukkitLivingEntity(), getWorld().capturedBlockStates.stream().map(state -> org.bukkit.craftbukkit.block.CraftBlockState.getBlockState(getWorld(), state.getPosition())).collect(java.util.stream.Collectors.toList()), org.bukkit.PortalType.ENDER);
|
|
+ if (!event.callEvent()) {
|
|
+ // revert captured blocks
|
|
+ for (org.bukkit.craftbukkit.block.CraftBlockState state : getWorld().capturedBlockStates) {
|
|
+ state.update(true);
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+ getWorld().capturedTileEntities.clear();
|
|
+ getWorld().capturedBlockStates.clear();
|
|
+ }
|
|
+ // Purpur end
|
|
+
|
|
+ private void generateExitPortal(boolean active) { a(active); } // Purpur - OBFHELPER
|
|
private void a(boolean flag) {
|
|
WorldGenEndTrophy worldgenendtrophy = new WorldGenEndTrophy(flag);
|
|
|
|
--
|
|
2.24.0.rc1
|
|
|