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


Java FluidActionResult.isSuccess方法代码示例

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


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

示例1: doFluidInteraction

import net.minecraftforge.fluids.FluidActionResult; //导入方法依赖的package包/类
private static boolean doFluidInteraction(TileEntity te, EnumFacing face, EntityPlayer player, EnumHand hand, boolean isInserting) {
    ItemStack stack = player.getHeldItem(hand);
    IFluidHandlerItem stackHandler = FluidUtil.getFluidHandler(stack);
    if (stackHandler != null && te.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, face)) {
        int capacity = stackHandler.getTankProperties()[0].getCapacity();
        IFluidHandler handler = te.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, face);
        PlayerInvWrapper invWrapper = new PlayerInvWrapper(player.inventory);
        FluidActionResult result = isInserting ?
                FluidUtil.tryEmptyContainerAndStow(player.getHeldItem(hand), handler, invWrapper, capacity, player) :
                FluidUtil.tryFillContainerAndStow(player.getHeldItem(hand), handler, invWrapper, capacity, player);
        if (result.isSuccess()) {
            player.setHeldItem(hand, result.getResult());
            return true;
        }
    }
    return false;
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:18,代码来源:FluidUtils.java

示例2: tryFluidExtraction

import net.minecraftforge.fluids.FluidActionResult; //导入方法依赖的package包/类
/**
 * Attempt to extract fluid from the given fluid handler into the given fluid-containing item.
 *
 * @param srcHandler fluid handler into which to place the fluid
 * @param destStack the fluid container item to extract from
 * @param returnedItems the modified fluid container after extraction
 * @return true if any fluid was moved, false otherwise
 */
public static boolean tryFluidExtraction(IFluidHandler srcHandler, ItemStack destStack, NonNullList<ItemStack> returnedItems) {
    FluidActionResult result = FluidUtil.tryFillContainer(destStack, srcHandler, 1000, null, true);
    if (result.isSuccess()) {
        returnedItems.add(result.getResult());
        destStack.shrink(1);
        return true;
    } else {
        return false;
    }
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:19,代码来源:FluidUtils.java

示例3: tryFluidInsertion

import net.minecraftforge.fluids.FluidActionResult; //导入方法依赖的package包/类
/**
 * Attempt to insert fluid into the given fluid handler from the given fluid container item.
 *
 * @param handler the handler to extract from
 * @param srcStack the fluid container item to insert to
 * @param returnedItems the modified fluid container after insertion
 * @return true if any fluid was moved, false otherwise
 */
public static boolean tryFluidInsertion(IFluidHandler handler, ItemStack srcStack, NonNullList<ItemStack> returnedItems) {
    FluidActionResult result = FluidUtil.tryEmptyContainer(srcStack, handler, 1000, null, true);
    if (result.isSuccess()) {
        returnedItems.add(result.getResult());
        srcStack.shrink(1);
        return true;
    } else {
        return false;
    }
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:19,代码来源:FluidUtils.java

示例4: handleRightClickFluidStorage

import net.minecraftforge.fluids.FluidActionResult; //导入方法依赖的package包/类
public static boolean handleRightClickFluidStorage(EntityPlayer player, EnumHand hand, IFluidHandler tank, int maxTransfer) {
	ItemStack fluidItem = player.getHeldItem(hand);
	if (fluidItem==null || fluidItem.isEmpty()) return false;
	if (!fluidItem.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null)) {
		return false;
	}
	
	FluidActionResult result = tryEmptyOrFillContainer(fluidItem, tank, maxTransfer, player);
	if (result.isSuccess()) {
		player.setHeldItem(hand, result.result);
		return true;
	} else {
		return false;
	}
}
 
开发者ID:elytra,项目名称:Thermionics,代码行数:16,代码来源:FluidTransport.java

示例5: update

import net.minecraftforge.fluids.FluidActionResult; //导入方法依赖的package包/类
@Override
public void update() {
	boolean curTickPower = world.isBlockIndirectlyGettingPowered(pos)!=0;
	
	//TODO: Actually lock tanks
	
	
	{ //Bottle fluids out
		ItemStack bottles = itemStorage.getStackInSlot(SLOT_EMPTY_BUCKET_IN);
		ItemStack outputItem = itemStorage.getStackInSlot(SLOT_FULL_BUCKET_OUT);
		FluidStack outputFluid = outputTank.getFluid();
		//Are there bottles to fill, is there room to put them, is there fluid to fill them with, and is there *enough* of that fluid?
		if (!bottles.isEmpty() && outputItem.getCount()<outputItem.getMaxStackSize() && outputFluid!=null && outputFluid.amount>250) {
			ItemStack outBottle = new ItemStack(ThermionicsItems.SPIRIT_BOTTLE);
			outBottle.setTagCompound(outputFluid.tag.copy());
			
			if (itemStorage.insertItem(SLOT_FULL_BUCKET_OUT, outBottle, true).isEmpty()) {
				outputTank.drainInternal(250,  true);
				itemStorage.insertItem(SLOT_FULL_BUCKET_OUT, outBottle, false);
				itemStorage.extractItem(SLOT_EMPTY_BUCKET_IN, 1, false);
			}
		}
	}
	
	if (!tanksLocked) {
		if (curTickPower & !lastTickPower) {
			//Lock the tanks on a rising current edge.
			setTanksLocked(true);
			processTime = 0;
		} else {
			//Fluid loading/unloading mode
			ItemStack inBucket = itemStorage.getStackInSlot(SLOT_FULL_BUCKET_IN);
			FluidActionResult result = FluidUtil.tryEmptyContainer(inBucket, inputTank, inputTank.getCapacity(), null, true);
			if (result.isSuccess()) {
				itemStorage.setStackInSlot(SLOT_FULL_BUCKET_IN, ItemStack.EMPTY);
				itemStorage.setStackInSlot(SLOT_EMPTY_BUCKET_OUT, result.getResult());
			}
		}
	} else {
		if (processTime<MAX_PROCESS_TIME) processTime++;
		FluidStack in = inputTank.getFluid();
		if (in==null) {
			//Batch is done...?
			setTanksLocked(false);
		} else {
			//Find a recipe, let's go :D
			//For the moment, use Water->Rum
			PotStillRecipe recipe = MachineRecipes.getPotStill(inputTank);
			if (recipe!=null) {
				FluidStack output = recipe.getOutput();
				int filled = outputTank.fillInternal(output, false);
				int extracted = heat.extractHeat(HEAT_REQUIRED, true);
				if (output.amount==filled && extracted==HEAT_REQUIRED) {
					recipe.consumeIngredients(inputTank);
					outputTank.fillInternal(output, true);
					heat.extractHeat(HEAT_REQUIRED, false);
				}
				
			}
		}
	}
	
	lastTickPower = curTickPower;
}
 
开发者ID:elytra,项目名称:Thermionics,代码行数:65,代码来源:TileEntityPotStill.java


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