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 jt) {
        this(jt.contains("Weight", 99) ? jt.getInt("Weight") : 1, jt.getCompound("Entity"));
    }
    
    public SpawnData(final int integer, final CompoundTag jt) {
        super(integer);
        this.tag = jt;
    }
    
    public CompoundTag save() {
        final CompoundTag jt2 = new CompoundTag();
        if (!this.tag.contains("id", 8)) {
            this.tag.putString("id", "minecraft:pig");
        }
        else if (!this.tag.getString("id").contains(":")) {
            this.tag.putString("id", new ResourceLocation(this.tag.getString("id")).toString());
        }
        jt2.put("Entity", this.tag);
        jt2.putInt("Weight", this.weight);
        return jt2;
    }
    
    public CompoundTag getTag() {
        return this.tag;
    }
}
