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


Java FluidStack.copy方法代碼示例

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


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

示例1: getRequestedAmount

import net.minecraftforge.fluids.FluidStack; //導入方法依賴的package包/類
public static int getRequestedAmount(SemiBlockLogistics requester, FluidStack providingStack) {
    int requestedAmount = requester instanceof ISpecificRequester ? ((ISpecificRequester) requester).amountRequested(providingStack) : providingStack.amount;
    if (requestedAmount == 0) return 0;
    providingStack = providingStack.copy();
    providingStack.amount = requestedAmount;
    FluidStack remainder = providingStack.copy();
    remainder.amount += requester.getIncomingFluid(remainder.getFluid());
    TileEntity te = requester.getTileEntity();
    if (te == null) return 0;
    for (EnumFacing d : EnumFacing.VALUES) {
        if (te.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, d)) {
            IFluidHandler handler = te.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, d);
            int fluidFilled = handler.fill(remainder, false);
            if (fluidFilled > 0) {
                remainder.amount -= fluidFilled;
                break;
            }
        }
    }
    providingStack.amount -= remainder.amount;
    if (providingStack.amount <= 0) return 0;
    return providingStack.amount;
}
 
開發者ID:TeamPneumatic,項目名稱:pnc-repressurized,代碼行數:24,代碼來源:LogisticsManager.java

示例2: fill

