本文整理汇总了Java中dan200.computercraft.api.peripheral.IPeripheralProvider类的典型用法代码示例。如果您正苦于以下问题:Java IPeripheralProvider类的具体用法?Java IPeripheralProvider怎么用?Java IPeripheralProvider使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IPeripheralProvider类属于dan200.computercraft.api.peripheral包,在下文中一共展示了IPeripheralProvider类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: shouldTrackWithThisEntry
import dan200.computercraft.api.peripheral.IPeripheralProvider; //导入依赖的package包/类
@Override
public boolean shouldTrackWithThisEntry(IBlockAccess world, BlockPos pos, IBlockState state, TileEntity te) {
if (state.getBlock() instanceof IPeripheralProvider) {
IPeripheral peripheral = ((IPeripheralProvider) state.getBlock()).getPeripheral(te.getWorld(), pos, EnumFacing.DOWN);
return peripheral != null && peripheral.getMethodNames().length != 0;
} else {
return false;
}
}
示例2: addInformation
import dan200.computercraft.api.peripheral.IPeripheralProvider; //导入依赖的package包/类
@Override
public void addInformation(World world, BlockPos pos, TileEntity te, List<String> infoList) {
infoList.add("blockTracker.info.peripheral.title");
infoList.add("blockTracker.info.peripheral.availableMethods");
IPeripheral peripheral = ((IPeripheralProvider) world.getBlockState(pos).getBlock()).getPeripheral(world, pos, EnumFacing.DOWN);
if (peripheral != null) {
for (String method : peripheral.getMethodNames()) {
infoList.add("-" + method);
}
}
}
示例3: registerPeripheralProvider
import dan200.computercraft.api.peripheral.IPeripheralProvider; //导入依赖的package包/类
/**
* 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
}
}
}
示例4: initComputerCraft
import dan200.computercraft.api.peripheral.IPeripheralProvider; //导入依赖的package包/类
@Optional.Method(modid = Configs.COMPUTERCRAFT)
private static void initComputerCraft() {
log.info("Init ComputerCraft Handler");
ComputerCraftAPI.registerPeripheralProvider((IPeripheralProvider) enderMemory);
// ComputerCraftAPI.registerPeripheralProvider((IPeripheralProvider)
// CCProxy);
ComputerCraftAPI.registerPeripheralProvider((IPeripheralProvider) GPU);
ComputerCraftAPI.registerPeripheralProvider((IPeripheralProvider) Monitor);
ComputerCraftAPI.registerPeripheralProvider((IPeripheralProvider) WirelessPeripheral);
ComputerCraftAPI.registerPeripheralProvider((IPeripheralProvider) EnderPlayerSensor);
ComputerCraftAPI.registerPeripheralProvider((IPeripheralProvider) holotapeReader);
ComputerCraftAPI.registerPeripheralProvider((IPeripheralProvider) holotapeWriter);
ComputerCraftAPI.registerPeripheralProvider((IPeripheralProvider) RedstonePort);
ComputerCraftAPI.registerPeripheralProvider((IPeripheralProvider) DefenseInit.forceCapacitor);
/*ComputerCraftAPI.registerPeripheralProvider((IPeripheralProvider) EnergyInit.MK1Storage);
ComputerCraftAPI.registerPeripheralProvider((IPeripheralProvider) EnergyInit.MK2Storage);
ComputerCraftAPI.registerPeripheralProvider((IPeripheralProvider) EnergyInit.MK3Storage);*/
ComputerCraftAPI.registerPeripheralProvider(EnergyInit.batteryBox);
ComputerCraftAPI.registerPeripheralProvider((IPeripheralProvider) MagCardDevice);
// ComputerCraftAPI.registerPeripheralProvider((IPeripheralProvider) ComputerRegulator);
// ComputerRegulatorClass.init();
if (Config.enableAdventureItems) {
ComputerCraftAPI.registerPeripheralProvider((IPeripheralProvider) TabletController);
ComputerCraftAPI.registerPeripheralProvider((IPeripheralProvider) AntennaController);
}
if (Config.enableCommandExecutor)
ComputerCraftAPI.registerPeripheralProvider((IPeripheralProvider) CommandExecutor);
ComputerCraftAPI.registerPeripheralProvider(MultipartProvider.INSTANCE);
log.info("ComputerCraft Handler Loaded");
}
示例5: init
import dan200.computercraft.api.peripheral.IPeripheralProvider; //导入依赖的package包/类
public static void init() {
registerTabs();
registerBlocks();
registerItems();
registerEvents();
if (Loader.isModLoaded("ComputerCraft")) {
ComputerCraftAPI.registerPeripheralProvider((IPeripheralProvider) blockRadio);
}
}
示例6: findCC
import dan200.computercraft.api.peripheral.IPeripheralProvider; //导入依赖的package包/类
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;
}
}
}
示例7: matches
import dan200.computercraft.api.peripheral.IPeripheralProvider; //导入依赖的package包/类
@Override
public boolean matches(InventoryCrafting craftingInventory, World world) {
boolean hasContainer = false;
boolean hasPeripheral = false;
int numOfPeripherals = 0;
int numOfContained = 0;
ItemStack container = new ItemStack(ModBlocks.peripheralContainer);
for (int i = 0; i < craftingInventory.getSizeInventory(); i++)
if (craftingInventory.getStackInSlot(i) != null) {
if (!(craftingInventory.getStackInSlot(i).getItem() instanceof ItemBlock))
return false;
else {
Block block = Block.getBlockFromItem(craftingInventory.getStackInSlot(i).getItem());
if (block instanceof BlockPeripheralContainer && hasContainer)
return false;
else if (block instanceof BlockPeripheralContainer) {
hasContainer = true;
container = craftingInventory.getStackInSlot(i);
} else if (ArrayUtils.indexOf(blacklist, block) == -1) {
return false;
} else if (block instanceof IPeripheralProvider) {
hasPeripheral = true;
numOfPeripherals++;
}
}
}
numOfContained = container.stackTagCompound == null || container.stackTagCompound.hasNoTags() ? 0 : NBTHelper.getIntArray(container, "ids").length;
return hasContainer && hasPeripheral && (numOfContained+numOfPeripherals <= Config.maxNumberOfPeripherals);
}
示例8: getCraftingResult
import dan200.computercraft.api.peripheral.IPeripheralProvider; //导入依赖的package包/类
@Override
public ItemStack getCraftingResult(InventoryCrafting craftingInventory) {
HashMap<Integer,IPeripheral> map = new HashMap<Integer,IPeripheral>();
ItemStack base = new ItemStack(ModBlocks.peripheralContainer);
for (int i = 0; i < craftingInventory.getSizeInventory(); i++)
if (craftingInventory.getStackInSlot(i) != null)
if (Block.getBlockFromItem(craftingInventory.getStackInSlot(i).getItem()) instanceof IPeripheralProvider && !(Block.getBlockFromItem(craftingInventory.getStackInSlot(i).getItem()) instanceof BlockPeripheralContainer)) {
TileEntity ent = Block.getBlockFromItem(craftingInventory.getStackInSlot(i).getItem()).createTileEntity(null, 0);
if (ent != null && ent instanceof IPeripheral)
map.put(Block.getIdFromBlock(Block.getBlockFromItem(craftingInventory.getStackInSlot(i).getItem())), (IPeripheral)ent);
}else if (Block.getBlockFromItem(craftingInventory.getStackInSlot(i).getItem()) instanceof BlockPeripheralContainer)
base.stackTagCompound = craftingInventory.getStackInSlot(i).stackTagCompound == null ? null : (NBTTagCompound) craftingInventory.getStackInSlot(i).stackTagCompound.copy();
List<String> text = new ArrayList<String>();
if (base.stackTagCompound == null || base.stackTagCompound.hasNoTags() || !base.stackTagCompound.hasKey("ids")) {
NBTHelper.setIntArray(base, "ids", setToArray(map.keySet()));
text.add(Colors.RESET.toString()+Colors.UNDERLINE+"Contained Peripherals:");
for (IPeripheral p : map.values())
text.add(Colors.RESET+p.getType());
NBTHelper.addInfo(base, text);
} else {
text.add(Colors.RESET.toString()+Colors.UNDERLINE+"Contained Peripherals:");
int[] ids = NBTHelper.getIntArray(base, "ids");
int[] newIds = new int[ids.length+map.size()];
for (int j = 0; j < ids.length+map.size(); j++)
newIds[j] = j >= ids.length ? (Integer)map.keySet().toArray()[j-ids.length] : ids[j];
NBTHelper.setIntArray(base, "ids", newIds);
for (int id : newIds) {
Block peripheral = Block.getBlockById(id);
IPeripheral iPeripheral = (IPeripheral)peripheral.createTileEntity(null, 0);
text.add(Colors.RESET+iPeripheral.getType());
}
NBTHelper.setInfo(base, text);
}
return base;
}
示例9: shouldTrackWithThisEntry
import dan200.computercraft.api.peripheral.IPeripheralProvider; //导入依赖的package包/类
@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;
}
}
示例10: addInformation
import dan200.computercraft.api.peripheral.IPeripheralProvider; //导入依赖的package包/类
@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);
}
}
}