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


Java IFluidHandler.getTankInfo方法代碼示例

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


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

示例1: updateFluidHandlers

import net.minecraftforge.fluids.IFluidHandler; //導入方法依賴的package包/類
void updateFluidHandlers() {
    for (int i = 0; i < 6; i++) {
        BlockPos c = BlockPos.offset(getBlockPos(), ForgeDirection.getOrientation(i));
        TileEntity tile = WorldUtilities.getTileEntity(getWorldObj(), c);

        if (tile != null && tile instanceof IFluidHandler) {
            IFluidHandler fluid = (IFluidHandler) tile;

            if (fluid.getTankInfo(ForgeDirection.getOrientation(i).getOpposite()) != null)
                handlers[i] = fluid;
            else
                handlers[i] = null;
        } else
            handlers[i] = null;
    }

    cached = true;
}
 
開發者ID:enhancedportals,項目名稱:enhancedportals,代碼行數:19,代碼來源:TileTransferFluid.java

示例2: applyPlayerContainerInteraction

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

        final ItemStack stack = player.getCurrentEquippedItem();
        if(stack == null || !FluidContainerRegistry.isContainer(stack))
        	return false;

		boolean update = false;
		final IFluidHandler handler = (IFluidHandler)entity;
		
		// Get the fluid from the item.  If there is one they are trying
		// to fill.  Otherwise they are trying to remove.
        FluidStack liquid = FluidContainerRegistry.getFluidForFilledItem(stack);
        if(liquid != null) {
        	update = FluidHelper.fillHandlerWithContainer(world, handler, player);
        }
        else {
        	liquid = handler.getTankInfo(ForgeDirection.UNKNOWN)[0].fluid;
        	update = FluidHelper.fillContainerFromHandler(world, handler, player, liquid);
        }

        if(update)
            world.markBlockForUpdate(entity.xCoord, entity.yCoord, entity.zCoord);
		
		return update;
	}
 
開發者ID:OreCruncher,項目名稱:ThermalRecycling,代碼行數:26,代碼來源:FluidStackHelper.java

示例3: isValidAcceptorOnSide

import net.minecraftforge.fluids.IFluidHandler; //導入方法依賴的package包/類
public static boolean isValidAcceptorOnSide(TileEntity tile, ForgeDirection side)
{
	if(tile instanceof ITransmitterTile || !(tile instanceof IFluidHandler))
		return false;

	IFluidHandler container = (IFluidHandler)tile;
	FluidTankInfo[] infoArray = container.getTankInfo(side.getOpposite());

	if(container.canDrain(side.getOpposite(), FluidRegistry.WATER)
		|| container.canFill(side.getOpposite(), FluidRegistry.WATER)) //I hesitate to pass null to these.
	{
		return true;
	}
	else if(infoArray != null && infoArray.length > 0)
	{
		for(FluidTankInfo info : infoArray)
		{
			if(info != null)
			{
				return true;
			}
		}
	}
	return false;
}
 
開發者ID:Microsoft,項目名稱:vsminecraft,代碼行數:26,代碼來源:PipeUtils.java

示例4: tryClearDirectionalTraffic

import net.minecraftforge.fluids.IFluidHandler; //導入方法依賴的package包/類
/**
 * Method once called will attempt to resolve the 'last received direction' if applicable.
 *
 * @param sourceCont container requesting fluid.
 * @param world world object as reference.
 * @param blockPos BlockPosition.
 * @param lastDir last direction received from (prevent continuous looping).
 */
