mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-28 19:22:50 +01:00
0b3afe6c97
Upstream has released updates that appears 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: 4db9e3dc Add API to locate structures CraftBukkit Changes:65bb2d0f
Increase expiration time to 10 days88a5346f
Add API to locate structures. Spigot Changes: 68acb93f Rebuild patches
111 lines
5.8 KiB
Diff
111 lines
5.8 KiB
Diff
From ec44d5b28d7c2c7810a846ef99da871b9ce244af 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 56700fc59..9b9c8361e 100644
|
|
--- a/src/main/java/com/destroystokyo/paper/PaperCommand.java
|
|
+++ b/src/main/java/com/destroystokyo/paper/PaperCommand.java
|
|
@@ -172,6 +172,7 @@ public class PaperCommand extends Command {
|
|
List<Entity> entities = world.entityList;
|
|
entities.forEach(e -> {
|
|
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/Entity.java b/src/main/java/net/minecraft/server/Entity.java
|
|
index 8951ac809..127a7c9b7 100644
|
|
--- a/src/main/java/net/minecraft/server/Entity.java
|
|
+++ b/src/main/java/net/minecraft/server/Entity.java
|
|
@@ -123,6 +123,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
|
|
protected boolean F;
|
|
private boolean az;
|
|
public boolean dead;
|
|
+ public boolean shouldBeRemoved; // Paper
|
|
public float width;
|
|
public float length;
|
|
public float J;
|
|
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
|
|
index 597169b4c..b18ea7154 100644
|
|
--- a/src/main/java/net/minecraft/server/World.java
|
|
+++ b/src/main/java/net/minecraft/server/World.java
|
|
@@ -1111,6 +1111,7 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
|
|
}
|
|
|
|
entity.valid = true; // CraftBukkit
|
|
+ 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
|
|
}
|
|
|
|
@@ -1179,6 +1180,7 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
|
|
if (entity.inChunk && this.isChunkLoaded(i, j, true)) {
|
|
this.getChunkAt(i, j).b(entity);
|
|
}
|
|
+ entity.shouldBeRemoved = true; // Paper
|
|
|
|
if (!guardEntityList) { // Spigot - It will get removed after the tick if we are ticking // Paper - always remove from current chunk above
|
|
// CraftBukkit start - Decrement loop variable field if we've already ticked this entity
|
|
@@ -2389,6 +2391,7 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
|
|
|
|
while (iterator.hasNext()) {
|
|
Entity entity = (Entity) iterator.next();
|
|
+ if (entity.shouldBeRemoved) continue; // Paper
|
|
|
|
if (oclass.isAssignableFrom(entity.getClass()) && predicate.test((T) entity)) {
|
|
arraylist.add(entity);
|
|
@@ -2475,6 +2478,7 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
|
|
|
|
while (iterator.hasNext()) {
|
|
Entity entity = (Entity) iterator.next();
|
|
+ if (entity.shouldBeRemoved) continue; // Paper
|
|
// CraftBukkit start - Split out persistent check, don't apply it to special persistent mobs
|
|
if (entity instanceof EntityInsentient) {
|
|
EntityInsentient entityinsentient = (EntityInsentient) entity;
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
|
index 0c83a070f..30ca72297 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
|
@@ -645,6 +645,7 @@ public class CraftWorld implements World {
|
|
for (Object o : world.entityList) {
|
|
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
|
|
@@ -663,6 +664,7 @@ public class CraftWorld implements World {
|
|
for (Object o : world.entityList) {
|
|
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
|
|
@@ -687,6 +689,7 @@ public class CraftWorld implements World {
|
|
|
|
for (Object entity: world.entityList) {
|
|
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) {
|
|
@@ -709,6 +712,7 @@ public class CraftWorld implements World {
|
|
|
|
for (Object entity: world.entityList) {
|
|
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.19.0
|
|
|