import net.minecraftforge.fluids.FluidStack; //導入方法依賴的package包/類
@Override
public int fill(FluidStack resource, boolean doFill)
{
    if (resource == null || resource.amount <= 0)
        return 0;

    resource = resource.copy();

    int totalFillAmount = 0;
    for (IFluidHandler handler : subHandlers)
    {
        int fillAmount = handler.fill(resource, doFill);
        totalFillAmount += fillAmount;
        resource.amount -= fillAmount;
        if (resource.amount <= 0)
            break;
    }
    return totalFillAmount;
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:20,代碼來源:FluidHandlerConcatenate.java

示例3: fill

import net.minecraftforge.fluids.FluidStack; //導入方法依賴的package包/類
@Override
public int fill(FluidStack resource, boolean doFill)
{
    if (container.stackSize != 1 || resource == null || resource.amount <= 0 || !canFillFluidType(resource))
    {
        return 0;
    }

    FluidStack contained = getFluid();
    if (contained == null)
    {
        int fillAmount = Math.min(capacity, resource.amount);
        if (fillAmount == capacity) {
            if (doFill) {
                FluidStack filled = resource.copy();
                filled.amount = fillAmount;
                setFluid(filled);
            }

            return fillAmount;
        }
    }

    return 0;
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:26,代碼來源:FluidHandlerItemStackSimple.java

示例4: finishWithMekanismHandling

import net.minecraftforge.fluids.FluidStack; //導入方法依賴的package包/類
@Optional.Method(modid = "mekanism")
private boolean finishWithMekanismHandling(HybridTank handler, ResultChance chance) {
    if(this.required instanceof HybridFluidGas && handler instanceof HybridGasTank) {
        GasStack gasOut = ((HybridFluidGas) this.required).asGasStack();
        HybridGasTank gasTankHandler = (HybridGasTank) handler;
        int fillableGas = gasTankHandler.receiveGas(EnumFacing.UP, gasOut, false);
        if(chance.canProduce(this.chance)) {
            return fillableGas >= gasOut.amount;
        }
        return fillableGas >= gasOut.amount && gasTankHandler.receiveGas(EnumFacing.UP, gasOut, true) >= gasOut.amount;
    } else {
        FluidStack outStack = this.required.asFluidStack();
        if(outStack != null) {
            int fillableAmount = handler.fillInternal(outStack.copy(), false);
            if(chance.canProduce(this.chance)) {
                return fillableAmount >= outStack.amount;
            }
            FluidStack copyOut = outStack.copy();
            if(this.tagDisplay != null ){
                copyOut.tag = this.tagDisplay.copy();
            }
            return fillableAmount >= outStack.amount && handler.fillInternal(copyOut.copy(), true) >= copyOut.amount;
        }
    }
    return false;
}
 
開發者ID:HellFirePvP,項目名稱:ModularMachinery,代碼行數:27,代碼來源:ComponentRequirement.java

示例5: SmeltingRecipeWrapper

import net.minecraftforge.fluids.FluidStack; //導入方法依賴的package包/類
public SmeltingRecipeWrapper(MeltingRecipe recipe) {
    this.inputs = recipe.input.getInputs();
    this.outputs = ImmutableList.of(recipe.getResult());
    this.temperature = recipe.getTemperature();

    ImmutableList.Builder<FluidStack> builder = ImmutableList.builder();
    for(FluidStack fs : TinkerRegistry.getSmelteryFuels()) {
        if(fs.getFluid().getTemperature(fs) >= temperature) {
            fs = fs.copy();
            fs.amount = 1000;
            builder.add(fs);
        }
    }
    fuels = builder.build();
}
 
開發者ID:primetoxinz,項目名稱:Meltery,代碼行數:16,代碼來源:SmeltingRecipeWrapper.java

示例6: getContents

import net.minecraftforge.fluids.FluidStack; //導入方法依賴的package包/類
@Nullable
@Override
public FluidStack getContents()
{
    FluidStack contents = tank.getFluid();
    return contents == null ? null : contents.copy();
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:8,代碼來源:FluidTankPropertiesWrapper.java

示例7: drain

import net.minecraftforge.fluids.FluidStack; //導入方法依賴的package包/類
@Override
public FluidStack drain(int maxDrain, boolean doDrain)
{
    if (container.stackSize != 1 || maxDrain <= 0)
    {
        return null;
    }

    FluidStack contained = getFluid();
    if (contained == null || contained.amount <= 0 || !canDrainFluidType(contained))
    {
        return null;
    }

    final int drainAmount = Math.min(contained.amount, maxDrain);
    if (drainAmount == capacity) {
        FluidStack drained = contained.copy();

        if (doDrain) {
            setContainerToEmpty();
        }

        return drained;
    }

    return null;
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:28,代碼來源:FluidHandlerItemStackSimple.java

示例8: fill

import net.minecraftforge.fluids.FluidStack; //導入方法依賴的package包/類
@Override
public int fill(FluidStack resource, boolean doFill)
{
	if (resource == null || !resource.getFluid().equals(WATER) || resource.amount <= 0)
	{
		return 0;
	}
	
	FluidStack contents = this.getContents();
	int max = this.getCapacity();
	int current = contents != null ? contents.amount : 0;
	int lacking = max - current;
	int filled = Math.min(lacking, resource.amount);
	if (doFill)
	{
		if (contents != null)
		{
			contents.amount += filled;
		}
		else
		{
			contents = resource.copy();
			contents.amount = filled;
		}
		
		this.setFluidStack(contents);
	}
	
	return filled;
}
 
開發者ID:V0idWa1k3r,項目名稱:ExPetrum,代碼行數:31,代碼來源:WateringCanCapability.java

示例9: finishCrafting

import net.minecraftforge.fluids.FluidStack; //導入方法依賴的package包/類
@Override
public boolean finishCrafting(MachineComponent component, RecipeCraftingContext context, ResultChance chance) {
    if(component.getComponentType() != MachineComponent.ComponentType.FLUID ||
            !(component instanceof MachineComponent.FluidHatch) ||
            component.getIOType() != getActionType()) return false;
    HybridTank handler = context.getFluidHandler(component);
    switch (getActionType()) {
        case OUTPUT:
            if(ModularMachinery.isMekanismLoaded) {
                return finishWithMekanismHandling(handler, chance);
            } else {
                FluidStack outStack = this.required.asFluidStack();
                if(outStack != null) {
                    int fillableAmount = handler.fillInternal(outStack.copy(), false);
                    if(chance.canProduce(this.chance)) {
                        return fillableAmount >= outStack.amount;
                    }
                    FluidStack copyOut = outStack.copy();
                    if(this.tagDisplay != null ){
                        copyOut.tag = this.tagDisplay.copy();
                    }
                    return fillableAmount >= outStack.amount && handler.fillInternal(copyOut.copy(), true) >= copyOut.amount;
                }
            }
    }
    return false;
}
 
開發者ID:HellFirePvP,項目名稱:ModularMachinery,代碼行數:28,代碼來源:ComponentRequirement.java

示例10: copyWhenNecessary

import net.minecraftforge.fluids.FluidStack; //導入方法依賴的package包/類
@Override
protected FluidStack copyWhenNecessary(FluidStack oldValue) {
    return oldValue.copy();
}
 
開發者ID:TeamPneumatic,項目名稱:pnc-repressurized,代碼行數:5,代碼來源:SyncedField.java


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