diff --git a/common/src/main/java/com/viaversion/viaversion/rewriter/EntityRewriter.java b/common/src/main/java/com/viaversion/viaversion/rewriter/EntityRewriter.java index eb18e8f80..74a3a4f73 100644 --- a/common/src/main/java/com/viaversion/viaversion/rewriter/EntityRewriter.java +++ b/common/src/main/java/com/viaversion/viaversion/rewriter/EntityRewriter.java @@ -110,7 +110,11 @@ public abstract class EntityRewriter dataList, final UserConnection connection) { final TrackedEntity entity = tracker(connection).entity(entityId); final EntityType type = entity != null ? entity.entityType() : null; - for (final EntityData entityData : dataList.toArray(EMPTY_ARRAY)) { // Copy the list to allow mutation + + // Iterate over indexed list to allow for removal and addition of elements, decrease current index and size if an element is removed + int size = dataList.size(); + for (int i = 0; i < size; i++) { + final EntityData entityData = dataList.get(i); EntityDataHandlerEvent event = null; for (final EntityDataFilter filter : entityDataFilters) { if (!filter.isFiltered(type, entityData)) { @@ -125,13 +129,15 @@ public abstract class EntityRewriter