public static void tryClearDirectionalTraffic(IFluidHandler sourceCont, World world, BlockPos blockPos, EnumFacing lastDir) {
	boolean shouldSend = false;

	final BlockPos pos = BlockUtils.createBlockPos(blockPos.getX() + lastDir.getFrontOffsetX(), blockPos.getY() + lastDir.getFrontOffsetY(),
			blockPos.getZ() + lastDir.getFrontOffsetZ());
	final TileEntity te = world.getTileEntity(pos);
	IFluidHandler cont = null;
	if (te != null && te instanceof IFluidContainer) cont = (IFluidContainer) te;
	if (cont == null || sourceCont.getTankInfo(lastDir)[0] == null || sourceCont.getTankInfo(lastDir)[0].fluid == null || sourceCont.getTankInfo(lastDir)[0].fluid.amount == 0) {
		shouldSend = true;
		clearDirectionalTraffic((IFluidContainer) sourceCont);
	}

	else if (cont instanceof TileEntityLiquiductBase && ((TileEntityLiquiductBase) cont).getLastReceivedDirection().getOpposite() == lastDir) {
		
		if ((((TileEntityLiquiductBase) sourceCont).getFluidID() != ((TileEntityLiquiductBase) cont).getFluidID())
				|| (((TileEntityLiquiductBase) sourceCont).getFluidID() == ((TileEntityLiquiductBase) cont).getFluidID() && ((TileEntityLiquiductBase) sourceCont)
						.getTank().getFluidAmount() <= ((TileEntityLiquiductBase) cont).getTank().getFluidAmount())) {
		
			shouldSend = true;
			clearDirectionalTraffic((IFluidContainer) sourceCont);
		}
	}
}
 
開發者ID:hockeyhurd,項目名稱:Project-Zed,代碼行數:33,代碼來源:FluidNet.java

示例5: isContainerValid

import net.minecraftforge.fluids.IFluidHandler; //導入方法依賴的package包/類
/**
 * Simple function to determine whether a fluid container is valid (has something) or invalid (has nothing).
 *
 * @param cont container to reference.
 * @param world world as reference of existance.
 * @return true if has something relavent, else returns false.
 */
public static boolean isContainerValid(IFluidHandler cont, World world) {
	boolean flag = false;

	if (cont != null) {
		for (EnumFacing dir : EnumFacing.VALUES) {
			if (cont.getTankInfo(dir) != null && cont.getTankInfo(dir).length > 0) {
				for (int i = 0; i < cont.getTankInfo(dir).length; i++) {
					if (cont.getTankInfo(dir)[i] != null && cont.getTankInfo(dir)[i].fluid != null && cont.getTankInfo(dir)[i].fluid.amount > 0) {
						flag = true;
						break;
					}
				}

				if (flag) break;
			}
		}
	}

	return flag;
}
 
開發者ID:hockeyhurd,項目名稱:Project-Zed,代碼行數:28,代碼來源:FluidNet.java

示例6: 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

示例7: drain

import net.minecraftforge.fluids.IFluidHandler; //導入方法依賴的package包/類
@Override
public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) {
	IFluidHandler handler = this.getFluidTankInDirection(ForgeDirection.UP);

	FluidStack stack = null;
	if(handler != null && handler.getTankInfo(ForgeDirection.UNKNOWN)[0].fluid != null && 
			fluidTank.getFluid() != null && fluidTank.getFluid().getFluidID() ==
			handler.getTankInfo(ForgeDirection.UNKNOWN)[0].fluid.getFluidID()) {

		stack = handler.drain(from, maxDrain, doDrain);
	}
	
	if(stack != null)
		return stack;

	FluidStack stack2 = super.drain(from, maxDrain - (stack != null ? stack.amount : 0), doDrain);

	if(stack != null && stack2 != null)
		stack2.amount += stack.amount;

	
	if(stack2 != null && doDrain) {
		fluidChanged = true;
	}
	checkForUpdate();
	
	
	return stack2;
}
 
開發者ID:zmaster587,項目名稱:AdvancedRocketry,代碼行數:30,代碼來源:TileFluidTank.java

示例8: useBucket

import net.minecraftforge.fluids.IFluidHandler; //導入方法依賴的package包/類
@Override
protected boolean useBucket(int slot, ItemStack stack) {
	boolean bucketUsed = super.useBucket(slot, stack);

	if(bucketUsed) {
		IFluidHandler handler = getFluidTankInDirection(ForgeDirection.DOWN);
		if(handler != null) {
			FluidStack othertank = handler.getTankInfo(ForgeDirection.UNKNOWN)[0].fluid;
			if(othertank == null || (othertank.amount < handler.getTankInfo(ForgeDirection.UNKNOWN)[0].capacity))
				fluidTank.drain(handler.fill(ForgeDirection.UNKNOWN, fluidTank.getFluid(), true),true);
		}
	}

	return bucketUsed;
}
 
