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


Java Arguments.count方法代码示例

本文整理汇总了Java中li.cil.oc.api.machine.Arguments.count方法的典型用法代码示例。如果您正苦于以下问题:Java Arguments.count方法的具体用法?Java Arguments.count怎么用?Java Arguments.count使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在li.cil.oc.api.machine.Arguments的用法示例。


在下文中一共展示了Arguments.count方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: set

import li.cil.oc.api.machine.Arguments; //导入方法依赖的package包/类
@Callback(doc = "function(face, direction):boolean -- Sets the motor's face and direction. Returns true if it succeeded, false if it didn't.")
public Object[] set(Context context, Arguments args) {

    if (args.count() < 2)
        throw new RuntimeException("At least 2 arguments are required (face, direction)");

    ForgeDirection face = toFD(args.checkAny(0));
    ForgeDirection direction = toFD(args.checkAny(1));

    if (face == null || direction == null)
        throw new RuntimeException("Invalid directions!");
    if (face == direction || face == direction.getOpposite())
        throw new RuntimeException("Motors cannot push or pull blocks!");

    // te.setFace(face, true);
    // te.setDirection(direction, true);

    return new Object[] { true };
}
 
开发者ID:amadornes,项目名称:Framez,代码行数:20,代码来源:EnvironmentMotor.java

示例2: toggleFluidLock

import li.cil.oc.api.machine.Arguments; //导入方法依赖的package包/类
@Callback(doc = "function([boolean:state]):boolean;  (Un-)locks the fluid in the tank. Returns the new state.")
public Object[] toggleFluidLock(Context c, Arguments a) throws Exception
{
    if(a.count() == 0) {
        if(tile.getMasterValve().getFluid() == null) {
            throw new Exception("can't lock tank to fluid, no fluid in tank");
        }

        tile.getMasterValve().toggleFluidLock(!tile.getMasterValve().getTankConfig().isFluidLocked());

        return new Object[]{tile.getMasterValve().getTankConfig().isFluidLocked()};
    }
    else if(a.count() == 1) {
        if(!a.isBoolean(1)) {
            throw new LuaException("expected argument 1 to be of type \"Boolean\", found \"" + a.checkAny(1).getClass().getSimpleName() + "\"");
        }

        boolean state = a.checkBoolean(1);
        if(state && tile.getMasterValve().getFluid() == null) {
            throw new LuaException("can't lock tank to fluid, no fluid in tank");
        }

        tile.getMasterValve().toggleFluidLock(state);

        return new Object[]{tile.getMasterValve().getTankConfig().isFluidLocked()};
    }
    else {
        throw new Exception("insufficient number of arguments found - expected 1, got " + a.count());
    }
}
 
开发者ID:Lordmau5,项目名称:FFS,代码行数:31,代码来源:OCCompatibility.java

示例3: toggleFluidLock

import li.cil.oc.api.machine.Arguments; //导入方法依赖的package包/类
@Callback(doc = "function([boolean:state]):boolean;  (Un-)locks the fluid in the tank. Returns the new state.")
public Object[] toggleFluidLock(Context c, Arguments a) throws Exception {
	if(a.count() == 0) {
		if(tile.getMasterValve().getTankConfig().getFluidStack() == null) {
			throw new Exception("can't lock tank to fluid, no fluid in tank");
		}

		tile.getMasterValve().toggleFluidLock(!tile.getMasterValve().getTankConfig().isFluidLocked());

		return new Object[]{tile.getMasterValve().getTankConfig().isFluidLocked()};
	}
	else if(a.count() == 1) {
		if(!a.isBoolean(1)) {
			throw new Exception("expected argument 1 to be of type \"Boolean\", found \"" + a.checkAny(1).getClass().getSimpleName() + "\"");
		}

		boolean state = a.checkBoolean(1);
		if(state && tile.getMasterValve().getTankConfig().getFluidStack() == null) {
			throw new Exception("can't lock tank to fluid, no fluid in tank");
		}

		tile.getMasterValve().toggleFluidLock(state);

		return new Object[]{tile.getMasterValve().getTankConfig().isFluidLocked()};
	}
	else {
		throw new Exception("insufficient number of arguments found - expected 1, got " + a.count());
	}
}
 
开发者ID:Lordmau5,项目名称:FFS,代码行数:30,代码来源:OCCompatibility.java

示例4: invoke

