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


Java FluidContainerRegistry.fillFluidContainer方法代码示例

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


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

示例1: fillCustomBucket

import net.minecraftforge.fluids.FluidContainerRegistry; //导入方法依赖的package包/类
private ItemStack fillCustomBucket(World world, MovingObjectPosition pos, ItemStack container) {
	Block block = world.getBlock(pos.blockX, pos.blockY, pos.blockZ);
	Fluid fluid = FluidRegistry.lookupFluidForBlock(block);
	if (fluid != null) {
		boolean isSource = world.getBlockMetadata(pos.blockX, pos.blockY, pos.blockZ) == 0;
		if (!isSource) {
			return null;
		}
		FluidStack fluidStack = new FluidStack(fluid, FluidContainerRegistry.BUCKET_VOLUME);
		ItemStack bucket = FluidContainerRegistry.fillFluidContainer(fluidStack, container);
		if (bucket != null) {
			world.setBlockToAir(pos.blockX, pos.blockY, pos.blockZ);
			return bucket;
		}
	}
	return null;
}
 
开发者ID:lawremi,项目名称:PerFabricaAdAstra,代码行数:18,代码来源:BucketHandler.java

示例2: fill

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

    FluidStack originalContained = FluidContainerRegistry.getFluidForFilledItem(container);

    ItemStack result = FluidContainerRegistry.fillFluidContainer(resource, container);
    if (result == null)
    {
        return 0;
    }

    if (doFill)
    {
        container.deserializeNBT(result.serializeNBT());
    }

    FluidStack newContained = FluidContainerRegistry.getFluidForFilledItem(result);

    int originalAmount = originalContained == null ? 0 : originalContained.amount;
    int newAmount = newContained == null ? 0 : newContained.amount;
    return newAmount - originalAmount;
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:28,代码来源:FluidContainerRegistryWrapper.java

示例3: getStackInSlot

import net.minecraftforge.fluids.FluidContainerRegistry; //导入方法依赖的package包/类
public ItemStack getStackInSlot(final int var1) {
    final FluidStack f = this.tank.getTankInfo(this.side)[var1].fluid;
    for (final ItemStack item : this.genericItems) {
        final ItemStack i = FluidContainerRegistry.fillFluidContainer(f, item);
        if (i != null) {
            return i;
        }
    }
    return null;
}
 
开发者ID:sameer,项目名称:ExtraUtilities,代码行数:11,代码来源:LiquidInventory.java

示例4: decrStackSize

import net.minecraftforge.fluids.FluidContainerRegistry; //导入方法依赖的package包/类
public ItemStack decrStackSize(final int var1, final int var2) {
    final FluidStack f = this.tank.getTankInfo(this.side)[var1].fluid;
    for (final ItemStack item : this.genericItems) {
        final ItemStack i = FluidContainerRegistry.fillFluidContainer(f, item);
        if (i != null) {
            final FluidStack t = FluidContainerRegistry.getFluidForFilledItem(i);
            if (t != null && t.isFluidEqual(this.tank.drain(this.side, t, false))) {
                this.tank.drain(this.side, t, true);
                return i;
            }
        }
    }
    return null;
}
 
开发者ID:sameer,项目名称:ExtraUtilities,代码行数:15,代码来源:LiquidInventory.java

示例5: tryFillContainer

