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


Java FluidStack.isFluidEqual方法代碼示例

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


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

示例1: drain

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

    FluidStack fluidStack = getFluid();
    if (fluidStack != null && fluidStack.isFluidEqual(resource))
    {
        if (doDrain)
        {
            setFluid(null);
        }
        return fluidStack;
    }

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

示例2: drain

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

    FluidStack contained = FluidContainerRegistry.getFluidForFilledItem(container);
    if (contained != null && contained.isFluidEqual(resource))
    {
        return drain(resource.amount, doDrain);
    }

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

示例3: drain

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

    FluidStack canDrain = drain(resource.amount, false);
    if (canDrain != null)
    {
        if (canDrain.isFluidEqual(resource))
        {
            return drain(resource.amount, doDrain);
        }
    }
    return null;
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:19,代碼來源:FluidContainerItemWrapper.java

示例4: areEqual

import net.minecraftforge.fluids.FluidStack; //導入方法依賴的package包/類
public static boolean areEqual(FluidStack stack1, FluidStack stack2) {
    if(stack1 == null || stack2 == null) {
        return false;
    }
    
    return stack1.isFluidEqual(stack2);
}
 
開發者ID:TeamPneumatic,項目名稱:pnc-repressurized,代碼行數:8,代碼來源:Helper.java

示例5: onBlockActivated

import net.minecraftforge.fluids.FluidStack; //導入方法依賴的package包/類
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
	if (world.isRemote) return true;
	TileEntityBarrel barrel = (TileEntityBarrel) world.getTileEntity(pos);
	world.notifyBlockUpdate(pos, state, state, 3);
	ItemStack stack = player.getHeldItem(hand);
	if (stack.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null)) {
		IFluidHandlerItem itemHandler = stack.getCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null);
		IFluidHandler barrelHandler = barrel.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, null);
		FluidStack fluidInItem = itemHandler.drain(Fluid.BUCKET_VOLUME, false);
		FluidStack fluidInBarrel = barrelHandler.drain(Fluid.BUCKET_VOLUME, false);
		if ((fluidInBarrel != null && fluidInBarrel.amount > 0) && (fluidInItem == null || fluidInItem.amount == 0 || (fluidInItem.isFluidEqual(fluidInBarrel) && fluidInItem.amount < Fluid.BUCKET_VOLUME))) {
			itemHandler.fill(barrelHandler.drain(Fluid.BUCKET_VOLUME, true), true);
			player.setHeldItem(hand, itemHandler.getContainer());
		} else if (fluidInItem != null && fluidInItem.amount > 0 && fluidInItem.getFluid() != null && (fluidInBarrel == null || fluidInBarrel.amount == 0 || (fluidInBarrel.amount < Fluid.BUCKET_VOLUME && fluidInBarrel.isFluidEqual(fluidInItem)))) {
			FluidStack fsin = itemHandler.drain(Fluid.BUCKET_VOLUME, true);
			if (fsin != null && fsin.amount > 0 && fsin.getFluid() != null) {
				barrelHandler.fill(fsin, true);
				player.setHeldItem(hand, itemHandler.getContainer());
				player.inventory.markDirty();
			}
		}
		return true;
	}

	player.openGui(Bewitchment.instance, LibGui.BARREL.ordinal(), world, pos.getX(), pos.getY(), pos.getZ());
	return true;
}
 
開發者ID:Um-Mitternacht,項目名稱:Bewitchment,代碼行數:29,代碼來源:BlockBarrel.java

示例6: fluidStackEqual

import net.minecraftforge.fluids.FluidStack; //導入方法依賴的package包/類
public static boolean fluidStackEqual(FluidStack stack, FluidStack input, boolean checkCount)
{
    if (stack == null && input == null)
        return true;
    if (stack == null ^ input == null)
        return false;

    return stack.isFluidEqual(input) && (!checkCount || input.amount <= stack.amount);
}
 
開發者ID:cubex2,項目名稱:customstuff4,代碼行數:10,代碼來源:ItemHelper.java

示例7: drain

import net.minecraftforge.fluids.FluidStack; //導入方法依賴的package包/類
@Override
public FluidStack drain(FluidStack resource, boolean doDrain)
{
    if (container.stackSize != 1 || resource == null || resource.amount <= 0 || !resource.isFluidEqual(getFluid()))
    {
        return null;
    }
    return drain(resource.amount, doDrain);
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:10,代碼來源:FluidHandlerItemStackSimple.java

示例8: drain

import net.minecraftforge.fluids.FluidStack; //導入方法依賴的package包/類
@Override
public FluidStack drain(FluidStack resource, boolean doDrain)
{
	FluidStack contents = this.getContents();
	if (contents == null || !resource.isFluidEqual(contents))
	{
		return null;
	}
	
	int requested = resource.amount;
	int current = this.getContents().amount;
	int drained = Math.min(requested, current);
	FluidStack ret = this.getContents().copy();
	ret.amount = drained;
	if (doDrain)
	{
		if (drained == current)
		{
			this.setFluidStack(null);
		}
		else
		{
			contents.amount -= drained;
			this.setFluidStack(contents);
		}
	}
	
	return ret;
}
 
開發者ID:V0idWa1k3r,項目名稱:ExPetrum,代碼行數:30,代碼來源:WateringCanCapability.java

示例9: equals

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


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