geforkt von Mirrors/Paper
ef0e5a642d
Upstream has released updates that appear to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: 9ae3f10f SPIGOT-3842: Add Player#fireworkBoost() and expand Firework API 48c0c547 PR-786: Add methods to get sounds from entities CraftBukkit Changes: 5cc9c022a SPIGOT-7152: Handle hand item changing during air interact event 4ffa1acf6 SPIGOT-7154: Players get kicked when interacting with a conversation 4daa21123 SPIGOT-3842: Add Player#fireworkBoost() and expand Firework API e5d6a9bbf PR-1100: Add methods to get sounds from entities b7e9f1c8b SPIGOT-7146: Reduce use of Material switch in ItemMeta Spigot Changes: 4c157bb4 Rebuild patches
87 Zeilen
4.2 KiB
Diff
87 Zeilen
4.2 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Spottedleaf <spottedleaf@users.noreply.github.com>
|
|
Date: Fri, 4 Jun 2021 17:06:52 -0400
|
|
Subject: [PATCH] Fix dangerous end portal logic
|
|
|
|
End portals could teleport entities during move calls. Stupid
|
|
logic given the caller will never expect that kind of thing,
|
|
and will result in all kinds of dupes.
|
|
|
|
Move the tick logic into the post tick, where portaling was
|
|
designed to happen in the first place.
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
|
index 525e712c5715f1fa323fae94d4158c4e66068fe3..0b524fb57af63ad3b9e11a30e7b2d0fd219664ad 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
|
@@ -459,6 +459,36 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
|
return chunkMap.playerEntityTrackerTrackMaps[type.ordinal()].getObjectsInRange(MCUtil.getCoordinateKey(this));
|
|
}
|
|
// Paper end - optimise entity tracking
|
|
+ // Paper start - make end portalling safe
|
|
+ public BlockPos portalBlock;
|
|
+ public ServerLevel portalWorld;
|
|
+ public void tickEndPortal() {
|
|
+ BlockPos pos = this.portalBlock;
|
|
+ ServerLevel world = this.portalWorld;
|
|
+ this.portalBlock = null;
|
|
+ this.portalWorld = null;
|
|
+
|
|
+ if (pos == null || world == null || world != this.level) {
|
|
+ return;
|
|
+ }
|
|
+
|
|
+ if (this.isPassenger() || this.isVehicle() || !this.canChangeDimensions() || this.isRemoved() || !this.valid || !this.isAlive()) {
|
|
+ return;
|
|
+ }
|
|
+
|
|
+ ResourceKey<Level> resourcekey = world.getTypeKey() == LevelStem.END ? Level.OVERWORLD : Level.END; // CraftBukkit - SPIGOT-6152: send back to main overworld in custom ends
|
|
+ ServerLevel worldserver = world.getServer().getLevel(resourcekey);
|
|
+
|
|
+ org.bukkit.event.entity.EntityPortalEnterEvent event = new org.bukkit.event.entity.EntityPortalEnterEvent(this.getBukkitEntity(), new org.bukkit.Location(world.getWorld(), pos.getX(), pos.getY(), pos.getZ()));
|
|
+ event.callEvent();
|
|
+
|
|
+ if (this instanceof ServerPlayer) {
|
|
+ ((ServerPlayer)this).changeDimension(worldserver, PlayerTeleportEvent.TeleportCause.END_PORTAL);
|
|
+ return;
|
|
+ }
|
|
+ this.teleportTo(worldserver, null);
|
|
+ }
|
|
+ // Paper end - make end portalling safe
|
|
|
|
public Entity(EntityType<?> type, Level world) {
|
|
this.id = Entity.ENTITY_COUNTER.incrementAndGet();
|
|
@@ -2635,6 +2665,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
|
}
|
|
|
|
this.processPortalCooldown();
|
|
+ this.tickEndPortal(); // Paper - make end portalling safe
|
|
}
|
|
}
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/level/block/EndPortalBlock.java b/src/main/java/net/minecraft/world/level/block/EndPortalBlock.java
|
|
index 150c16da7caa655cfc2c371d3336a8d7345438c6..15c5cccfe02c924c02f605eb47dd0b420b189891 100644
|
|
--- a/src/main/java/net/minecraft/world/level/block/EndPortalBlock.java
|
|
+++ b/src/main/java/net/minecraft/world/level/block/EndPortalBlock.java
|
|
@@ -53,16 +53,10 @@ public class EndPortalBlock extends BaseEntityBlock {
|
|
// return; // CraftBukkit - always fire event in case plugins wish to change it
|
|
}
|
|
|
|
- // CraftBukkit start - Entity in portal
|
|
- EntityPortalEnterEvent event = new EntityPortalEnterEvent(entity.getBukkitEntity(), new org.bukkit.Location(world.getWorld(), pos.getX(), pos.getY(), pos.getZ()));
|
|
- world.getCraftServer().getPluginManager().callEvent(event);
|
|
-
|
|
- if (entity instanceof ServerPlayer) {
|
|
- ((ServerPlayer) entity).changeDimension(worldserver, PlayerTeleportEvent.TeleportCause.END_PORTAL);
|
|
- return;
|
|
- }
|
|
- // CraftBukkit end
|
|
- entity.changeDimension(worldserver);
|
|
+ // Paper start - move all of this logic into portal tick
|
|
+ entity.portalWorld = ((ServerLevel)world);
|
|
+ entity.portalBlock = pos.immutable();
|
|
+ // Paper end - move all of this logic into portal tick
|
|
}
|
|
|
|
}
|