import net.minecraftforge.fluids.FluidContainerRegistry; //导入方法依赖的package包/类
/**
 * This tries to fill the given container (at inventory[slot]) with fluid from the specified tank
 * If successful, it places the resulting filled container in inventory[slot]
 * 
 * Note: this deals with the issue where FluidContainerRegistry.fillFluidContainer() returns null for failed fills
 * 
 * @param tank		The tank to take the fluid from
 * @param liquid   The type of liquid in that tank (the calling method will normally have checked this already)
 * @param inventory
 * @param slot
 * @param canisterType  The type of canister to return, if it's a canister being filled (pre-matched with the liquid type)
 * 
 */
   public static void tryFillContainer(FluidTank tank, FluidStack liquid, ItemStack[] inventory, int slot, Item canisterType)
{
	ItemStack slotItem = inventory[slot];
	boolean isCanister = slotItem.getItem() instanceof ItemCanisterGeneric;
	final int amountToFill = Math.min(liquid.amount, isCanister ? slotItem.getItemDamage() - 1 : FluidContainerRegistry.BUCKET_VOLUME);

	if (amountToFill <= 0 || (isCanister && slotItem.getItem() != canisterType && slotItem.getItemDamage() != ItemCanisterGeneric.EMPTY))
		return;
	
	if (isCanister)
	{
		inventory[slot] = new ItemStack(canisterType, 1, slotItem.getItemDamage() - amountToFill);
		tank.drain(amountToFill, true);
	}
	else if (amountToFill == FluidContainerRegistry.BUCKET_VOLUME)
	{
		inventory[slot] = FluidContainerRegistry.fillFluidContainer(liquid, inventory[slot]);

		if (inventory[slot] == null)
		{
			//Failed to fill container: restore item that was there before
			inventory[slot] = slotItem;
		}
		else
		{
			tank.drain(amountToFill, true);
		}
	}
}
 
开发者ID:4Space,项目名称:4Space-5,代码行数:43,代码来源:FluidUtil.java

示例6: emptyTankIntoContainer

import net.minecraftforge.fluids.FluidContainerRegistry; //导入方法依赖的package包/类
public static boolean emptyTankIntoContainer(IFluidHandler tank, EntityPlayer player, FluidStack tankLiquid)
{
    ItemStack stack = player.getCurrentEquippedItem();

    if(!FluidContainerRegistry.isEmptyContainer(stack))
        return false;
    
    ItemStack filled = FluidContainerRegistry.fillFluidContainer(tankLiquid, stack);
    FluidStack liquid = FluidContainerRegistry.getFluidForFilledItem(filled);

    if(liquid == null || filled == null)
        return false;
    
    tank.drain(ForgeDirection.UNKNOWN, liquid.amount, true);

    if(!player.capabilities.isCreativeMode)
    {
        if(stack.stackSize == 1)
            player.inventory.setInventorySlotContents(player.inventory.currentItem, filled);
        else if(player.inventory.addItemStackToInventory(filled))
            stack.stackSize--;
        else
            return false;
    }
    
    player.inventoryContainer.detectAndSendChanges();        
    return true;
}
 
开发者ID:4Space,项目名称:4Space-5,代码行数:29,代码来源:FluidUtils.java

示例7: bucktFill

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

示例8: harvestBlock

import net.minecraftforge.fluids.FluidContainerRegistry; //导入方法依赖的package包/类
@Override
public ItemStack[] harvestBlock(World world, int x, int y, int z, EntityPlayer player, IToggleController controller)
{
    Block block = world.getBlock(x, y, z);
    System.out.println(block.getClass().getSimpleName());
    if (block instanceof IFluidBlock)
    {
        IToggleStorage storage = controller.getStorageHandler();
        IFluidBlock fluidBlock = (IFluidBlock) block;
        FluidStack containing = fluidBlock.drain(world, x, y, z, true);
        ItemStack emptyContainer = null;
        for (int s = 0; s < storage.getStorageSlots(); s++)
        {
            ItemStack inSlot = storage.getItemFromSlot(s);
            if (FluidContainerRegistry.isEmptyContainer(inSlot))
            {
                emptyContainer = inSlot;
                break;
            }
        }
        if (emptyContainer == null) return null;
        ItemStack filledContainer = FluidContainerRegistry.fillFluidContainer(containing, emptyContainer);
        emptyContainer.stackSize--;
        return new ItemStack[]{filledContainer};
    } else if (block instanceof BlockStaticLiquid)
    {
        ItemStack emptyBucket = controller.getStorageHandler().getItemFromStorage(new ItemStack(Items.bucket));
        if (emptyBucket != null)
        {
            emptyBucket.stackSize--;
            ItemStack filledBucket = null;
            if (block == Blocks.water) filledBucket = new ItemStack(Items.water_bucket);
            else if (block == Blocks.lava) filledBucket = new ItemStack(Items.lava_bucket);
            world.setBlockToAir(x, y, z);
            return filledBucket != null ? new ItemStack[]{filledBucket} : null;
        }
    }
    return null;
}
 
