Search in sources :

Example 1 with DefaultItemInsertionHandler

use of pl.asie.charset.lib.capability.inventory.DefaultItemInsertionHandler in project Charset by CharsetMC.

the class Capabilities method preInit.

public static void preInit() {
    CapabilityManager.INSTANCE.register(IAudioSource.class, DummyCapabilityStorage.get(), DefaultAudioSource::new);
    CapabilityManager.INSTANCE.register(IAudioReceiver.class, DummyCapabilityStorage.get(), DefaultAudioReceiver::new);
    CapabilityManager.INSTANCE.register(IAxisRotatable.class, DummyCapabilityStorage.get(), DefaultAxisRotatable::new);
    CapabilityManager.INSTANCE.register(IDebuggable.class, DummyCapabilityStorage.get(), DefaultDebuggable::new);
    CapabilityManager.INSTANCE.register(IMovable.class, DummyCapabilityStorage.get(), DefaultMovable::new);
    CapabilityManager.INSTANCE.register(IItemInsertionHandler.class, DummyCapabilityStorage.get(), DefaultItemInsertionHandler::new);
    CapabilityManager.INSTANCE.register(IPipeView.class, DummyCapabilityStorage.get(), DefaultPipeView::new);
    CapabilityManager.INSTANCE.register(IBundledEmitter.class, new DefaultBundledEmitterStorage(), DefaultBundledEmitter::new);
    CapabilityManager.INSTANCE.register(IRedstoneEmitter.class, new DefaultRedstoneEmitterStorage(), DefaultRedstoneEmitter::new);
    CapabilityManager.INSTANCE.register(IBundledReceiver.class, DummyCapabilityStorage.get(), DummyRedstoneReceiver::new);
    CapabilityManager.INSTANCE.register(IRedstoneReceiver.class, DummyCapabilityStorage.get(), DummyRedstoneReceiver::new);
    CapabilityManager.INSTANCE.register(IBarrel.class, DummyCapabilityStorage.get(), DummyBarrel::new);
    CapabilityManager.INSTANCE.register(Lockable.class, LOCKABLE_STORAGE, Lockable::new);
    CapabilityManager.INSTANCE.register(IMultiblockStructure.class, DummyCapabilityStorage.get(), DefaultMultiblockStructure::new);
    CapabilityManager.INSTANCE.register(ILaserReceiver.class, DummyCapabilityStorage.get(), DummyLaserReceiver::new);
    CapabilityManager.INSTANCE.register(CustomCarryHandler.Provider.class, DummyCapabilityStorage.get(), () -> handler -> new CustomCarryHandler(handler));
    MinecraftForge.EVENT_BUS.register(new Capabilities());
    multiblockStructureFactory = new CapabilityProviderFactory<>(Capabilities.MULTIBLOCK_STRUCTURE, DummyCapabilityStorage.get());
}
Also used : DefaultPipeView(pl.asie.charset.lib.capability.pipe.DefaultPipeView) Lockable(pl.asie.charset.api.locks.Lockable) DefaultAudioReceiver(pl.asie.charset.lib.capability.audio.DefaultAudioReceiver) DefaultItemInsertionHandler(pl.asie.charset.lib.capability.inventory.DefaultItemInsertionHandler) DefaultAudioSource(pl.asie.charset.lib.capability.audio.DefaultAudioSource) DummyLaserReceiver(pl.asie.charset.lib.capability.laser.DummyLaserReceiver) CustomCarryHandler(pl.asie.charset.api.carry.CustomCarryHandler) DummyBarrel(pl.asie.charset.lib.capability.storage.DummyBarrel)

Example 2 with DefaultItemInsertionHandler

use of pl.asie.charset.lib.capability.inventory.DefaultItemInsertionHandler in project Charset by CharsetMC.

the class CharsetStorageLocks method preInit.

@Mod.EventHandler
public void preInit(FMLPreInitializationEvent event) {
    masterKeyItem = new ItemMasterKey();
    keyItem = new ItemKey();
    keyringItem = new ItemKeyring();
    lockItem = new ItemLock();
    ModCharset.dataFixes.registerFix(FixTypes.ITEM_INSTANCE, new FixCharsetLockKeyTagChange());
    if (PatchworkHelper.getBoolean("LOCKS_BLOCK_CAPABILITIES")) {
        LocksCapabilityHook.handler = new LocksCapabilityHandler();
        LocksCapabilityHandler.addCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, (o) -> {
            if (o != null) {
                return new ReadOnlyItemHandler((IItemHandler) o);
            } else {
                return null;
            }
        }, true);
        LocksCapabilityHandler.addCapability(Capabilities.ITEM_INSERTION_HANDLER, (o) -> new DefaultItemInsertionHandler(), true);
        LocksCapabilityHandler.addCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, (o) -> {
            if (o != null) {
                return new ReadOnlyFluidHandler((IFluidHandler) o);
            } else {
                return null;
            }
        }, true);
        LocksCapabilityHandler.addCapability(Capabilities.BARREL, (o) -> {
            if (o != null) {
                return new ReadOnlyBarrel((IBarrel) o);
            } else {
                return null;
            }
        }, true);
        CharsetStorageLocks.config.getCategory("blockedCapabilities").setComment("NOTE: This functionality requires a special configuration option in CharsetPatches to be turned on! Otherwise, it will not be effective!");
        if (config.hasChanged()) {
            config.save();
        }
    }
}
Also used : DefaultItemInsertionHandler(pl.asie.charset.lib.capability.inventory.DefaultItemInsertionHandler) ReadOnlyFluidHandler(pl.asie.charset.module.storage.locks.wrapper.ReadOnlyFluidHandler) ReadOnlyBarrel(pl.asie.charset.module.storage.locks.wrapper.ReadOnlyBarrel) ReadOnlyItemHandler(pl.asie.charset.module.storage.locks.wrapper.ReadOnlyItemHandler)

Aggregations

DefaultItemInsertionHandler (pl.asie.charset.lib.capability.inventory.DefaultItemInsertionHandler)2 CustomCarryHandler (pl.asie.charset.api.carry.CustomCarryHandler)1 Lockable (pl.asie.charset.api.locks.Lockable)1 DefaultAudioReceiver (pl.asie.charset.lib.capability.audio.DefaultAudioReceiver)1 DefaultAudioSource (pl.asie.charset.lib.capability.audio.DefaultAudioSource)1 DummyLaserReceiver (pl.asie.charset.lib.capability.laser.DummyLaserReceiver)1 DefaultPipeView (pl.asie.charset.lib.capability.pipe.DefaultPipeView)1 DummyBarrel (pl.asie.charset.lib.capability.storage.DummyBarrel)1 ReadOnlyBarrel (pl.asie.charset.module.storage.locks.wrapper.ReadOnlyBarrel)1 ReadOnlyFluidHandler (pl.asie.charset.module.storage.locks.wrapper.ReadOnlyFluidHandler)1 ReadOnlyItemHandler (pl.asie.charset.module.storage.locks.wrapper.ReadOnlyItemHandler)1