Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-11-15 20:40:07 +01:00
f09fed894f
--- work/Bukkit Submodule work/Bukkit 6a4242cb..337955e3: > SPIGOT-5468: Improve Beehive TileEntity API > #473: Add an API for passing the heightmap to getHighestBlockAt* method --- work/CraftBukkit Submodule work/CraftBukkit 807a677e..708be695: > SPIGOT-5468: Improve Beehive TileEntity API > #624: Add an API for passing the heightmap to getHighestBlockAt* method > MC-135989, SPIGOT-5564: Don't kick players for flight while riptiding This deprecates the Paper getHighestBlockAt HeightMap APIs now that Bukkit has added their own. These methods will stick around long enough for people to migrate. Their API is pretty much the same as ours, migration should be quick and easy.
133 Zeilen
6.7 KiB
Diff
133 Zeilen
6.7 KiB
Diff
From e8d0b2c90a6e8abd3404c38ca5b18e28e531c73e Mon Sep 17 00:00:00 2001
|
|
From: Aikar <aikar@aikar.co>
|
|
Date: Sat, 28 Jul 2018 12:18:27 -0400
|
|
Subject: [PATCH] Ignore Dead Entities in entityList iteration
|
|
|
|
A spigot change delays removal of entities from the entity list.
|
|
This causes a change in behavior from Vanilla where getEntities type
|
|
methods will return dead entities that they shouldn't otherwise be doing.
|
|
|
|
This will ensure that dead entities are skipped from iteration since
|
|
they shouldn't of been in the list in the first place.
|
|
|
|
diff --git a/src/main/java/com/destroystokyo/paper/PaperCommand.java b/src/main/java/com/destroystokyo/paper/PaperCommand.java
|
|
index eecf27370..d704fc79c 100644
|
|
--- a/src/main/java/com/destroystokyo/paper/PaperCommand.java
|
|
+++ b/src/main/java/com/destroystokyo/paper/PaperCommand.java
|
|
@@ -179,6 +179,7 @@ public class PaperCommand extends Command {
|
|
return;
|
|
}
|
|
MinecraftKey key = e.getMinecraftKey();
|
|
+ if (e.shouldBeRemoved) return; // Paper
|
|
|
|
MutablePair<Integer, Map<ChunkCoordIntPair, Integer>> info = list.computeIfAbsent(key, k -> MutablePair.of(0, Maps.newHashMap()));
|
|
ChunkCoordIntPair chunk = new ChunkCoordIntPair(e.getChunkX(), e.getChunkZ());
|
|
diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java
|
|
index 1d47e4737..c464d6962 100644
|
|
--- a/src/main/java/net/minecraft/server/Chunk.java
|
|
+++ b/src/main/java/net/minecraft/server/Chunk.java
|
|
@@ -681,6 +681,7 @@ public class Chunk implements IChunkAccess {
|
|
|
|
while (iterator.hasNext()) {
|
|
Entity entity1 = (Entity) iterator.next();
|
|
+ if (entity1.shouldBeRemoved) continue; // Paper
|
|
|
|
if (entity1.getBoundingBox().c(axisalignedbb) && entity1 != entity) {
|
|
if (predicate == null || predicate.test(entity1)) {
|
|
@@ -718,6 +719,7 @@ public class Chunk implements IChunkAccess {
|
|
|
|
while (iterator.hasNext()) {
|
|
T entity = (T) iterator.next(); // CraftBukkit - decompile error
|
|
+ if (entity.shouldBeRemoved) continue; // Paper
|
|
|
|
if ((entitytypes == null || entity.getEntityType() == entitytypes) && entity.getBoundingBox().c(axisalignedbb) && predicate.test(entity)) {
|
|
list.add(entity);
|
|
@@ -739,6 +741,7 @@ public class Chunk implements IChunkAccess {
|
|
|
|
while (iterator.hasNext()) {
|
|
T t0 = (T) iterator.next(); // CraftBukkit - decompile error
|
|
+ if (t0.shouldBeRemoved) continue; // Paper
|
|
|
|
if (oclass.isInstance(t0) && t0.getBoundingBox().c(axisalignedbb) && (predicate == null || predicate.test(t0))) { // Spigot - instance check
|
|
list.add(t0);
|
|
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
|
|
index 09ec144eb..4880ece94 100644
|
|
--- a/src/main/java/net/minecraft/server/Entity.java
|
|
+++ b/src/main/java/net/minecraft/server/Entity.java
|
|
@@ -196,6 +196,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
|
|
protected int numCollisions = 0; // Paper
|
|
public void inactiveTick() { }
|
|
// Spigot end
|
|
+ public boolean shouldBeRemoved; // Paper
|
|
|
|
public float getBukkitYaw() {
|
|
return this.yaw;
|
|
diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java
|
|
index 70e4b58a9..54505e056 100644
|
|
--- a/src/main/java/net/minecraft/server/WorldServer.java
|
|
+++ b/src/main/java/net/minecraft/server/WorldServer.java
|
|
@@ -904,7 +904,7 @@ public class WorldServer extends World {
|
|
|
|
while (objectiterator.hasNext()) {
|
|
Entity entity = (Entity) objectiterator.next();
|
|
-
|
|
+ if (entity.shouldBeRemoved) continue; // Paper
|
|
if (entity instanceof EntityInsentient) {
|
|
EntityInsentient entityinsentient = (EntityInsentient) entity;
|
|
|
|
@@ -1225,6 +1225,7 @@ public class WorldServer extends World {
|
|
entity.origin = entity.getBukkitEntity().getLocation();
|
|
}
|
|
// Paper end
|
|
+ entity.shouldBeRemoved = false; // Paper - shouldn't be removed after being re-added
|
|
new com.destroystokyo.paper.event.entity.EntityAddToWorldEvent(entity.getBukkitEntity()).callEvent(); // Paper - fire while valid
|
|
}
|
|
|
|
@@ -1237,6 +1238,7 @@ public class WorldServer extends World {
|
|
this.removeEntityFromChunk(entity);
|
|
this.entitiesById.remove(entity.getId());
|
|
this.unregisterEntity(entity);
|
|
+ entity.shouldBeRemoved = true; // Paper
|
|
}
|
|
}
|
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
|
index f957d4272..a6a273c31 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
|
@@ -1021,6 +1021,7 @@ public class CraftWorld implements World {
|
|
for (Object o : world.entitiesById.values()) {
|
|
if (o instanceof net.minecraft.server.Entity) {
|
|
net.minecraft.server.Entity mcEnt = (net.minecraft.server.Entity) o;
|
|
+ if (mcEnt.shouldBeRemoved) continue; // Paper
|
|
Entity bukkitEntity = mcEnt.getBukkitEntity();
|
|
|
|
// Assuming that bukkitEntity isn't null
|
|
@@ -1040,6 +1041,7 @@ public class CraftWorld implements World {
|
|
for (Object o : world.entitiesById.values()) {
|
|
if (o instanceof net.minecraft.server.Entity) {
|
|
net.minecraft.server.Entity mcEnt = (net.minecraft.server.Entity) o;
|
|
+ if (mcEnt.shouldBeRemoved) continue; // Paper
|
|
Entity bukkitEntity = mcEnt.getBukkitEntity();
|
|
|
|
// Assuming that bukkitEntity isn't null
|
|
@@ -1066,6 +1068,7 @@ public class CraftWorld implements World {
|
|
|
|
for (Object entity: world.entitiesById.values()) {
|
|
if (entity instanceof net.minecraft.server.Entity) {
|
|
+ if (((net.minecraft.server.Entity) entity).shouldBeRemoved) continue; // Paper
|
|
Entity bukkitEntity = ((net.minecraft.server.Entity) entity).getBukkitEntity();
|
|
|
|
if (bukkitEntity == null) {
|
|
@@ -1089,6 +1092,7 @@ public class CraftWorld implements World {
|
|
|
|
for (Object entity: world.entitiesById.values()) {
|
|
if (entity instanceof net.minecraft.server.Entity) {
|
|
+ if (((net.minecraft.server.Entity) entity).shouldBeRemoved) continue; // Paper
|
|
Entity bukkitEntity = ((net.minecraft.server.Entity) entity).getBukkitEntity();
|
|
|
|
if (bukkitEntity == null) {
|
|
--
|
|
2.25.0
|
|
|