import li.cil.oc.api.machine.Arguments; //导入方法依赖的package包/类
@Optional.Method(modid = "OpenComputers")
@Override
public Object[] invoke(String method, Context context, Arguments arguments) throws Exception
{
    if (("setActive".equals(method) && arguments.count() == 1 && arguments.isBoolean(0)) || ("setMode".equals(method) && arguments.count() == 1 && arguments.isString(0)) || ("getActive".equals(method) && arguments.count() == 0) || ("getMode".equals(method) && arguments.count() == 0))
    {
        Object[] result = call(method, arguments.checkAny(0));
        if (result[0] != null && result[0].equals("Throw!"))
        {
            throw new NoSuchMethodException("Wrong argument!");
        }
        return result;
    }
    throw new NoSuchMethodException("Wrong argument!");
}
 
开发者ID:XFactHD,项目名称:RFUtilities,代码行数:16,代码来源:TileEntityTransistor.java

示例5: invoke

import li.cil.oc.api.machine.Arguments; //导入方法依赖的package包/类
@Optional.Method(modid = "OpenComputers")
@Override
public Object[] invoke(String method, Context context, Arguments arguments) throws Exception
{
    if (("setActive".equals(method) && arguments.count() == 1 && arguments.isBoolean(0)) || "getActive".equals(method))
    {
        return call(method, arguments.checkBoolean(0));
    }
    throw new Exception("Wrong argument");
}
 
开发者ID:XFactHD,项目名称:RFUtilities,代码行数:11,代码来源:TileEntityTransistor.java

示例6: invoke

import li.cil.oc.api.machine.Arguments; //导入方法依赖的package包/类
@Override
@Optional.Method(modid = "OpenComputers")
public Object[] invoke(final String method, final Context context, final Arguments args) throws Exception {
	final Object[] arguments = new Object[args.count()];
	for (int i = 0; i < args.count(); ++i) {
		arguments[i] = args.checkAny(i);
	}
	final Integer methodId = methodIds.get(method);
	if (methodId == null) {
		throw new NoSuchMethodError();
	}
	return callMethod(methodId, arguments);
}
 
开发者ID:PC-Logix,项目名称:OpenFM,代码行数:14,代码来源:TileEntityRadio.java

示例7: dial

import li.cil.oc.api.machine.Arguments; //导入方法依赖的package包/类
@Callback(doc = "function(uid:string):boolean -- Attempts to create a connection to the specified portal. UID must be given as a single string in the format of numbers separated by spaces.")
@Method(modid = OpenComputers.MOD_ID)
public Object[] dial(Context context, Arguments args) throws Exception {
    if (args.count() < 1)
        return null;

    return comp_Dial(ComputerUtils.argsToArray(args));
}
 
开发者ID:enhancedportals,项目名称:enhancedportals,代码行数:9,代码来源:TileDialingDevice.java

示例8: argsToArray

import li.cil.oc.api.machine.Arguments; //导入方法依赖的package包/类
public static Object[] argsToArray(Arguments args) {
    Object[] data = new Object[args.count()];

    for (int i = 0; i < data.length; i++)
        if (args.isString(i))
            data[i] = args.checkString(i);
        else
            data[i] = args.checkAny(i);

    return data;
}
 
开发者ID:enhancedportals,项目名称:enhancedportals,代码行数:12,代码来源:ComputerUtils.java

示例9: setFace

import li.cil.oc.api.machine.Arguments; //导入方法依赖的package包/类
@Callback(doc = "function(face):boolean -- Sets the motor's face. Returns true if it succeeded, false if it didn't.")
public Object[] setFace(Context context, Arguments args) {

    if (args.count() == 0)
        throw new RuntimeException("At least 1 argument is required (direction)");
    return new Object[] { te.setFace(toFD(args.checkAny(0))) };
}
 
开发者ID:amadornes,项目名称:Framez,代码行数:8,代码来源:EnvironmentMotor.java

示例10: setDirection

import li.cil.oc.api.machine.Arguments; //导入方法依赖的package包/类
@Callback(doc = "function(direction):boolean -- Sets the motor's direction. Returns true if it succeeded, false if it didn't.")
public Object[] setDirection(Context context, Arguments args) {

    if (args.count() == 0)
        throw new RuntimeException("At least 1 argument is required (direction)");
    return new Object[] { /* te.setDirection(toFD(args.checkAny(0))) */};
}
 
开发者ID:amadornes,项目名称:Framez,代码行数:8,代码来源:EnvironmentMotor.java


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