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


Java Arguments.isBoolean方法代码示例

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


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

示例1: 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

示例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().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

示例3: 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

示例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)) || "getActive".equals(method))
    {
        return call(method, arguments.checkBoolean(0));
    }
    throw new Exception("Wrong argument");
}
 
开发者ID:XFactHD,项目名称:RFUtilities,代码行数:11,代码来源:TileEntityTransistor.java


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