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


Java TeslaCapabilities类代码示例

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


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

示例1: pushEnergy

import net.darkhax.tesla.capability.TeslaCapabilities; //导入依赖的package包/类
protected boolean pushEnergy() {
    boolean pushed = false;
    for(EnumFacing dir : EnumFacing.VALUES) {
        TileEntity tile = world.getTileEntity(getPos().offset(dir));
        if(tile != null)
            if(tile.hasCapability(TeslaCapabilities.CAPABILITY_CONSUMER, dir.getOpposite())) {
                BaseTeslaContainer cont = (BaseTeslaContainer) tile.getCapability(TeslaCapabilities.CAPABILITY_CONSUMER, dir.getOpposite());
                container.takePower(cont.givePower(container.takePower(container.getOutputRate(), true), false), false);
                if(!world.isRemote) {
                    tile.markDirty();
                    markDirty();
                    pushed = true;
                }
            }
    }
    return pushed;
}
 
开发者ID:jaredlll08,项目名称:Machines-and-Stuff,代码行数:18,代码来源:GeneratorBase.java

示例2: pushEnergy

import net.darkhax.tesla.capability.TeslaCapabilities; //导入依赖的package包/类
protected boolean pushEnergy() {
    boolean pushed = false;
    for(AccumulatorInfo info : accumulatorInfos) {
        if(info.getIoInfo() == AccumulatorInfo.AccumulatorIOInfo.OUTPUT) {
            EnumFacing dir = info.getFacing();
            TileEntity tile = world.getTileEntity(getPos().offset(dir));
            if(tile != null)
                if(tile.hasCapability(TeslaCapabilities.CAPABILITY_CONSUMER, dir.getOpposite())) {
                    BaseTeslaContainer cont = (BaseTeslaContainer) tile.getCapability(TeslaCapabilities.CAPABILITY_CONSUMER, dir.getOpposite());
                    container.takePower(cont.givePower(container.takePower(container.getOutputRate(), true), false), false);
                    if(!world.isRemote) {
                        tile.markDirty();
                        markDirty();
                        pushed = true;
                    }
                }
        }
    }
    return pushed;
}
 
开发者ID:jaredlll08,项目名称:Machines-and-Stuff,代码行数:21,代码来源:TileEntityAccumulator.java

示例3: hasCapability

import net.darkhax.tesla.capability.TeslaCapabilities; //导入依赖的package包/类
@Override
public boolean hasCapability(Capability<?> capability, EnumFacing side)
{
    if (RFUtilities.TESLA_LOADED && capability == TeslaCapabilities.CAPABILITY_CONSUMER && side == getBlockState().getValue(BlockDiode.ORIENTATION).rotateYCCW())
    {
        return true;
    }
    else if (RFUtilities.TESLA_LOADED && capability == TeslaCapabilities.CAPABILITY_PRODUCER && side == getBlockState().getValue(BlockDiode.ORIENTATION).rotateY())
    {
        return true;
    }
    else if (capability == CapabilityEnergy.ENERGY && side == getBlockState().getValue(BlockDiode.ORIENTATION).rotateYCCW())
    {
        return true;
    }
    return super.hasCapability(capability, side);
}
 
开发者ID:XFactHD,项目名称:RFUtilities,代码行数:18,代码来源:TileEntityDiode.java

示例4: getCapability

import net.darkhax.tesla.capability.TeslaCapabilities; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public <T> T getCapability(Capability<T> capability, EnumFacing side)
{
    if (RFUtilities.TESLA_LOADED && capability == TeslaCapabilities.CAPABILITY_CONSUMER && side == getBlockState().getValue(BlockDiode.ORIENTATION).rotateYCCW())
    {
        return (T)teslaHandler;
    }
    else if (RFUtilities.TESLA_LOADED && capability == TeslaCapabilities.CAPABILITY_PRODUCER && side == getBlockState().getValue(BlockDiode.ORIENTATION).rotateY())
    {
        return (T)teslaHandler;
    }
    else if (capability == CapabilityEnergy.ENERGY && side == getBlockState().getValue(BlockDiode.ORIENTATION).rotateYCCW())
    {
        return (T)energyHandler;
    }
    return super.getCapability(capability, side);
}
 
开发者ID:XFactHD,项目名称:RFUtilities,代码行数:19,代码来源:TileEntityDiode.java

示例5: transferEnergy

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

示例6: transferEnergy

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

示例7: transferEnergy

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

示例8: transferEnergy

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

示例9: hasCapability

import net.darkhax.tesla.capability.TeslaCapabilities; //导入依赖的package包/类
@Override
public boolean hasCapability(Capability<?> capability, EnumFacing facing)
{
    boolean grantAccess = false;
    if (facing == getBlockState().getValue(BlockCapacitor.ORIENTATION).rotateY())
    {
        //we are the receiver
        grantAccess = capability == CapabilityEnergy.ENERGY || (RFUtilities.TESLA_LOADED && capability == TeslaCapabilities.CAPABILITY_CONSUMER);
    }
    else if (facing == getBlockState().getValue(BlockCapacitor.ORIENTATION).rotateYCCW())
    {
        //we are the provider
        grantAccess = capability == CapabilityEnergy.ENERGY || (RFUtilities.TESLA_LOADED && capability == TeslaCapabilities.CAPABILITY_CONSUMER);
    }
    return grantAccess || super.hasCapability(capability, facing);
}
 
开发者ID:XFactHD,项目名称:RFUtilities,代码行数:17,代码来源:TileEntityCapacitor.java

示例10: transferPower

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

示例11: getCapability

