• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Node类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中li.cil.oc.api.network.Node的典型用法代码示例。如果您正苦于以下问题:Java Node类的具体用法?Java Node怎么用?Java Node使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Node类属于li.cil.oc.api.network包,在下文中一共展示了Node类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: readFromNBT

import li.cil.oc.api.network.Node; //导入依赖的package包/类
@Override
public void readFromNBT(final NBTTagCompound nbt) {
    super.readFromNBT(nbt);
    int index = 0;
    for (Node node : nodes) {
        // The host check may be superfluous for you. It's just there to allow
        // some special cases, where getNode() returns some node managed by
        // some other instance (for example when you have multiple internal
        // nodes in this tile entity).
        if (node != null && node.host() == this) {
            // This restores the node's address, which is required for networks
            // to continue working without interruption across loads. If the
            // node is a power connector this is also required to restore the
            // internal energy buffer of the node.
            node.load(nbt.getCompoundTag("oc:node" + index));
        }
        ++index;
    }
}
 
开发者ID:Herobone,项目名称:HeroUtils,代码行数:20,代码来源:TileEntitySidedEnvironment.java


示例2: hardwareInvoke

import li.cil.oc.api.network.Node; //导入依赖的package包/类
private Object[] hardwareInvoke(String address, String method, Object[] params) throws Exception {
	if(method.equals("_getMethods")) {
		Node node = machine.node().network().node(address);
		if(node == null || !(node instanceof Component)) return new Object[]{null, "node disappeared?"};
		Component component = (Component)node;
		TreeMap<Object, Object> ret = new TreeMap<Object, Object>();
		for(String name : component.methods()) {
			Callback cb = component.annotation(name);
			if(cb != null) {
				TreeMap<Object, Object> map = new TreeMap<Object, Object>();
				map.put("direct", cb.direct());
				map.put("getter", cb.getter());
				map.put("setter", cb.setter());
				ret.put(name, map);
			}
		}
		return new Object[]{ret};
	}
	else return machine.invoke(address, method, params);
}
 
开发者ID:SolraBizna,项目名称:jarm,代码行数:21,代码来源:CP3.java


示例3: sidedNode

import li.cil.oc.api.network.Node; //导入依赖的package包/类
@Optional.Method(modid = "OpenComputers")
@Override
public Node sidedNode(ForgeDirection side) {
	if (worldObj.isRemote) {
		return null;
	}

	Pocket p = getPocket();
	if (p == null) {
		return null;
	}

	switch (p.getFlowState(side)) {
		case ENERGY:
			TileEntity te = getFrameConnectorNeighborTileEntity(side);
			if (te instanceof SidedEnvironment) {
				return ((SidedEnvironment) te).sidedNode(side);
			} else if (te instanceof Environment) {
				return ((Environment) te).node();
			}
			return null;
		default:
			return null;
	}
}
 
开发者ID:NPException,项目名称:Dimensional-Pockets,代码行数:26,代码来源:TileDimensionalPocket.java


示例4: updateVolume

import li.cil.oc.api.network.Node; //导入依赖的package包/类
public void updateVolume()
{
	for (int x=0; x<mWidth; x++)
	{
		for (int y=0; y<mHeight; y++)
		{
			TileEntityExternalMonitor rtile = (TileEntityExternalMonitor) worldObj.getTileEntity(getXFromOrient(x-mX,y-mY), getYFromOrient(x-mX,y-mY), getZFromOrient(x-mX,y-mY));
			rtile.r = r;
			rtile.g = g;
			rtile.b = b;
			rtile.mX = x;
			rtile.mY = y;
			rtile.mWidth = mWidth;
			rtile.mHeight = mHeight;
			if (rtile.mon != mon && rtile.mon != null)
			{
				for (Node n : rtile.mon.node().network().nodes(rtile.mon.node()))
				{
					n.network().disconnect(n, rtile.mon.node());
				}
			}
			rtile.mon = mon;
		}
	}
}
 
开发者ID:ds84182,项目名称:OpenGX,代码行数:26,代码来源:TileEntityExternalMonitor.java


示例5: testNodeConnectivity

import li.cil.oc.api.network.Node; //导入依赖的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


示例6: onChunkUnload

