Search in sources :

Example 1 with MultipartTile

use of pl.asie.charset.lib.modcompat.mcmultipart.MultipartTile in project Charset by CharsetMC.

the class MCMPAddonGates method onAttachCaps.

@SubscribeEvent
public void onAttachCaps(AttachCapabilitiesEvent<TileEntity> event) {
    if (event.getObject() instanceof PartGate) {
        final PartGate gate = (PartGate) event.getObject();
        final IMultipartTile mpartTile = new MultipartTile<>(gate);
        event.addCapability(LOC, new ICapabilityProvider() {

            @Override
            public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable EnumFacing facing) {
                return capability == MCMPCapabilities.MULTIPART_TILE;
            }

            @Nullable
            @Override
            public <T> T getCapability(@Nonnull Capability<T> capability, @Nullable EnumFacing facing) {
                return capability == MCMPCapabilities.MULTIPART_TILE ? MCMPCapabilities.MULTIPART_TILE.cast(mpartTile) : null;
            }
        });
    }
}
Also used : ICapabilityProvider(net.minecraftforge.common.capabilities.ICapabilityProvider) EnumFacing(net.minecraft.util.EnumFacing) PartGate(pl.asie.simplelogic.gates.PartGate) MultipartTile(pl.asie.charset.lib.modcompat.mcmultipart.MultipartTile) IMultipartTile(mcmultipart.api.multipart.IMultipartTile) IMultipartTile(mcmultipart.api.multipart.IMultipartTile) Nullable(javax.annotation.Nullable) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Aggregations

Nullable (javax.annotation.Nullable)1 IMultipartTile (mcmultipart.api.multipart.IMultipartTile)1 EnumFacing (net.minecraft.util.EnumFacing)1 ICapabilityProvider (net.minecraftforge.common.capabilities.ICapabilityProvider)1 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)1 MultipartTile (pl.asie.charset.lib.modcompat.mcmultipart.MultipartTile)1 PartGate (pl.asie.simplelogic.gates.PartGate)1