net.minecraftforge.common.capabilities.Capability Java Examples

The following examples show how to use net.minecraftforge.common.capabilities.Capability. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TileEntityTofuBattery.java    From TofuCraftReload with MIT License 6 votes vote down vote up
@Nullable
@Override
public <T> T getCapability(Capability<T> capability, @Nullable EnumFacing facing) {
    if (capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY) {
        if (facing == null) return CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY.cast(inputTank);
        switch (facing) {
            case UP:
            case EAST:
            case WEST:
            case NORTH:
            case SOUTH:
                return CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY.cast(inputTank);
            case DOWN:
                return CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY.cast(outputTank);
        }
    }
    return super.getCapability(capability, facing);
}
 
Example #2
Source File: TileEntitySoymilkAggregator.java    From TofuCraftReload with MIT License 6 votes vote down vote up
@SuppressWarnings("unchecked")
@Nullable
   @Override
   public <T> T getCapability(Capability<T> capability, @Nullable EnumFacing facing) {
       if (facing == null)
           return (T) handlerInput;

       switch (facing) {
           case WEST:
           case EAST:
           case NORTH:
           case SOUTH:
               return CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY.cast(input);
           case DOWN:
               return (T) handlerOutput;
           default:
               return (T) handlerInput;
       }
   }
 
Example #3
Source File: HarvesterTileEntity.java    From EmergingTechnology with MIT License 5 votes vote down vote up
@Override
public boolean hasCapability(Capability<?> capability, EnumFacing facing) {
    if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY)
        return true;
    if (capability == CapabilityEnergy.ENERGY)
        return true;
    if (capability == CapabilityAnimation.ANIMATION_CAPABILITY)
        return true;

    return super.hasCapability(capability, facing);
}
 
Example #4
Source File: LightTileEntity.java    From EmergingTechnology with MIT License 5 votes vote down vote up
@Override
public <T> T getCapability(Capability<T> capability, EnumFacing facing) {
    if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY)
        return CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.cast(this.itemHandler);
    if (capability == CapabilityEnergy.ENERGY)
        return CapabilityEnergy.ENERGY.cast(this.consumerEnergyHandler);
    return super.getCapability(capability, facing);
}
 
Example #5
Source File: AlgaeBioreactorTileEntity.java    From EmergingTechnology with MIT License 5 votes vote down vote up
@Override
public boolean hasCapability(Capability<?> capability, EnumFacing facing) {
    if (capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY)
        return true;
    if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY)
        return true;
    if (capability == CapabilityEnergy.ENERGY)
        return true;

    return super.hasCapability(capability, facing);
}
 
Example #6
Source File: AlgaeBioreactorTileEntity.java    From EmergingTechnology with MIT License 5 votes vote down vote up
@Override
public <T> T getCapability(Capability<T> capability, EnumFacing facing) {
    if (capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY)
        return CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY.cast(this.automationFluidHandler);
    if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY)
        return CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.cast(this.automationItemHandler);
    if (capability == CapabilityEnergy.ENERGY)
        return CapabilityEnergy.ENERGY.cast(this.consumerEnergyHandler);
    return super.getCapability(capability, facing);
}
 
Example #7
Source File: WindTileEntity.java    From EmergingTechnology with MIT License 5 votes vote down vote up
@Override
public boolean hasCapability(Capability<?> capability, EnumFacing facing) {
    if (capability == CapabilityEnergy.ENERGY)
        return true;
    if (capability == CapabilityAnimation.ANIMATION_CAPABILITY)
        return true;

    return super.hasCapability(capability, facing);
}
 
Example #8
Source File: WindTileEntity.java    From EmergingTechnology with MIT License 5 votes vote down vote up
@Override
public <T> T getCapability(Capability<T> capability, EnumFacing facing) {
    if (capability == CapabilityEnergy.ENERGY)
        return CapabilityEnergy.ENERGY.cast(this.generatorEnergyHandler);
    if (capability == CapabilityAnimation.ANIMATION_CAPABILITY)
        return CapabilityAnimation.ANIMATION_CAPABILITY.cast(getAnimator());
    return super.getCapability(capability, facing);
}
 
Example #9
Source File: ShredderTileEntity.java    From EmergingTechnology with MIT License 5 votes vote down vote up
@Override
public <T> T getCapability(Capability<T> capability, EnumFacing facing) {
    if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY)
        return CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.cast(this.automationItemHandler);
    if (capability == CapabilityEnergy.ENERGY)
        return CapabilityEnergy.ENERGY.cast(this.consumerEnergyHandler);
    return super.getCapability(capability, facing);
}
 
