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


Java FluidContainerRegistry.drainFluidContainer方法代码示例

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


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

示例1: placeBlock

import net.minecraftforge.fluids.FluidContainerRegistry; //导入方法依赖的package包/类
@Override
public void placeBlock(World world, int x, int y, int z, ForgeDirection direction, EntityPlayer player,
                       ItemStack placing, IToggleController controller) // TODO: Add storage item index as parameter?
{
    if (FluidContainerRegistry.isFilledContainer(placing))
    {
        FluidStack fluidStack = FluidContainerRegistry.getFluidForFilledItem(placing);
        Fluid fluid = fluidStack.getFluid();
        if (fluidStack.getFluid().canBePlacedInWorld())
        {
            Block fluidBlock = fluid.getBlock();
            world.setBlock(x, y, z, fluidBlock);
            world.notifyBlockChange(x, y, z, fluidBlock);
            fluidBlock.onBlockAdded(world, x, y, z);
            ItemStack drainedContainer = FluidContainerRegistry.drainFluidContainer(placing);
            placing.stackSize--;
            controller.getStorageHandler().addItemStackToStorage(drainedContainer);
        }
    } else if (placing.getItem() instanceof ItemBucket)
    {
        ItemBucket item = (ItemBucket) placing.getItem();
        item.tryPlaceContainedLiquid(world, x, y, z);
    }
}
 
开发者ID:MrSpring,项目名称:ToggleBlocks,代码行数:25,代码来源:BucketToggleAction.java

示例2: addLiquid

import net.minecraftforge.fluids.FluidContainerRegistry; //导入方法依赖的package包/类
public ItemStack addLiquid(ItemStack is)
{
	if(is == null || is.stackSize > 1)
		return is;
	
	if(FluidContainerRegistry.isFilledContainer(is))
	{
		FluidStack fs = FluidContainerRegistry.getFluidForFilledItem(is);
		if(addLiquid(fs))
		{
			worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
			return FluidContainerRegistry.drainFluidContainer(is);
		}
	}
	else if(is.getItem() instanceof IFluidContainerItem)
	{
		FluidStack isfs = ((IFluidContainerItem) is.getItem()).getFluid(is);
		if(isfs != null && addLiquid(isfs))
		{
			((IFluidContainerItem) is.getItem()).drain(is, is.getMaxDamage(), true);
			worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
		}
	}
	return is;
}
 
开发者ID:StrayWolfe,项目名称:Cooking-with-TFC,代码行数:26,代码来源:TileCookingPot.java

示例3: useBucket

import net.minecraftforge.fluids.FluidContainerRegistry; //导入方法依赖的package包/类
private boolean useBucket( int slot, ItemStack stack) {
	if(slot == 0 && FluidContainerRegistry.isFilledContainer(stack) && FuelRegistry.instance.isFuel(FuelType.LIQUID,FluidContainerRegistry.getFluidForFilledItem(stack).getFluid()) && tank.getFluidAmount() + FluidContainerRegistry.getContainerCapacity(stack) <= tank.getCapacity()) {
		ItemStack emptyContainer = FluidContainerRegistry.drainFluidContainer(stack);

		if(emptyContainer != null && inventory.getStackInSlot(1) == null || (emptyContainer.isItemEqual(inventory.getStackInSlot(1)) && inventory.getStackInSlot(1).stackSize < inventory.getStackInSlot(1).getMaxStackSize())) {
			tank.fill(FluidContainerRegistry.getFluidForFilledItem(stack), true);

			if(inventory.getStackInSlot(1) == null)
				super.setInventorySlotContents(1, emptyContainer);
			else
				inventory.getStackInSlot(1).stackSize++;
			decrStackSize(0, 1);
		}
		else
			return false;
	}
	else
		return false;
	
	return true;
}
 
开发者ID:zmaster587,项目名称:AdvancedRocketry,代码行数:22,代码来源:TileEntityFuelingStation.java

示例4: drain

