本文整理汇总了Java中li.cil.oc.api.network.ManagedEnvironment类的典型用法代码示例。如果您正苦于以下问题:Java ManagedEnvironment类的具体用法?Java ManagedEnvironment怎么用?Java ManagedEnvironment使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ManagedEnvironment类属于li.cil.oc.api.network包,在下文中一共展示了ManagedEnvironment类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: testSignallingPeripheral
import li.cil.oc.api.network.ManagedEnvironment; //导入依赖的package包/类
@Test
public void testSignallingPeripheral() throws Exception {
setupEnvMocks();
Map<String, Pair<IMethodExecutor, IMethodCall>> mocks = Maps.newHashMap();
addMethod(mocks, "async", true, Optional.of("hello"), "desc1");
addMethod(mocks, "sync", false, Optional.of("hello"), "desc2");
Map<String, IMethodExecutor> methods = extractExecutors(mocks);
ICodeGenerator generator = new PeripheralCodeGenerator();
Class<?> cls = generateClass("TestClass\u2659", TargetClass.class, methods, generator);
final TargetClass target = mock(TargetClass.class);
Object o = cls.getConstructor(TargetClass.class).newInstance(target);
Assert.assertTrue(o instanceof ISignallingCallerBase);
Assert.assertTrue(o instanceof ManagedEnvironment);
ManagedEnvironment e = (ManagedEnvironment)o;
Assert.assertTrue(e.canUpdate());
testSignallingMethod(cls, "async");
testSignallingMethod(cls, "sync");
}
开发者ID:OpenMods,项目名称:OpenPeripheral,代码行数:25,代码来源:EnvironmentGeneratorTest.java
示例2: testNodeConnectivity
import li.cil.oc.api.network.ManagedEnvironment; //导入依赖的package包/类
@Test
public void testNodeConnectivity() throws Exception {
setupOpenComputersApiMock();
ICodeGenerator generator = new PeripheralCodeGenerator();
Map<String, IMethodExecutor> methods = Maps.newHashMap();
Class<? extends ManagedEnvironment> cls = generateClass("TestClass\u2654", SemiAwareTargetClass.class, ImmutableSet.<Class<?>> of(), methods, generator);
final SemiAwareTargetClass target = mock(SemiAwareTargetClass.class);
ManagedEnvironment o = cls.getConstructor(SemiAwareTargetClass.class).newInstance(target);
Node node = mock(Node.class);
o.onConnect(node);
verifyOcSpecificConnectCall(target, node);
o.onDisconnect(node);
verifyOcSpecificDisconnectCall(target, node);
}
开发者ID:OpenMods,项目名称:OpenPeripheral,代码行数:21,代码来源:EnvironmentGeneratorTest.java
示例3: createEnvironment
import li.cil.oc.api.network.ManagedEnvironment; //导入依赖的package包/类
@Override
public ManagedEnvironment createEnvironment(World world, int x, int y, int z) {
TileEntity te = world.getTileEntity(x, y, z);
if (te != null && te instanceof TileMotor)
return new EnvironmentMotor((TileMotor) te);
return null;
}
开发者ID:amadornes,项目名称:Framez,代码行数:9,代码来源:DriverMotor.java
示例4: init
import li.cil.oc.api.network.ManagedEnvironment; //导入依赖的package包/类
public static void init() {
final MethodSelector peripheralSelector = new MethodSelector(Constants.ARCH_OPEN_COMPUTERS)
.allowReturnSignal()
.addDefaultEnv()
.addProvidedEnv(Constants.ARG_ACCESS, IArchitectureAccess.class)
.addProvidedEnv(Constants.ARG_CONTEXT, Context.class)
.addProvidedEnv(Constants.ARG_NODE, Node.class);
PERIPHERAL_METHODS_FACTORY = new EnvironmentMethodsFactory<ManagedEnvironment>(
AdapterRegistry.PERIPHERAL_ADAPTERS,
peripheralSelector,
PERIPHERAL_CLASS_PREFIX,
new PeripheralCodeGenerator());
InjectedClassesManager.instance.registerProvider(PERIPHERAL_CLASS_PREFIX, new EnvironmentClassBytesProvider<ManagedEnvironment>(PERIPHERAL_METHODS_FACTORY));
final MethodSelector objectSelector = new MethodSelector(Constants.ARCH_OPEN_COMPUTERS)
// .allowReturnSignal() // for symmetry with CC
.addDefaultEnv()
.addProvidedEnv(Constants.ARG_CONTEXT, Context.class);
OBJECT_METHODS_FACTORY = new EnvironmentMethodsFactory<Value>(
AdapterRegistry.OBJECT_ADAPTERS,
objectSelector,
OBJECT_CLASS_PREFIX,
new ObjectCodeGenerator());
InjectedClassesManager.instance.registerProvider(OBJECT_CLASS_PREFIX, new EnvironmentClassBytesProvider<Value>(OBJECT_METHODS_FACTORY));
CommandDump.addArchSerializer("OpenComputers", "peripheral", DocBuilder.TILE_ENTITY_DECORATOR, PERIPHERAL_METHODS_FACTORY);
CommandDump.addArchSerializer("OpenComputers", "object", DocBuilder.SCRIPT_OBJECT_DECORATOR, OBJECT_METHODS_FACTORY);
final IConverter converter = new TypeConversionRegistryOC();
TypeConvertersProvider.INSTANCE.registerConverter(Constants.ARCH_OPEN_COMPUTERS, converter);
TypeClassifier.INSTANCE.registerType(Value.class, SingleArgType.OBJECT);
ENV = new OpenComputersEnv(converter);
}
开发者ID:OpenMods,项目名称:OpenPeripheral,代码行数:40,代码来源:ModuleOpenComputers.java
示例5: createEnvironment
import li.cil.oc.api.network.ManagedEnvironment; //导入依赖的package包/类
@Override
public ManagedEnvironment createEnvironment(World world, int x, int y, int z) {
TileEntity te = world.getTileEntity(x, y, z);
if (te == null) {
Log.warn("Trying to provide environment for %d,%d,%d in world %d, but TE not found", x, y, z, world.provider.dimensionId);
return null;
}
final IEnviromentInstanceWrapper<ManagedEnvironment> adaptedClass = ModuleOpenComputers.PERIPHERAL_METHODS_FACTORY.getAdaptedClass(te.getClass());
return adaptedClass.createEnvironment(te);
}
开发者ID:OpenMods,项目名称:OpenPeripheral,代码行数:12,代码来源:DriverOpenPeripheral.java
示例6: createPeripheral
import li.cil.oc.api.network.ManagedEnvironment; //导入依赖的package包/类
@Override
public ManagedEnvironment createPeripheral(Object target) {
try {
return wrap(target, ModuleOpenComputers.PERIPHERAL_METHODS_FACTORY);
} catch (Throwable t) {
throw new GenerationFailedException(String.format("%s (%s)", target, target.getClass()), t);
}
}
开发者ID:OpenMods,项目名称:OpenPeripheral,代码行数:9,代码来源:AdapterFactoryWrapperOC.java
示例7: testPeripheral
import li.cil.oc.api.network.ManagedEnvironment; //导入依赖的package包/类
@Test
public void testPeripheral() throws Exception {
setupEnvMocks();
final Node node = setupOpenComputersApiMock();
Map<String, Pair<IMethodExecutor, IMethodCall>> mocks = Maps.newHashMap();
addDefaultMethods(mocks);
Map<String, IMethodExecutor> methods = extractExecutors(mocks);
ICodeGenerator generator = new PeripheralCodeGenerator();
Class<?> cls = generateClass("TestClass\u2652", TargetClass.class, ImmutableSet.of(InterfaceA.class, InterfaceB.class), methods, generator);
final TargetClass target = mock(TargetClass.class);
Object o = cls.getConstructor(TargetClass.class).newInstance(target);
Assert.assertTrue(o instanceof ICallerBase);
Assert.assertTrue(o instanceof ManagedEnvironment);
Assert.assertTrue(o instanceof InterfaceA);
Assert.assertTrue(o instanceof InterfaceB);
ManagedEnvironment e = (ManagedEnvironment)o;
Assert.assertFalse(e.canUpdate());
verifyCallThrough(target, o);
testMethods(mocks, cls, target, o, new ArgVerifier() {
@Override
public void verifyCall(IMethodCall call, Context context) {
verify(ModuleOpenComputers.ENV).addPeripheralArgs(call, node, context);
}
});
}
开发者ID:OpenMods,项目名称:OpenPeripheral,代码行数:35,代码来源:EnvironmentGeneratorTest.java
示例8: testPeripheralNullTarget
import li.cil.oc.api.network.ManagedEnvironment; //导入依赖的package包/类
@Test(expected = IllegalStateException.class)
public void testPeripheralNullTarget() throws Throwable {
setupEnvMocks();
setupOpenComputersApiMock();
Map<String, Pair<IMethodExecutor, IMethodCall>> mocks = Maps.newHashMap();
addMethod(mocks, "a1", true, "desc1");
Map<String, IMethodExecutor> methods = extractExecutors(mocks);
ICodeGenerator generator = new PeripheralCodeGenerator();
Class<?> cls = generateClass("TestClass\u2655", TargetClass.class, ImmutableSet.<Class<?>> of(), methods, generator);
Object o = cls.getConstructor(TargetClass.class).newInstance(new Object[] { null });
Assert.assertTrue(o instanceof ManagedEnvironment);
Method m = getMethod(cls, "a1");
Arguments args = mock(Arguments.class);
Context context = mock(Context.class);
try {
m.invoke(o, context, args);
} catch (InvocationTargetException e) {
throw e.getTargetException();
}
}
开发者ID:OpenMods,项目名称:OpenPeripheral,代码行数:30,代码来源:EnvironmentGeneratorTest.java
示例9: testConnectivity
import li.cil.oc.api.network.ManagedEnvironment; //导入依赖的package包/类
@Test
public void testConnectivity() throws Exception {
final Node node = setupOpenComputersApiMock();
ICodeGenerator generator = new PeripheralCodeGenerator();
Map<String, IMethodExecutor> methods = Maps.newHashMap();
Class<? extends ManagedEnvironment> cls = generateClass("TestClass\u2653", AwareTargetClass.class, ImmutableSet.<Class<?>> of(), methods, generator);
final AwareTargetClass target = mock(AwareTargetClass.class);
ManagedEnvironment o = cls.getConstructor(AwareTargetClass.class).newInstance(target);
ContextEnvironment environment = mock(ContextEnvironment.class);
final String nodeAddress = "node_11";
when(node.address()).thenReturn(nodeAddress);
when(node.host()).thenReturn(environment);
when(environment.node()).thenReturn(node);
final OpenComputersEnv env = mock(OpenComputersEnv.class);
final IArchitectureAccess access = mock(IArchitectureAccess.class);
when(env.createAccess(node, environment)).thenReturn(access);
ModuleOpenComputers.ENV = env;
o.onConnect(node);
verify(target).addComputer(access);
verifyOcSpecificConnectCall(target, node);
o.onDisconnect(node);
verify(target).removeComputer(access);
verifyOcSpecificDisconnectCall(target, node);
}
开发者ID:OpenMods,项目名称:OpenPeripheral,代码行数:32,代码来源:EnvironmentGeneratorTest.java
示例10: testCommonConnectivity
import li.cil.oc.api.network.ManagedEnvironment; //导入依赖的package包/类
@Test
public void testCommonConnectivity() throws Exception {
final Node node = setupOpenComputersApiMock();
ICodeGenerator generator = new PeripheralCodeGenerator();
Map<String, IMethodExecutor> methods = Maps.newHashMap();
Class<? extends ManagedEnvironment> cls = generateClass("TestClass\u2658", CommonAwareTargetClass.class, ImmutableSet.<Class<?>> of(), methods, generator);
final CommonAwareTargetClass target = mock(CommonAwareTargetClass.class);
ManagedEnvironment o = cls.getConstructor(CommonAwareTargetClass.class).newInstance(target);
ContextEnvironment environment = mock(ContextEnvironment.class);
final String nodeAddress = "node_13";
when(node.address()).thenReturn(nodeAddress);
when(node.host()).thenReturn(environment);
when(environment.node()).thenReturn(node);
final OpenComputersEnv env = mock(OpenComputersEnv.class);
final IArchitectureAccess access = mock(IArchitectureAccess.class);
when(env.createAccess(node, environment)).thenReturn(access);
ModuleOpenComputers.ENV = env;
o.onConnect(node);
verify(target).addComputer(access);
o.onDisconnect(node);
verify(target).removeComputer(access);
}
开发者ID:OpenMods,项目名称:OpenPeripheral,代码行数:30,代码来源:EnvironmentGeneratorTest.java
示例11: createEnvironment
import li.cil.oc.api.network.ManagedEnvironment; //导入依赖的package包/类
@Override
public ManagedEnvironment createEnvironment(World world, BlockPos blockPos, EnumFacing enumFacing) {
return new InternalManagedEnvironment((TileEntityBase) world.getTileEntity(blockPos));
}
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:5,代码来源:DriverPneumaticCraft.java
示例12: createEnvironment
import li.cil.oc.api.network.ManagedEnvironment; //导入依赖的package包/类
@Override
public ManagedEnvironment createEnvironment(ItemStack stack, EnvironmentHost host)
{
return new Environment(host);
}
开发者ID:lumien231,项目名称:Simple-Dimensions,代码行数:6,代码来源:SimpleDimensionsCardDriver.java
示例13: createEnvironment
import li.cil.oc.api.network.ManagedEnvironment; //导入依赖的package包/类
@Override
public ManagedEnvironment createEnvironment(ItemStack stack, EnvironmentHost host) {
return new EnvTeslaUpgrade(host);
}
开发者ID:Avaja,项目名称:OpenTechnology,代码行数:5,代码来源:DriverTeslaUpgrade.java
示例14: createEnvironment
import li.cil.oc.api.network.ManagedEnvironment; //导入依赖的package包/类
@Override
public ManagedEnvironment createEnvironment(ItemStack stack, EnvironmentHost host) {
return new EnvNRUpgrade(host);
}
开发者ID:Avaja,项目名称:OpenTechnology,代码行数:5,代码来源:DriverNRUpgrade.java
示例15: createEnvironment
import li.cil.oc.api.network.ManagedEnvironment; //导入依赖的package包/类
@Override
public ManagedEnvironment createEnvironment(ItemStack stack, EnvironmentHost host) {
return new EnvRadarUpgrade(host);
}
开发者ID:Avaja,项目名称:OpenTechnology,代码行数:5,代码来源:DriverRadarUpgrade.java
示例16: createEnvironment
import li.cil.oc.api.network.ManagedEnvironment; //导入依赖的package包/类
@Override
public ManagedEnvironment createEnvironment(World world, int x, int y, int z) {
return new Environment((TileEntityInfoPanel)world.getTileEntity(x, y, z));
}
开发者ID:xbony2,项目名称:Nuclear-Control,代码行数:5,代码来源:DriverInfoPanel.java
示例17: createEnvironment
import li.cil.oc.api.network.ManagedEnvironment; //导入依赖的package包/类
@Override
public ManagedEnvironment createEnvironment(World world, int x, int y, int z) {
return new Environment((TileEntityHowlerAlarm)world.getTileEntity(x, y, z));
}
开发者ID:xbony2,项目名称:Nuclear-Control,代码行数:5,代码来源:DriverHowlerAlarm.java
示例18: createEnvironment
import li.cil.oc.api.network.ManagedEnvironment; //导入依赖的package包/类
@Override
public ManagedEnvironment createEnvironment(World world, int x, int y, int z){
return new Environment((TileEntityEnergyCounter)world.getTileEntity(x, y, z));
}
开发者ID:xbony2,项目名称:Nuclear-Control,代码行数:5,代码来源:DriverEnergyCounter.java
示例19: createEnvironment
import li.cil.oc.api.network.ManagedEnvironment; //导入依赖的package包/类
@Override
public ManagedEnvironment createEnvironment(World world, int x, int y, int z) {
return new Environment((TileEntityThermo)world.getTileEntity(x, y, z));
}
开发者ID:xbony2,项目名称:Nuclear-Control,代码行数:5,代码来源:DriverThermalMonitor.java
示例20: createEnvironment
import li.cil.oc.api.network.ManagedEnvironment; //导入依赖的package包/类
@Override
public ManagedEnvironment createEnvironment(World world, int x, int y, int z) {
return new Environment((TileEntityAdvancedInfoPanel)world.getTileEntity(x, y, z));
}
开发者ID:xbony2,项目名称:Nuclear-Control,代码行数:5,代码来源:DriverAdvancedInfoPanel.java
注:本文中的li.cil.oc.api.network.ManagedEnvironment类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论