Example #10
Source File: BatteryTileEntity.java    From EmergingTechnology with MIT License 5 votes vote down vote up
@Override
public boolean hasCapability(Capability<?> capability, EnumFacing facing) {
    if (capability == CapabilityEnergy.ENERGY)
        return true;

    return super.hasCapability(capability, facing);
}
 
Example #11
Source File: BatteryTileEntity.java    From EmergingTechnology with MIT License 5 votes vote down vote up
@Override
public <T> T getCapability(Capability<T> capability, EnumFacing facing) {
    if (capability == CapabilityEnergy.ENERGY) {
        if (facing == getFacing()) {
            return CapabilityEnergy.ENERGY.cast(this.consumerStorageHandler);
        } else {
            return CapabilityEnergy.ENERGY.cast(this.generatorStorageHandler);
        }
    }

    return super.getCapability(capability, facing);
}
 
Example #12
Source File: PiezoelectricTileEntity.java    From EmergingTechnology with MIT License 5 votes vote down vote up
@Override
public boolean hasCapability(Capability<?> capability, EnumFacing facing) {
    if (capability == CapabilityEnergy.ENERGY)
        return true;

    return super.hasCapability(capability, facing);
}
 
Example #13
Source File: CookerTileEntity.java    From EmergingTechnology with MIT License 5 votes vote down vote up
@Override
public boolean hasCapability(Capability<?> capability, EnumFacing facing) {
    if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY)
        return true;

    return super.hasCapability(capability, facing);
}
 
Example #14
Source File: BiomassGeneratorTileEntity.java    From EmergingTechnology with MIT License 5 votes vote down vote up
@Override
public boolean hasCapability(Capability<?> capability, EnumFacing facing) {
    if (capability == CapabilityEnergy.ENERGY)
        return true;
    if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY)
        return true;

    return super.hasCapability(capability, facing);
}
 
Example #15
Source File: DiffuserTileEntity.java    From EmergingTechnology with MIT License 5 votes vote down vote up
@Override
public <T> T getCapability(Capability<T> capability, EnumFacing facing) {

    if (capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY)
        return CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY.cast(this.gasHandler);
    if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY)
        return CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.cast(this.itemHandler);
    if (capability == CapabilityEnergy.ENERGY)
        return CapabilityEnergy.ENERGY.cast(this.consumerEnergyHandler);
    return super.getCapability(capability, facing);
}
 
Example #16
Source File: DiffuserTileEntity.java    From EmergingTechnology with MIT License 5 votes vote down vote up
@Override
public boolean hasCapability(Capability<?> capability, EnumFacing facing) {
    if (capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY)
        return true;
    if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY)
        return true;
    if (capability == CapabilityEnergy.ENERGY)
        return true;

    return super.hasCapability(capability, facing);
}
 
Example #17
Source File: HarvesterTileEntity.java    From EmergingTechnology with MIT License 5 votes vote down vote up
@Override
public <T> T getCapability(Capability<T> capability, EnumFacing facing) {
    if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY)
        return CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.cast(this.automationItemHandler);
    if (capability == CapabilityEnergy.ENERGY)
        return CapabilityEnergy.ENERGY.cast(this.consumerEnergyHandler);
    if (capability == CapabilityAnimation.ANIMATION_CAPABILITY)
        return CapabilityAnimation.ANIMATION_CAPABILITY.cast(getAnimator());
    return super.getCapability(capability, facing);
}
 
Example #18
Source File: LightTileEntity.java    From EmergingTechnology with MIT License 5 votes vote down vote up
@Override
public boolean hasCapability(Capability<?> capability, EnumFacing facing) {
    if (capability == CapabilityEnergy.ENERGY)
        return true;
    if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY)
        return true;

    return super.hasCapability(capability, facing);
}
 
Example #19
Source File: CollectorTileEntity.java    From EmergingTechnology with MIT License 5 votes vote down vote up
@Override
public boolean hasCapability(Capability<?> capability, EnumFacing facing) {
    if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY)
        return true;

    return super.hasCapability(capability, facing);
}
 
Example #20
Source File: HydroponicTileEntity.java    From EmergingTechnology with MIT License 5 votes vote down vote up
@Override
public <T> T getCapability(Capability<T> capability, EnumFacing facing) {
    if (capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY)
        return CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY.cast(this.fluidHandler);
    if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY)
        return CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.cast(this.itemHandler);
    if (capability == CapabilityEnergy.ENERGY)
        return CapabilityEnergy.ENERGY.cast(this.consumerEnergyHandler);
    return super.getCapability(capability, facing);
}
 
