dan200.computercraft.api.peripheral.IPeripheralProvider Java Examples

The following examples show how to use dan200.computercraft.api.peripheral.IPeripheralProvider. 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: ComputerCraftAPI.java    From OpenPeripheral-Integration with MIT License 5 votes vote down vote up
/**
 * Registers a peripheral handler to convert blocks into IPeripheral implementations.
 * @see dan200.computercraft.api.peripheral.IPeripheral
 * @see dan200.computercraft.api.peripheral.IPeripheralProvider
 */
public static void registerPeripheralProvider( IPeripheralProvider handler )
{
	findCC();
	if ( computerCraft_registerPeripheralProvider != null)
	{
		try {
			computerCraft_registerPeripheralProvider.invoke( null, handler );
		} catch (Exception e){
			// It failed
		}
	}
}
 
Example #2
Source File: ComputerCraftAPI.java    From OpenPeripheral-Integration with MIT License 5 votes vote down vote up
private static void findCC()
{
	if( !ccSearched ) {
		try {
			computerCraft = Class.forName( "dan200.computercraft.ComputerCraft" );
			computerCraft_createUniqueNumberedSaveDir = findCCMethod( "createUniqueNumberedSaveDir", new Class[]{
                   World.class, String.class
               } );
			computerCraft_createSaveDirMount = findCCMethod( "createSaveDirMount", new Class[] {
				World.class, String.class, Long.TYPE
			} );
			computerCraft_createResourceMount = findCCMethod( "createResourceMount", new Class[] {
				Class.class, String.class, String.class
			} );
			computerCraft_registerPeripheralProvider = findCCMethod( "registerPeripheralProvider", new Class[] {
				IPeripheralProvider.class
			} );
               computerCraft_registerTurtleUpgrade = findCCMethod( "registerTurtleUpgrade", new Class[] {
                   ITurtleUpgrade.class
               } );
               computerCraft_registerBundledRedstoneProvider = findCCMethod( "registerBundledRedstoneProvider", new Class[] {
                   IBundledRedstoneProvider.class
               } );
               computerCraft_getDefaultBundledRedstoneOutput = findCCMethod( "getDefaultBundledRedstoneOutput", new Class[] {
                   World.class, Integer.TYPE, Integer.TYPE, Integer.TYPE, Integer.TYPE
               } );
               computerCraft_registerMediaProvider = findCCMethod( "registerMediaProvider", new Class[] {
                   IMediaProvider.class
               } );
		} catch( Exception e ) {
			System.out.println( "ComputerCraftAPI: ComputerCraft not found." );
		} finally {
			ccSearched = true;
		}
	}
}
 
Example #3
Source File: ComputerCraftAPI.java    From Framez with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Registers a peripheral handler to convert blocks into IPeripheral implementations.
 * @see dan200.computercraft.api.peripheral.IPeripheral
 * @see dan200.computercraft.api.peripheral.IPeripheralProvider
 */
public static void registerPeripheralProvider( IPeripheralProvider handler )
{
	findCC();
	if ( computerCraft_registerPeripheralProvider != null)
	{
		try {
			computerCraft_registerPeripheralProvider.invoke( null, handler );
		} catch (Exception e){
			// It failed
		}
	}
}
 
