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


Java IEnergyReceiver類代碼示例

本文整理匯總了Java中cofh.api.energy.IEnergyReceiver的典型用法代碼示例。如果您正苦於以下問題:Java IEnergyReceiver類的具體用法?Java IEnergyReceiver怎麽用?Java IEnergyReceiver使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


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

示例1: sendToAllAcceptors

import cofh.api.energy.IEnergyReceiver; //導入依賴的package包/類
public void sendToAllAcceptors()
{
	Map<ForgeDirection, TileEntity> tiles = Maps.filterValues(WorldHelper.getAdjacentTileEntitiesMapped(worldObj, this), Predicates.instanceOf(IEnergyReceiver.class));

	double powerToGive = Math.min(this.getEnergyStorage().getMaxExtract(), this.getEnergyStored());
	for (Map.Entry<ForgeDirection, TileEntity> entry : tiles.entrySet())
	{
		if(powerToGive > 0){
			double powerUsed = ((IEnergyReceiver) entry.getValue()).receiveEnergy(entry.getKey().getOpposite(),(int) powerToGive, false);
			this.getEnergyStorage().extractEnergy((int) powerUsed, false);
			powerToGive -= powerUsed;
		} else{
			return;
		}
	}
}
 
開發者ID:solidDoWant,項目名稱:ExtraE,代碼行數:17,代碼來源:EMCEngineTile.java

示例2: transferEnergy

import cofh.api.energy.IEnergyReceiver; //導入依賴的package包/類
public int transferEnergy(int amount, boolean simulate)
{
    EnumFacing side = worldObj.getBlockState(pos).getValue(BlockDiode.ORIENTATION).rotateYCCW();
    TileEntity te = worldObj.getTileEntity(pos.offset(side));
    if (te == null) { return 0; }
    if (te instanceof IEnergyReceiver && ((IEnergyReceiver)te).receiveEnergy(side.getOpposite(), amount, true) > 0)
    {
        return ((IEnergyReceiver)te).receiveEnergy(side.getOpposite(), amount, simulate);
    }
    else if (RFUtilities.TESLA_LOADED && te.hasCapability(TeslaCapabilities.CAPABILITY_CONSUMER, side.getOpposite()) && te.getCapability(TeslaCapabilities.CAPABILITY_CONSUMER, side.getOpposite()).givePower(amount, true) > 0)
    {
        return (int)te.getCapability(TeslaCapabilities.CAPABILITY_CONSUMER, side.getOpposite()).givePower(amount, simulate);
    }
    else if (te.hasCapability(CapabilityEnergy.ENERGY, side.getOpposite()) && te.getCapability(CapabilityEnergy.ENERGY, side.getOpposite()).receiveEnergy(amount, true) > 0)
    {
        return te.getCapability(CapabilityEnergy.ENERGY, side.getOpposite()).receiveEnergy(amount, simulate);
    }
    return 0;
}
 
開發者ID:XFactHD,項目名稱:RFUtilities,代碼行數:20,代碼來源:TileEntityDiode.java

示例3: transferEnergy

import cofh.api.energy.IEnergyReceiver; //導入依賴的package包/類
public int transferEnergy(EnumFacing side, int amount, boolean simulate)
{
    int transfered = 0;
    TileEntity te = worldObj.getTileEntity(pos.offset(side));
    if (te == null) { return 0; }
    if (te instanceof IEnergyReceiver && ((IEnergyReceiver)te).receiveEnergy(side.getOpposite(), amount, true) > 0)
    {
        transfered = ((IEnergyReceiver)te).receiveEnergy(side.getOpposite(), amount, simulate);
    }
    else if (RFUtilities.TESLA_LOADED && te.hasCapability(TeslaCapabilities.CAPABILITY_CONSUMER, side.getOpposite()) && te.getCapability(TeslaCapabilities.CAPABILITY_CONSUMER, side.getOpposite()).givePower(amount, true) > 0)
    {
        transfered = (int)te.getCapability(TeslaCapabilities.CAPABILITY_CONSUMER, side.getOpposite()).givePower(amount, simulate);
    }
    else if (te.hasCapability(CapabilityEnergy.ENERGY, side.getOpposite()) && te.getCapability(CapabilityEnergy.ENERGY, side.getOpposite()).receiveEnergy(amount, true) > 0)
    {
        transfered = te.getCapability(CapabilityEnergy.ENERGY, side.getOpposite()).receiveEnergy(amount, simulate);
    }
    if (!simulate)
    {
        lastRF = transfered;
        addToTransfered(transfered);
    }
    return transfered;
}
 
開發者ID:XFactHD,項目名稱:RFUtilities,代碼行數:25,代碼來源:TileEntityRFMeter.java

示例4: transferEnergy