Example #21
Source File: BioreactorTileEntity.java    From EmergingTechnology with MIT License 5 votes vote down vote up
@Override
public boolean hasCapability(Capability<?> capability, EnumFacing facing) {
    if (capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY)
        return true;
    if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY)
        return true;
    if (capability == CapabilityEnergy.ENERGY)
        return true;

    return super.hasCapability(capability, facing);
}
 
Example #22
Source File: FabricatorTileEntity.java    From EmergingTechnology with MIT License 5 votes vote down vote up
@Override
public <T> T getCapability(Capability<T> capability, EnumFacing facing) {
    if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY)
        return CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.cast(this.automationItemHandler);
    if (capability == CapabilityEnergy.ENERGY)
        return CapabilityEnergy.ENERGY.cast(this.consumerEnergyHandler);
    return super.getCapability(capability, facing);
}
 
Example #23
Source File: FabricatorTileEntity.java    From EmergingTechnology with MIT License 5 votes vote down vote up
@Override
public boolean hasCapability(Capability<?> capability, EnumFacing facing) {
    if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY)
        return true;
    if (capability == CapabilityEnergy.ENERGY)
        return true;

    return super.hasCapability(capability, facing);
}
 
Example #24
Source File: ScaffolderTileEntity.java    From EmergingTechnology with MIT License 5 votes vote down vote up
@Override
public <T> T getCapability(Capability<T> capability, EnumFacing facing) {
    if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY)
        return CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.cast(this.automationItemHandler);
    if (capability == CapabilityEnergy.ENERGY)
        return CapabilityEnergy.ENERGY.cast(this.consumerEnergyHandler);
    return super.getCapability(capability, facing);
}
 
Example #25
Source File: ScaffolderTileEntity.java    From EmergingTechnology with MIT License 5 votes vote down vote up
@Override
public boolean hasCapability(Capability<?> capability, EnumFacing facing) {
    if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY)
        return true;
    if (capability == CapabilityEnergy.ENERGY)
        return true;

    return super.hasCapability(capability, facing);
}
 
Example #26
Source File: ScrubberTileEntity.java    From EmergingTechnology with MIT License 5 votes vote down vote up
@Override
public <T> T getCapability(Capability<T> capability, EnumFacing facing) {

    if (capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY)
        return CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY.cast(this.fluidTanksHandler);
    if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY)
        return CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.cast(this.automationItemHandler);
    if (capability == CapabilityEnergy.ENERGY)
        return CapabilityEnergy.ENERGY.cast(this.consumerEnergyHandler);
    if (capability == CapabilityAnimation.ANIMATION_CAPABILITY)
        return CapabilityAnimation.ANIMATION_CAPABILITY.cast(getAnimator());
    return super.getCapability(capability, facing);
}
 
Example #27
Source File: ScrubberTileEntity.java    From EmergingTechnology with MIT License 5 votes vote down vote up
@Override
public boolean hasCapability(Capability<?> capability, EnumFacing facing) {
    if (capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY)
        return true;
    if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY)
        return true;
    if (capability == CapabilityEnergy.ENERGY)
        return true;
    if (capability == CapabilityAnimation.ANIMATION_CAPABILITY)
        return true;

    return super.hasCapability(capability, facing);
}
 
Example #28
Source File: OptimiserTileEntity.java    From EmergingTechnology with MIT License 5 votes vote down vote up
@Override
public <T> T getCapability(Capability<T> capability, EnumFacing facing) {

    if (capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY)
        return CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY.cast(this.fluidHandler);
    if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY)
        return CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.cast(this.itemHandler);
    if (capability == CapabilityEnergy.ENERGY)
        return CapabilityEnergy.ENERGY.cast(this.consumerEnergyHandler);
    return super.getCapability(capability, facing);
}
 
Example #29
Source File: OptimiserTileEntity.java    From EmergingTechnology with MIT License 5 votes vote down vote up
@Override
public boolean hasCapability(Capability<?> capability, EnumFacing facing) {
    if (capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY)
        return true;
    if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY)
        return true;
    if (capability == CapabilityEnergy.ENERGY)
        return true;

    return super.hasCapability(capability, facing);
}
 
Example #30
Source File: FillerTileEntity.java    From EmergingTechnology with MIT License 5 votes vote down vote up
@Override
public boolean hasCapability(Capability<?> capability, EnumFacing facing) {
    if (capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY)
        return true;

    return super.hasCapability(capability, facing);
}