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


Java ITeslaProducer.takePower方法代码示例

本文整理汇总了Java中net.darkhax.tesla.api.ITeslaProducer.takePower方法的典型用法代码示例。如果您正苦于以下问题:Java ITeslaProducer.takePower方法的具体用法?Java ITeslaProducer.takePower怎么用?Java ITeslaProducer.takePower使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.darkhax.tesla.api.ITeslaProducer的用法示例。


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

示例1: consumePowerFromAllFaces

import net.darkhax.tesla.api.ITeslaProducer; //导入方法依赖的package包/类
/**
 * Attempts to consume power from all producers touching the given BlockPos.
 *
 * @param world The world that this is happening in.
 * @param pos The position to search around.
 * @param amount The amount of power to request from each individual face.
 * @param simulated Whether or not this is being ran as part of a simulation.
 * @return The amount of power that was successfully consumed.
 */
public static long consumePowerFromAllFaces (World world, BlockPos pos, long amount, boolean simulated) {

    long recievedPower = 0L;

    for (final ITeslaProducer producer : getConnectedCapabilities(TeslaCapabilities.CAPABILITY_PRODUCER, world, pos)) {
        recievedPower += producer.takePower(amount, simulated);
    }

    return recievedPower;
}
 
开发者ID:Darkhax-Minecraft,项目名称:Tesla,代码行数:20,代码来源:TeslaUtils.java

示例2: tryPushEnergy

import net.darkhax.tesla.api.ITeslaProducer; //导入方法依赖的package包/类
/** Provide (push-only) adjacent energy */
public static void tryPushEnergy(TileEntityRF origin) {
	TileEntity adjacent;
	ITeslaProducer producer;
	ITeslaConsumer consumer;
	long calc;
	for(EnumFacing face : EnumFacing.values()) {
		// make sure the tile exists and isn't another export bus / LE generator
		if((adjacent = origin.getWorld().getTileEntity(origin.getPos().offset(face))) != null && 
				!(adjacent instanceof TileEntityRF)) {
			
			EnumFacing swap = face.getOpposite();
			
			// only push energy, unlike the RF handler
			if(origin.hasCapability(TeslaCapabilities.CAPABILITY_PRODUCER, face) && 
					adjacent.hasCapability(TeslaCapabilities.CAPABILITY_CONSUMER, swap)) {
				producer = origin.getCapability(TeslaCapabilities.CAPABILITY_PRODUCER, face);
				consumer = adjacent.getCapability(TeslaCapabilities.CAPABILITY_CONSUMER, swap);
			} else {
				continue; // nothing to do here
			}

			// make sure the operation is valid, then do it
			if((calc = producer.takePower(Long.MAX_VALUE, true)) > 0) {
				if(consumer.givePower(Long.MAX_VALUE, true) > 0) {
					long realTesla = consumer.givePower(calc, false);
					producer.takePower(realTesla, false);
				}
			}
		}
	}
}
 
开发者ID:sblectric,项目名称:LightningCraft,代码行数:33,代码来源:TeslaUtils.java

示例3: update

import net.darkhax.tesla.api.ITeslaProducer; //导入方法依赖的package包/类
@Override
public void update()
{
	if (attachedTile == null)
	{
		getAttachedTile();
	}
	
	if (connectedCoils != null)
	{
		IBlockState state = world.getBlockState(pos);
		EnumFacing facing = state.getValue(BlockTeslaCoil.FACING);
		
		ITeslaHolder holder = attachedTile.getCapability(TeslaCapabilities.CAPABILITY_HOLDER, facing.getOpposite()); 
				
		if (hasConnectedCapability(TeslaCapabilities.CAPABILITY_CONSUMER) && 
				attachedTile.hasCapability(TeslaCapabilities.CAPABILITY_PRODUCER, facing.getOpposite()) && 
				holder.getStoredPower() > 0)
		{
			List<ITeslaConsumer> consumers = getConnectedCapabilities(TeslaCapabilities.CAPABILITY_CONSUMER);
			ITeslaProducer producer = attachedTile.getCapability(TeslaCapabilities.CAPABILITY_PRODUCER, facing.getOpposite());
			
			for(ITeslaConsumer consumer : consumers)
			{
				producer.takePower(consumer.givePower(producer.takePower(Config.teslaCoilTransferRate, true), false), false);
			}
           }
	}
}
 
开发者ID:gunnerwolf,项目名称:TeslaCoils,代码行数:30,代码来源:TileEntityTeslarract.java

示例4: consumePowerFromAllFaces

import net.darkhax.tesla.api.ITeslaProducer; //导入方法依赖的package包/类
/**
 * Attempts to consume power from all producers touching the given BlockPos.
 * 
 * @param world The world that this is happening in.
 * @param pos The position to search around.
 * @param amount The amount of power to request from each individual face.
 * @param simulated Whether or not this is being ran as part of a simulation.
 * @return The amount of power that was successfully consumed.
 */
public static long consumePowerFromAllFaces (World world, BlockPos pos, long amount, boolean simulated) {
    
    long recievedPower = 0L;
    
    for (final ITeslaProducer producer : getConnectedCapabilities(TeslaCapabilities.CAPABILITY_PRODUCER, world, pos))
        recievedPower += producer.takePower(amount, simulated);
        
    return recievedPower;
}
 
开发者ID:Herobone,项目名称:HeroUtils,代码行数:19,代码来源:TeslaUtils.java


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