Add support for loading legacy liquid stacks as new fluid stacks.
Requires having been written with the "liquidname" code from forge 1.5.x
This commit is contained in:
parent
8b78f21199
commit
31bd8d438d
1 changed files with 25 additions and 10 deletions
|
@ -1,6 +1,8 @@
|
|||
|
||||
package net.minecraftforge.fluids;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
|
@ -53,16 +55,29 @@ public class FluidStack
|
|||
*/
|
||||
public static FluidStack loadFluidStackFromNBT(NBTTagCompound nbt)
|
||||
{
|
||||
if (nbt == null || FluidRegistry.getFluid(nbt.getString("FluidName")) == null)
|
||||
if (nbt == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
FluidStack stack = new FluidStack(FluidRegistry.getFluidID(nbt.getString("FluidName")), nbt.getInteger("Amount"));
|
||||
String fluidName = nbt.getString("FluidName");
|
||||
if (fluidName == null)
|
||||
{
|
||||
fluidName = nbt.hasKey("LiquidName") ? nbt.getString("LiquidName").toLowerCase(Locale.ENGLISH) : null;
|
||||
}
|
||||
if (fluidName ==null || FluidRegistry.getFluid(fluidName) == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
FluidStack stack = new FluidStack(FluidRegistry.getFluidID(fluidName), nbt.getInteger("Amount"));
|
||||
|
||||
if (nbt.hasKey("Tag"))
|
||||
{
|
||||
stack.tag = nbt.getCompoundTag("Tag");
|
||||
}
|
||||
else if (nbt.hasKey("extra"))
|
||||
{
|
||||
stack.tag = nbt.getCompoundTag("extra");
|
||||
}
|
||||
return stack;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue