Cleanup PortalCreateEvent patch

This commit is contained in:
Shane Freeder 2018-07-31 15:14:54 +01:00
parent a8c3640efd
commit 897d804c62

View file

@ -5,27 +5,10 @@ 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
@@ -0,0 +0,0 @@ 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
@@ -0,0 +0,0 @@ import org.bukkit.util.Vector;
public class PortalTravelAgent {
@ -38,8 +21,8 @@ index 402d8d7d..cd8b4b4a 100644
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) {
@ -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);
+ }
@ -72,8 +55,8 @@ index 402d8d7d..cd8b4b4a 100644
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);
@ -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));
+ }