import li.cil.oc.api.network.Node; //导入依赖的package包/类
@Override
public void onChunkUnload() {
    super.onChunkUnload();
    // Make sure to remove the node from its network when its environment,
    // meaning this tile entity, gets unloaded.
    for (Node node : nodes) {
        if (node != null) node.remove();
    }
}
 
开发者ID:Herobone,项目名称:HeroUtils,代码行数:10,代码来源:TileEntitySidedEnvironment.java


示例7: invalidate

import li.cil.oc.api.network.Node; //导入依赖的package包/类
@Override
public void invalidate() {
    super.invalidate();
    // Make sure to remove the node from its network when its environment,
    // meaning this tile entity, gets unloaded.
    for (Node node : nodes) {
        if (node != null) node.remove();
    }
}
 
开发者ID:Herobone,项目名称:HeroUtils,代码行数:10,代码来源:TileEntitySidedEnvironment.java


示例8: writeToNBT

import li.cil.oc.api.network.Node; //导入依赖的package包/类
@Override
public NBTTagCompound writeToNBT(NBTTagCompound nbt) {
    super.writeToNBT(nbt);
    int index = 0;
    for (Node node : nodes) {
        // See readFromNBT() regarding host check.
        if (node != null && node.host() == this) {
            final NBTTagCompound nodeNbt = new NBTTagCompound();
            node.save(nodeNbt);
            nbt.setTag("oc:node" + index, nodeNbt);
        }
        ++index;
    }
    return nbt;
}
 
开发者ID:Herobone,项目名称:HeroUtils,代码行数:16,代码来源:TileEntitySidedEnvironment.java


示例9: onConnect

import li.cil.oc.api.network.Node; //导入依赖的package包/类
@Override
public void onConnect(final Node node) {
    // This is called when the call to Network.joinOrCreateNetwork(this) in
    // updateEntity was successful, in which case `node == this`.
    // This is also called for any other node that gets connected to the
    // network our node is in, in which case `node` is the added node.
    // If our node is added to an existing network, this is called for each
    // node already in said network.
}
 
开发者ID:Herobone,项目名称:HeroUtils,代码行数:10,代码来源:TileEntityEnvironment.java


示例10: onDisconnect

import li.cil.oc.api.network.Node; //导入依赖的package包/类
@Override
public void onDisconnect(final Node node) {
    // This is called when this node is removed from its network when the
    // tile entity is removed from the world (see onChunkUnload() and
    // invalidate()), in which case `node == this`.
    // This is also called for each other node that gets removed from the
    // network our node is in, in which case `node` is the removed node.
    // If a net-split occurs this is called for each node that is no longer
    // connected to our node.
}
 
开发者ID:Herobone,项目名称:HeroUtils,代码行数:11,代码来源:TileEntityEnvironment.java


示例11: writeToNBT

import li.cil.oc.api.network.Node; //导入依赖的package包/类
@Override
public void writeToNBT(NBTTagCompound nbt) {
    super.writeToNBT(nbt);
    int index = 0;
    for (Node node : nodes) {
        // See readFromNBT() regarding host check.
        if (node != null && node.host() == this) {
            final NBTTagCompound nodeNbt = new NBTTagCompound();
            node.save(nodeNbt);
            nbt.setTag("oc:node" + index, nodeNbt);
        }
        ++index;
    }
}
 
开发者ID:java8compiler,项目名称:OpenTeleporter,代码行数:15,代码来源:TileEntitySidedEnvironment.java


示例12: invoke

import li.cil.oc.api.network.Node; //导入依赖的package包/类
@Override
public Object[] invoke(String address, String method, Object[] args)
		throws Exception {
	Node n = network.node(address);
	if (n == null || !(n instanceof Component)) {
		throw new NoSuchMethodError();
	}
	return ((Component) n).invoke(method, this, args);
}
 
开发者ID:SolraBizna,项目名称:jarm,代码行数:10,代码来源:FakeMachine.java


示例13: getComponents

import li.cil.oc.api.network.Node; //导入依赖的package包/类
List<SimComponent> getComponents() {
	List<SimComponent> components = new ArrayList<SimComponent>();
	for (Node n : network.nodes()) {
		if (n instanceof SimComponent) {
			components.add((SimComponent) n);
		}
	}

	return components;
}
 
开发者ID:SolraBizna,项目名称:jarm,代码行数:11,代码来源:FakeMachine.java


