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


Java ITeslaConsumer类代码示例

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


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

示例1: update

import net.darkhax.tesla.api.ITeslaConsumer; //导入依赖的package包/类
@Override
public void update() {
    if (inventory[0] != null && inventory[0].hasCapability(TeslaCapabilities.CAPABILITY_CONSUMER, EnumFacing.DOWN) &&
            inventory[0].hasCapability(TeslaCapabilities.CAPABILITY_HOLDER, EnumFacing.DOWN)) {
        ITeslaConsumer c = inventory[0].getCapability(TeslaCapabilities.CAPABILITY_CONSUMER, EnumFacing.DOWN);
        ITeslaHolder h = inventory[0].getCapability(TeslaCapabilities.CAPABILITY_HOLDER, EnumFacing.DOWN);
        if (h.getStoredPower() < h.getCapacity()) container.takePower(c.givePower(Math.min(container.getOutputRate(), container.getStoredPower()), false), false);
    }
    if(syncTick==10 && !worldObj.isRemote){
        if(pos!=null){
            int dim = 0;
            for(int i : DimensionManager.getIDs())
                if(DimensionManager.getWorld(i).equals(worldObj)) {
                    dim = i;
                    break;
                }
            ModSquad.channel.sendToAll(new TileDataSync(pos, serializeNBT().toString(), dim));
        }
        syncTick = 0;
    }else if(syncTick<10) ++syncTick;
}
 
开发者ID:tjkenmate,项目名称:TeslaEssentials,代码行数:22,代码来源:TileCharger.java

示例2: preInit

import net.darkhax.tesla.api.ITeslaConsumer; //导入依赖的package包/类
@EventHandler
public void preInit (FMLPreInitializationEvent event) {
    
    CapabilityManager.INSTANCE.register(ITeslaConsumer.class, new CapabilityTeslaConsumer<ITeslaConsumer>(), BaseTeslaContainer.class);
    CapabilityManager.INSTANCE.register(ITeslaProducer.class, new CapabilityTeslaProducer<ITeslaProducer>(), BaseTeslaContainer.class);
    CapabilityManager.INSTANCE.register(ITeslaHolder.class, new CapabilityTeslaHolder<ITeslaHolder>(), BaseTeslaContainer.class);
}
 
开发者ID:Herobone,项目名称:HeroUtils,代码行数:8,代码来源:Tesla.java

示例3: outputToTile

import net.darkhax.tesla.api.ITeslaConsumer; //导入依赖的package包/类
public void outputToTile() {
	if(metaphaser.getTankConfig().getFluidAmount() <= 0) {
		return;
	}

	BlockPos outsidePos = metaphaser.getPos().offset(metaphaser.getTileFacing().getOpposite());
	if(metaphaser.getWorld().isAirBlock(outsidePos)) {
		return;
	}

	TileEntity outsideTile = metaphaser.getWorld().getTileEntity(outsidePos);
	if(outsideTile == null) {
		return;
	}

	if(!metaphaser.containsMetaphasedFlux()) {
		return;
	}

	if(!outsideTile.hasCapability(Capabilities.Tesla.RECEIVER, metaphaser.getTileFacing().getOpposite())) {
		return;
	}

	ITeslaConsumer consumer = outsideTile.getCapability(Capabilities.Tesla.RECEIVER, metaphaser.getTileFacing().getOpposite());
	int maxPowa = Math.min(50, metaphaser.getTankConfig().getFluidAmount());
	maxPowa = (int) Math.max(Integer.MAX_VALUE, consumer.givePower(takePower(maxPowa, true), true));
	if(maxPowa > 0) {
		consumer.givePower(takePower(maxPowa, false), false);
	}
}
 
开发者ID:Lordmau5,项目名称:FFS,代码行数:31,代码来源:MetaphaserTesla.java

示例4: preInit

import net.darkhax.tesla.api.ITeslaConsumer; //导入依赖的package包/类
@EventHandler
public void preInit (FMLPreInitializationEvent event) {

    CapabilityManager.INSTANCE.register(ITeslaConsumer.class, new CapabilityTeslaConsumer<>(), BaseTeslaContainer.class);
    CapabilityManager.INSTANCE.register(ITeslaProducer.class, new CapabilityTeslaProducer<>(), BaseTeslaContainer.class);
    CapabilityManager.INSTANCE.register(ITeslaHolder.class, new CapabilityTeslaHolder<>(), BaseTeslaContainer.class);
}
 
开发者ID:Darkhax-Minecraft,项目名称:Tesla,代码行数:8,代码来源:Tesla.java

示例5: distributePowerToAllFaces

import net.darkhax.tesla.api.ITeslaConsumer; //导入依赖的package包/类
/**
 * Attempts to give power to all consumers 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 offer to each individual face.
 * @param simulated Whether or not this is being ran as part of a simulation.
 * @return The amount of power that was consumed.
 */
