本文整理汇总了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);
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
}
示例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);
}
示例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);
}
示例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);
}
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
}
示例14: hasCapability
@Override
public boolean hasCapability(Capability<?> capability, EnumFacing facing) {
if (capability == CapabilityEnergy.ENERGY && m_storage.getMaxEnergyStored() > 0)
{
return true;
}
return false;
}
示例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;
}