Fix crash when creating a tank stack with meta > 15 (#1057)

Also finally fixes the tanks so they properly drop themselves.
This commit is contained in:
Nicholas Ignoffo 2017-02-20 14:07:35 -08:00
parent 4ac87f5e8a
commit 1fb221c7f0
5 changed files with 40 additions and 35 deletions

View file

@ -5,7 +5,6 @@ import java.util.Map;
import javax.annotation.Nonnull;
import mezz.jei.api.*;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.oredict.OreDictionary;
import WayofTime.bloodmagic.api.Constants;
@ -91,7 +90,7 @@ public class BloodMagicPlugin extends BlankModPlugin
@Override
public void registerItemSubtypes(ISubtypeRegistry subtypeRegistry) {
subtypeRegistry.useNbtForSubtypes(Item.getItemFromBlock(ModBlocks.BLOOD_TANK));
}
@Override

View file

@ -44,16 +44,15 @@ public class DataProviderBloodTank implements IWailaDataProvider
{
TileBloodTank bloodTank = (TileBloodTank) accessor.getTileEntity();
NBTTagCompound tag = accessor.getNBTData();
int capacity = tag.getInteger(Constants.NBT.ALTAR_CAPACITY);
int capacity = accessor.getNBTData().getInteger(Constants.NBT.ALTAR_CAPACITY);
currenttip.add(TextHelper.localizeEffect("tooltip.BloodMagic.tier", bloodTank.getBlockMetadata() + 1));
currenttip.add(TextHelper.localizeEffect("tooltip.BloodMagic.fluid.capacity") + ": " + capacity + "mB");
currenttip.add(TextHelper.localizeEffect("tooltip.BloodMagic.fluid.capacity", capacity));
tag = tag.getCompoundTag(Constants.NBT.TANK);
FluidStack fluidStack = FluidStack.loadFluidStackFromNBT(tag);
if (!Strings.isNullOrEmpty(tag.getString("FluidName")) && fluidStack != null)
FluidStack fluidStack = FluidStack.loadFluidStackFromNBT(tag.getCompoundTag(Constants.NBT.TANK));
if (fluidStack != null)
{
currenttip.add(TextHelper.localizeEffect("tooltip.BloodMagic.fluid.type") + ": " + fluidStack.getLocalizedName());
currenttip.add(TextHelper.localizeEffect("tooltip.BloodMagic.fluid.amount") + ": " + tag.getInteger("Amount") + "/" + capacity + "mB");
currenttip.add(TextHelper.localizeEffect("tooltip.BloodMagic.fluid.type", fluidStack.getLocalizedName()));
currenttip.add(TextHelper.localizeEffect("tooltip.BloodMagic.fluid.amount", fluidStack.amount, capacity));
}
}
}