当前位置: 首页>>代码示例>>Java>>正文


Java IFluidContainerItem.drain方法代码示例

本文整理汇总了Java中net.minecraftforge.fluids.IFluidContainerItem.drain方法的典型用法代码示例。如果您正苦于以下问题:Java IFluidContainerItem.drain方法的具体用法?Java IFluidContainerItem.drain怎么用?Java IFluidContainerItem.drain使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.minecraftforge.fluids.IFluidContainerItem的用法示例。


在下文中一共展示了IFluidContainerItem.drain方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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);
}
 
开发者ID:Microsoft,项目名称:vsminecraft,代码行数:17,代码来源:FluidContainerUtils.java

示例2: updateEntity

import net.minecraftforge.fluids.IFluidContainerItem; //导入方法依赖的package包/类
@Override
public void updateEntity()
{
	if(!worldObj.isRemote && worldObj.getItemStack(pos) != null)
	{
		EVecInt dvec = McInvDirection.LEFT.toDifference();
		McInvPos cur = pos.getDiffPos(dvec);
		dvec = McInvDirection.RIGHT.toDifference();
		McInvPos next = pos.getDiffPos(dvec);
		
		ItemStack from = worldObj.getItemStack(cur);
		ItemStack to = worldObj.getItemStack(next);
		
		if(from == null || !(from.getItem() instanceof IFluidContainerItem))
			return;
		
		if(to == null || !(to.getItem() instanceof IFluidContainerItem))
			return;
		
		IFluidContainerItem fri = (IFluidContainerItem) from.getItem();
		IFluidContainerItem toi = (IFluidContainerItem) to.getItem();
		
		FluidStack drain = fri.drain(from, 10, false);
		if(drain == null || drain.amount == 0)
			return;
		if(toi.fill(to, drain, false) != 0)
		{
			int dr = toi.fill(to, drain, true);
			fri.drain(from, dr, true);
		}
	}
}
 
开发者ID:nolimet,项目名称:SciAPI,代码行数:33,代码来源:IEFluidMover.java

示例3: updateEntity

import net.minecraftforge.fluids.IFluidContainerItem; //导入方法依赖的package包/类
@Override
public void updateEntity()
{
	if(!worldObj.isRemote && worldObj.getItemStack(pos) != null)
	{
		EVecInt dvec = McInvDirection.LEFT.toDifference();
		McInvPos cur = pos.getDiffPos(dvec);
		dvec = McInvDirection.RIGHT.toDifference();
		McInvPos next = pos.getDiffPos(dvec);
		dvec = McInvDirection.UP.toDifference();
		McInvPos fr = pos.getDiffPos(dvec);
		
		ItemStack frup = worldObj.getItemStack(fr);
		ItemStack from = worldObj.getItemStack(cur);
		ItemStack post = worldObj.getItemStack(next);
		
		if(frup == null || !(frup.getItem() instanceof IFluidContainerItem))
			return;
		
		if(from == null || !FluidContainerRegistry.isEmptyContainer(from))
			return;
		
		IFluidContainerItem con = (IFluidContainerItem) frup.getItem();
		ItemStack copy = from.copy();
		ItemStack res = FluidContainerRegistry.fillFluidContainer(con.drain(frup, Integer.MAX_VALUE, false), copy);
		
		if(res == null)
			return;
		
		if(post != null)
		{
			if(!post.isItemEqual(res))
				return;
			int max = post.getMaxStackSize();
			if((res.stackSize + post.stackSize) > max)
				return;
		}
		
		delay++;
		worldObj.getItemStack(pos).setItemDamage(100-delay);
		
		if(delay >= 100)
		{
			delay = 0;
			
			FluidStack filled = FluidContainerRegistry.getFluidForFilledItem(res);
			
			if(from.stackSize <= 1)
				worldObj.setItemStack(cur, null);
			else from.stackSize--;
			
			if(post == null)
				worldObj.setItemStack(next, res);
			else post.stackSize += res.stackSize;
			
			con.drain(frup, filled.amount, true);
		}
	}
}
 
开发者ID:nolimet,项目名称:SciAPI,代码行数:60,代码来源:IEFluidFiller.java


注:本文中的net.minecraftforge.fluids.IFluidContainerItem.drain方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。