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


Java CapabilityEnergy.ENERGY属性代码示例

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


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

示例1: getCapability

@Nullable
@Override
public <T> T getCapability(Capability<T> capability, @Nullable EnumFacing facing) {
    if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) {
        if (facing == null) return CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.cast(playerMainInvHandler);
        switch (facing) {
            case UP:
                return CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.cast(playerArmorInvHandler);
            case DOWN:
                return super.getCapability(capability, facing);
            default:
                return dispenserUpgradeInserted ?
                        CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.cast(playerFoodHandler) :
                        CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.cast(playerMainInvHandler);
        }
    } else if (capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY && dispenserUpgradeInserted) {
        return CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY.cast(playerExperienceHandler);
    } else if (capability == CapabilityEnergy.ENERGY) {
        return CapabilityEnergy.ENERGY.cast(energyRF);
    }
    return super.getCapability(capability, facing);
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:22,代码来源:TileEntityAerialInterface.java

示例2: getCapability

@Nullable
@Override
public <T> T getCapability(@Nonnull Capability<T> capability, @Nullable EnumFacing facing) {
    if(capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY){
        IItemHandler inventory = getInventory(facing);
        if(inventory != null){
            return CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.cast(inventory);
        }
    }
    if(capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY){
        IFluidHandler tank = getTank(facing);
        if(tank != null){
            return CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY.cast(tank);
        }
    }
    if(capability == CapabilityEnergy.ENERGY){
        IEnergyStorage energy = getEnergy(facing);
        if(energy != null){
            return CapabilityEnergy.ENERGY.cast(energy);
        }
    }
    return null;
}
 
开发者ID:canitzp,项目名称:Metalworks,代码行数:23,代码来源:TileBase.java

示例3: getCapability

@SuppressWarnings("unchecked")
@Nullable
@Override
public <T> T getCapability(@Nonnull Capability<T> capability, @Nullable EnumFacing facing) {
    if (capability == CapabilityEnergy.ENERGY) return (T) energyStorage;
    else if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) {
        if (facing == null)
            return (T) itemHandler;
        switch (facing) {
            case UP:
                return (T) new ItemStackHandler(NonNullList.withSize(1, itemHandler.getStackInSlot(0)));
            case DOWN:
                return (T) new ItemStackHandler(NonNullList.withSize(1, itemHandler.getStackInSlot(1)));
            default:
                return (T) itemHandler;
        }
    }
    else return super.getCapability(capability, facing);
}
 
开发者ID:LasmGratel,项目名称:FoodCraft-Reloaded,代码行数:19,代码来源:TileEntityDrinkMachine.java

示例4: getCapability

@SuppressWarnings("unchecked")
@Override
public <T> T getCapability(net.minecraftforge.common.capabilities.Capability<T> capability, @javax.annotation.Nullable net.minecraft.util.EnumFacing facing) {
  if (capability == net.minecraftforge.items.CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) {
    //      if (facing == EnumFacing.DOWN)
    //        return (T) handlerBottom;
    //      else if (facing == EnumFacing.UP)
    //facing != null &&
    return (T) invHandler;
    //      else
    //        return (T) handlerSide;
  }
  if (doesUseFuel() && capability == CapabilityEnergy.ENERGY) {
    this.initEnergyStorage();
    return CapabilityEnergy.ENERGY.cast(energyStorage);
  }
  return super.getCapability(capability, facing);
}
 
开发者ID:PrinceOfAmber,项目名称:Cyclic,代码行数:18,代码来源:TileEntityBaseMachineInvo.java

示例5: getCapability

@SuppressWarnings("unchecked")
@Override
public <T> T getCapability(Capability<T> capability, @Nullable EnumFacing facing)
{
    IEnergyStorage buffer = getEnergyBuffer();
    if (capability == CapabilityEnergy.ENERGY)
        return (T) buffer;
    if (teslaConsumerCap != null && capability == teslaConsumerCap)
    {
        if (teslaConsumerInstance == null && buffer != null)
            teslaConsumerInstance = TeslaControllerBase.CONSUMER.createInstance(getEnergyBuffer());
        return (T) teslaConsumerInstance;
    }
    if (teslaHolderCap != null && capability == teslaHolderCap)
    {
        if (teslaHolderInstance == null && buffer != null)
            teslaHolderInstance = TeslaControllerBase.HOLDER.createInstance(getEnergyBuffer());
        return (T) teslaHolderInstance;
    }
    return super.getCapability(capability, facing);
}
 
