13
0
geforkt von Mirrors/Paper

Cleanup PortalCreateEvent patch

Dieser Commit ist enthalten in:
Shane Freeder 2018-07-31 15:14:54 +01:00
Ursprung 810a2f24bf
Commit 5311679c74
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: A3F61EA5A085289C

Datei anzeigen

@ -1,31 +1,14 @@
From cedf22782245c8cfa8dbfecc3a445dc2f31552b1 Mon Sep 17 00:00:00 2001
From 45e58212dd6edf171819c56157f7fb32fa3ad617 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 402d8d7d..cd8b4b4a 100644
index 402d8d7d63..8ef31e72a5 100644
--- a/src/main/java/net/minecraft/server/PortalTravelAgent.java
+++ b/src/main/java/net/minecraft/server/PortalTravelAgent.java
@@ -3,16 +3,24 @@ package net.minecraft.server;
import it.unimi.dsi.fastutil.longs.Long2ObjectMap;
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap;
import it.unimi.dsi.fastutil.objects.ObjectIterator;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedHashMap;
+import java.util.Map;
import java.util.Random;
// CraftBukkit start
import org.bukkit.Location;
+import org.bukkit.block.Block;
import org.bukkit.event.entity.EntityPortalExitEvent;
+import org.bukkit.event.world.PortalCreateEvent;
import org.bukkit.util.Vector;
// CraftBukkit end
@@ -12,7 +12,7 @@ import org.bukkit.util.Vector;
public class PortalTravelAgent {
@ -34,17 +17,17 @@ index 402d8d7d..cd8b4b4a 100644
public final WorldServer world; // Paper - private -> public
private final Random c;
private final Long2ObjectMap<PortalTravelAgent.ChunkCoordinatesPortal> d = new Long2ObjectOpenHashMap(4096);
@@ -48,6 +56,9 @@ public class PortalTravelAgent {
@@ -48,6 +48,9 @@ public class PortalTravelAgent {
byte b0 = 1;
byte b1 = 0;
+ Collection<Block> bukkitBlocks = new HashSet<>(); // Paper
+ Map<BlockPosition, IBlockData> nmsBlocks = new HashMap<>(); // Paper
+ java.util.Collection<org.bukkit.block.Block> bukkitBlocks = new java.util.HashSet<>(); // Paper
+ java.util.Map<BlockPosition, IBlockData> nmsBlocks = new java.util.HashMap<>(); // Paper
+
for (int l = -2; l <= 2; ++l) {
for (int i1 = -2; i1 <= 2; ++i1) {
for (int j1 = -1; j1 < 3; ++j1) {
@@ -56,11 +67,22 @@ public class PortalTravelAgent {
@@ -56,11 +59,22 @@ public class PortalTravelAgent {
int i2 = k + i1 * 0 - l * 1;
boolean flag2 = j1 < 0;
@ -59,7 +42,7 @@ index 402d8d7d..cd8b4b4a 100644
}
+ // Paper start
+ PortalCreateEvent event = new PortalCreateEvent(bukkitBlocks, this.world.getWorld(), PortalCreateEvent.CreateReason.OBC_DESTINATION);
+ 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);
+ }
@ -68,17 +51,17 @@ index 402d8d7d..cd8b4b4a 100644
// CraftBukkit start
return new BlockPosition(i, k, k);
}
@@ -404,6 +426,9 @@ public class PortalTravelAgent {
@@ -404,6 +418,9 @@ public class PortalTravelAgent {
l5 = -l5;
}
+ Collection<Block> bukkitBlocks = new HashSet<>(); // Paper
+ Map<BlockPosition, IBlockData> nmsBlocks = new LinkedHashMap<>(); // Paper
+ java.util.Collection<org.bukkit.block.Block> bukkitBlocks = new java.util.HashSet<>(); // Paper
+ java.util.Map<BlockPosition, IBlockData> nmsBlocks = new java.util.HashMap<>(); // Paper
+
if (d0 < 0.0D) {
i1 = MathHelper.clamp(i1, 70, this.world.aa() - 10);
j5 = i1;
@@ -416,8 +441,11 @@ public class PortalTravelAgent {
@@ -416,8 +433,11 @@ public class PortalTravelAgent {
l3 = j2 + (l2 - 1) * l5 - k2 * k5;
boolean flag1 = i3 < 0;
@ -92,7 +75,7 @@ index 402d8d7d..cd8b4b4a 100644
}
}
}
@@ -427,7 +455,11 @@ public class PortalTravelAgent {
@@ -427,7 +447,11 @@ public class PortalTravelAgent {
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);
@ -105,7 +88,7 @@ index 402d8d7d..cd8b4b4a 100644
}
}
}
@@ -437,10 +469,22 @@ public class PortalTravelAgent {
@@ -437,10 +461,22 @@ public class PortalTravelAgent {
for (l2 = 0; l2 < 2; ++l2) {
for (i3 = 0; i3 < 3; ++i3) {
blockposition_mutableblockposition.c(i5 + l2 * k5, j5 + i3, j2 + l2 * l5);
@ -120,7 +103,7 @@ index 402d8d7d..cd8b4b4a 100644
}
+ // Paper start
+ PortalCreateEvent event = new PortalCreateEvent(bukkitBlocks, this.world.getWorld(), PortalCreateEvent.CreateReason.OBC_DESTINATION);
+ 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, 2));
+ }
@ -130,5 +113,5 @@ index 402d8d7d..cd8b4b4a 100644
}
--
2.12.2.windows.2
2.18.0