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


Java IFluidHandler.fill方法代碼示例

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


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

示例1: transferTo

import net.minecraftforge.fluids.IFluidHandler; //導入方法依賴的package包/類
@Override
public boolean transferTo(final INodeBuffer receptor, final int no) {
    if (this.getBuffer() == null || !this.getBufferType().equals(receptor.getBufferType())) {
        return false;
    }
    if (!(receptor.getNode() instanceof IFluidHandler)) {
        return false;
    }
    final ForgeDirection dir = receptor.getNode().getNodeDir();
    final IFluidHandler dest = (IFluidHandler)receptor.getNode();
    final int k = dest.fill(dir, this.tank.drain(200 * no, false), false);
    if (k <= 0) {
        return false;
    }
    dest.fill(dir, this.tank.drain(k, true), true);
    receptor.setBuffer(dest);
    receptor.markDirty();
    return true;
}
 
開發者ID:sameer,項目名稱:ExtraUtilities,代碼行數:20,代碼來源:FluidBuffer.java

示例2: fillTankWithContainer

import net.minecraftforge.fluids.IFluidHandler; //導入方法依賴的package包/類
public static boolean fillTankWithContainer(IFluidHandler tank, EntityPlayer player)
{
    ItemStack stack = player.getCurrentEquippedItem();
    FluidStack liquid = FluidContainerRegistry.getFluidForFilledItem(stack);

    if(liquid == null)
        return false;

    if(tank.fill(ForgeDirection.UNKNOWN, liquid, false) != liquid.amount && !player.capabilities.isCreativeMode)
        return false;
    
    tank.fill(ForgeDirection.UNKNOWN, liquid, true);
    
    if(!player.capabilities.isCreativeMode)
        InventoryUtils.consumeItem(player.inventory, player.inventory.currentItem);

    player.inventoryContainer.detectAndSendChanges();
    return true;
}
 
開發者ID:4Space,項目名稱:4Space-5,代碼行數:20,代碼來源:FluidUtils.java

示例3: relievePressure

import net.minecraftforge.fluids.IFluidHandler; //導入方法依賴的package包/類
public boolean relievePressure(World world, BlockPos pos, BlockPos up) {
    IBlockState stateAbove = world.getBlockState(up);
    Block blockAbove = stateAbove.getBlock();
    if (blockAbove.hasTileEntity(stateAbove)) {
        TileEntity te = world.getTileEntity(up);
        if (te instanceof IFluidHandler) {
            IFluidHandler tank = (IFluidHandler) te;
            FluidStack steam = TileEntitySolarBoiler.getSteamStack().copy();
            steam.amount = getAmount(world, pos);
            return tank.fill(EnumFacing.DOWN, steam, true) > 0;
        }
    }
    if (!blockAbove.isPassable(world, up)) {
        return false;
    }
    if (world.getClosestPlayer(pos.getX(), pos.getY(), pos.getZ(), 16 * 3) != null) {
        // Could also check ForgeChunkManager to see if this chunk is force-loaded.
        // I think I won't though.
        EntitySteamGeyser geyser = new EntitySteamGeyser(world);
        geyser.setPosition(pos.getX() + 0.5, pos.getY() + 1, pos.getZ() + 0.5);
        world.spawnEntityInWorld(geyser);
    }
    return true;
}
 
開發者ID:purpleposeidon,項目名稱:Factorization,代碼行數:25,代碼來源:BlockGeyser.java

示例4: pushUp

import net.minecraftforge.fluids.IFluidHandler; //導入方法依賴的package包/類
public int pushUp(FluidStack fluid, boolean doFill)
{
	Coord4D up = Coord4D.get(this).getFromSide(ForgeDirection.UP);
	
	if(up.getTileEntity(worldObj) instanceof TileEntityPortableTank)
	{
		IFluidHandler handler = (IFluidHandler)up.getTileEntity(worldObj);
		
		if(handler.canFill(ForgeDirection.DOWN, fluid.getFluid()))
		{
			return handler.fill(ForgeDirection.DOWN, fluid, doFill);
		}
	}
	
	return 0;
}
 
開發者ID:Microsoft,項目名稱:vsminecraft,代碼行數:17,代碼來源:TileEntityPortableTank.java

示例5: fill

