001package net.minecraft.tileentity;
002
003import net.minecraft.nbt.NBTTagCompound;
004import net.minecraft.util.WeightedRandomItem;
005
006public class WeightedRandomMinecart extends WeightedRandomItem
007{
008    public final NBTTagCompound field_98222_b;
009    public final String minecartName;
010
011    final MobSpawnerBaseLogic field_98221_d;
012
013    public WeightedRandomMinecart(MobSpawnerBaseLogic par1MobSpawnerBaseLogic, NBTTagCompound par2NBTTagCompound)
014    {
015        super(par2NBTTagCompound.getInteger("Weight"));
016        this.field_98221_d = par1MobSpawnerBaseLogic;
017        NBTTagCompound nbttagcompound1 = par2NBTTagCompound.getCompoundTag("Properties");
018        String s = par2NBTTagCompound.getString("Type");
019
020        if (s.equals("Minecart"))
021        {
022            if (nbttagcompound1 != null)
023            {
024                switch (nbttagcompound1.getInteger("Type"))
025                {
026                    case 0:
027                        s = "MinecartRideable";
028                        break;
029                    case 1:
030                        s = "MinecartChest";
031                        break;
032                    case 2:
033                        s = "MinecartFurnace";
034                }
035            }
036            else
037            {
038                s = "MinecartRideable";
039            }
040        }
041
042        this.field_98222_b = nbttagcompound1;
043        this.minecartName = s;
044    }
045
046    public WeightedRandomMinecart(MobSpawnerBaseLogic par1MobSpawnerBaseLogic, NBTTagCompound par2NBTTagCompound, String par3Str)
047    {
048        super(1);
049        this.field_98221_d = par1MobSpawnerBaseLogic;
050
051        if (par3Str.equals("Minecart"))
052        {
053            if (par2NBTTagCompound != null)
054            {
055                switch (par2NBTTagCompound.getInteger("Type"))
056                {
057                    case 0:
058                        par3Str = "MinecartRideable";
059                        break;
060                    case 1:
061                        par3Str = "MinecartChest";
062                        break;
063                    case 2:
064                        par3Str = "MinecartFurnace";
065                }
066            }
067            else
068            {
069                par3Str = "MinecartRideable";
070            }
071        }
072
073        this.field_98222_b = par2NBTTagCompound;
074        this.minecartName = par3Str;
075    }
076
077    public NBTTagCompound func_98220_a()
078    {
079        NBTTagCompound nbttagcompound = new NBTTagCompound();
080        nbttagcompound.setCompoundTag("Properties", this.field_98222_b);
081        nbttagcompound.setString("Type", this.minecartName);
082        nbttagcompound.setInteger("Weight", this.itemWeight);
083        return nbttagcompound;
084    }
085}