use of org.spongepowered.common.accessor.server.level.ServerLevelAccessor in project SpongeCommon by SpongePowered.
the class SpawnEntityTransaction method restore.
@Override
public void restore(final PhaseContext<@NonNull ?> context, final SpawnEntityEvent event) {
final ServerLevel serverWorld = this.worldSupplier.get();
if (((ServerLevelAccessor) serverWorld).accessor$tickingEntities()) {
// More than likely we could also be needing to remove the entity from both the entities to add
// and the chunk.
((ServerLevelAccessor) serverWorld).accessor$toAddAfterTick().remove(this.entityToSpawn);
((ServerLevelAccessor) serverWorld).invoker$removeFromChunk(this.entityToSpawn);
} else {
serverWorld.despawn(this.entityToSpawn);
}
}
Aggregations