import net.minecraftforge.fluids.FluidContainerRegistry; //导入方法依赖的package包/类
@Nullable
@Override
public FluidStack drain(int maxDrain, boolean doDrain)
{
    if (container.stackSize != 1)
    {
        return null;
    }

    FluidStack contained = FluidContainerRegistry.getFluidForFilledItem(container);
    if (contained != null)
    {
        if (contained.amount <= maxDrain)
        {
            ItemStack emptyContainer = FluidContainerRegistry.drainFluidContainer(container);
            if (emptyContainer != null)
            {
                if (doDrain)
                {
                    if (FluidContainerRegistry.hasNullEmptyContainer(container))
                    {
                        emptyContainer.stackSize = 0;
                    }
                    container.deserializeNBT(emptyContainer.serializeNBT());
                }
                return contained;
            }
        }
    }

    return null;
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:33,代码来源:FluidContainerRegistryWrapper.java

示例5: bucktDrain

import net.minecraftforge.fluids.FluidContainerRegistry; //导入方法依赖的package包/类
public static void bucktDrain(EntityPlayer playerIn, ItemStack item, World worldIn){
    if (!playerIn.capabilities.isCreativeMode){
        ItemStack newBucket = FluidContainerRegistry.drainFluidContainer(item);
        if (item.stackSize == 1) {
            playerIn.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, (ItemStack)newBucket);
        } else {
            item.stackSize--;
            SpawnEntityHelper.spawnItemStack(worldIn,playerIn.getPosition(),newBucket);
        }
    }
}
 
开发者ID:Dark32,项目名称:NordMod,代码行数:12,代码来源:FluidHelper.java

示例6: drainFluidContainer

import net.minecraftforge.fluids.FluidContainerRegistry; //导入方法依赖的package包/类
public static ItemStack drainFluidContainer(ItemStack stackInSlot) {
    if (stackInSlot.getItem() instanceof IFluidContainerItem) {
        ItemStack working = stackInSlot.copy();
        ((IFluidContainerItem) stackInSlot.getItem()).drain(working, ((IFluidContainerItem) stackInSlot.getItem()).getCapacity(stackInSlot), true);
        return working;
    }
    else {
        return FluidContainerRegistry.drainFluidContainer(stackInSlot);
    }
}
 
开发者ID:TeamDmfMM,项目名称:Extra-Food,代码行数:11,代码来源:FluidContainerRegistryHelper.java

示例7: onBlockActivated

import net.minecraftforge.fluids.FluidContainerRegistry; //导入方法依赖的package包/类
@Override
public boolean onBlockActivated(World world, BlockPos blockPos, IBlockState blockState, EntityPlayer player, EnumHand hand,
		ItemStack stack, EnumFacing side, float hitX, float hitY, float hitZ) {
	if (world.isRemote) return true;

	else {
		TileEntityLavaGenerator te = (TileEntityLavaGenerator) world.getTileEntity(blockPos);

		if (te != null && player != null) {

			// empty item fluid into fluid tank

			FluidStack containerFluid = getFluidForItem(stack);
			if (containerFluid == null || containerFluid.getFluid() == null || containerFluid.getFluid() != FluidRegistry.LAVA) {
				return openGui(world, player, stack, blockPos.getX(), blockPos.getY(), blockPos.getZ());
			}

			if (te.fill(null, containerFluid, true) > 0 && !player.capabilities.isCreativeMode) {
				ItemStack emptyContainer = FluidContainerRegistry.drainFluidContainer(stack);

				if (stack.stackSize-- <= 0) player.inventory.setInventorySlotContents(player.inventory.currentItem, null);

				if (player instanceof FakePlayer || !player.inventory.addItemStackToInventory(emptyContainer))
					world.spawnEntityInWorld(new EntityItem(world, player.posX + 0.5D, player.posY + 1.5D, player.posZ + 0.5D, emptyContainer));
				else if (player instanceof EntityPlayerMP) ((EntityPlayerMP) player).sendContainerToPlayer(player.inventoryContainer);
			}

			// ProjectZed.logHelper.info("Stored: " + ((TileEntityIndustrialCentrifuge) te).getTank().getFluidAmount());
		}
	}

	return true;
}
 