import net.minecraftforge.fluids.IFluidHandler; //導入方法依賴的package包/類
@Override
public int fill(ForgeDirection from, FluidStack resource, boolean doFill) {
	IFluidHandler handler = this.getFluidTankInDirection(ForgeDirection.DOWN);
	int amt = 0;

	if(handler != null) {
		amt = handler.fill(from, resource, doFill);
	}
	//Copy to avoid modifiying the passed one
	FluidStack resource2 = resource.copy();
	resource2.amount -= amt;
	if(resource2.amount > 0)
		amt += super.fill(from, resource2, doFill);
	
	if(amt > 0 && doFill)
		fluidChanged = true;	
	
	checkForUpdate();
	
	return amt;
}
 
開發者ID:zmaster587,項目名稱:AdvancedRocketry,代碼行數:22,代碼來源:TileFluidTank.java

示例6: addEnergy

import net.minecraftforge.fluids.IFluidHandler; //導入方法依賴的package包/類
/**
 * Adds energy to this conductor, up to the maximum allowed energy. The 
 * amount of energy that was actually added (or subtracted) to the energy 
 * buffer is returned. 
 * @param energy The amount of energy to add (can be negative to subtract 
 * energy).
 * @param type The type of energy to be added to the buffer
 * @return The actual change to the internal energy buffer.
 */
@Override
public float addEnergy(float energy, ConduitType type){
	Fluid f = Fluids.conduitTypeToFluid(type);
	if(f == null) return 0;
	int delta = 0, original = (int) energy;
	for(int i = 0; i < 6; i++){
		IFluidHandler n = neighbors[i];
		EnumFacing face = faces[i].getOpposite();
		if(n != null){
			FluidStack fs = new FluidStack(f,original - delta);
			delta += n.fill(face, fs, true);
		}
		if(delta >= original) break;
	}
	return delta;
}
 
開發者ID:cyanobacterium,項目名稱:PowerAdvantageAPI,代碼行數:26,代碼來源:TerminalFluidPipeTileEntity.java

示例7: fillHandlerWithContainer

import net.minecraftforge.fluids.IFluidHandler; //導入方法依賴的package包/類
public static boolean fillHandlerWithContainer(World world, IFluidHandler handler, EntityPlayer player) {

		ItemStack container = player.getCurrentEquippedItem();
		FluidStack fluid = FluidContainerRegistry.getFluidForFilledItem(container);

		if (fluid != null) {
			if (handler.fill(ForgeDirection.UNKNOWN, fluid, false) == fluid.amount || player.capabilities.isCreativeMode) {
				if (ServerHelper.isClientWorld(world)) {
					return true;
				}
				handler.fill(ForgeDirection.UNKNOWN, fluid, true);

				if (!player.capabilities.isCreativeMode) {
					player.inventory.setInventorySlotContents(player.inventory.currentItem, ItemHelper.consumeItem(container));
				}
				return true;
			}
		}
		return false;
	}
 
開發者ID:PaleoCrafter,項目名稱:R0b0ts,代碼行數:21,代碼來源:FluidHelper.java

示例8: getRequestedAmount

import net.minecraftforge.fluids.IFluidHandler; //導入方法依賴的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 instanceof IFluidHandler) {
        IFluidHandler fluidHandler = (IFluidHandler)te;
        for(ForgeDirection d : ForgeDirection.VALID_DIRECTIONS) {
            int fluidFilled = fluidHandler.fill(d, remainder, false);
            if(fluidFilled > 0) {
                remainder.amount -= fluidFilled;
                break;
            }
        }
    }
    providingStack.amount -= remainder.amount;
    if(providingStack.amount <= 0) return 0;
    return providingStack.amount;
}
 
開發者ID:MineMaarten,項目名稱:PneumaticCraft,代碼行數:23,代碼來源:LogisticsManager.java

示例9: transfer

