本文整理汇总了Java中net.minecraftforge.fluids.IFluidContainerItem.getFluid方法的典型用法代码示例。如果您正苦于以下问题:Java IFluidContainerItem.getFluid方法的具体用法?Java IFluidContainerItem.getFluid怎么用?Java IFluidContainerItem.getFluid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraftforge.fluids.IFluidContainerItem
的用法示例。
在下文中一共展示了IFluidContainerItem.getFluid方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getFluidContainerContents
import net.minecraftforge.fluids.IFluidContainerItem; //导入方法依赖的package包/类
private String getFluidContainerContents(ItemStack pItemInQuestion)
{
String tResult = "No fluid container";
if (pItemInQuestion.getItem() instanceof IFluidContainerItem)
{
IFluidContainerItem tFluidContainer = IFluidContainerItem.class.cast(pItemInQuestion.getItem());
FluidStack tContents = tFluidContainer.getFluid(pItemInQuestion);
if (tContents != null)
{
tResult = String.format("FluidID: [%d], UnlocName: [%s], Name: [%s]", tContents.getFluid().getID(), tContents.getFluid().getUnlocalizedName(), tContents.getFluid().getName());
}
}
return tResult;
}
示例2: extractFluid
import net.minecraftforge.fluids.IFluidContainerItem; //导入方法依赖的package包/类
public static FluidStack extractFluid(int needed, ItemStack container, Fluid fluid)
{
IFluidContainerItem item = (IFluidContainerItem)container.getItem();
if(item.getFluid(container) == null)
{
return null;
}
if(fluid != null && item.getFluid(container).getFluid() != fluid)
{
return null;
}
return item.drain(container, needed, true);
}
示例3: getFluidStackFromContainer
import net.minecraftforge.fluids.IFluidContainerItem; //导入方法依赖的package包/类
/**
* 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;
}
示例4: matches
import net.minecraftforge.fluids.IFluidContainerItem; //导入方法依赖的package包/类
@Override
public boolean matches(ItemStack subject) {
FluidStack fs = FluidContainerRegistry.getFluidForFilledItem(subject);
if (fs == null && subject.getItem() instanceof IFluidContainerItem) {
IFluidContainerItem item = (IFluidContainerItem)subject.getItem();
fs = item.getFluid(subject);
}
// match amount precisely to avoid having to deal with leftover
return fs == null && fluid == null ||
fs != null && fs.getFluid() == fluid && fs.amount >= amount;
}
示例5: getMeta
import net.minecraftforge.fluids.IFluidContainerItem; //导入方法依赖的package包/类
@Override
public Object getMeta(IFluidContainerItem target, ItemStack stack) {
FluidStack fluidStack = target.getFluid(stack);
if (fluidStack != null && fluidStack.amount > 0) {
int heatPerBucket = FuelManager.getBoilerFuelValue(fluidStack.getFluid());
if (heatPerBucket > 0) {
Map<String, Number> result = Maps.newHashMap();
result.put("total", heatPerBucket / 1000.0f * fluidStack.amount);
result.put("per_bucket", heatPerBucket);
return result;
}
}
return null;
}
示例6: isEmptyComplexContainer
import net.minecraftforge.fluids.IFluidContainerItem; //导入方法依赖的package包/类
protected boolean isEmptyComplexContainer(ItemStack item) {
if (item == null) return false;
if (item.getItem() instanceof IFluidContainerItem) {
IFluidContainerItem container = (IFluidContainerItem) item.getItem();
FluidStack containerFluid = container.getFluid(item);
return (containerFluid == null || containerFluid.amount == 0);
}
return false;
}