开发者ID:gigaherz,项目名称:Ender-Rift,代码行数:21,代码来源:TileEnderRiftCorner.java

示例6: getCapability

@SuppressWarnings("unchecked")
@Override
public <T> T getCapability(@Nonnull Capability<T> capability, @Nullable EnumFacing facingIn) {
  if (isMaster()) {
    if (capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY) {
      return CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY.cast(tank);
    }
    return super.getCapability(capability, facingIn);
  } else if (inNetwork()) {
    return NullHelper.notnull(getMaster(), "Telepad master is null while in network!").getCapability(capability, facingIn);
  } else if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY || capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY
      || capability == CapabilityEnergy.ENERGY) {
    return null;
  } else {
    return super.getCapability(capability, facingIn);
  }
}
 
开发者ID:SleepyTrousers,项目名称:EnderIO,代码行数:17,代码来源:TileTelePad.java

示例7: hasCapability

@Override
public boolean hasCapability(Capability<?> capability, @Nullable EnumFacing facing) {
    return capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY
            || capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY
            || capability == CapabilityEnergy.ENERGY
            || super.hasCapability(capability, facing);
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:7,代码来源:EntityDrone.java

示例8: getCapability

@Nullable
@Override
public <T> T getCapability(Capability<T> capability, @Nullable EnumFacing facing) {
    if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) {
        return CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.cast(inventory);
    } else if (capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY) {
        return CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY.cast(tank);
    } else if (capability == CapabilityEnergy.ENERGY) {
        return CapabilityEnergy.ENERGY.cast(energy);
    }
    return super.getCapability(capability, facing);
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:12,代码来源:EntityDrone.java

示例9: getCapability

@Nullable
@Override
public <T> T getCapability(Capability<T> capability, @Nullable EnumFacing facing) {
    if (capability == CapabilityEnergy.ENERGY && facing != getRotation().getOpposite()) {
        return CapabilityEnergy.ENERGY.cast(energy);
    } else {
        return super.getCapability(capability, facing);
    }
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:9,代码来源:TileEntityFluxCompressor.java

示例10: getCapability

@Nullable
@Override
public <T> T getCapability(Capability<T> capability, @Nullable EnumFacing facing) {
    return capability == CapabilityEnergy.ENERGY && (facing == getRotation() || facing == null) ?
            CapabilityEnergy.ENERGY.cast(energy) :
            super.getCapability(capability, facing);
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:7,代码来源:TileEntityPneumaticDynamo.java

示例11: hasCapability

@Override
public boolean hasCapability(Capability<?> capability, @Nullable EnumFacing facing) {
    return ((isConnectedToPlayer &&
            (capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY && dispenserUpgradeInserted)
            || capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY))
            || capability == CapabilityEnergy.ENERGY
            || super.hasCapability(capability, facing);

}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:9,代码来源:TileEntityAerialInterface.java

示例12: getCapability

@Nullable
@Override
public <T> T getCapability(Capability<T> capability, @Nullable EnumFacing facing) {
    if(capability == CapabilityEnergy.ENERGY) {
        return (T) this;
    }
    return super.getCapability(capability, facing);
}
 
开发者ID:HellFirePvP,项目名称:ModularMachinery,代码行数:8,代码来源:TileEnergyHatch.java

示例13: getCapability

@Override
public <T> T getCapability(Capability<T> capability, @Nullable EnumFacing facing) {
    if (capability == CapabilityEnergy.ENERGY) {
        return (T) storage;
    } else {
        return super.getCapability(capability, facing);
    }
}
 
开发者ID:CreeperShift,项目名称:WirelessCharger,代码行数:8,代码来源:TileWirelessCharger.java

示例14: hasCapability

@Override
public boolean hasCapability(Capability<?> capability, EnumFacing facing) {
	if (capability == CapabilityEnergy.ENERGY && m_storage.getMaxEnergyStored() > 0)
	{
		return true;
	}

	return false;
}
 
开发者ID:orbwoi,项目名称:UniversalRemote,代码行数:9,代码来源:ItemEnergyBase.java

示例15: getCapability

@SuppressWarnings("unchecked")
@Override
public <T> T getCapability(Capability<T> capability, EnumFacing facing) {
	if (capability == CapabilityEnergy.ENERGY && m_storage.getMaxEnergyStored() > 0)
	{
		return (T)m_storage;
	}
	return null;
}
 
开发者ID:orbwoi,项目名称:UniversalRemote,代码行数:9,代码来源:ItemEnergyBase.java


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