3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-11-15 20:40:07 +01:00
Paper/Spigot-Server-Patches/0241-Call-PortalCreateEvent-for-exit-portals.patch
Zach Brown a2ad49b22f
Update upstream BD/B/CB/S
Note to other developers: This commit may require you to wipe your
workspace as a result of the changes to BD.

--- work/BuildData
Submodule work/BuildData f527a8ff..d56672db:
  > Mappings Update

--- work/Bukkit
Submodule work/Bukkit 0c1d258bb..db06c80d7:
  > Add list of entities to EntityTransformEvent
  > SPIGOT-4347: Add API to allow storing arbitrary values on ItemStacks

---work/CraftBukkit
Submodule work/CraftBukkit 6a398ac44..068dab5be:
  > Enable optional source JAR shading via profile shadeSourcesJar
  > Use ImmutableList rather than AbstractList for CraftMetaBook
  > Fix setRecipes(List) not setting Knowledge Book recipes.
  > Mappings Update
  > Add list of entities to EntityTransformEvent & move die calls
  > SPIGOT-4347: Add API to allow storing arbitrary values on ItemStacks
  > Add Vanilla help to default permissions

--- work/Spigot
Submodule work/Spigot a1f2566f6..e769fe4d9:
  > Mappings Update
  > Rebuild patches
2018-12-08 05:09:55 -05:00

109 Zeilen
5.4 KiB
Diff

From 66b22bb50ee08233312675626b9ed979fed3eac9 Mon Sep 17 00:00:00 2001
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
index 434589adb..7e858bab4 100644
--- a/src/main/java/net/minecraft/server/PortalTravelAgent.java
+++ b/src/main/java/net/minecraft/server/PortalTravelAgent.java
@@ -48,6 +48,9 @@ public class PortalTravelAgent {
byte b0 = 1;
byte b1 = 0;
+ java.util.Collection<org.bukkit.block.Block> bukkitBlocks = new java.util.HashSet<>(); // Paper
+ java.util.Map<BlockPosition, IBlockData> nmsBlocks = new java.util.LinkedHashMap<>(); // Paper
+
for (int l = -2; l <= 2; ++l) {
for (int i1 = -2; i1 <= 2; ++i1) {
for (int j1 = -1; j1 < 3; ++j1) {
@@ -56,11 +59,22 @@ public class PortalTravelAgent {
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.put(pos, flag2 ? Blocks.OBSIDIAN.getBlockData() : Blocks.AIR.getBlockData());
+ bukkitBlocks.add(this.world.getWorld().getBlockAt(pos.getX(), pos.getY(), pos.getZ()));
+ // Paper end
}
}
}
+ // Paper start
+ org.bukkit.event.world.PortalCreateEvent event = new org.bukkit.event.world.PortalCreateEvent(bukkitBlocks, this.world.getWorld(), org.bukkit.event.world.PortalCreateEvent.CreateReason.OBC_DESTINATION);
+ if (event.callEvent()) {
+ nmsBlocks.forEach(this.world::setTypeUpdate);
+ }
+ // Paper end
+
// CraftBukkit start
return new BlockPosition(i, k, k);
}
@@ -404,6 +418,9 @@ public class PortalTravelAgent {
l5 = -l5;
}
+ java.util.Collection<org.bukkit.block.Block> bukkitBlocks = new java.util.HashSet<>(); // Paper
+ java.util.Map<BlockPosition, IBlockData> nmsBlocks = new java.util.LinkedHashMap<>(); // Paper
+
if (d0 < 0.0D) {
i1 = MathHelper.clamp(i1, 70, this.world.ab() - 10);
j5 = i1;
@@ -416,8 +433,11 @@ public class PortalTravelAgent {
i4 = j2 + (i3 - 1) * l5 - k2 * k5;
boolean flag1 = l2 < 0;
- blockposition_mutableblockposition.c(j3, l3, i4);
- this.world.setTypeUpdate(blockposition_mutableblockposition, flag1 ? Blocks.OBSIDIAN.getBlockData() : Blocks.AIR.getBlockData());
+ // Paper start
+ BlockPosition pos = new BlockPosition(j3, l3, i4);
+ nmsBlocks.put(pos, flag1 ? Blocks.OBSIDIAN.getBlockData() : Blocks.AIR.getBlockData());
+ bukkitBlocks.add(this.world.getWorld().getBlockAt(pos.getX(), pos.getY(), pos.getZ()));
+ // Paper end
}
}
}
@@ -427,7 +447,11 @@ public class PortalTravelAgent {
for (i3 = -1; i3 < 4; ++i3) {
if (k2 == -1 || k2 == 2 || i3 == -1 || i3 == 3) {
blockposition_mutableblockposition.c(i5 + k2 * k5, j5 + i3, j2 + k2 * l5);
- this.world.setTypeAndData(blockposition_mutableblockposition, Blocks.OBSIDIAN.getBlockData(), 3);
+ // Paper start
+ BlockPosition pos = new BlockPosition(blockposition_mutableblockposition.getX(), blockposition_mutableblockposition.getY(), blockposition_mutableblockposition.getZ());
+ nmsBlocks.put(pos, Blocks.OBSIDIAN.getBlockData());
+ bukkitBlocks.add(this.world.getWorld().getBlockAt(pos.getX(), pos.getY(), pos.getZ()));
+ // Paper end
}
}
}
@@ -437,10 +461,22 @@ public class PortalTravelAgent {
for (i3 = 0; i3 < 2; ++i3) {
for (l2 = 0; l2 < 3; ++l2) {
blockposition_mutableblockposition.c(i5 + i3 * k5, j5 + l2, j2 + i3 * l5);
- this.world.setTypeAndData(blockposition_mutableblockposition, iblockdata, 18);
+
+ // Paper start
+ BlockPosition pos = new BlockPosition(blockposition_mutableblockposition.getX(), blockposition_mutableblockposition.getY(), blockposition_mutableblockposition.getZ());
+ nmsBlocks.put(pos, iblockdata);
+ bukkitBlocks.add(this.world.getWorld().getBlockAt(pos.getX(), pos.getY(), pos.getZ()));
+ // Paper end
}
}
+ // Paper start
+ org.bukkit.event.world.PortalCreateEvent event = new org.bukkit.event.world.PortalCreateEvent(bukkitBlocks, this.world.getWorld(), org.bukkit.event.world.PortalCreateEvent.CreateReason.OBC_DESTINATION);
+ if (event.callEvent()) {
+ nmsBlocks.forEach((pos, data) -> this.world.setTypeAndData(pos, data, 18)); // keep flag in sync with removed call above
+ }
+ // Paper end
+
return true;
}
--
2.19.2