Java Code Examples for net.minecraftforge.items.CapabilityItemHandler#ITEM_HANDLER_CAPABILITY

The following examples show how to use net.minecraftforge.items.CapabilityItemHandler#ITEM_HANDLER_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: TileEntityEngineeringTable.java    From Cyberware with MIT License 6 votes vote down vote up
@Override
public <T> T getCapability(Capability<T> capability, EnumFacing facing)
{
	if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY)
	{
		if (facing == EnumFacing.DOWN)
		{
			return (T) slotsBottom;
		}
		else
		{
			return (T) slotsTopSides;
		}
	}
	return super.getCapability(capability, facing);
}
 
Example 2
Source File: TileFastFurnace.java    From YouTubeModdingTutorial with MIT License 6 votes vote down vote up
@Override
public <T> T getCapability(Capability<T> capability, EnumFacing facing) {
    if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) {
        if (facing == null) {
            return CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.cast(combinedHandler);
        } else if (facing == EnumFacing.UP) {
            return CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.cast(inputHandler);
        } else {
            return CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.cast(outputHandler);
        }
    }
    if (capability == CapabilityEnergy.ENERGY) {
        return CapabilityEnergy.ENERGY.cast(energyStorage);
    }
    return super.getCapability(capability, facing);
}
 
Example 3
Source File: TileBarrel.java    From ExNihiloAdscensio with MIT License 5 votes vote down vote up
@Override
public boolean hasCapability(Capability<?> capability, EnumFacing facing)
{
	return capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY ||
			capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY ||
			super.hasCapability(capability, facing);
}
 
Example 4
Source File: InjectorTileEntity.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);
    return super.getCapability(capability, facing);
}
 
Example 5
Source File: TileEntityModuleCrafting.java    From customstuff4 with GNU General Public License v3.0 5 votes vote down vote up
@Nullable
@Override
public <T> T getCapability(Capability<T> capability, @Nullable EnumFacing facing)
{
    if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY &&
        (facing == null))
    {
        return (T) invHandler;
    }

    return null;
}
 
Example 6
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 7
Source File: BioreactorTileEntity.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.automationItemHandler);
    if (capability == CapabilityEnergy.ENERGY)
        return CapabilityEnergy.ENERGY.cast(this.consumerEnergyHandler);
    return super.getCapability(capability, facing);
}
 
Example 8
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 9
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 10
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 11
Source File: TileEntityPhysicsInfuser.java    From Valkyrien-Skies with Apache License 2.0 5 votes vote down vote up
@Override
public boolean hasCapability(Capability<?> capability, @Nullable EnumFacing facing) {
    if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) {
        return true;
    }
    return super.hasCapability(capability, facing);
}
 
Example 12
Source File: TileSuperchest.java    From YouTubeModdingTutorial with MIT License 5 votes vote down vote up
@Override
public boolean hasCapability(Capability<?> capability, EnumFacing facing) {
    IBlockState state = world.getBlockState(pos);
    if (state.getBlock() != ModBlocks.blockSuperchest || state.getValue(BlockSuperchest.FORMED) == SuperchestPartIndex.UNFORMED) {
        return false;
    }

    if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) {
        return true;
    }
    return super.hasCapability(capability, facing);
}
 
Example 13
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 14
Source File: ProcessorTileEntity.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.automationItemHandler);
    if (capability == CapabilityEnergy.ENERGY)
        return CapabilityEnergy.ENERGY.cast(this.consumerEnergyHandler);
    return super.getCapability(capability, facing);
}
 
Example 15
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 16
Source File: ModificationTableTileEntity.java    From MiningGadgets with MIT License 5 votes vote down vote up
@Nonnull
@Override
public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> cap, @Nullable Direction side) {
    if (cap == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) {
        return handler.cast();
    }
    return super.getCapability(cap, side);
}
 
Example 17
Source File: TileEnderChest.java    From EnderStorage with MIT License 5 votes vote down vote up
@Nonnull
@Override
public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> cap, @Nullable Direction side) {
    if (!removed && cap == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) {
        return itemHandler.cast();
    }
    return super.getCapability(cap, side);
}
 
Example 18
Source File: DryingRackTileEntity.java    From Survivalist with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public <T> LazyOptional<T> getCapability(Capability<T> capability, @Nullable Direction facing)
{
    if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY)
        return itemsProvider.cast();
    return super.getCapability(capability, facing);
}
 
Example 19
Source File: TileEntitySoymilkAggregator.java    From TofuCraftReload with MIT License 5 votes vote down vote up
@Override
public boolean hasCapability(Capability<?> capability, @Nullable EnumFacing facing) {
    if (facing == null)
        return capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY;

    switch (facing) {
        case SOUTH:
        case NORTH:
        case EAST:
        case WEST:
            return capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY;
        default:
            return capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY;
    }
}
 
Example 20
Source File: TileEntityModuleCrafting.java    From customstuff4 with GNU General Public License v3.0 4 votes vote down vote up
@Override
public boolean hasCapability(Capability<?> capability, @Nullable EnumFacing facing)
{
    return capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY &&
           (facing == null);
}