diff --git a/src/main/java/net/minecraft/world/World.java b/src/main/java/net/minecraft/world/World.java index b7a0639..ec4881f 100644 --- a/src/main/java/net/minecraft/world/World.java +++ b/src/main/java/net/minecraft/world/World.java @@ -28,6 +28,7 @@ import org.ultramine.server.event.ServerWorldEventProxy; import org.ultramine.server.event.WorldEventProxy; import org.ultramine.server.event.WorldUpdateObjectType; +import org.ultramine.server.internal.LambdaHolder; import org.ultramine.server.util.VanillaChunkCoordIntPairSet; import net.minecraft.block.Block; @@ -1913,9 +1914,10 @@ if (entity.isDead) { - this.weatherEffects.remove(i--); +// this.weatherEffects.remove(i--); } } + weatherEffects.removeIf(LambdaHolder.ENTITY_REMOVAL_PREDICATE); eventProxy.popState(); this.theProfiler.endStartSection("remove"); @@ -2005,12 +2007,13 @@ this.getChunkFromChunkCoords(j, l).removeEntity(entity); } - this.loadedEntityList.remove(i--); +// this.loadedEntityList.remove(i--); this.onEntityRemoved(entity); } this.theProfiler.endSection(); } + loadedEntityList.removeIf(LambdaHolder.ENTITY_REMOVAL_PREDICATE); eventProxy.popState(); this.theProfiler.endStartSection("blockEntities"); @@ -2057,7 +2060,7 @@ if (tileentity.isInvalid()) { - iterator.remove(); +// iterator.remove(); if (this.chunkExists(tileentity.xCoord >> 4, tileentity.zCoord >> 4)) { @@ -2070,6 +2073,7 @@ } } } + loadedTileEntityList.removeIf(LambdaHolder.TILE_ENTITY_REMOVAL_PREDICATE); eventProxy.popState(); theProfiler.startSection("unload"); diff --git a/src/main/java/org/ultramine/server/internal/LambdaHolder.java b/src/main/java/org/ultramine/server/internal/LambdaHolder.java new file mode 100644 index 0000000..22c6cad --- /dev/null +++ b/src/main/java/org/ultramine/server/internal/LambdaHolder.java @@ -0,0 +1,12 @@ +package org.ultramine.server.internal; + +import net.minecraft.entity.Entity; +import net.minecraft.tileentity.TileEntity; + +import java.util.function.Predicate; + +public class LambdaHolder +{ + public static final Predicate ENTITY_REMOVAL_PREDICATE = o -> ((Entity)o).isDead; + public static final Predicate TILE_ENTITY_REMOVAL_PREDICATE = o -> ((TileEntity)o).isInvalid(); +}