開發者ID:zmaster587,項目名稱:AdvancedRocketry,代碼行數:16,代碼來源:TileFluidTank.java

示例9: renderTileEntityAt

import net.minecraftforge.fluids.IFluidHandler; //導入方法依賴的package包/類
@Override
public void renderTileEntityAt(TileEntity tile, double x,
		double y, double z, float p_147500_8_) {

	IFluidHandler fluidTile = (IFluidHandler)tile;
	FluidStack fluid = fluidTile.getTankInfo(ForgeDirection.UNKNOWN)[0].fluid;


	if(fluid != null && fluid.getFluid() != null)
	{
		GL11.glPushMatrix();

		GL11.glTranslatef((float)x, (float)y, (float)z);

		IIcon icon = fluid.getFluid().getIcon();
		Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture);
		
		int color = fluid.getFluid().getColor();
		GL11.glColor4f(((color >>> 16) & 0xFF)/255f, ((color >>> 8) & 0xFF)/255f, ((color& 0xFF)/255f),1f);
		
		Block block = tile.getBlockType();
		Tessellator tess = Tessellator.instance;

		float amt = fluid.amount / (float)fluidTile.getTankInfo(ForgeDirection.UNKNOWN)[0].capacity;
		
		GL11.glEnable(GL11.GL_BLEND);
		GL11.glDisable(GL11.GL_LIGHTING);
		
		GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
		
		tess.startDrawingQuads();
		RenderHelper.renderCubeWithUV(tess, block.getBlockBoundsMinX() + 0.01, block.getBlockBoundsMinY() + 0.01, block.getBlockBoundsMinZ() + 0.01, block.getBlockBoundsMaxX() - 0.01, block.getBlockBoundsMaxY()*amt - 0.01, block.getBlockBoundsMaxZ() - 0.01, icon.getMinU(), icon.getMaxU(), icon.getMinV(), icon.getMaxV());
		tess.draw();

		GL11.glEnable(GL11.GL_LIGHTING);
		GL11.glDisable(GL11.GL_BLEND);
		GL11.glPopMatrix();
		GL11.glColor3f(1f, 1f, 1f);
	}
}
 
開發者ID:zmaster587,項目名稱:AdvancedRocketry,代碼行數:41,代碼來源:RenderTank.java

示例10: containsFluid

import net.minecraftforge.fluids.IFluidHandler; //導入方法依賴的package包/類
/**
 * Static method to check if container/tank contains any fluid.
 * 
 * @param container cotnainer/tank to check.
 * @return true if has any fluid, else returns false.
 */
public static boolean containsFluid(IFluidHandler container) {
	if (container != null) {
		for (EnumFacing dir : EnumFacing.VALUES) {
			if (container.getTankInfo(dir) != null) {
				for (FluidTankInfo info : container.getTankInfo(dir)) {
					if (info.fluid != null && info.fluid.amount > 0) return true;
				}
			}
		}
	}
	
	return false;
}
 
開發者ID:hockeyhurd,項目名稱:Project-Zed,代碼行數:20,代碼來源:FluidNode.java

示例11: getAmountFromTank

import net.minecraftforge.fluids.IFluidHandler; //導入方法依賴的package包/類
private int getAmountFromTank(IFluidHandler tank, FluidStack stack, EnumFacing dir) {
	if (tank != null && stack != null && stack.amount > 0 && dir != null && tank.getTankInfo(dir) != null &&tank.getTankInfo(dir).length > 0) {
		for (int i = 0; i < tank.getTankInfo(dir).length; i++) {
			if (tank.getTankInfo(dir)[i].fluid != null && tank.getTankInfo(dir)[i].fluid.amount > 0
					&& tank.getTankInfo(dir)[i].fluid.isFluidEqual(stack)) return tank.getTankInfo(dir)[i].fluid.amount; 
		}
	}
	
	return 0;
}
 
