當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。