import net.minecraftforge.fluids.IFluidHandler; //導入方法依賴的package包/類
@Override
public boolean transfer(final TileEntity tile, final ForgeDirection side, final IPipe insertingPipe, final int x, final int y, final int z, final ForgeDirection travelDir) {
    if (this.isEmpty()) {
        return true;
    }
    if (tile instanceof IFluidHandler) {
        final IFluidHandler destTank = (IFluidHandler)tile;
        int filter = -1;
        boolean eof = false;
        if (insertingPipe != null) {
            filter = insertingPipe.limitTransfer(tile, side, this);
            eof = insertingPipe.getOutputDirections((IBlockAccess)tile.getWorldObj(), x, y, z, travelDir, this).isEmpty();
        }
        if (filter < 0) {
            filter = this.tank.getFluidAmount();
        }
        if (!eof && filter > 1) {
            filter /= 2;
        }
        final FluidStack b = this.tank.getFluid().copy();
        b.amount = Math.min(b.amount, filter);
        filter = destTank.fill(side, b, false);
        final FluidStack c = this.tank.drain(filter, true);
        destTank.fill(side, c, true);
    }
    return true;
}
 
開發者ID:sameer,項目名稱:ExtraUtilities,代碼行數:28,代碼來源:FluidBuffer.java

示例10: unloadTank

import net.minecraftforge.fluids.IFluidHandler; //導入方法依賴的package包/類
public void unloadTank() {
    if (this.buffer.isEmpty()) {
        return;
    }
    final int dir = this.getBlockMetadata() % 6;
    final ForgeDirection side = ForgeDirection.getOrientation(dir).getOpposite();
    if (this.worldObj.getTileEntity(this.xCoord + Facing.offsetsXForSide[dir], this.yCoord + Facing.offsetsYForSide[dir], this.zCoord + Facing.offsetsZForSide[dir]) instanceof IFluidHandler) {
        final IFluidHandler dest = (IFluidHandler)this.worldObj.getTileEntity(this.xCoord + Facing.offsetsXForSide[dir], this.yCoord + Facing.offsetsYForSide[dir], this.zCoord + Facing.offsetsZForSide[dir]);
        final FluidTank tank = (FluidTank)this.buffer.getBuffer();
        final int a = dest.fill(side, tank.getFluid(), this.initDirection());
        if (a > 0) {
            dest.fill(side, tank.drain(a, true), true);
        }
    }
}
 
開發者ID:sameer,項目名稱:ExtraUtilities,代碼行數:16,代碼來源:TileEntityRetrievalNodeLiquid.java

示例11: onNexusExportCall

import net.minecraftforge.fluids.IFluidHandler; //導入方法依賴的package包/類
@Override
public void onNexusExportCall(TileEntityTransporter nexus)
{
    ForgeDirection nexusOrientation = ForgeDirection.getOrientation(nexus.getBlockMetadata());
    FluidTankInfo[] tankInfo = nexus.getTankInfo(nexusOrientation);
    FluidStack nexusFluid = tankInfo[0].fluid;

    if (nexusFluid != null && nexusFluid.amount > 0)
    {
        TileEntity tile = nexus.getAttachedTileEntity();
        if (tile instanceof IFluidHandler)
        {
            IFluidHandler inv = (IFluidHandler) tile;
            if (inv.canFill(nexusOrientation, nexusFluid.getFluid()))
            {
                FluidStack toFill = new FluidStack(nexusFluid.getFluid(), Math.min(nexusFluid.amount,
                        nexus.isHighCapacity() ?
                                ConfigValues.highCapacityFluidPickup :
                                ConfigValues.standardFluidPickup));
                int filled = inv.fill(nexusOrientation, toFill, true);
                nexus.drain(nexusOrientation, filled, true);

                if (filled != 0)
                {
                    nexus.resetCounter();
                    return;
                }
            }
        }
        attemptTeleport(nexus, nexusOrientation);
    }
}
 
開發者ID:samvbeckmann,項目名稱:network,代碼行數:33,代碼來源:ItemFluidCore.java

示例12: pour

import net.minecraftforge.fluids.IFluidHandler; //導入方法依賴的package包/類
@Override
protected void pour() {
	if(drained == null) {
		return;
	}

	EntityMinecart fillMinecart = Utils.getMinecartAt(worldObj, pos.down(), 1f);
	if(fillMinecart instanceof IFluidHandler)  {
		IFluidHandler toFill = (IFluidHandler) fillMinecart;

		FluidStack fillStack = drained.copy();
		fillStack.amount = Math.min(drained.amount, LIQUID_TRANSFER);

		// can we fill?
		int filled = toFill.fill(EnumFacing.UP, fillStack, false);
		if(filled > 0) {
			// transfer it
			this.drained.amount -= filled;
			fillStack.amount = filled;
			toFill.fill(EnumFacing.UP, fillStack, true);
		}
	}
	else {
		// filling TE got lost. reset. all liquid buffered is lost.
		reset();
	}
}
 
