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


Java IFluidContainerItem.fill方法代码示例

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


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

示例1: insertFluid

import net.minecraftforge.fluids.IFluidContainerItem; //导入方法依赖的package包/类
public static int insertFluid(FluidStack fluid, ItemStack container)
{
	IFluidContainerItem item = (IFluidContainerItem)container.getItem();
	
	if(fluid == null)
	{
		return 0;
	}
	
	return item.fill(container, fluid, true);
}
 
开发者ID:Microsoft,项目名称:vsminecraft,代码行数:12,代码来源: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: onBlockActivated

import net.minecraftforge.fluids.IFluidContainerItem; //导入方法依赖的package包/类
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9) {
	if (!world.isRemote) {
		ItemStack equippedItemStack = player.getCurrentEquippedItem();

		if (equippedItemStack != null)
			if (equippedItemStack.getItem() instanceof IToolWrench) { // react to Buildcraft Api ToolWrench
				this.handleToolWrenchClick(world, x, y, z, player, equippedItemStack);
				return true;
			} else {
				TileEntityTank tileTank = (TileEntityTank) world.getBlockTileEntity(x, y, z);
				if (tileTank != null)
					if (equippedItemStack.getItem().itemID == Item.bucketLava.itemID) { // Lava Bucket
						FluidStack fluidstack = new FluidStack(FluidRegistry.LAVA, 1000);
						if (tileTank.fill(null, fluidstack, false) == 1000) {
							tileTank.fill(null, fluidstack, true);

							if (!player.capabilities.isCreativeMode)
								player.inventory.setInventorySlotContents(player.inventory.currentItem, new ItemStack(Item.bucketEmpty, 1));
							// FlowCraft.log("onBlcokActivated", "tankFilledEvent", world);
						}
					} else if (equippedItemStack.getItem().itemID == Item.bucketEmpty.itemID) { // Empty Bucket

						FluidStack drained = tileTank.drain(ForgeDirection.DOWN, 1000, false);

						if (drained != null && drained.amount >= 1000) {

							tileTank.drain(ForgeDirection.DOWN, 1000, true);
							player.inventory.setInventorySlotContents(player.inventory.currentItem, new ItemStack(Item.bucketLava, 1));
						}
					} else if (equippedItemStack.getItem() instanceof IFluidContainerItem) { // IFluidContainer

						NBTTagCompound tag = equippedItemStack.getTagCompound();

						if (tag != null && tag.hasKey("Fluid")) {
							tag = tag.getCompoundTag("Fluid");
							// Just drain the container as much as the tank can fit;
							((IFluidContainerItem) equippedItemStack.getItem()).drain(	equippedItemStack,
																						tileTank.fill(	ForgeDirection.UP,
																										FluidStack.loadFluidStackFromNBT(tag),
																										true),
																						true);
						} else {
							NBTTagCompound fluidTag = new NBTTagCompound();
							IFluidContainerItem item = ((IFluidContainerItem) equippedItemStack.getItem());
							if (item.getCapacity(equippedItemStack) <= tileTank.getFluidAmount())
								item.fill(equippedItemStack, tileTank.drain(ForgeDirection.DOWN, item.getCapacity(equippedItemStack), true), true);

						}
					}

				return false;
			}
		return false;
	}
	return true;
}
 
开发者ID:BraynStorm,项目名称:FlowCraft,代码行数:58,代码来源:BlockTank.java

示例4: 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.DOWN.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.isFilledContainer(from))
			return;
		
		IFluidContainerItem con = (IFluidContainerItem) frup.getItem();
		
		FluidStack in = FluidContainerRegistry.getFluidForFilledItem(from);
		int res = con.fill(frup, in, false);
		
		if(res != in.amount)
			return;
		
		ItemStack result = from.getItem().getContainerItem(from);
		
		if(post != null)
		{
			if(!post.isItemEqual(result))
				return;
			int max = post.getMaxStackSize();
			if((result.stackSize + post.stackSize) > max)
				return;
		}
		
		delay++;
		worldObj.getItemStack(pos).setItemDamage(100-delay);
		
		if(delay >= 100)
		{
			delay = 0;
							
			if(from.stackSize <= 1)
				worldObj.setItemStack(cur, null);
			else from.stackSize--;
			
			if(result == null)
				return;
			if(post == null)
				worldObj.setItemStack(next, result);
			else post.stackSize += result.stackSize;
			
			con.fill(frup, in, true);
		}
	}
}
 
开发者ID:nolimet,项目名称:SciAPI,代码行数:63,代码来源:IEFluidDrain.java


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