public static long distributePowerToAllFaces (World world, BlockPos pos, long amount, boolean simulated) {

    long consumedPower = 0L;

    for (final ITeslaConsumer consumer : getConnectedCapabilities(TeslaCapabilities.CAPABILITY_CONSUMER, world, pos)) {
        consumedPower += consumer.givePower(amount, simulated);
    }

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

示例6: createTeslaCapability

import net.darkhax.tesla.api.ITeslaConsumer; //导入依赖的package包/类
@SuppressWarnings("rawtypes")
@Optional.Method(modid = Configs.TESLA)
static Entry<Capability, Map<EnumFacing, Object>> createTeslaCapability(IRFReceiver receiver) {
	Map<EnumFacing, Object> forge = new HashMap<>();
	for (EnumFacing f : EnumFacing.VALUES) {
		forge.put(f, new ITeslaConsumer() {

			@Override
			public long givePower(long power, boolean simulated) {
				return receiver.receiveRF(f, power, simulated);
			}
		});
	}
	return new EmptyEntry<>(TeslaCapabilities.CAPABILITY_CONSUMER, forge);
}
 
开发者ID:tom5454,项目名称:Toms-Mod,代码行数:16,代码来源:IRFReceiver.java

示例7: tryPushEnergy

import net.darkhax.tesla.api.ITeslaConsumer; //导入依赖的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

示例8: update

import net.darkhax.tesla.api.ITeslaConsumer; //导入依赖的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

示例9: getCapability

import net.darkhax.tesla.api.ITeslaConsumer; //导入依赖的package包/类
@Override
public IEnergyStorage getCapability(@Nullable ICapabilityProvider provider, @Nullable EnumFacing side) {
  if (provider == null) {
    return null;
  }
  ITeslaHolder capHolder = provider.getCapability(NullHelper.notnull(TeslaCapabilities.CAPABILITY_HOLDER, "Tesla broke"), side);
  ITeslaConsumer capConsumer = provider.getCapability(NullHelper.notnull(TeslaCapabilities.CAPABILITY_CONSUMER, "Tesla broke"), side);
  ITeslaProducer capProducer = provider.getCapability(NullHelper.notnull(TeslaCapabilities.CAPABILITY_PRODUCER, "Tesla broke"), side);
  if (capHolder == null && capConsumer == null && capProducer == null) {
    return null;
  }
  return new TeslaToForgeAdapter(capHolder, capConsumer, capProducer);
}
 
开发者ID:SleepyTrousers,项目名称:EnderIO,代码行数:14,代码来源:TeslaAdapter.java

示例10: writeNBT

import net.darkhax.tesla.api.ITeslaConsumer; //导入依赖的package包/类
@Override
public NBTBase writeNBT (Capability<ITeslaConsumer> capability, ITeslaConsumer instance, EnumFacing side) {
    
    return null;
}
 
开发者ID:Herobone,项目名称:HeroUtils,代码行数:6,代码来源:TeslaCapabilities.java

示例11: chargeItem

import net.darkhax.tesla.api.ITeslaConsumer; //导入依赖的package包/类
public static int chargeItem(ItemStack stack, int energy, boolean simulate) {
    ITeslaConsumer cap = stack.getCapability(TeslaCapabilities.CAPABILITY_CONSUMER, null);
    return (int) cap.givePower(energy, simulate);
}
 
开发者ID:CreeperShift,项目名称:WirelessCharger,代码行数:5,代码来源:TeslaCompat.java

示例12: writeNBT

import net.darkhax.tesla.api.ITeslaConsumer; //导入依赖的package包/类
@Override
public NBTBase writeNBT (Capability<ITeslaConsumer> capability, ITeslaConsumer instance, EnumFacing side) {

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

示例13: consumer

import net.darkhax.tesla.api.ITeslaConsumer; //导入依赖的package包/类
@CapabilityInject(ITeslaConsumer.class)
public static void consumer(Capability tesla)
{
    TeslaControllerBase.CONSUMER = new Consumer(tesla);
}
 
开发者ID:gigaherz,项目名称:Ender-Rift,代码行数:6,代码来源:TeslaController.java

示例14: TeslaConsumerWrapper

import net.darkhax.tesla.api.ITeslaConsumer; //导入依赖的package包/类
public TeslaConsumerWrapper(ITeslaConsumer consumer)
{
    this.consumer = consumer;
}
 
开发者ID:gigaherz,项目名称:Ender-Rift,代码行数:5,代码来源:TeslaConsumerWrapper.java

示例15: TeslaToForgeAdapter

import net.darkhax.tesla.api.ITeslaConsumer; //导入依赖的package包/类
public TeslaToForgeAdapter(ITeslaHolder capHolder, ITeslaConsumer capConsumer, ITeslaProducer capProducer) {
  this.capHolder = capHolder;
  this.capConsumer = capConsumer;
  this.capProducer = capProducer;
}
 
开发者ID:SleepyTrousers,项目名称:EnderIO,代码行数:6,代码来源:TeslaToForgeAdapter.java


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