示例14: invalidate

import li.cil.oc.api.network.Node; //导入依赖的package包/类
public static void invalidate(final SimpleComponentImpl self) {
    self.invalidate_OpenComputers();
    final Node node = node(self);
    if (node != null) {
        node.remove();
        nodes.remove(self);
    }
}
 
开发者ID:Avaja,项目名称:OpenTechnology,代码行数:9,代码来源:StaticSimpleEnvironment.java


示例15: onChunkUnload

import li.cil.oc.api.network.Node; //导入依赖的package包/类
public static void onChunkUnload(final SimpleComponentImpl self) {
    self.onChunkUnload_OpenComputers();
    final Node node = node(self);
    if (node != null) {
        node.remove();
        nodes.remove(self);
    }
}
 
开发者ID:Avaja,项目名称:OpenTechnology,代码行数:9,代码来源:StaticSimpleEnvironment.java


示例16: readFromNBT

import li.cil.oc.api.network.Node; //导入依赖的package包/类
public static void readFromNBT(final SimpleComponentImpl self, NBTTagCompound nbt) {
    self.readFromNBT_OpenComputers(nbt);
    final Node node = node(self);
    if (node != null) {
        node.load(nbt.getCompoundTag("oc:node"));
    }
}
 
开发者ID:Avaja,项目名称:OpenTechnology,代码行数:8,代码来源:StaticSimpleEnvironment.java


示例17: writeToNBT

import li.cil.oc.api.network.Node; //导入依赖的package包/类
public static void writeToNBT(final SimpleComponentImpl self, NBTTagCompound nbt) {
    self.writeToNBT_OpenComputers(nbt);
    final Node node = node(self);
    if (node != null) {
        final NBTTagCompound nodeNbt = new NBTTagCompound();
        node.save(nodeNbt);
        nbt.setTag("oc:node", nodeNbt);
    }
}
 
开发者ID:Avaja,项目名称:OpenTechnology,代码行数:10,代码来源:StaticSimpleEnvironment.java


示例18: distance

import li.cil.oc.api.network.Node; //导入依赖的package包/类
public static double distance( Node n1, Node n2 ){
    TileEntity te1 = (  TileEntity  ) n1.host(  );
    TileEntity te2 = (  TileEntity  ) n2.host(  );
    if(  te1 != null && te2 != null  ){
        double dx = Math.pow(  te2.xCoord - te1.xCoord, 2  );
        double dy = Math.pow(  te2.yCoord - te1.yCoord, 2  );
        double dz = Math.pow(  te2.zCoord - te1.zCoord, 2  );
        double res = dx + dy + dz;
        return Math.abs(  Math.sqrt(  res  ) );
    }
    return 0;
}
 
开发者ID:Avaja,项目名称:OpenTechnology,代码行数:13,代码来源:Utils.java


示例19: sidedNode

import li.cil.oc.api.network.Node; //导入依赖的package包/类
@Optional.Method(modid = "OpenComputers")
@Override
public Node sidedNode(ForgeDirection side) {
	if (worldObj.isRemote) {
		return null;
	}

	Pocket p = getPocket();
	if (p == null) {
		return null;
	}

	side = side.getOpposite();

	switch (p.getFlowState(side)) {
		case ENERGY:
			TileEntity te = getDimPocketNeighbourTileEntity(side);
			if (te instanceof SidedEnvironment) {
				return ((SidedEnvironment) te).sidedNode(side);
			} else if (te instanceof Environment) {
				return ((Environment) te).node();
			}
			return null;
		default:
			return null;
	}
}
 
开发者ID:NPException,项目名称:Dimensional-Pockets,代码行数:28,代码来源:TileDimensionalPocketWallConnector.java


示例20: onConnect

import li.cil.oc.api.network.Node; //导入依赖的package包/类
@Override
public void onConnect(Node node)
{
	if (!initd)
		init();
	if (node.host() instanceof Context)
	{
		node.connect(romGX.node());
		if (monitor != null) node.connect(monitor.node());
	}
}
 
开发者ID:ds84182,项目名称:OpenGX,代码行数:12,代码来源:ComponentGX.java



注:本文中的li.cil.oc.api.network.Node类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ProtobufIOUtil类代码示例发布时间:2022-05-22
下一篇:
Java Supplier类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap