本文整理汇总了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);
}
示例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);
}
}
}
示例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);
}
}
}