开发者ID:hockeyhurd,项目名称:Project-Zed,代码行数:34,代码来源:BlockLavaGenerator.java

示例8: onBlockActivated

import net.minecraftforge.fluids.FluidContainerRegistry; //导入方法依赖的package包/类
@Override
public boolean onBlockActivated(World world, BlockPos blockPos, IBlockState blockState, EntityPlayer player, EnumHand hand, ItemStack stack,
		EnumFacing side, float hitX, float hitY, float hitZ) {
	// TODO: read through and clean-up this code!

	if (world.isRemote) return true;

	else {
		TileEntityIndustrialCentrifuge te = (TileEntityIndustrialCentrifuge) world.getTileEntity(blockPos);

		if (te != null && player != null) {

			// empty item fluid into fluid tank

			FluidStack containerFluid = getFluidForItem(stack);
			if (containerFluid == null || containerFluid.getFluid() == null || containerFluid.getFluid() != FluidRegistry.WATER) {
				return openGui(world, player, stack, blockPos.getX(), blockPos.getY(), blockPos.getZ());
			}

			if (te.fill(null, containerFluid, true) > 0 && !player.capabilities.isCreativeMode) {
				ItemStack emptyContainer = FluidContainerRegistry.drainFluidContainer(stack);

				if (stack.stackSize-- <= 0) player.inventory.setInventorySlotContents(player.inventory.currentItem, null);

				if (player instanceof FakePlayer || !player.inventory.addItemStackToInventory(emptyContainer))
					world.spawnEntityInWorld(new EntityItem(world, player.posX + 0.5D, player.posY + 1.5D, player.posZ + 0.5D, emptyContainer));
				else if (player instanceof EntityPlayerMP) ((EntityPlayerMP) player).sendContainerToPlayer(player.inventoryContainer);
			}

			// ProjectZed.logHelper.info("Stored: " + ((TileEntityIndustrialCentrifuge) te).getTank().getFluidAmount());

		}
	}

	return true;
}
 
开发者ID:hockeyhurd,项目名称:Project-Zed,代码行数:37,代码来源:BlockIndustrialCentrifuge.java

示例9: addFinalValues

import net.minecraftforge.fluids.FluidContainerRegistry; //导入方法依赖的package包/类
private static void addFinalValues() {
    // Fluid handling
    for (Item item : GameData.getItemRegistry().typeSafeIterable()) {
        LinkedList<ItemStack> subItems = Lists.newLinkedList();

        try {
            item.getSubItems(item, item.getCreativeTab(), subItems);
        } catch (Exception ignore) {}

        for (ItemStack itemStack : subItems) {
            if (FluidContainerRegistry.isContainer(itemStack)) {
                FluidStack fluidStack = FluidContainerRegistry.getFluidForFilledItem(itemStack);
                ItemStack empty = FluidContainerRegistry.drainFluidContainer(itemStack);

                if (fluidStack != null && empty != null) {
                    setEMC(itemStack, getEMC(empty) + getEMC(fluidStack.getFluid()));
                }
            }
        }
    }

    // Stone brick handling
    double stoneBrickEmc = getEMC(Blocks.stonebrick);
    for (int i = 1; i < BlockStoneBrick.field_150141_b.length; i++) {
        setEMC(new ItemStack(Blocks.stonebrick, 1, i), stoneBrickEmc);
    }

    // Anvil handling
    double anvilEmc = getEMC(new ItemStack(Blocks.anvil, 1, 0));
    setEMC(new ItemStack(Blocks.anvil, 1, 1), anvilEmc * 0.66D);
    setEMC(new ItemStack(Blocks.anvil, 1, 2), anvilEmc * 0.33D);

    // Name tag
    double string = getEMC(Items.string);
    double paper = getEMC(Items.paper);
    setEMC(Items.name_tag, string + paper);

    if (Loader.isModLoaded("Thaumcraft")) {
        setEMC(GameRegistry.findItem("Thaumcraft", "ItemThaumonomicon"), getEMC(Blocks.bookshelf));
    }
}
 
开发者ID:AgileMods,项目名称:MateriaMuto,代码行数:42,代码来源:EMCRegistry.java


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