import cofh.api.energy.IEnergyReceiver; //導入依賴的package包/類
public int transferEnergy(EnumFacing side, int amount, boolean simulate)
{
    TileEntity te = worldObj.getTileEntity(pos.offset(side));
    if (!isOn || te == null) { return 0; }
    if (te instanceof IEnergyReceiver && ((IEnergyReceiver)te).receiveEnergy(side.getOpposite(), amount, true) > 0)
    {
        return ((IEnergyReceiver)te).receiveEnergy(side.getOpposite(), amount, simulate);
    }
    else if (RFUtilities.TESLA_LOADED && te.hasCapability(TeslaCapabilities.CAPABILITY_CONSUMER, side.getOpposite()) && te.getCapability(TeslaCapabilities.CAPABILITY_CONSUMER, side.getOpposite()).givePower(amount, true) > 0)
    {
        return (int)te.getCapability(TeslaCapabilities.CAPABILITY_CONSUMER, side.getOpposite()).givePower(amount, simulate);
    }
    else if (te.hasCapability(CapabilityEnergy.ENERGY, side.getOpposite()) && te.getCapability(CapabilityEnergy.ENERGY, side.getOpposite()).receiveEnergy(amount, true) > 0)
    {
        return te.getCapability(CapabilityEnergy.ENERGY, side.getOpposite()).receiveEnergy(amount, simulate);
    }
    return 0;
}
 
開發者ID:XFactHD,項目名稱:RFUtilities,代碼行數:19,代碼來源:TileEntitySwitch.java

示例5: transferEnergy

import cofh.api.energy.IEnergyReceiver; //導入依賴的package包/類
public int transferEnergy(EnumFacing side, int amount, boolean simulate)
{
    TileEntity te = worldObj.getTileEntity(pos.offset(side));
    if (te == null) { return 0; }
    if (te instanceof IEnergyReceiver && ((IEnergyReceiver)te).receiveEnergy(side.getOpposite(), amount, true) > 0)
    {
        return ((IEnergyReceiver)te).receiveEnergy(side.getOpposite(), amount, simulate);
    }
    else if (RFUtilities.TESLA_LOADED && te.hasCapability(TeslaCapabilities.CAPABILITY_CONSUMER, side.getOpposite()) && te.getCapability(TeslaCapabilities.CAPABILITY_CONSUMER, side.getOpposite()).givePower(amount, true) > 0)
    {
        return (int)te.getCapability(TeslaCapabilities.CAPABILITY_CONSUMER, side.getOpposite()).givePower(amount, simulate);
    }
    else if (te.hasCapability(CapabilityEnergy.ENERGY, side.getOpposite()) && te.getCapability(CapabilityEnergy.ENERGY, side.getOpposite()).receiveEnergy(amount, true) > 0)
    {
        return te.getCapability(CapabilityEnergy.ENERGY, side.getOpposite()).receiveEnergy(amount, simulate);
    }
    return 0;
}
 
開發者ID:XFactHD,項目名稱:RFUtilities,代碼行數:19,代碼來源:TileEntityResistor.java

示例6: transferPower

import cofh.api.energy.IEnergyReceiver; //導入依賴的package包/類
@SuppressWarnings("ConstantConditions")
private int transferPower(IBlockState state)
{
    if (!isServerWorld())
    {
        return 0;
    }
    EnumFacing side = state.getValue(BlockCapacitor.ORIENTATION).rotateYCCW();
    TileEntity te = worldObj.getTileEntity(pos.offset(side));
    if (te == null || side == null) { return 0; }
    if (te instanceof IEnergyReceiver && ((IEnergyReceiver)te).receiveEnergy(side.getOpposite(), storage.extractEnergy(storage.getMaxExtract(), true), true) > 0)
    {
        return ((IEnergyReceiver)te).receiveEnergy(side.getOpposite(), storage.extractEnergy(storage.getMaxExtract(), false), false);
    }
    else if (RFUtilities.TESLA_LOADED && te.hasCapability(TeslaCapabilities.CAPABILITY_CONSUMER, side.getOpposite()) && te.getCapability(TeslaCapabilities.CAPABILITY_CONSUMER, side.getOpposite()).givePower(storage.extractEnergy(storage.getMaxExtract(), true), true) > 0)
    {
        return (int)te.getCapability(TeslaCapabilities.CAPABILITY_CONSUMER, side.getOpposite()).givePower(storage.extractEnergy(storage.getMaxExtract(), false), false);
    }
    else if (te.hasCapability(CapabilityEnergy.ENERGY, side.getOpposite()) && te.getCapability(CapabilityEnergy.ENERGY, side.getOpposite()).receiveEnergy(storage.extractEnergy(storage.getMaxExtract(), true), true) > 0)
    {
        return te.getCapability(CapabilityEnergy.ENERGY, side.getOpposite()).receiveEnergy(storage.extractEnergy(storage.getMaxExtract(), false), false);
    }
    return 0;
}
 
