2019-04-28 19:59:47 +02:00
|
|
|
From 3875cf67129d1cceb03e3c6500121465ad92985c Mon Sep 17 00:00:00 2001
|
2018-03-20 19:56:44 +01:00
|
|
|
From: MiniDigger <admin@minidigger.me>
|
|
|
|
Date: Sun, 18 Mar 2018 15:44:44 +0100
|
|
|
|
Subject: [PATCH] Call PortalCreateEvent for exit portals
|
|
|
|
|
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/PortalTravelAgent.java b/src/main/java/net/minecraft/server/PortalTravelAgent.java
|
2019-04-28 19:59:47 +02:00
|
|
|
index e7ca777c1..7807f7c41 100644
|
2018-03-20 19:56:44 +01:00
|
|
|
--- a/src/main/java/net/minecraft/server/PortalTravelAgent.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/PortalTravelAgent.java
|
2019-04-28 19:59:47 +02:00
|
|
|
@@ -259,6 +259,9 @@ public class PortalTravelAgent {
|
2018-03-20 19:56:44 +01:00
|
|
|
l5 = -l5;
|
|
|
|
}
|
|
|
|
|
2018-07-31 16:14:54 +02:00
|
|
|
+ java.util.Collection<org.bukkit.block.Block> bukkitBlocks = new java.util.HashSet<>(); // Paper
|
2018-07-31 22:16:12 +02:00
|
|
|
+ java.util.Map<BlockPosition, IBlockData> nmsBlocks = new java.util.LinkedHashMap<>(); // Paper
|
2018-03-20 19:56:44 +01:00
|
|
|
+
|
|
|
|
if (d0 < 0.0D) {
|
2019-04-28 19:59:47 +02:00
|
|
|
i1 = MathHelper.clamp(i1, 70, this.world.getHeight() - 10);
|
2018-03-20 19:56:44 +01:00
|
|
|
j5 = i1;
|
2019-04-28 19:59:47 +02:00
|
|
|
@@ -271,8 +274,11 @@ public class PortalTravelAgent {
|
2018-12-08 11:09:55 +01:00
|
|
|
i4 = j2 + (i3 - 1) * l5 - k2 * k5;
|
|
|
|
boolean flag1 = l2 < 0;
|
2018-03-20 19:56:44 +01:00
|
|
|
|
2019-04-28 19:59:47 +02:00
|
|
|
- blockposition_mutableblockposition.d(j3, l3, i4);
|
2018-07-18 20:55:52 +02:00
|
|
|
- this.world.setTypeUpdate(blockposition_mutableblockposition, flag1 ? Blocks.OBSIDIAN.getBlockData() : Blocks.AIR.getBlockData());
|
2018-03-20 19:56:44 +01:00
|
|
|
+ // Paper start
|
2018-12-08 11:09:55 +01:00
|
|
|
+ BlockPosition pos = new BlockPosition(j3, l3, i4);
|
2018-08-12 08:14:31 +02:00
|
|
|
+ nmsBlocks.put(pos, flag1 ? Blocks.OBSIDIAN.getBlockData() : Blocks.AIR.getBlockData());
|
2018-03-20 19:56:44 +01:00
|
|
|
+ bukkitBlocks.add(this.world.getWorld().getBlockAt(pos.getX(), pos.getY(), pos.getZ()));
|
|
|
|
+ // Paper end
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-04-28 19:59:47 +02:00
|
|
|
@@ -282,7 +288,11 @@ public class PortalTravelAgent {
|
2018-12-08 11:09:55 +01:00
|
|
|
for (i3 = -1; i3 < 4; ++i3) {
|
|
|
|
if (k2 == -1 || k2 == 2 || i3 == -1 || i3 == 3) {
|
2019-04-28 19:59:47 +02:00
|
|
|
blockposition_mutableblockposition.d(i5 + k2 * k5, j5 + i3, j2 + k2 * l5);
|
2018-07-18 20:55:52 +02:00
|
|
|
- this.world.setTypeAndData(blockposition_mutableblockposition, Blocks.OBSIDIAN.getBlockData(), 3);
|
2018-03-20 19:56:44 +01:00
|
|
|
+ // Paper start
|
2018-07-18 20:55:52 +02:00
|
|
|
+ BlockPosition pos = new BlockPosition(blockposition_mutableblockposition.getX(), blockposition_mutableblockposition.getY(), blockposition_mutableblockposition.getZ());
|
2018-08-12 08:14:31 +02:00
|
|
|
+ nmsBlocks.put(pos, Blocks.OBSIDIAN.getBlockData());
|
2018-03-20 19:56:44 +01:00
|
|
|
+ bukkitBlocks.add(this.world.getWorld().getBlockAt(pos.getX(), pos.getY(), pos.getZ()));
|
|
|
|
+ // Paper end
|
|
|
|
}
|
|
|
|
}
|
2018-07-18 20:55:52 +02:00
|
|
|
}
|
2019-04-28 19:59:47 +02:00
|
|
|
@@ -292,10 +302,22 @@ public class PortalTravelAgent {
|
2018-12-08 11:09:55 +01:00
|
|
|
for (i3 = 0; i3 < 2; ++i3) {
|
|
|
|
for (l2 = 0; l2 < 3; ++l2) {
|
2019-04-28 19:59:47 +02:00
|
|
|
blockposition_mutableblockposition.d(i5 + i3 * k5, j5 + l2, j2 + i3 * l5);
|
2018-07-18 20:55:52 +02:00
|
|
|
- this.world.setTypeAndData(blockposition_mutableblockposition, iblockdata, 18);
|
|
|
|
+
|
|
|
|
+ // Paper start
|
|
|
|
+ BlockPosition pos = new BlockPosition(blockposition_mutableblockposition.getX(), blockposition_mutableblockposition.getY(), blockposition_mutableblockposition.getZ());
|
2018-08-12 08:14:31 +02:00
|
|
|
+ nmsBlocks.put(pos, iblockdata);
|
2018-07-18 20:55:52 +02:00
|
|
|
+ bukkitBlocks.add(this.world.getWorld().getBlockAt(pos.getX(), pos.getY(), pos.getZ()));
|
2018-08-03 10:26:10 +02:00
|
|
|
+ // Paper end
|
2018-03-20 19:56:44 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
+ // Paper start
|
2018-07-31 16:14:54 +02:00
|
|
|
+ org.bukkit.event.world.PortalCreateEvent event = new org.bukkit.event.world.PortalCreateEvent(bukkitBlocks, this.world.getWorld(), org.bukkit.event.world.PortalCreateEvent.CreateReason.OBC_DESTINATION);
|
2018-08-03 10:26:10 +02:00
|
|
|
+ if (event.callEvent()) {
|
|
|
|
+ nmsBlocks.forEach((pos, data) -> this.world.setTypeAndData(pos, data, 18)); // keep flag in sync with removed call above
|
2018-03-20 19:56:44 +01:00
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
+
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
--
|
2019-03-20 02:46:00 +01:00
|
|
|
2.21.0
|
2018-03-20 19:56:44 +01:00
|
|
|
|