开发者ID:MrSpring,项目名称:ToggleBlocks,代码行数:40,代码来源:BucketToggleAction.java

示例9: removeLiquid

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

示例10: fillOreBucket

import net.minecraftforge.fluids.FluidContainerRegistry; //导入方法依赖的package包/类
private ItemStack fillOreBucket(World world, MovingObjectPosition target) {
	Block targetBlock = world.getBlock(target.blockX, target.blockY, target.blockZ);
	if (!(targetBlock instanceof BlockFluidClassic)) {
		return null;
	}
	ItemStack filledBucket = FluidContainerRegistry.fillFluidContainer(new FluidStack(((BlockFluidClassic)targetBlock).getFluid(), 1000), new ItemStack(net.minecraft.init.Items.bucket));
	if (filledBucket != null && world.getBlockMetadata(target.blockX, target.blockY, target.blockZ) == 0) {
		world.setBlockToAir(target.blockX, target.blockY, target.blockZ);
		return filledBucket;
	}
	else {
		return null;
	}
}
 
开发者ID:TheTorbinWren,项目名称:OresPlus,代码行数:15,代码来源:BucketHandler.java

示例11: fillContainerFromHandler

import net.minecraftforge.fluids.FluidContainerRegistry; //导入方法依赖的package包/类
public static boolean fillContainerFromHandler(World world, IFluidHandler handler, EntityPlayer player, FluidStack tankFluid) {

		ItemStack container = player.getCurrentEquippedItem();

		if (FluidContainerRegistry.isEmptyContainer(container)) {
			ItemStack returnStack = FluidContainerRegistry.fillFluidContainer(tankFluid, container);
			FluidStack fluid = FluidContainerRegistry.getFluidForFilledItem(returnStack);

			if (fluid == null || returnStack == null) {
				return false;
			}
			if (!player.capabilities.isCreativeMode) {
				if (container.stackSize == 1) {
					container = container.copy();
					player.inventory.setInventorySlotContents(player.inventory.currentItem, returnStack);
				} else if (!player.inventory.addItemStackToInventory(returnStack)) {
					return false;
				}
				handler.drain(ForgeDirection.UNKNOWN, fluid.amount, true);
				container.stackSize--;

				if (container.stackSize <= 0) {
					container = null;
				}
			} else {
				handler.drain(ForgeDirection.UNKNOWN, fluid.amount, true);
			}
			return true;
		}
		return false;
	}
 
开发者ID:PaleoCrafter,项目名称:R0b0ts,代码行数:32,代码来源:FluidHelper.java

示例12: getSubItems

import net.minecraftforge.fluids.FluidContainerRegistry; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
   @SideOnly(Side.CLIENT)
   public void getSubItems(Item item, CreativeTabs tabs, @SuppressWarnings("rawtypes") List itemStacks)
   {
       Collection<Fluid> fluids = FluidRegistry.getRegisteredFluids().values();
       for (Fluid fluid : fluids) {
           FluidStack fluidStack = new FluidStack(fluid, FluidContainerRegistry.BUCKET_VOLUME);
           ItemStack filledContainer = FluidContainerRegistry.fillFluidContainer(fluidStack, FluidContainerRegistry.EMPTY_BOTTLE);
           if (filledContainer != null && filledContainer.getItem() instanceof FilledGlassBottleItem) {
               itemStacks.add(filledContainer);
           }
       }
   }
 
开发者ID:lawremi,项目名称:PerFabricaAdAstra,代码行数:15,代码来源:FilledGlassBottleItem.java

示例13: registerMixingRecipe