開發者ID:BrassGoggledCoders,項目名稱:MoarCarts,代碼行數:28,代碼來源:TileCartFaucet.java

示例13: doPull

import net.minecraftforge.fluids.IFluidHandler; //導入方法依賴的package包/類
public static boolean doPull(IFluidHandler into, ForgeDirection fromDir, int maxVolume) {
  TileEntity te = (TileEntity) into;
  BlockCoord loc = new BlockCoord(te).getLocation(fromDir);
  IFluidHandler target = FluidUtil.getFluidHandler(te.getWorldObj(), loc);
  if (target != null) {
    FluidTankInfo[] infos = target.getTankInfo(fromDir.getOpposite());
    if (infos != null) {
      for (FluidTankInfo info : infos) {
        if (info.fluid != null && info.fluid.amount > 0) {
          if (into.canFill(fromDir, info.fluid.getFluid())) {
            FluidStack canPull = info.fluid.copy();
            canPull.amount = Math.min(maxVolume, canPull.amount);
            FluidStack drained = target.drain(fromDir.getOpposite(), canPull, false);
            if (drained != null && drained.amount > 0) {
              int filled = into.fill(fromDir, drained, false);
              if (filled > 0) {
                drained = target.drain(fromDir.getOpposite(), filled, true);
                into.fill(fromDir, drained, true);
                return true;
              }
            }
          }
        }
      }
    }
  }
  return false;
}
 
開發者ID:SleepyTrousers,項目名稱:EnderCore,代碼行數:29,代碼來源:FluidUtil.java

示例14: updateEntity

import net.minecraftforge.fluids.IFluidHandler; //導入方法依賴的package包/類
@Override
public void updateEntity() {
	super.updateEntity();

	//Move a stack of items
	if(rocket != null ) {
		List<TileEntity> tiles = rocket.storage.getFluidTiles();
		boolean foundStack = false;
		boolean rocketContainsItems = false;

		//Function returns if something can be moved
		for(TileEntity tile : tiles) {
			IFluidHandler handler = (IFluidHandler)tile;

			//See if we have anything to fill because redstone output
			FluidStack stack = handler.drain(ForgeDirection.DOWN, 1, false);
			if(stack == null || handler.fill(ForgeDirection.UP, stack, false) > 0)
				rocketContainsItems = true;

			stack = fluidTank.drain(fluidTank.getCapacity(), false);
			if(stack != null && stack.amount > 0)
				fluidTank.drain(handler.fill(ForgeDirection.UP, stack, true), true);
		}

		//Update redstone state
		setRedstoneState(!rocketContainsItems);
	}
}
 
開發者ID:zmaster587,項目名稱:AdvancedRocketry,代碼行數:29,代碼來源:TileRocketFluidLoader.java

示例15: doPush

import net.minecraftforge.fluids.IFluidHandler; //導入方法依賴的package包/類
@Override
protected boolean doPush(@Nullable ForgeDirection dir) {
  if (dir == null || isSideDisabled(dir.ordinal())) {
    return false;
  }

  boolean res = super.doPush(dir);
  if (outputTank.getFluidAmount() > 0) {

    BlockCoord loc = getLocation().getLocation(dir);
    IFluidHandler target = FluidUtil.getFluidHandler(worldObj, loc);
    if (target != null) {
      if (target.canFill(dir.getOpposite(), outputTank.getFluid().getFluid())) {
        FluidStack push = outputTank.getFluid().copy();
        push.amount = Math.min(push.amount, IO_MB_TICK);
        int filled = target.fill(dir.getOpposite(), push, true);
        if (filled > 0) {
          outputTank.drain(filled, true);
          tanksDirty = true;
          return res;
        }
      }
    }

  }
  return res;
}
 
開發者ID:HenryLoenwind,項目名稱:EnderIOAddons,代碼行數:28,代碼來源:TileWaterworks.java


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