本文整理汇总了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());
}
}
示例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());
}
}
示例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!");
}
示例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");
}