開發者ID:XFactHD,項目名稱:RFUtilities,代碼行數:25,代碼來源:TileEntityCapacitor.java

示例7: receiveEnergy

import cofh.api.energy.IEnergyReceiver; //導入依賴的package包/類
@Override
public int receiveEnergy(int amount, boolean simulate)
{
    EnumFacing facing = EnumFacing.UP;
    for (int i = 0; i < 6; i++)
    {
        if (canConnectEnergy(EnumFacing.getFront(i)))
        {
            facing = EnumFacing.getFront(i);
            break;
        }
    }
    TileEntity te = worldObj.getTileEntity(pos.offset(facing));
    if (te instanceof IEnergyReceiver && (((IEnergyReceiver)te).receiveEnergy(facing.getOpposite(), amount, true)) > 0)
    {
        return (((IEnergyReceiver)te).receiveEnergy(facing.getOpposite(), amount, simulate));
    }
    return 0;
}
 
開發者ID:XFactHD,項目名稱:RFUtilities,代碼行數:20,代碼來源:TileEntityInvisibleTesseract.java

示例8: receiveEnergy

import cofh.api.energy.IEnergyReceiver; //導入依賴的package包/類
@Override
public int receiveEnergy(EnumFacing facing, int amount, boolean simulate)
{
    //if (transferOncePerTick && !wait)
    //{
    //    wait = true;
    //}

    EnumFacing opposite = facing.getOpposite();
    TileEntity te = worldObj.getTileEntity(pos.offset(opposite));
    if (canConnectEnergy(facing) && te instanceof IEnergyReceiver && (((IEnergyReceiver)te).receiveEnergy(facing, amount, true) > 0))
    {
        if (amount<=throughput)
        {
            return ((IEnergyReceiver)te).receiveEnergy(facing, amount, simulate);
        }
        else
        {
            return ((IEnergyReceiver)te).receiveEnergy(facing, throughput, simulate);
        }
    }
    else
    {
        return 0;
    }
}
 
開發者ID:XFactHD,項目名稱:RFUtilities,代碼行數:27,代碼來源:TileEntityResistor.java

示例9: receiveEnergy

import cofh.api.energy.IEnergyReceiver; //導入依賴的package包/類
@Override
public int receiveEnergy(int amount, boolean simulate)
{
    ForgeDirection fd = ForgeDirection.UNKNOWN;
    for (int i = 0; i < 6; i++)
    {
        if (canConnectEnergy(ForgeDirection.getOrientation(i)))
        {
            fd = ForgeDirection.getOrientation(i);
            break;
        }
    }
    TileEntity te = worldObj.getTileEntity(xCoord + fd.offsetX, yCoord + fd.offsetY, zCoord + fd.offsetZ);
    if (te instanceof IEnergyReceiver && (((IEnergyReceiver)te).receiveEnergy(fd.getOpposite(), amount, true)) > 0)
    {
        return (((IEnergyReceiver)te).receiveEnergy(fd.getOpposite(), amount, simulate));
    }
    return 0;
}
 
開發者ID:XFactHD,項目名稱:RFUtilities,代碼行數:20,代碼來源:TileEntityInvisibleTesseract.java

示例10: receiveEnergy

import cofh.api.energy.IEnergyReceiver; //導入依賴的package包/類
@Override
public int receiveEnergy(ForgeDirection fd, int amount, boolean simulate)
{
    //if (transferOncePerTick && !wait)
    //{
    //    wait = true;
    //}

    ForgeDirection opposite = fd.getOpposite();
    TileEntity te = worldObj.getTileEntity(xCoord + opposite.offsetX, yCoord, zCoord + opposite.offsetZ);
    if (canConnectEnergy(fd) && te instanceof IEnergyReceiver && (((IEnergyReceiver)te).receiveEnergy(fd, amount, true) > 0))
    {
        if (amount<=throughput)
        {
            return ((IEnergyReceiver)te).receiveEnergy(fd, amount, simulate);
        }
        else
        {
            return ((IEnergyReceiver)te).receiveEnergy(fd, throughput, simulate);
        }
    }
    else
    {
        return 0;
    }
}
 
開發者ID:XFactHD,項目名稱:RFUtilities,代碼行數:27,代碼來源:TileEntityResistor.java

示例11: getTargetList

