当前位置: 首页>>代码示例>>Java>>正文


Java Callback类代码示例

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


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

示例1: isDown

import li.cil.oc.api.network.Callback; //导入依赖的package包/类
@Callback(direct=true)
public Object[] isDown(Context context, Arguments arguments)
{
	Button b = null;
	String arg = arguments.checkString(0).toLowerCase();
	if (arg.equals("action1"))
	{
		b = Button.ACTION1;
	}
	else if (arg.equals("action2"))
	{
		b = Button.ACTION2;
	}
	else if (arg.equals("actionmod"))
	{
		b = Button.ACTIONM;
	}
	else
		throw new RuntimeException("invalid button id");
	System.out.println(downButtons.contains(b));
	return new Object[]{downButtons.contains(b)};
}
 
开发者ID:ds84182,项目名称:OpenGX,代码行数:23,代码来源:ComponentButton.java

示例2: upload

import li.cil.oc.api.network.Callback; //导入依赖的package包/类
@Callback(direct=true)
public Object[] upload(Context context, Arguments arguments)
{
	//convert fifo to byte array
	byte[] data = fifo.toByteArray();
	try
	{
		gx.uploadFIFO(ByteStreams.newDataInput(data),data);
		GXFifoUploadMessage msg = new GXFifoUploadMessage();
		msg.uuid = uuid;
		msg.tier = tier;
		msg.data = data;
		OpenGX.network.sendToAllAround(msg, new TargetPoint(worldObj.provider.dimensionId, own.x(), own.y(), own.z(), 64));
	}
	catch (Exception ex)
	{
		ex.printStackTrace();
	}
	double waitTime = (((double)fifoBytes)/((double)fifoSize))*(1D/15D);
	//System.out.println(waitTime);
	//context.pause(waitTime);
	fifoBytes = 0;
	fifo = ByteStreams.newDataOutput(fifoSize);
	return null;
}
 
开发者ID:ds84182,项目名称:OpenGX,代码行数:26,代码来源:ComponentGX.java

示例3: uploadTexture

import li.cil.oc.api.network.Callback; //导入依赖的package包/类
@Callback(limit=5)
public Object[] uploadTexture(Context context, Arguments arguments)
{
	byte id = (byte) arguments.checkInteger(0);
	byte[] data = arguments.checkByteArray(1);
	byte fmt = (byte) arguments.checkInteger(2);
	
	GXTextureUploadMessage msg = new GXTextureUploadMessage();
	msg.uuid = uuid;
	msg.tier = tier;
	msg.id = id;
	msg.fmt = fmt;
	msg.data = data;
	OpenGX.network.sendToAllAround(msg, new TargetPoint(worldObj.provider.dimensionId, own.x(), own.y(), own.z(), 64));
	gx.uploadTexture(id, new ByteArrayInputStream(data), fmt);
	//technically, the fifo would have to be copied into memory in order for a texture to upload
	//context.pause((data.length/1024D)*(1/5D));
	
	return null;
}
 
开发者ID:ds84182,项目名称:OpenGX,代码行数:21,代码来源:ComponentGX.java

示例4: setAcceptedCol

import li.cil.oc.api.network.Callback; //导入依赖的package包/类
@Callback
@Optional.Method(modid = Dependencies.OPEN_COMPUTERS)
public Object[] setAcceptedCol(Context context, Arguments arguments) throws Exception {
    Object[] args = new Object[arguments.count()];
    for (int i = 0; i < args.length; i++) {
        args[i] = arguments.checkAny(i);
    }
    return setAcceptedCol(args);
}
 
开发者ID:Quetzi,项目名称:BluePower,代码行数:10,代码来源:TileSortron.java

示例5: getAcceptedCol

import li.cil.oc.api.network.Callback; //导入依赖的package包/类
@Callback
@Optional.Method(modid = Dependencies.OPEN_COMPUTERS)
public Object[] getAcceptedCol(Context context, Arguments arguments) throws Exception {
    Object[] args = new Object[arguments.count()];
    for (int i = 0; i < args.length; i++) {
        args[i] = arguments.checkAny(i);
    }
    return getAcceptedCol(args);
}
 
开发者ID:Quetzi,项目名称:BluePower,代码行数:10,代码来源:TileSortron.java

示例6: setAcceptedItem

import li.cil.oc.api.network.Callback; //导入依赖的package包/类
@Callback
@Optional.Method(modid = Dependencies.OPEN_COMPUTERS)
public Object[] setAcceptedItem(Context context, Arguments arguments) throws Exception {
    Object[] args = new Object[arguments.count()];
    for (int i = 0; i < args.length; i++) {
        args[i] = arguments.checkAny(i);
    }
    return setAcceptedItem(args);
}
 
开发者ID:Quetzi,项目名称:BluePower,代码行数:10,代码来源:TileSortron.java

示例7: getAcceptedItem

import li.cil.oc.api.network.Callback; //导入依赖的package包/类
@Callback
@Optional.Method(modid = Dependencies.OPEN_COMPUTERS)
public Object[] getAcceptedItem(Context context, Arguments arguments) throws Exception {
    Object[] args = new Object[arguments.count()];
    for (int i = 0; i < args.length; i++) {
        args[i] = arguments.checkAny(i);
    }
    return getAcceptedItem(args);
}
 
开发者ID:Quetzi,项目名称:BluePower,代码行数:10,代码来源:TileSortron.java

示例8: getNumSlots

import li.cil.oc.api.network.Callback; //导入依赖的package包/类
@Callback
@Optional.Method(modid = Dependencies.OPEN_COMPUTERS)
public Object[] getNumSlots(Context context, Arguments arguments) throws Exception {
    Object[] args = new Object[arguments.count()];
    for (int i = 0; i < args.length; i++) {
        args[i] = arguments.checkAny(i);
    }
    return getNumSlots(args);
}
 