Example #4
Source File: ComputerCraftAPI.java    From Framez with GNU General Public License v3.0 5 votes vote down vote up
private static void findCC()
{
	if( !ccSearched ) {
		try {
			computerCraft = Class.forName( "dan200.computercraft.ComputerCraft" );
			computerCraft_createUniqueNumberedSaveDir = findCCMethod( "createUniqueNumberedSaveDir", new Class[]{
                   World.class, String.class
               } );
			computerCraft_createSaveDirMount = findCCMethod( "createSaveDirMount", new Class[] {
				World.class, String.class, Long.TYPE
			} );
			computerCraft_createResourceMount = findCCMethod( "createResourceMount", new Class[] {
				Class.class, String.class, String.class
			} );
			computerCraft_registerPeripheralProvider = findCCMethod( "registerPeripheralProvider", new Class[] {
				IPeripheralProvider.class
			} );
               computerCraft_registerTurtleUpgrade = findCCMethod( "registerTurtleUpgrade", new Class[] {
                   ITurtleUpgrade.class
               } );
               computerCraft_registerBundledRedstoneProvider = findCCMethod( "registerBundledRedstoneProvider", new Class[] {
                   IBundledRedstoneProvider.class
               } );
               computerCraft_getDefaultBundledRedstoneOutput = findCCMethod( "getDefaultBundledRedstoneOutput", new Class[] {
                   World.class, Integer.TYPE, Integer.TYPE, Integer.TYPE, Integer.TYPE
               } );
               computerCraft_registerMediaProvider = findCCMethod( "registerMediaProvider", new Class[] {
                   IMediaProvider.class
               } );
		} catch( Exception e ) {
			System.out.println( "ComputerCraftAPI: ComputerCraft not found." );
		} finally {
			ccSearched = true;
		}
	}
}
 
Example #5
Source File: ComputerCraftAPI.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Registers a peripheral handler to convert blocks into IPeripheral implementations.
 * @see dan200.computercraft.api.peripheral.IPeripheral
 * @see dan200.computercraft.api.peripheral.IPeripheralProvider
 */
public static void registerPeripheralProvider( IPeripheralProvider handler )
{
	findCC();
	if ( computerCraft_registerPeripheralProvider != null)
	{
		try {
			computerCraft_registerPeripheralProvider.invoke( null, handler );
		} catch (Exception e){
			// It failed
		}
	}
}
 
Example #6
Source File: ComputerCraftAPI.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
private static void findCC()
{
	if( !ccSearched ) {
		try {
			computerCraft = Class.forName( "dan200.computercraft.ComputerCraft" );
			computerCraft_createUniqueNumberedSaveDir = findCCMethod( "createUniqueNumberedSaveDir", new Class[]{
                   World.class, String.class
               } );
			computerCraft_createSaveDirMount = findCCMethod( "createSaveDirMount", new Class[] {
				World.class, String.class, Long.TYPE
			} );
			computerCraft_createResourceMount = findCCMethod( "createResourceMount", new Class[] {
				Class.class, String.class, String.class
			} );
			computerCraft_registerPeripheralProvider = findCCMethod( "registerPeripheralProvider", new Class[] {
				IPeripheralProvider.class
			} );
               computerCraft_registerTurtleUpgrade = findCCMethod( "registerTurtleUpgrade", new Class[] {
                   ITurtleUpgrade.class
               } );
               computerCraft_registerBundledRedstoneProvider = findCCMethod( "registerBundledRedstoneProvider", new Class[] {
                   IBundledRedstoneProvider.class
               } );
               computerCraft_getDefaultBundledRedstoneOutput = findCCMethod( "getDefaultBundledRedstoneOutput", new Class[] {
                   World.class, Integer.TYPE, Integer.TYPE, Integer.TYPE, Integer.TYPE
               } );
               computerCraft_registerMediaProvider = findCCMethod( "registerMediaProvider", new Class[] {
                   IMediaProvider.class
               } );
		} catch( Exception e ) {
			System.out.println( "ComputerCraftAPI: ComputerCraft not found." );
		} finally {
			ccSearched = true;
		}
	}
}
 
Example #7
Source File: BlockTrackEntryPeripheral.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean shouldTrackWithThisEntry(IBlockAccess world, int x, int y, int z, Block block, TileEntity te){
    if(block instanceof IPeripheralProvider) {
        IPeripheral peripheral = ((IPeripheralProvider)block).getPeripheral(te.getWorldObj(), x, y, z, 0);
        return peripheral != null && peripheral.getMethodNames().length != 0;
    } else {
        return false;
    }
}
 
