// 
// Decompiled by Procyon v0.6.0
// 

package com.hypixel.hytale.builtin.buildertools.snapshot;

import com.hypixel.hytale.component.RemoveReason;
import com.hypixel.hytale.component.ComponentAccessor;
import com.hypixel.hytale.server.core.universe.world.World;
import javax.annotation.Nonnull;
import com.hypixel.hytale.server.core.entity.entities.Player;
import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
import com.hypixel.hytale.component.Ref;

public class EntityAddSnapshot implements EntitySnapshot<EntityRemoveSnapshot>
{
    private final Ref<EntityStore> entityRef;
    
    public EntityAddSnapshot(final Ref<EntityStore> entityRef) {
        this.entityRef = entityRef;
    }
    
    public Ref<EntityStore> getEntityRef() {
        return this.entityRef;
    }
    
    @Override
    public EntityRemoveSnapshot restoreEntity(@Nonnull final Player player, @Nonnull final World world, @Nonnull final ComponentAccessor<EntityStore> componentAccessor) {
        if (!this.entityRef.isValid()) {
            return null;
        }
        final EntityRemoveSnapshot snapshot = new EntityRemoveSnapshot(this.entityRef);
        world.getEntityStore().getStore().removeEntity(this.entityRef, RemoveReason.UNLOAD);
        return snapshot;
    }
}