开发者ID:Quetzi,项目名称:BluePower,代码行数:10,代码来源:TileSortron.java

示例9: getSlotContents

import li.cil.oc.api.network.Callback; //导入依赖的package包/类
@Callback
@Optional.Method(modid = Dependencies.OPEN_COMPUTERS)
public Object[] getSlotContents(Context context, Arguments arguments) throws Exception {
    Object[] args = new Object[arguments.count()];
    for (int i = 0; i < args.length; i++) {
        args[i] = arguments.checkAny(i);
    }
    return getSlotContents(args);
}
 
开发者ID:Quetzi,项目名称:BluePower,代码行数:10,代码来源:TileSortron.java

示例10: pullFromSlot

import li.cil.oc.api.network.Callback; //导入依赖的package包/类
@Callback
@Optional.Method(modid = Dependencies.OPEN_COMPUTERS)
public Object[] pullFromSlot(Context context, Arguments arguments) throws Exception {
    Object[] args = new Object[arguments.count()];
    for (int i = 0; i < args.length; i++) {
        args[i] = arguments.checkAny(i);
    }
    return pullFromSlot(args);
}
 
开发者ID:Quetzi,项目名称:BluePower,代码行数:10,代码来源:TileSortron.java

示例11: sort

import li.cil.oc.api.network.Callback; //导入依赖的package包/类
@Callback
@Optional.Method(modid = Dependencies.OPEN_COMPUTERS)
public Object[] sort(Context context, Arguments arguments) throws Exception {
    Object[] args = new Object[arguments.count()];
    for (int i = 0; i < args.length; i++) {
        args[i] = arguments.checkAny(i);
    }
    return sort(args);
}
 
开发者ID:Quetzi,项目名称:BluePower,代码行数:10,代码来源:TileSortron.java

示例12: getStackSizeLeft

import li.cil.oc.api.network.Callback; //导入依赖的package包/类
@Callback
@Optional.Method(modid = Dependencies.OPEN_COMPUTERS)
public Object[] getStackSizeLeft(Context context, Arguments arguments) throws Exception {
    Object[] args = new Object[arguments.count()];
    for (int i = 0; i < args.length; i++) {
        args[i] = arguments.checkAny(i);
    }
    return getStackSizeLeft(args);
}
 
开发者ID:Quetzi,项目名称:BluePower,代码行数:10,代码来源:TileSortron.java

示例13: getEntities

import li.cil.oc.api.network.Callback; //导入依赖的package包/类
@Callback
public Object[] getEntities(Context context, Arguments args) {
    List<Map> entities = new ArrayList<Map>();
    if (isEnabled) {
        // Get a initial list of entities near the tile entity.
        AxisAlignedBB bounds = AxisAlignedBB.
                getBoundingBox(xCoord, yCoord, zCoord, xCoord + 1, yCoord + 1, zCoord + 1).
                expand(RadarRange, RadarRange, RadarRange);
        for (Object obj : getWorldObj().getEntitiesWithinAABB(EntityLivingBase.class, bounds)) {
            EntityLivingBase entity = (EntityLivingBase) obj;
            double dx = entity.posX - (xCoord + 0.5);
            double dz = entity.posZ - (zCoord + 0.5);
            // Check if the entity is actually in range.
            if (Math.sqrt(dx * dx + dz * dz) < RadarRange) {
                // Maps are converted to tables on the Lua side.
                Map<String, Object> entry = new HashMap<String, Object>();
                entry.put("name", entity.getEntityName());
                entry.put("x", (int) dx);
                entry.put("z", (int) dz);
                entities.add(entry);
            }
        }

        // Force the computer that made the call to sleep for a bit, to
        // avoid calling this method excessively (since it could be quite
        // expensive). The time is specified in seconds.
        context.pause(0.5);
    }

    // The returned array is treated as a tuple, meaning if we return the
    // entities as an array directly, we'd end up with each entity as an
    // individual result value (i.e. in Lua we'd have to write
    //   result = {radar.getEntities()}
    // and we'd be limited in the number of entities, due to the limit of
    // return values. So we wrap it in an array to return it as a list.
    return new Object[]{entities.toArray()};
}
 
开发者ID:MightyPirates,项目名称:OC-Example-TileEntity,代码行数:38,代码来源:TileEntitySimpleRadar.java

示例14: motion

import li.cil.oc.api.network.Callback; //导入依赖的package包/类
@Callback(direct = true)
public Object[] motion(Context context, Arguments arguments)
{
	return new Object[]{
			own.holder.posX-own.holder.lastTickPosX+own.holder.motionX,
			own.holder.posY-own.holder.lastTickPosY+own.holder.motionY,
			own.holder.posZ-own.holder.lastTickPosZ+own.holder.motionZ
		};
}
 
开发者ID:ds84182,项目名称:OpenGX,代码行数:10,代码来源:ComponentSensor.java

示例15: read

import li.cil.oc.api.network.Callback; //导入依赖的package包/类
@Callback(direct=true)
public Object[] read(Context context, Arguments arguments)
{
	int index = arguments.checkInteger(0);
	if (index<1) throw new RuntimeException("Index < 1");
	if (index>prom.length) throw new RuntimeException("Index > "+prom.length);
	index--;
	int n = arguments.checkInteger(1);
	if (n<1) throw new RuntimeException("N < 1");
	if (index+n>prom.length) n = prom.length-index;
	return new Object[]{Arrays.copyOfRange(prom, index, index+n)};
}
 
开发者ID:ds84182,项目名称:OpenGX,代码行数:13,代码来源:ComponentPROM.java


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