Example #8
Source File: BlockTrackEntryPeripheral.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void addInformation(World world, int x, int y, int z, TileEntity te, List<String> infoList){
    infoList.add("blockTracker.info.peripheral.title");
    infoList.add("blockTracker.info.peripheral.availableMethods");
    IPeripheral peripheral = ((IPeripheralProvider)world.getBlock(x, y, z)).getPeripheral(world, x, y, z, 0);
    if(peripheral != null) {
        for(String method : peripheral.getMethodNames()) {
            infoList.add("-" + method);
        }
    }
}
 
Example #9
Source File: ComputerCraftAPI.java    From OpenPeripheral-Addons with MIT License 5 votes vote down vote up
/**
 * Registers a peripheral handler to convert blocks into IPeripheral implementations.
 * @see dan200.computercraft.api.peripheral.IPeripheral
 * @see dan200.computercraft.api.peripheral.IPeripheralProvider
 */
public static void registerPeripheralProvider( IPeripheralProvider handler )
{
	findCC();
	if ( computerCraft_registerPeripheralProvider != null)
	{
		try {
			computerCraft_registerPeripheralProvider.invoke( null, handler );
		} catch (Exception e){
			// It failed
		}
	}
}
 
Example #10
Source File: ComputerCraftAPI.java    From OpenPeripheral-Addons with MIT License 5 votes vote down vote up
private static void findCC()
{
	if( !ccSearched ) {
		try {
			computerCraft = Class.forName( "dan200.computercraft.ComputerCraft" );
			computerCraft_createUniqueNumberedSaveDir = findCCMethod( "createUniqueNumberedSaveDir", new Class[]{
                   World.class, String.class
               } );
			computerCraft_createSaveDirMount = findCCMethod( "createSaveDirMount", new Class[] {
				World.class, String.class, Long.TYPE
			} );
			computerCraft_createResourceMount = findCCMethod( "createResourceMount", new Class[] {
				Class.class, String.class, String.class
			} );
			computerCraft_registerPeripheralProvider = findCCMethod( "registerPeripheralProvider", new Class[] {
				IPeripheralProvider.class
			} );
               computerCraft_registerTurtleUpgrade = findCCMethod( "registerTurtleUpgrade", new Class[] {
                   ITurtleUpgrade.class
               } );
               computerCraft_registerBundledRedstoneProvider = findCCMethod( "registerBundledRedstoneProvider", new Class[] {
                   IBundledRedstoneProvider.class
               } );
               computerCraft_getDefaultBundledRedstoneOutput = findCCMethod( "getDefaultBundledRedstoneOutput", new Class[] {
                   World.class, Integer.TYPE, Integer.TYPE, Integer.TYPE, Integer.TYPE
               } );
               computerCraft_registerMediaProvider = findCCMethod( "registerMediaProvider", new Class[] {
                   IMediaProvider.class
               } );
		} catch( Exception e ) {
			System.out.println( "ComputerCraftAPI: ComputerCraft not found." );
		} finally {
			ccSearched = true;
		}
	}
}
 
Example #11
Source File: ComputerCraftAPI.java    From BigReactors with MIT License 5 votes vote down vote up
/**
 * Registers a peripheral handler to convert blocks into IPeripheral implementations.
 * @see dan200.computercraft.api.peripheral.IPeripheral
 * @see dan200.computercraft.api.peripheral.IPeripheralProvider
 */
public static void registerPeripheralProvider( IPeripheralProvider handler )
{
	findCC();
	if ( computerCraft_registerPeripheralProvider != null)
	{
		try {
			computerCraft_registerPeripheralProvider.invoke( null, handler );
		} catch (Exception e){
			// It failed
		}
	}
}
 
