2018-07-31 20:16:12 +00:00
|
|
|
From aede0a63093907f88b869b485c595bf1c8cb1efe Mon Sep 17 00:00:00 2001
|
2018-03-20 18:56:44 +00: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
|
2018-07-31 20:16:12 +00:00
|
|
|
index 402d8d7d6..ba8d15431 100644
|
2018-03-20 18:56:44 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/PortalTravelAgent.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/PortalTravelAgent.java
|
2018-07-31 14:14:54 +00:00
|
|
|
@@ -12,7 +12,7 @@ import org.bukkit.util.Vector;
|
2018-03-20 18:56:44 +00:00
|
|
|
|
2018-07-18 18:55:52 +00:00
|
|
|
public class PortalTravelAgent {
|
|
|
|
|
|
|
|
- private static final BlockPortal a = (BlockPortal) Blocks.NETHER_PORTAL;
|
|
|
|
+ private static final BlockPortal a = (BlockPortal) Blocks.NETHER_PORTAL; private static final BlockPortal PORTAL_BLOCK = a; // Paper - OBFHELPER
|
|
|
|
public final WorldServer world; // Paper - private -> public
|
|
|
|
private final Random c;
|
|
|
|
private final Long2ObjectMap<PortalTravelAgent.ChunkCoordinatesPortal> d = new Long2ObjectOpenHashMap(4096);
|
2018-07-31 14:14:54 +00:00
|
|
|
@@ -48,6 +48,9 @@ public class PortalTravelAgent {
|
2018-03-20 18:56:44 +00:00
|
|
|
byte b0 = 1;
|
|
|
|
byte b1 = 0;
|
|
|
|
|
2018-07-31 14:14:54 +00:00
|
|
|
+ java.util.Collection<org.bukkit.block.Block> bukkitBlocks = new java.util.HashSet<>(); // Paper
|
2018-07-31 20:16:12 +00:00
|
|
|
+ java.util.Map<BlockPosition, IBlockData> nmsBlocks = new java.util.LinkedHashMap<>(); // Paper
|
2018-03-20 18:56:44 +00:00
|
|
|
+
|
|
|
|
for (int l = -2; l <= 2; ++l) {
|
|
|
|
for (int i1 = -2; i1 <= 2; ++i1) {
|
|
|
|
for (int j1 = -1; j1 < 3; ++j1) {
|
2018-07-31 14:14:54 +00:00
|
|
|
@@ -56,11 +59,22 @@ public class PortalTravelAgent {
|
2018-03-20 18:56:44 +00:00
|
|
|
int i2 = k + i1 * 0 - l * 1;
|
|
|
|
boolean flag2 = j1 < 0;
|
|
|
|
|
|
|
|
- this.world.setTypeUpdate(new BlockPosition(k1, l1, i2), flag2 ? Blocks.OBSIDIAN.getBlockData() : Blocks.AIR.getBlockData());
|
|
|
|
+ // Paper start
|
|
|
|
+ BlockPosition pos = new BlockPosition(k1, l1, i2);
|
|
|
|
+ nmsBlocks.putIfAbsent(pos, flag2 ? Blocks.OBSIDIAN.getBlockData() : Blocks.AIR.getBlockData());
|
|
|
|
+ bukkitBlocks.add(this.world.getWorld().getBlockAt(pos.getX(), pos.getY(), pos.getZ()));
|
|
|
|
+ // Paper end
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
+ // Paper start
|
2018-07-31 14:14:54 +00: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-03-20 18:56:44 +00:00
|
|
|
+ if(event.callEvent()){
|
|
|
|
+ nmsBlocks.forEach(this.world::setTypeUpdate);
|
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
+
|
|
|
|
// CraftBukkit start
|
|
|
|
return new BlockPosition(i, k, k);
|
|
|
|
}
|
2018-07-31 14:14:54 +00:00
|
|
|
@@ -404,6 +418,9 @@ public class PortalTravelAgent {
|
2018-03-20 18:56:44 +00:00
|
|
|
l5 = -l5;
|
|
|
|
}
|
|
|
|
|
2018-07-31 14:14:54 +00:00
|
|
|
+ java.util.Collection<org.bukkit.block.Block> bukkitBlocks = new java.util.HashSet<>(); // Paper
|
2018-07-31 20:16:12 +00:00
|
|
|
+ java.util.Map<BlockPosition, IBlockData> nmsBlocks = new java.util.LinkedHashMap<>(); // Paper
|
2018-03-20 18:56:44 +00:00
|
|
|
+
|
|
|
|
if (d0 < 0.0D) {
|
2018-07-18 18:55:52 +00:00
|
|
|
i1 = MathHelper.clamp(i1, 70, this.world.aa() - 10);
|
2018-03-20 18:56:44 +00:00
|
|
|
j5 = i1;
|
2018-07-31 14:14:54 +00:00
|
|
|
@@ -416,8 +433,11 @@ public class PortalTravelAgent {
|
2018-03-20 18:56:44 +00:00
|
|
|
l3 = j2 + (l2 - 1) * l5 - k2 * k5;
|
|
|
|
boolean flag1 = i3 < 0;
|
|
|
|
|
2018-07-18 18:55:52 +00:00
|
|
|
- blockposition_mutableblockposition.c(j3, k3, l3);
|
|
|
|
- this.world.setTypeUpdate(blockposition_mutableblockposition, flag1 ? Blocks.OBSIDIAN.getBlockData() : Blocks.AIR.getBlockData());
|
2018-03-20 18:56:44 +00:00
|
|
|
+ // Paper start
|
|
|
|
+ BlockPosition pos = new BlockPosition(j3, k3, l3);
|
|
|
|
+ nmsBlocks.putIfAbsent(pos, flag1 ? Blocks.OBSIDIAN.getBlockData() : Blocks.AIR.getBlockData());
|
|
|
|
+ bukkitBlocks.add(this.world.getWorld().getBlockAt(pos.getX(), pos.getY(), pos.getZ()));
|
|
|
|
+ // Paper end
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-07-31 14:14:54 +00:00
|
|
|
@@ -427,7 +447,11 @@ public class PortalTravelAgent {
|
2018-07-18 18:55:52 +00:00
|
|
|
for (l2 = -1; l2 < 4; ++l2) {
|
|
|
|
if (k2 == -1 || k2 == 2 || l2 == -1 || l2 == 3) {
|
|
|
|
blockposition_mutableblockposition.c(i5 + k2 * k5, j5 + l2, j2 + k2 * l5);
|
|
|
|
- this.world.setTypeAndData(blockposition_mutableblockposition, Blocks.OBSIDIAN.getBlockData(), 3);
|
2018-03-20 18:56:44 +00:00
|
|
|
+ // Paper start
|
2018-07-18 18:55:52 +00:00
|
|
|
+ BlockPosition pos = new BlockPosition(blockposition_mutableblockposition.getX(), blockposition_mutableblockposition.getY(), blockposition_mutableblockposition.getZ());
|
|
|
|
+ nmsBlocks.putIfAbsent(pos, Blocks.OBSIDIAN.getBlockData());
|
2018-03-20 18:56:44 +00:00
|
|
|
+ bukkitBlocks.add(this.world.getWorld().getBlockAt(pos.getX(), pos.getY(), pos.getZ()));
|
|
|
|
+ // Paper end
|
|
|
|
}
|
|
|
|
}
|
2018-07-18 18:55:52 +00:00
|
|
|
}
|
2018-07-31 14:14:54 +00:00
|
|
|
@@ -437,10 +461,22 @@ public class PortalTravelAgent {
|
2018-07-18 18:55:52 +00:00
|
|
|
for (l2 = 0; l2 < 2; ++l2) {
|
|
|
|
for (i3 = 0; i3 < 3; ++i3) {
|
|
|
|
blockposition_mutableblockposition.c(i5 + l2 * k5, j5 + i3, j2 + l2 * l5);
|
|
|
|
- this.world.setTypeAndData(blockposition_mutableblockposition, iblockdata, 18);
|
|
|
|
+
|
|
|
|
+ // Paper start
|
|
|
|
+ BlockPosition pos = new BlockPosition(blockposition_mutableblockposition.getX(), blockposition_mutableblockposition.getY(), blockposition_mutableblockposition.getZ());
|
|
|
|
+ nmsBlocks.putIfAbsent(pos, PORTAL_BLOCK.getBlockData());
|
|
|
|
+ bukkitBlocks.add(this.world.getWorld().getBlockAt(pos.getX(), pos.getY(), pos.getZ()));
|
|
|
|
+ // paper end
|
2018-03-20 18:56:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
+ // Paper start
|
2018-07-31 14:14:54 +00: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-03-20 18:56:44 +00:00
|
|
|
+ if(event.callEvent()){
|
|
|
|
+ nmsBlocks.forEach((pos, data) -> this.world.setTypeAndData(pos, data, 2));
|
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
+
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
--
|
2018-07-31 14:14:54 +00:00
|
|
|
2.18.0
|
2018-03-20 18:56:44 +00:00
|
|
|
|