当前位置: 首页>>代码示例>>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;未经允许,请勿转载。