import net.minecraftforge.fluids.FluidContainerRegistry; //导入方法依赖的package包/类
protected void registerMixingRecipe(Object[] inputs, FluidStack fluidInput, FluidStack fluidInput2,
		ItemStack output, FluidStack liquidOutput, Condition condition, Set<ItemStack> catalyst) {
	if (condition.temperature != Constants.STANDARD_TEMPERATURE) {
		return;
	}
	if (fluidInput != null && (fluidInput.getFluid().isGaseous() || 
			fluidInput.amount > FluidContainerRegistry.BUCKET_VOLUME) || 
		fluidInput2 != null && (fluidInput2.getFluid().isGaseous() ||
			fluidInput2.amount > FluidContainerRegistry.BUCKET_VOLUME)) {
		return;
	}
	if (!catalyst.isEmpty()) {
		return;
	}
	int offset = fluidInput2 != null ? 2 : fluidInput != null ? 1 : 0;
	inputs = Arrays.copyOf(inputs, inputs.length + offset);
	if (fluidInput != null) {
		inputs[inputs.length - offset] = toBucket(fluidInput);
	}
	if (fluidInput2 != null) {
		inputs[inputs.length - 1] = toBucket(fluidInput2);
	}
	if (output == null && liquidOutput.amount >= FluidContainerRegistry.BUCKET_VOLUME) {
		inputs = Arrays.copyOf(inputs, inputs.length + 1);
		inputs[inputs.length - 1] = new ItemStack(Items.bucket);
		output = FluidContainerRegistry.fillFluidContainer(liquidOutput, new ItemStack(Items.bucket));
	}
	RecipeUtils.addShapelessRecipe(output, inputs);
}
 
开发者ID:lawremi,项目名称:PerFabricaAdAstra,代码行数:30,代码来源:VanillaIntegration.java

示例14: fillFluidContainer

import net.minecraftforge.fluids.FluidContainerRegistry; //导入方法依赖的package包/类
public static ItemStack fillFluidContainer(ItemStack stack, FluidStack fluidStack) {
	if(stack != null && stack.getItem() instanceof IFluidContainerItem) {
		((IFluidContainerItem) stack.getItem()).fill(stack, fluidStack, true);
		return stack;
	}
	return FluidContainerRegistry.fillFluidContainer(fluidStack, stack);
}
 
开发者ID:AgeCraft,项目名称:AgeCraft-Old,代码行数:8,代码来源:ACUtil.java

示例15: onBlockActivated

import net.minecraftforge.fluids.FluidContainerRegistry; //导入方法依赖的package包/类
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9) {
	
	ItemStack stack = player.inventory.getCurrentItem();
	if (stack != null) {
		FluidStack liquid = FluidContainerRegistry.getFluidForFilledItem(stack);
		TileGlassFluidTank tank = (TileGlassFluidTank) world.getTileEntity(x, y, z);
		if (liquid != null) {
			int amount = tank.fill(ForgeDirection.UNKNOWN, liquid, false);
			if (amount == liquid.amount) {
				tank.fill(ForgeDirection.UNKNOWN, liquid, true);
				if (!player.capabilities.isCreativeMode)
					player.inventory.setInventorySlotContents(player.inventory.currentItem, Utils.useItemSafely(stack));

				if(tank.tank.getFluid().getFluid().getBlock() != null){
}
				return true;
			}
			else
				return true;
		}
		else if (FluidContainerRegistry.isBucket(stack)) {
			FluidTankInfo[] tanks = tank.getTankInfo(ForgeDirection.UNKNOWN);
			if (tanks[0] != null) {
				FluidStack fillFluid = tanks[0].fluid;
				ItemStack fillStack = FluidContainerRegistry.fillFluidContainer(fillFluid, stack);
				if (fillStack != null) {
					tank.drain(ForgeDirection.UNKNOWN, FluidContainerRegistry.getFluidForFilledItem(fillStack).amount, true);
					if (!player.capabilities.isCreativeMode) {
						if (stack.stackSize == 1)
							player.inventory.setInventorySlotContents(player.inventory.currentItem, fillStack);
						else {
							player.inventory.setInventorySlotContents(player.inventory.currentItem, Utils.useItemSafely(stack));
							if (!player.inventory.addItemStackToInventory(fillStack))
								player.dropPlayerItemWithRandomChoice(fillStack, false);
						}
					}
					return true;
				}
				else
					return true;
			}

		}
	}
	return false;
	}
 
开发者ID:grand-mine-inc,项目名称:Steam-and-Steel,代码行数:48,代码来源:GlassFluidTank.java


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