開發者ID:hockeyhurd,項目名稱:Project-Zed,代碼行數:11,代碼來源:TileEntityFluidTankBase.java

示例12: getTankInfo

import net.minecraftforge.fluids.IFluidHandler; //導入方法依賴的package包/類
public FluidTankInfo[] getTankInfo(IFluidHandler tank)
{
	if (tank != null)
	{
		if (tank.getTankInfo(facing) != null && tank.getTankInfo(facing).length != 0)
		{
			return tank.getTankInfo(facing);
		} else if (tank.getTankInfo(ForgeDirection.UNKNOWN) != null && tank.getTankInfo(ForgeDirection.UNKNOWN).length != 0)
		{
			return tank.getTankInfo(ForgeDirection.UNKNOWN);
		}
	}
	return null;
}
 
開發者ID:ExtraCells,項目名稱:ExtraCells1,代碼行數:15,代碼來源:FluidBusInventoryHandler.java

示例13: transferFluid

import net.minecraftforge.fluids.IFluidHandler; //導入方法依賴的package包/類
@LuaFunction
public int transferFluid(String source, ForgeDirection sourceSide, int sourceTankId, String target, ForgeDirection targetSide, int amount) throws Exception {
	sourceTankId--;

	if (!posByName.containsKey(source)) {
		throw new Exception("Invalid source '" + source + "'. Not specified, use setName(x,y,z,name) first.");
	}

	if (!posByName.containsKey(target)) {
		throw new Exception("Invalid target '" + target + "'. Not specified, use setName(x,y,z,name) first.");
	}

	if (amount <= 0) {
		throw new Exception("At least 1mb needs to be transferred.");
	}

	RelativePos sourcePos = posByName.get(source);
	TileEntity sourceTile = worldObj.getTileEntity(xCoord + sourcePos.x, yCoord + sourcePos.y, zCoord + sourcePos.z);
	if (!(sourceTile instanceof IFluidHandler)) {
		throw new Exception("Source tile is no fluid handler.");
	}

	RelativePos targetPos = posByName.get(target);
	TileEntity targetTile = worldObj.getTileEntity(xCoord + targetPos.x, yCoord + targetPos.y, zCoord + targetPos.z);
	if (!(targetTile instanceof IFluidHandler)) {
		throw new Exception("Target tile is no fluid handler.");
	}

	IFluidHandler sourceHandler = (IFluidHandler) sourceTile;
	FluidTankInfo sourceTankInfos[] = sourceHandler.getTankInfo(sourceSide);
	if (sourceTankInfos.length == 0) {
		return 0;
	}

	if (sourceTankId >= sourceTankInfos.length) {
		throw new Exception("Source tile has no tank " + sourceTankId + " on side '" + sourceSide + "'.");
	}

	FluidTankInfo sourceTankInfo = sourceTankInfos[sourceTankId];
	if (sourceTankInfo.fluid == null) {
		return 0;
	}

	FluidStack sourceFluid = sourceTankInfo.fluid.copy();

	if (sourceHandler.canDrain(sourceSide, sourceFluid.getFluid())) {
		sourceFluid.amount = amount;
		FluidStack sourceDrainageSim = sourceHandler.drain(sourceSide, sourceFluid, false);
		if (sourceDrainageSim.amount > 0) {
			// Drain simulation successful

			IFluidHandler targetHandler = (IFluidHandler) targetTile;
			if (targetHandler.canFill(targetSide, sourceFluid.getFluid())) {
				int filledSim = targetHandler.fill(targetSide, sourceDrainageSim, false);
				if (filledSim > 0) {
					// Fill simulation successful

					FluidStack sourceDrainage = sourceHandler.drain(sourceSide, sourceFluid, true);
					int filled = targetHandler.fill(targetSide, sourceDrainage, true);
					sourceTile.markDirty();
					targetTile.markDirty();
					return filled;
				}
			}
		}
	}

	return 0;
}
 
開發者ID:thraaawn,項目名稱:CCFactoryManager,代碼行數:70,代碼來源:TileEntityFactoryController.java