import net.darkhax.tesla.capability.TeslaCapabilities; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public <T> T getCapability (Capability<T> capability, EnumFacing facing) {

    // This method is where other things will try to access your TileEntity's Tesla
    // capability. In the case of the analyzer, is a consumer, producer and holder so we
    // can allow requests that are looking for any of those things. This example also does
    // not care about which side is being accessed, however if you wanted to restrict which
    // side can be used, for example only allow power input through the back, that could be
    // done here.
    if (capability == TeslaCapabilities.CAPABILITY_CONSUMER || capability == TeslaCapabilities.CAPABILITY_PRODUCER || capability == TeslaCapabilities.CAPABILITY_HOLDER) {
        return (T) this.container;
    }

    return super.getCapability(capability, facing);
}
 
开发者ID:Darkhax-Minecraft,项目名称:Tesla,代码行数:17,代码来源:TileEntityAnalyzer.java

示例12: onItemUseFinish

import net.darkhax.tesla.capability.TeslaCapabilities; //导入依赖的package包/类
@Nullable
@Override
public ItemStack onItemUseFinish(ItemStack stack, World worldIn, EntityLivingBase entityLiving) {
    BaseTeslaContainer container = (BaseTeslaContainer) stack.getCapability(TeslaCapabilities.CAPABILITY_HOLDER, EnumFacing.DOWN);
    if (entityLiving instanceof EntityPlayer && container.getStoredPower() > 400) {
        EntityPlayer entityplayer = (EntityPlayer)entityLiving;
        worldIn.playSound(null, entityplayer.posX, entityplayer.posY, entityplayer.posZ, SoundEvents.ENTITY_PLAYER_BURP, SoundCategory.PLAYERS, 0.5F, worldIn.rand.nextFloat() * 0.1F + 0.9F);
        container.takePower(drain, false);
        entityplayer.getFoodStats().setFoodLevel(entityplayer.getFoodStats().getFoodLevel() + 4);
        entityplayer.getFoodStats().setFoodSaturationLevel(entityplayer.getFoodStats().getSaturationLevel() + 0.8F);
        this.onFoodEaten(stack, worldIn, entityplayer);
        if(!worldIn.isRemote && electricPotatoBreakChance && ThreadLocalRandom.current().nextInt(0,100) < breakChance){
            if(entityLiving instanceof EntityPlayerMP) ChatSync.forMod(ModSquad.MODID).sendPlayerChatMessage((EntityPlayerMP) entityLiving, "The Capacitors Overloaded;/n All that remains is a Baked Potato", Ref.ITEM_ID_POTATO);
            return new ItemStack(Items.BAKED_POTATO, 1);
        }

    }
    return stack;
}
 
开发者ID:tjkenmate,项目名称:TeslaEssentials,代码行数:20,代码来源:PoweredPotato.java

示例13: update

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

示例14: updateModel

import net.darkhax.tesla.capability.TeslaCapabilities; //导入依赖的package包/类
public static IBlockState updateModel(World world, BlockPos pos, IBlockState defaultState, boolean simulate){
    List<EnumFacing> connected = new ArrayList<>();
    int i = -1;
    TileEntity e;
    for(EnumFacing f : EnumFacing.VALUES)
        if((e=world.getTileEntity(pos.offset(f)))!=null && (e.hasCapability(TeslaCapabilities.CAPABILITY_CONSUMER, f.getOpposite()) ||
                e.hasCapability(TeslaCapabilities.CAPABILITY_PRODUCER, f.getOpposite()))) connected.add(f);

    // Ensure that a valid BlockState is provided, even if the block isn't available
    IBlockState base = world.getBlockState(pos)!=Blocks.AIR.getDefaultState()?world.getBlockState(pos):defaultState;

    IBlockState state = base.withProperty(NORTH, connected.contains(EnumFacing.NORTH))
            .withProperty(SOUTH, connected.contains(EnumFacing.SOUTH))
            .withProperty(EAST, connected.contains(EnumFacing.EAST))
            .withProperty(WEST, connected.contains(EnumFacing.WEST))
            .withProperty(UP, connected.contains(EnumFacing.UP))
            .withProperty(DOWN, connected.contains(EnumFacing.DOWN));

    if(!simulate) world.setBlockState(pos, state);

    return state;
}
 
开发者ID:tjkenmate,项目名称:TeslaEssentials,代码行数:23,代码来源:BasicCable.java

示例15: drawGuiContainerBackgroundLayer

import net.darkhax.tesla.capability.TeslaCapabilities; //导入依赖的package包/类
@Override
protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) {
    mc.renderEngine.getTexture(grinderGUI);
    mc.renderEngine.bindTexture(grinderGUI);
    GL11.glColor4f(1f, 1f, 1f, 1f);

    drawTexturedModalRect(super.guiLeft, super.guiTop, 0, 0, xSize, ySize);
    if (this.grinder.getIsGrinding()) {
        drawTexturedModalRect(super.guiLeft + 80, super.guiTop + 35, 177, 14, Math.round(22.0f * this.grinder.getGrinderProgress() / 100.0f), 16);
    }

    ITeslaHolder tesla = this.grinder.getCapability(TeslaCapabilities.CAPABILITY_HOLDER, EnumFacing.DOWN);
    if (tesla != null) {
        PowerBar bar = new PowerBar(this, super.guiLeft + 8, super.guiTop + 34 - (PowerBar.HEIGHT - 18) / 2, PowerBar.BackgroundType.LIGHT);
        bar.draw(tesla);
    }
}
 
开发者ID:tjkenmate,项目名称:TeslaEssentials,代码行数:18,代码来源:GUIGrinder.java


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