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


Java IFluidHandler类代码示例

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


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

示例1: addData

import net.minecraftforge.fluids.IFluidHandler; //导入依赖的package包/类
@Override
public void addData(final Object tile, final List<String> data, final ForgeDirection side, final EntityPlayer player) {
    final FluidTankInfo[] tanks = ((IFluidHandler)tile).getTankInfo(side);
    if (tanks != null) {
        if (tanks.length == 1) {
            if (tanks[0].fluid != null && tanks[0].fluid.amount > 0) {
                data.add("Fluid Tank: " + tanks[0].fluid.getFluid().getLocalizedName(tanks[0].fluid) + " - " + tanks[0].fluid.amount + " / " + tanks[0].capacity);
            }
            else {
                data.add("Fluid Tank: Empty - 0 / " + tanks[0].capacity);
            }
        }
        else {
            for (int i = 0; i < tanks.length; ++i) {
                if (tanks[i].fluid != null && tanks[i].fluid.amount > 0) {
                    data.add("Fluid Tank " + i + ": " + tanks[i].fluid.getFluid().getLocalizedName(tanks[i].fluid) + " - " + tanks[i].fluid.amount + " / " + tanks[i].capacity);
                }
                else {
                    data.add("Fluid Tank " + i + ": Empty - 0 / " + tanks[i].capacity);
                }
            }
        }
    }
}
 
开发者ID:sameer,项目名称:ExtraUtilities,代码行数:25,代码来源:ScannerRegistry.java

示例2: detectInventories

import net.minecraftforge.fluids.IFluidHandler; //导入依赖的package包/类
public void detectInventories() {
    this.inventoryMask = 0;
    this.fluidMask = 0;
    this.upgrades = new boolean[16];
    for (int i = 0; i < 6; ++i) {
        final int x = this.xCoord + Facing.offsetsXForSide[i];
        final int y = this.yCoord + Facing.offsetsYForSide[i];
        final int z = this.zCoord + Facing.offsetsZForSide[i];
        final TileEntity tile = this.worldObj.getTileEntity(x, y, z);
        if (tile instanceof IInventory) {
            this.inventoryMask |= 1 << i;
        }
        if (tile instanceof IFluidHandler) {
            this.fluidMask |= 1 << i;
        }
        if (this.worldObj.getBlock(x, y, z) == ExtraUtils.enderQuarryUpgrade) {
            this.upgrades[this.worldObj.getBlockMetadata(x, y, z)] = true;
        }
    }
}
 
开发者ID:sameer,项目名称:ExtraUtilities,代码行数:21,代码来源:TileEntityEnderQuarry.java

示例3: isValidTileEntity

import net.minecraftforge.fluids.IFluidHandler; //导入依赖的package包/类
public static boolean isValidTileEntity(final TileEntity inv, final int side) {
    if (inv == null) {
        return false;
    }
    final ForgeDirection forgeSide = ForgeDirection.getOrientation(side);
    final String classname = inv.getClass().toString();
    if (classname.contains("thermalexpansion") && classname.contains("conduit")) {
        return false;
    }
    if (inv instanceof IFluidHandler) {
        final FluidTankInfo[] t = ((IFluidHandler)inv).getTankInfo(forgeSide);
        if (t != null && t.length != 0) {
            return true;
        }
    }
    if (inv instanceof IInventory && ((IInventory)inv).getSizeInventory() > 0) {
        if (!(inv instanceof ISidedInventory)) {
            return true;
        }
        final int[] t2 = ((ISidedInventory)inv).getAccessibleSlotsFromSide(side);
        if (t2 != null && t2.length != 0) {
            return true;
        }
    }
    return isRFEnergy(inv, forgeSide);
}
 
开发者ID:sameer,项目名称:ExtraUtilities,代码行数:27,代码来源:TNHelper.java

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

示例5: onBlockActivated

import net.minecraftforge.fluids.IFluidHandler; //导入依赖的package包/类
public boolean onBlockActivated(final World worldObj, final int x, final int y, final int z, final EntityPlayer player, final int side, final float dx, final float dy, final float dz) {
    if (worldObj.isRemote) {
        return true;
    }
    final TileEntity tile = worldObj.getTileEntity(x, y, z);
    if (player.getCurrentEquippedItem() != null && tile instanceof IFluidHandler) {
        final ItemStack item = player.getCurrentEquippedItem();
        final FluidStack fluid = FluidContainerRegistry.getFluidForFilledItem(item);
        if (fluid != null && ((IFluidHandler)tile).fill(ForgeDirection.getOrientation(side), fluid, false) == fluid.amount) {
            ((IFluidHandler)tile).fill(ForgeDirection.getOrientation(side), fluid, true);
            if (!player.capabilities.isCreativeMode) {
                player.setCurrentItemOrArmor(0, item.getItem().getContainerItem(item));
            }
            return true;
        }
    }
    player.openGui((Object)ExtraUtilsMod.instance, 0, worldObj, x, y, z);
    return true;
}
 
开发者ID:sameer,项目名称:ExtraUtilities,代码行数:20,代码来源:BlockGenerator.java

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

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

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

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

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

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

示例12: getConnectedAcceptors

import net.minecraftforge.fluids.IFluidHandler; //导入依赖的package包/类
/**
 * Gets all the acceptors around a tile entity.
 * @param tileEntity - center tile entity
 * @return array of IFluidHandlers
 */
public static IFluidHandler[] getConnectedAcceptors(TileEntity tileEntity)
{
	IFluidHandler[] acceptors = new IFluidHandler[] {null, null, null, null, null, null};

	for(ForgeDirection orientation : ForgeDirection.VALID_DIRECTIONS)
	{
		TileEntity acceptor = Coord4D.get(tileEntity).getFromSide(orientation).getTileEntity(tileEntity.getWorldObj());

		if(acceptor instanceof IFluidHandler && !(acceptor instanceof ITransmitterTile))
		{
			acceptors[orientation.ordinal()] = (IFluidHandler)acceptor;
		}
	}

	return acceptors;
}
 
开发者ID:Microsoft,项目名称:vsminecraft,代码行数:22,代码来源:PipeUtils.java

示例13: absorbBuffer

import net.minecraftforge.fluids.IFluidHandler; //导入依赖的package包/类
@Override
public void absorbBuffer(IGridTransmitter<IFluidHandler, FluidNetwork> transmitter)
{
	Object b = transmitter.getBuffer();
	if(!(b instanceof FluidStack) || ((FluidStack)b).getFluid() == null || ((FluidStack)b).amount == 0)
	{
		return;
	}

	FluidStack fluid = (FluidStack)b;

	if(buffer == null || buffer.getFluid() == null || buffer.amount == 0)
	{
		buffer = fluid.copy();
		return;
	}

	if(!fluid.isFluidEqual(buffer)) Mekanism.logger.warn("Fluid type " + fluid.getFluid().getName() + " of buffer doesn't match type " + buffer.getFluid().getName() + " of absorbing network");

	buffer.amount += fluid.amount;
	fluid.amount = 0;
}
 
开发者ID:Microsoft,项目名称:vsminecraft,代码行数:23,代码来源:FluidNetwork.java

示例14: getTypes

import net.minecraftforge.fluids.IFluidHandler; //导入依赖的package包/类
private ArrayList<String> getTypes(RelativePos pos) throws Exception {
	TileEntity tile = worldObj.getTileEntity(xCoord + pos.x, yCoord + pos.y, zCoord + pos.z);
	if (tile == null) {
		throw new Exception("Not a valid target!");
	}

	ArrayList<String> types = new ArrayList<String>();
	if (tile instanceof IInventory) {
		types.add("item");
	}
	if (tile instanceof IFluidHandler) {
		types.add("fluid");
	}
	if (tile instanceof IEnergyProvider) {
		types.add("energy-provider");
	}
	if (tile instanceof IEnergyReceiver) {
		types.add("energy-receiver");
	}

	return types;
}
 
开发者ID:thraaawn,项目名称:CCFactoryManager,代码行数:23,代码来源:TileEntityFactoryController.java

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


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