示例14: getTankInfo

import net.minecraftforge.fluids.IFluidHandler; //導入方法依賴的package包/類
@ScriptCallable(returnTypes = ReturnType.TABLE, description = "A table of tanks will be returned, each with a table of information")
public FluidTankInfo[] getTankInfo(IFluidHandler fluidHandler,
		@Optionals @Arg(name = "direction", description = "The internal direction of the tank. If you're not sure, use 'unknown' (north, south, east, west, up, down or unknown)") ForgeDirection direction) {
	return fluidHandler.getTankInfo(direction != null? direction : ForgeDirection.UNKNOWN);
}
 
開發者ID:OpenMods,項目名稱:OpenPeripheral-Integration,代碼行數:6,代碼來源:AdapterFluidHandler.java

示例15: pushFluid

import net.minecraftforge.fluids.IFluidHandler; //導入方法依賴的package包/類
public void pushFluid()
{
	int sideAttached = worldObj.getBlockMetadata(xCoord, yCoord, zCoord) ^ 1;
 if(this.tank.getFluidAmount()>= 1000)
 	{
 		lastDir[worldObj.getBlockMetadata(xCoord, yCoord, zCoord)] = 0;
 		for(int ix = 0; ix < 6; ix++)
 		{
 			if(lastDir[0] == 0 && lastDir[1] == 0 &&  lastDir[2] == 0 && lastDir[3] == 0 && lastDir[4] == 0 && lastDir[5] == 0)
 			{
 				
 				lastDir[0] = 1;
 				lastDir[1] = 1;
 				lastDir[2] = 1;
 				lastDir[3] = 1;
 				lastDir[4] = 1;
 				lastDir[5] = 1;
 				lastDir[worldObj.getBlockMetadata(xCoord, yCoord, zCoord)] = 0;
 			}
 			ForgeDirection dir = ForgeDirection.getOrientation(ix);
 			if(lastDir[ix] == 0 || worldObj.getTileEntity(xCoord+dir.offsetX, yCoord+dir.offsetY, zCoord+dir.offsetZ) == null || !(worldObj.getTileEntity(xCoord+dir.offsetX, yCoord+dir.offsetY, zCoord+dir.offsetZ) instanceof IFluidHandler))
  			{
  				lastDir[ix] = 0;
  				continue;
  			}
 			else if(worldObj.getTileEntity(xCoord+dir.offsetX, yCoord+dir.offsetY, zCoord+dir.offsetZ) != null && worldObj.getTileEntity(xCoord+dir.offsetX, yCoord+dir.offsetY, zCoord+dir.offsetZ) instanceof IFluidHandler)
 			{
 				try
  			{
  				IFluidHandler tile = (IFluidHandler) (worldObj.getTileEntity(xCoord+dir.offsetX, yCoord+dir.offsetY, dir.offsetZ+zCoord));
  				if(tile.canFill(dir, this.tank.getFluid().getFluid())   && this.canDrain(dir.getOpposite(), tank.getFluid().getFluid()))
  				{
  					if(!(tile instanceof TileEntityTank) && tile.getTankInfo(dir)[0]!=null && tile.getTankInfo(dir)[0].fluid != null)
  					{
  						if(tile.getTankInfo(dir)[0].fluid.amount+this.transferAmount <= tile.getTankInfo(dir)[0].capacity)
  						{
  							tile.fill(dir, this.drain(dir.getOpposite(), new FluidStack(tank.getFluid().getFluid(), this.transferAmount), true), true);
  							lastDir[ix] = 0;
  						}
  					}
  					else
  					{
  						lastDir[ix] = 0;
  						tile.fill(dir, this.drain(dir.getOpposite(), new FluidStack(tank.getFluid().getFluid(), this.transferAmount), true), true);
  					}
  				}
  			}
  			catch(Exception e)
  			{
  				
  			}
 			}
 		}
	}
}
 
開發者ID:Sudwood,項目名稱:AdvancedUtilities,代碼行數:56,代碼來源:TileEntitySplitterFluidTube.java


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