Example #12
Source File: ComputerCraftAPI.java    From BigReactors with MIT License 5 votes vote down vote up
private static void findCC()
{
	if( !ccSearched ) {
		try {
			computerCraft = Class.forName( "dan200.computercraft.ComputerCraft" );
			computerCraft_createUniqueNumberedSaveDir = findCCMethod( "createUniqueNumberedSaveDir", new Class[]{
                   World.class, String.class
               } );
			computerCraft_createSaveDirMount = findCCMethod( "createSaveDirMount", new Class[] {
				World.class, String.class, Long.TYPE
			} );
			computerCraft_createResourceMount = findCCMethod( "createResourceMount", new Class[] {
				Class.class, String.class, String.class
			} );
			computerCraft_registerPeripheralProvider = findCCMethod( "registerPeripheralProvider", new Class[] {
				IPeripheralProvider.class
			} );
               computerCraft_registerTurtleUpgrade = findCCMethod( "registerTurtleUpgrade", new Class[] {
                   ITurtleUpgrade.class
               } );
               computerCraft_registerBundledRedstoneProvider = findCCMethod( "registerBundledRedstoneProvider", new Class[] {
                   IBundledRedstoneProvider.class
               } );
               computerCraft_getDefaultBundledRedstoneOutput = findCCMethod( "getDefaultBundledRedstoneOutput", new Class[] {
                   World.class, Integer.TYPE, Integer.TYPE, Integer.TYPE, Integer.TYPE
               } );
               computerCraft_registerMediaProvider = findCCMethod( "registerMediaProvider", new Class[] {
                   IMediaProvider.class
               } );
		} catch( Exception e ) {
			System.out.println( "ComputerCraftAPI: ComputerCraft not found." );
		} finally {
			ccSearched = true;
		}
	}
}
 
Example #13
Source File: ComputerCraftAPI.java    From OpenPeripheral with MIT License 5 votes vote down vote up
/**
 * Registers a peripheral handler to convert blocks into IPeripheral implementations.
 * @see dan200.computercraft.api.peripheral.IPeripheral
 * @see dan200.computercraft.api.peripheral.IPeripheralProvider
 */
public static void registerPeripheralProvider( IPeripheralProvider handler )
{
	findCC();
	if ( computerCraft_registerPeripheralProvider != null)
	{
		try {
			computerCraft_registerPeripheralProvider.invoke( null, handler );
		} catch (Exception e){
			// It failed
		}
	}
}
 
Example #14
Source File: ComputerCraftAPI.java    From OpenPeripheral with MIT License 5 votes vote down vote up
private static void findCC()
{
	if( !ccSearched ) {
		try {
			computerCraft = Class.forName( "dan200.computercraft.ComputerCraft" );
			computerCraft_createUniqueNumberedSaveDir = findCCMethod( "createUniqueNumberedSaveDir", new Class[]{
                   World.class, String.class
               } );
			computerCraft_createSaveDirMount = findCCMethod( "createSaveDirMount", new Class[] {
				World.class, String.class, Long.TYPE
			} );
			computerCraft_createResourceMount = findCCMethod( "createResourceMount", new Class[] {
				Class.class, String.class, String.class
			} );
			computerCraft_registerPeripheralProvider = findCCMethod( "registerPeripheralProvider", new Class[] {
				IPeripheralProvider.class
			} );
               computerCraft_registerTurtleUpgrade = findCCMethod( "registerTurtleUpgrade", new Class[] {
                   ITurtleUpgrade.class
               } );
               computerCraft_registerBundledRedstoneProvider = findCCMethod( "registerBundledRedstoneProvider", new Class[] {
                   IBundledRedstoneProvider.class
               } );
               computerCraft_getDefaultBundledRedstoneOutput = findCCMethod( "getDefaultBundledRedstoneOutput", new Class[] {
                   World.class, Integer.TYPE, Integer.TYPE, Integer.TYPE, Integer.TYPE
               } );
               computerCraft_registerMediaProvider = findCCMethod( "registerMediaProvider", new Class[] {
                   IMediaProvider.class
               } );
		} catch( Exception e ) {
			System.out.println( "ComputerCraftAPI: ComputerCraft not found." );
		} finally {
			ccSearched = true;
		}
	}
}
 
Example #15
Source File: ComputerCraft.java    From PneumaticCraft with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void onBlockRegistry(Block block){
    if(block instanceof IPeripheralProvider) {
        ComputerCraftAPI.registerPeripheralProvider((IPeripheralProvider)block);
    }
}