import cofh.api.energy.IEnergyReceiver; //導入依賴的package包/類
protected List<EnergyConnection> getTargetList() {
	final List<EnergyConnection> targets = new ArrayList<EnergyConnection>();

	final ForgeDirection myOrientation = ForgeDirection.getOrientation(getFacing());
	final IEnergyReceiver top = getTargetReceiver(ForgeDirection.UP);
	final IEnergyReceiver bottom = getTargetReceiver(ForgeDirection.DOWN);
	final IEnergyReceiver back = getTargetReceiver(myOrientation.getOpposite());

	if (back != null)
		targets.add(new EnergyConnection(myOrientation, back));

	if (top != null)
		targets.add(new EnergyConnection(ForgeDirection.DOWN, top));

	if (bottom != null)
		targets.add(new EnergyConnection(ForgeDirection.UP, bottom));

	return targets;
}
 
開發者ID:OreCruncher,項目名稱:ThermalRecycling,代碼行數:20,代碼來源:BatteryRackTileEntity.java

示例12: get

import cofh.api.energy.IEnergyReceiver; //導入依賴的package包/類
public static EnergyAcceptorWrapper get(TileEntity tileEntity)
{
	EnergyAcceptorWrapper wrapper = null;
	
	if(tileEntity instanceof IStrictEnergyAcceptor)
	{
		wrapper = new MekanismAcceptor((IStrictEnergyAcceptor)tileEntity);
	}
	else if(MekanismUtils.useRF() && tileEntity instanceof IEnergyReceiver)
	{
		wrapper = new RFAcceptor((IEnergyReceiver)tileEntity);
	}
	else if(MekanismUtils.useIC2() && tileEntity instanceof IEnergySink)
	{
		wrapper = new IC2Acceptor((IEnergySink)tileEntity);
	}
	
	if(wrapper != null)
	{
		wrapper.coord = Coord4D.get(tileEntity);
	}
	
	return wrapper;
}
 
開發者ID:Microsoft,項目名稱:vsminecraft,代碼行數:25,代碼來源:EnergyAcceptorWrapper.java

示例13: attemptEnergyPush

import cofh.api.energy.IEnergyReceiver; //導入依賴的package包/類
public void attemptEnergyPush()
{
    TileEntity tileEntity;
    int transferred;
    for (int i=0;i<locations.length;i++)
    {
        if (battery.getEnergyStored()==0)
        {
            return;
        }

        tileEntity = worldObj.getTileEntity(locations[i].getX(),locations[i].getY(),locations[i].getZ());

        if (tileEntity!=null && tileEntity instanceof IEnergyReceiver)
        {
            transferred = ((IEnergyReceiver)tileEntity).receiveEnergy(MiscHelper.getOppositeDirectionDirection(directions[i]),Math.min(battery.getMaxExtract(),battery.getEnergyStored()),false);

            if (transferred>0)
            {
                battery.modifyEnergyStored(-transferred);
                prepareSync();
            }
        }

    }
}
 
開發者ID:M4thG33k,項目名稱:M4thThings,代碼行數:27,代碼來源:TileSolarGenerator.java

示例14: distributeEnergy

import cofh.api.energy.IEnergyReceiver; //導入依賴的package包/類
/**
 * Transfer energy to any blocks demanding energy that are connected to
 * this one.
 */
protected void distributeEnergy() {
	if (MachineUtils.canFunction(this)) {
		for (ForgeDirection direction : getExtractingDirections()) {
			TileEntity tileEntity = worldObj.getTileEntity(xCoord + direction.offsetX, yCoord + direction.offsetY, zCoord + direction.offsetZ);

			if (tileEntity instanceof IEnergyReceiver) {
				IEnergyReceiver receiver = (IEnergyReceiver) tileEntity;
				int actualEnergyAmount = extractEnergy(direction, getExtract(), true);

				if (actualEnergyAmount > 0) {
					extractEnergy(direction, receiver.receiveEnergy(direction.getOpposite(), actualEnergyAmount, false), false);
				}
			}
		}
	}
}
 
開發者ID:halvors,項目名稱:Electrometrics,代碼行數:21,代碼來源:TileEntityElectricityProvider.java

示例15: distributeEnergy

import cofh.api.energy.IEnergyReceiver; //導入依賴的package包/類
@Override
protected void distributeEnergy() {
	for (ForgeDirection direction : getExtractingDirections()) {
		TileEntity tileEntity = worldObj.getTileEntity(xCoord + direction.offsetX, yCoord + direction.offsetY, zCoord + direction.offsetZ);

		if (tileEntity != null) {
			if (tileEntity instanceof IEnergyReceiver) {
				int actualEnergyAmount = extractEnergy(direction, getExtract(), true);

				if (!MachineUtils.canFunction(this) || actualEnergyAmount <= 0) {
					setActive(false);
				}
			}
		} else {
			setActive(false);
		}
	}

	super.distributeEnergy();
}
 
開發者ID:halvors,項目名稱:Electrometrics,代碼行數:21,代碼來源:TileEntityElectricityMeter.java


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