Fluidhelper; Moved from GTNH CoreMod (Why was it there anyway?)

This commit is contained in:
Namikon committed 2017-01-12 09:36:35 +01:00
1 parent 65b8162713
commit cdcc3da32a
2 files changed
+57 -1

No files matched your search

+1 -1
View File
@@ -25,7 +25,7 @@ allprojects {
targetCompatibility = 1.7
}
version = "1.7.10-0.5.69"
version = "1.7.10-0.5.70"
group= "eu.usrv" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "YAMCore"
@@ -0,0 +1,56 @@
package eu.usrv.yamcore.auxiliary;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.IFluidContainerItem;
public class FluidHelper
{
/**
* Try to find the fluid that is in the fluidcontainer. Returns null if none
* could be found
*
* @param pItemStack
* @return
*/
public static Fluid getFluidFromContainer( ItemStack pItemStack )
{
Fluid tRet = null;
if( pItemStack != null )
{
FluidStack fs = getFluidStackFromContainer( pItemStack );
if( fs != null )
tRet = fs.getFluid();
}
return tRet;
}
/**
* Get the fluidStack of given itemStack, if there is any.
* returns null if itemstack is null or not a fluid container
*
* @param pItemStack
* @return
*/
public static FluidStack getFluidStackFromContainer( ItemStack pItemStack )
{
FluidStack tReturnVal = null;
if( (Object) pItemStack.getItem() instanceof IFluidContainerItem )
{
IFluidContainerItem tFluidContainer = IFluidContainerItem.class.cast( pItemStack.getItem() );
FluidStack tContents = tFluidContainer.getFluid( pItemStack );
if( tContents != null )
{
tReturnVal = tContents;
}
}
return tReturnVal;
}
}