當前位置: 首頁>>代碼示例>>Java>>正文


Java FluidTank.drain方法代碼示例

本文整理匯總了Java中net.minecraftforge.fluids.FluidTank.drain方法的典型用法代碼示例。如果您正苦於以下問題:Java FluidTank.drain方法的具體用法?Java FluidTank.drain怎麽用?Java FluidTank.drain使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在net.minecraftforge.fluids.FluidTank的用法示例。


在下文中一共展示了FluidTank.drain方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: drain

import net.minecraftforge.fluids.FluidTank; //導入方法依賴的package包/類
@Override
@Nullable
public FluidStack drain(FluidStack resource, boolean doDrain) {
  if (ItemStackTools.getStackSize(container) != 1) {
    return null;
  }
  FluidTank tank = loadTank(container);
  if(tank == null)return null;
  
  boolean infi = container.getMetadata() == TankType.CREATIVE.getMeta();
  if(infi){
	  return resource.copy();
  }
  FluidStack ret = tank.drain(resource, doDrain);
  saveTank(container, tank);
  return ret;
}
 
開發者ID:Alec-WAM,項目名稱:CrystalMod,代碼行數:18,代碼來源:ItemBlockTank.java

示例2: consumeFluids

import net.minecraftforge.fluids.FluidTank; //導入方法依賴的package包/類
public void consumeFluids(ArrayList<FluidStack> fluids, FluidMixingRecipe recipe) {
    for (FluidTank tank : tanks) {
        FluidStack tankFluid = tank.getFluid();
        boolean doContinue = true;
        for (int j = 0; j < recipe.inputs.size() && doContinue; j++) {
            FluidStack recipeFluid = recipe.inputs.get(j);
            if (recipeFluid != null && tankFluid != null && recipeFluid.getFluid() == tankFluid.getFluid()) {
                doContinue = false;
                tank.drain(recipeFluid.amount,true);
            }
        }
    }
}
 
開發者ID:DaedalusGame,項目名稱:Soot,代碼行數:14,代碼來源:TileEntityMixerBottomImproved.java

示例3: tryFillContainer

import net.minecraftforge.fluids.FluidTank; //導入方法依賴的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

示例4: consumeIngredients

import net.minecraftforge.fluids.FluidTank; //導入方法依賴的package包/類
public boolean consumeIngredients(FluidTank input) {
	if (!recipe.apply(input.getFluid())) return false;
	return input.drain(recipe.getAmount(), true)!=null;
}
 
開發者ID:elytra,項目名稱:Thermionics,代碼行數:5,代碼來源:PotStillRecipe.java

示例5: update

import net.minecraftforge.fluids.FluidTank; //導入方法依賴的package包/類
@SuppressWarnings("deprecation")
@Override
public void update(TileBarrel barrel) {
	// Fluids on top.
	if (barrel.getTank().getFluid() != null) {
		FluidTank tank = barrel.getTank();
		if (tank.getFluid().amount != tank.getCapacity())
			return;

		Fluid fluidInBarrel = tank.getFluid().getFluid();

		BlockPos barrelPos = barrel.getPos();
		BlockPos pos = new BlockPos(barrelPos.getX(), barrelPos.getY() + 1, barrelPos.getZ());
		Block onTop = barrel.getWorld().getBlockState(pos).getBlock();

		Fluid fluidOnTop = null;
		if (onTop instanceof BlockLiquid) {
			fluidOnTop = onTop.getMaterial(barrel.getWorld().getBlockState(pos)) == Material.WATER
					? FluidRegistry.WATER : FluidRegistry.LAVA;
		}

		if (onTop != null && onTop instanceof IFluidBlock) {
			fluidOnTop = ((BlockFluidBase) onTop).getFluid();
		}

		if (FluidOnTopRegistry.isValidRecipe(fluidInBarrel, fluidOnTop)) {
			ItemInfo info = FluidOnTopRegistry.getTransformedBlock(fluidInBarrel, fluidOnTop);
			tank.drain(tank.getCapacity(), true);
			barrel.setMode("block");
			PacketHandler.sendToAllAround(new MessageBarrelModeUpdate("block", barrel.getPos()), barrel);

			barrel.getMode().addItem(info.getItemStack(), barrel);

			return;
		}

		// Fluid transforming time!
		if (FluidTransformRegistry.containsKey(barrel.getTank().getFluid().getFluid().getName())) {
			List<FluidTransformer> transformers = FluidTransformRegistry
					.getFluidTransformers(barrel.getTank().getFluid().getFluid().getName());

			boolean found = false;
			for (int radius = 0; radius <= 2; radius++) {
				for (FluidTransformer transformer : transformers) {
					if (!BarrelLiquidBlacklistRegistry.isBlacklisted(barrel.getTier(), transformer.getOutputFluid())
							&& (Util.isSurroundingBlocksAtLeastOneOf(transformer.getTransformingBlocks(),
									barrel.getPos().add(0, -1, 0), barrel.getWorld(), radius)
									|| Util.isSurroundingBlocksAtLeastOneOf(transformer.getTransformingBlocks(),
											barrel.getPos(), barrel.getWorld(), radius))) {
						// Time to start the process.
						FluidStack fstack = tank.getFluid();
						tank.setFluid(null);

						barrel.setMode("fluidTransform");
						BarrelModeFluidTransform mode = (BarrelModeFluidTransform) barrel.getMode();

						mode.setTransformer(transformer);
						mode.setInputStack(fstack);
						mode.setOutputStack(FluidRegistry.getFluidStack(transformer.getOutputFluid(), 1000));

						PacketHandler.sendNBTUpdate(barrel);
						found = true;
					}
				}
				if (found) break;
			}
		}
	}
}
 
開發者ID:MikeLydeamore,項目名稱:ExNihiloAdscensio,代碼行數:70,代碼來源:BarrelModeFluid.java


注:本文中的net.minecraftforge.fluids.FluidTank.drain方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。