package net.minecraft.world.level;

import net.minecraft.nbt.Tag;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.util.WeighedRandom;

public class SpawnData extends WeighedRandom.WeighedRandomItem {
    private final CompoundTag tag;
    
    public SpawnData() {
        super(1);
        (this.tag = new CompoundTag()).putString("id", "minecraft:pig");
    }
    
    public SpawnData(final CompoundTag le) {
        this(le.contains("Weight", 99) ? le.getInt("Weight") : 1, le.getCompound("Entity"));
    }
    
    public SpawnData(final int integer, final CompoundTag le) {
        super(integer);
        this.tag = le;
        final ResourceLocation uh4 = ResourceLocation.tryParse(le.getString("id"));
        if (uh4 != null) {
            le.putString("id", uh4.toString());
        }
        else {
            le.putString("id", "minecraft:pig");
        }
    }
    
    public CompoundTag save() {
        final CompoundTag le2 = new CompoundTag();
        le2.put("Entity", this.tag);
        le2.putInt("Weight", this.weight);
        return le2;
    }
    
    public CompoundTag getTag() {
        return this.tag;
    }
}
