Archiviert
13
0

make EntityPortalReadyEvent#setTargetWorld work again

Dieser Commit ist enthalten in:
Jake Potrebic 2024-06-16 15:48:38 -07:00
Ursprung fb762cf368
Commit a7f6633362
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: ECE0B3C133C016C5
17 geänderte Dateien mit 47 neuen und 52 gelöschten Zeilen

Datei anzeigen

@ -6,10 +6,10 @@ Subject: [PATCH] Add EntityPortalReadyEvent
diff --git a/src/main/java/io/papermc/paper/event/entity/EntityPortalReadyEvent.java b/src/main/java/io/papermc/paper/event/entity/EntityPortalReadyEvent.java
new file mode 100644
index 0000000000000000000000000000000000000000..a3242498c1c44cee3eec708cbca5b776ceb84c3e
index 0000000000000000000000000000000000000000..3450735c86a8af45491c010a796262ae892f14dc
--- /dev/null
+++ b/src/main/java/io/papermc/paper/event/entity/EntityPortalReadyEvent.java
@@ -0,0 +1,96 @@
@@ -0,0 +1,94 @@
+package io.papermc.paper.event.entity;
+
+import org.bukkit.PortalType;
@ -37,7 +37,7 @@ index 0000000000000000000000000000000000000000..a3242498c1c44cee3eec708cbca5b776
+ private static final HandlerList HANDLER_LIST = new HandlerList();
+
+ private final PortalType portalType;
+ private final World targetWorld;
+ private World targetWorld;
+
+ private boolean cancelled;
+
@ -71,11 +71,9 @@ index 0000000000000000000000000000000000000000..a3242498c1c44cee3eec708cbca5b776
+ * or {@link EntityPortalEvent}.
+ *
+ * @param targetWorld the world
+ * @deprecated changing the target world has no effect
+ */
+ @Deprecated(forRemoval = true, since = "1.21")
+ public void setTargetWorld(final @Nullable World targetWorld) {
+ // this.targetWorld = targetWorld;
+ this.targetWorld = targetWorld;
+ }
+
+ /**

Datei anzeigen

@ -4,25 +4,22 @@ Date: Wed, 12 May 2021 04:30:42 -0700
Subject: [PATCH] Add EntityPortalReadyEvent
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index d328393e62e4e49ddd56c10a9f4f5fcf0b218ddf..6be5d68567ba7b598644a3feeaa34ae5171c3b97 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -2943,6 +2943,17 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
if (this.portalProcess != null) {
if (this.portalProcess.processPortalTeleportation(worldserver, this, this.canUsePortal(false))) {
worldserver.getProfiler().push("portal");
diff --git a/src/main/java/net/minecraft/world/level/block/NetherPortalBlock.java b/src/main/java/net/minecraft/world/level/block/NetherPortalBlock.java
index caa22afb0781671b901c23ebcc89e5bb0d2bd615..a530276b0123dee5680d7e09ad3d2f0414909c91 100644
--- a/src/main/java/net/minecraft/world/level/block/NetherPortalBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/NetherPortalBlock.java
@@ -133,6 +133,14 @@ public class NetherPortalBlock extends Block implements Portal {
// CraftBukkit start
ResourceKey<Level> resourcekey = world.getTypeKey() == LevelStem.NETHER ? Level.OVERWORLD : Level.NETHER;
ServerLevel worldserver1 = world.getServer().getLevel(resourcekey);
+ // Paper start - Add EntityPortalReadyEvent
+ ServerLevel changedTarget = worldserver.getServer().getLevel(worldserver.getTypeKey() == net.minecraft.world.level.dimension.LevelStem.NETHER ? Level.OVERWORLD : Level.NETHER);
+ if (this.portalProcess.isSamePortal(((net.minecraft.world.level.block.NetherPortalBlock) net.minecraft.world.level.block.Blocks.NETHER_PORTAL))) {
+ io.papermc.paper.event.entity.EntityPortalReadyEvent event = new io.papermc.paper.event.entity.EntityPortalReadyEvent(this.getBukkitEntity(), changedTarget == null ? null : changedTarget.getWorld(), org.bukkit.PortalType.NETHER);
+ if (!event.callEvent()) {
+ this.portalProcess = null;
+ worldserver.getProfiler().pop();
+ return;
+ }
+ io.papermc.paper.event.entity.EntityPortalReadyEvent portalReadyEvent = new io.papermc.paper.event.entity.EntityPortalReadyEvent(entity.getBukkitEntity(), worldserver1 == null ? null : worldserver1.getWorld(), org.bukkit.PortalType.NETHER);
+ if (!portalReadyEvent.callEvent()) {
+ entity.portalProcess = null;
+ return null;
+ }
+ worldserver1 = portalReadyEvent.getTargetWorld() == null ? null : ((org.bukkit.craftbukkit.CraftWorld) portalReadyEvent.getTargetWorld()).getHandle();
+ // Paper end - Add EntityPortalReadyEvent
this.setPortalCooldown();
DimensionTransition dimensiontransition = this.portalProcess.getPortalDestination(worldserver, this);
if (worldserver1 == null) {
return new DimensionTransition(PlayerTeleportEvent.TeleportCause.NETHER_PORTAL); // always fire event in case plugins wish to change it

Datei anzeigen

@ -6,10 +6,10 @@ Subject: [PATCH] Fix EntityCombustEvent cancellation cant fully prevent
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index 6be5d68567ba7b598644a3feeaa34ae5171c3b97..1097fe9791a012568070b7b522c35303c85f4375 100644
index d328393e62e4e49ddd56c10a9f4f5fcf0b218ddf..1ce674329b3e977be09d40a01ed85d6fce71b2b3 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -3206,6 +3206,10 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
@@ -3195,6 +3195,10 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
pluginManager.callEvent(entityCombustEvent);
if (!entityCombustEvent.isCancelled()) {
this.igniteForSeconds(entityCombustEvent.getDuration(), false);

Datei anzeigen

@ -21,10 +21,10 @@ index ccbd527803a2a4e911a01f815cc9c7ab785af836..e2521e1a56df8dcb1de815e5973de952
} else if (this.seenBy.remove(player.connection)) {
this.serverEntity.removePairing(player);
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index 1097fe9791a012568070b7b522c35303c85f4375..b68ba105c84346057d8ee02c745d688c7379483e 100644
index 1ce674329b3e977be09d40a01ed85d6fce71b2b3..4d70a5fd3cc6473942c9542a7f2a61edbc00b661 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -3881,7 +3881,14 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
@@ -3870,7 +3870,14 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
public void startSeenByPlayer(ServerPlayer player) {}

Datei anzeigen

@ -5,10 +5,10 @@ Subject: [PATCH] Improve PortalEvents
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index b68ba105c84346057d8ee02c745d688c7379483e..9a49ab3cf682faef790c17579aec204b2778e461 100644
index 4d70a5fd3cc6473942c9542a7f2a61edbc00b661..9058e5cd8ef661d59e93e82a3222506a13d0b1f4 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -3540,7 +3540,14 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
@@ -3529,7 +3529,14 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
org.bukkit.entity.Entity bukkitEntity = entity.getBukkitEntity();
Location enter = bukkitEntity.getLocation();

Datei anzeigen

@ -6,7 +6,7 @@ Subject: [PATCH] Expose pre-collision moving velocity to
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index 9a49ab3cf682faef790c17579aec204b2778e461..c6d356fc0b94255299299eade9fb4b77bae8cc03 100644
index 9058e5cd8ef661d59e93e82a3222506a13d0b1f4..609d6b02d0aa90ea1d7dae0345b824334966239d 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -943,6 +943,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess

Datei anzeigen

@ -14,7 +14,7 @@ clearing the owner.
Co-authored-by: Warrior <50800980+Warriorrrr@users.noreply.github.com>
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index c6d356fc0b94255299299eade9fb4b77bae8cc03..ce648d328ceb7d98fc523398c52915f7e7b5e23e 100644
index 609d6b02d0aa90ea1d7dae0345b824334966239d..382ba6e846afdb41f6651b13b477ef4553a15b11 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -391,6 +391,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess

Datei anzeigen

@ -5,7 +5,7 @@ Subject: [PATCH] Don't load chunks for supporting block checks
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index ce648d328ceb7d98fc523398c52915f7e7b5e23e..880546f6727b90ebb021bb0939283739adaa93f6 100644
index 382ba6e846afdb41f6651b13b477ef4553a15b11..ceafb9a540aa0871516f220c79c7f2c30639f069 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -1186,7 +1186,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess

Datei anzeigen

@ -1185,7 +1185,7 @@ index 2ea29c9491186d7a25ed3eed99ee4a488bcaa272..de96d7df65713f2fa7b8f2dd068856bb
this.players.remove(entityplayer);
this.playersByName.remove(entityplayer.getScoreboardName().toLowerCase(java.util.Locale.ROOT)); // Spigot
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index 880546f6727b90ebb021bb0939283739adaa93f6..94c5dcfdf1dae1f4764c3c7287e4b51928a35a4c 100644
index ceafb9a540aa0871516f220c79c7f2c30639f069..30c979591001af9f465a2d3d23766e6f9f7d8892 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -255,11 +255,23 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
@ -1213,7 +1213,7 @@ index 880546f6727b90ebb021bb0939283739adaa93f6..94c5dcfdf1dae1f4764c3c7287e4b519
@Override
public CommandSender getBukkitSender(CommandSourceStack wrapper) {
return this.getBukkitEntity();
@@ -4496,6 +4508,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
@@ -4485,6 +4497,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
public final void setRemoved(Entity.RemovalReason entity_removalreason, EntityRemoveEvent.Cause cause) {
CraftEventFactory.callEntityRemoveEvent(this, cause);
// CraftBukkit end
@ -1221,7 +1221,7 @@ index 880546f6727b90ebb021bb0939283739adaa93f6..94c5dcfdf1dae1f4764c3c7287e4b519
if (this.removalReason == null) {
this.removalReason = entity_removalreason;
}
@@ -4506,12 +4519,28 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
@@ -4495,12 +4508,28 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
this.getPassengers().forEach(Entity::stopRiding);
this.levelCallback.onRemove(entity_removalreason);

Datei anzeigen

@ -5,7 +5,7 @@ Subject: [PATCH] Expand Pose API
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index 94c5dcfdf1dae1f4764c3c7287e4b51928a35a4c..84d735d358e2b58df0fccc8ffc5ef3346e62071d 100644
index 30c979591001af9f465a2d3d23766e6f9f7d8892..e99fc105b39e1ad92cbebc2f9de900c165d32a57 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -426,6 +426,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess

Datei anzeigen

@ -17,7 +17,7 @@ index 9d6c6a979fb1751ca90c9c1210ec52bbf12495f4..46d6fb2591f47c245446db210a00cbaa
this.containerMenu.findSlot(this.getInventory(), this.getInventory().selected).ifPresent(s -> {
this.containerSynchronizer.sendSlotChange(this.containerMenu, s, this.getMainHandItem());
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index 84d735d358e2b58df0fccc8ffc5ef3346e62071d..9afb2154a85da83ed50b1c80c21f03e4843ce63c 100644
index e99fc105b39e1ad92cbebc2f9de900c165d32a57..b70a7985280d52bd1d00c65a202316449e0d9561 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -2640,8 +2640,9 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess

Datei anzeigen

@ -31,7 +31,7 @@ index 8b5eabea1a0926c22b58ef8761caee3a06aa5ee0..53fdf4e104f36a2bd88fdf26d8c68cd3
if (entity.valid) {
MinecraftServer.LOGGER.error("Attempted Double World add on {}", entity, new Throwable());
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index 9afb2154a85da83ed50b1c80c21f03e4843ce63c..e4ad97071ed0e82fc910c34e700c6c6eee99deea 100644
index b70a7985280d52bd1d00c65a202316449e0d9561..d25bf5d1f0335e75edd78aa7b9706228e4d7fdec 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -625,7 +625,11 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess

Datei anzeigen

@ -50,7 +50,7 @@ index 184f3c7a1304f4f9d2aaeae27172be9d853c30de..3cbb59df34156479d24a8251f2b3acbb
if (entityitem == null) {
return null;
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index e4ad97071ed0e82fc910c34e700c6c6eee99deea..3d150ed6c3f7313628ccf110c1a67aa77b142326 100644
index d25bf5d1f0335e75edd78aa7b9706228e4d7fdec..1052133e22d90c90e5345ba423f6872cb5d2ad2d 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -2564,6 +2564,25 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess

Datei anzeigen

@ -84,10 +84,10 @@ index caf1d79e2bbdd257a5439e2973653747e678805f..e34584e4780f343d6c946af5377088d5
public DamageSource sonicBoom(Entity attacker) {
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index 3d150ed6c3f7313628ccf110c1a67aa77b142326..8779d54c816bb97ccdeb268d1929f693d322ee14 100644
index 1052133e22d90c90e5345ba423f6872cb5d2ad2d..8b6a905f398f5aadd0801ea50d49506a002d4ff5 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -3275,7 +3275,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
@@ -3264,7 +3264,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
return;
}

Datei anzeigen

@ -26054,7 +26054,7 @@ index ea72dcb064a35bc6245bc5c94d592efedd8faf41..87ee8e51dfa7657ed7d83fcbceef48bf
this.comparator = comparator;
if (initialCapacity < 0) {
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index 8779d54c816bb97ccdeb268d1929f693d322ee14..bf60b1aba3019996f53a3cf051d2a603cb7b8404 100644
index 8b6a905f398f5aadd0801ea50d49506a002d4ff5..138616b36b5e4d43b786876efc147d2648af1461 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -167,7 +167,7 @@ import org.bukkit.event.player.PlayerTeleportEvent;
@ -26144,7 +26144,7 @@ index 8779d54c816bb97ccdeb268d1929f693d322ee14..bf60b1aba3019996f53a3cf051d2a603
public Entity(EntityType<?> type, Level world) {
this.id = Entity.ENTITY_COUNTER.incrementAndGet();
@@ -4408,6 +4479,15 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
@@ -4397,6 +4468,15 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
this.setPosRaw(x, y, z, false);
}
public final void setPosRaw(double x, double y, double z, boolean forceBoundingBoxUpdate) {
@ -26160,7 +26160,7 @@ index 8779d54c816bb97ccdeb268d1929f693d322ee14..bf60b1aba3019996f53a3cf051d2a603
if (!checkPosition(this, x, y, z)) {
return;
}
@@ -4539,6 +4619,12 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
@@ -4528,6 +4608,12 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
@Override
public final void setRemoved(Entity.RemovalReason entity_removalreason, EntityRemoveEvent.Cause cause) {
@ -26173,7 +26173,7 @@ index 8779d54c816bb97ccdeb268d1929f693d322ee14..bf60b1aba3019996f53a3cf051d2a603
CraftEventFactory.callEntityRemoveEvent(this, cause);
// CraftBukkit end
final boolean alreadyRemoved = this.removalReason != null; // Paper - Folia schedulers
@@ -4550,7 +4636,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
@@ -4539,7 +4625,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
this.stopRiding();
}
@ -26182,7 +26182,7 @@ index 8779d54c816bb97ccdeb268d1929f693d322ee14..bf60b1aba3019996f53a3cf051d2a603
this.levelCallback.onRemove(entity_removalreason);
// Paper start - Folia schedulers
if (!(this instanceof ServerPlayer) && entity_removalreason != RemovalReason.CHANGED_DIMENSION && !alreadyRemoved) {
@@ -4581,7 +4667,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
@@ -4570,7 +4656,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
@Override
public boolean shouldBeSaved() {

Datei anzeigen

@ -111,7 +111,7 @@ index e06501f8856d2a8a877727151dfbc41caa9cfe95..657e7c1588bbbca8149cc4df37211780
} else {
passenger.stopRiding();
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index bf60b1aba3019996f53a3cf051d2a603cb7b8404..14db8510af7465eb663501008ca35f8ec63bfe30 100644
index 138616b36b5e4d43b786876efc147d2648af1461..2fa05c07cd9fc5acb844fac331986c2322433303 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -419,6 +419,8 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess

Datei anzeigen

@ -115,7 +115,7 @@ index 0d0b07c9199be9ca0d5ac3feb1d44f149ba69283..3d30427e75bdfb9cf453fb5cd2a34422
this.sendLevelInfo(player, worldserver1);
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index 14db8510af7465eb663501008ca35f8ec63bfe30..898651b7cfff15fe1afb690c247cdc3936d12fa6 100644
index 2fa05c07cd9fc5acb844fac331986c2322433303..437956b18d5bffd93c46e0be34cf413e9c704e5a 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -664,13 +664,44 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess