當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。