本文整理汇总了Java中openperipheral.api.adapter.method.IMultiReturn类的典型用法代码示例。如果您正苦于以下问题:Java IMultiReturn类的具体用法?Java IMultiReturn怎么用?Java IMultiReturn使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IMultiReturn类属于openperipheral.api.adapter.method包,在下文中一共展示了IMultiReturn类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPoint
import openperipheral.api.adapter.method.IMultiReturn; //导入依赖的package包/类
@Asynchronous
@ScriptCallable(returnTypes = { ReturnType.NUMBER, ReturnType.NUMBER }, description = "Get height and color of point on map")
public IMultiReturn getPoint(TileEntityProjector projector,
@Arg(name = "row", description = "Map row (0..63)") int row,
@Arg(name = "column", description = "Map column (0..63)") int column,
@Arg(name = "layer", description = "Map layer") int layer) {
Preconditions.checkElementIndex(row, 64, "row");
Preconditions.checkElementIndex(column, 64, "column");
HeightMapData data = projector.getMap();
Preconditions.checkState(data != null && data.isValid(), "Map not loaded");
Preconditions.checkElementIndex(layer, data.layers.length, "layer");
int index = 64 * row + column;
LayerData layerData = data.layers[layer];
return MultiReturn.wrap(UnsignedBytes.toInt(layerData.heightMap[index]), layerData.colorMap[index]);
}
示例2: validateResultCount
import openperipheral.api.adapter.method.IMultiReturn; //导入依赖的package包/类
private void validateResultCount() {
Class<?> javaReturn = method.getReturnType();
final int returnLength = returnTypes.size();
for (ReturnType t : returnTypes) {
Preconditions.checkArgument(t != ReturnType.VOID, "Method '%s' declares Void as return type. Use empty list instead.", method);
}
if (javaReturn == void.class) {
Preconditions.checkArgument(returnLength == 0, "Method '%s' returns nothing, but declares at least one Lua result", method);
}
if (returnLength == 0) {
Preconditions.checkArgument(javaReturn == void.class, "Method '%s' returns '%s', but declares no Lua results", method, javaReturn);
}
if (multipleReturn) {
Preconditions.checkArgument(IMultiReturn.class.isAssignableFrom(javaReturn) || Collection.class.isAssignableFrom(javaReturn) || javaReturn.isArray(), "Method '%s' declared more than one Lua result, but returns single '%s' instead of array, collection or IMultiReturn", method, javaReturn);
}
if (returnLength > 1) {
Preconditions.checkArgument(IMultiReturn.class.isAssignableFrom(javaReturn) || multipleReturn, "Method '%s' declared more than one Lua result, but returns single '%s' instead of array, collection or IMultiReturn", method, javaReturn);
}
}
示例3: getCellStatus
import openperipheral.api.adapter.method.IMultiReturn; //导入依赖的package包/类
@ScriptCallable(returnTypes = { ReturnType.NUMBER, ReturnType.STRING })
public IMultiReturn getCellStatus(IChestOrDrive target, @Arg(name = "slot") Index slot) {
try {
int status = target.getCellStatus(slot.value);
return MultiReturn.wrap(status, intToState(status));
} catch (IndexOutOfBoundsException e) {
throw new IllegalArgumentException("Invalid cell index: " + slot);
}
}
示例4: getPosition
import openperipheral.api.adapter.method.IMultiReturn; //导入依赖的package包/类
@ScriptCallable(returnTypes = { ReturnType.NUMBER, ReturnType.NUMBER, ReturnType.NUMBER },
description = "Get turtle position")
public IMultiReturn getPosition() {
EntityMagnet magnet = getMagnet();
Vec3d rotated = getRelativeDistance(magnet);
return MultiReturn.wrap(rotated.x, rotated.y, rotated.z);
}
示例5: getDistanceToTarget
import openperipheral.api.adapter.method.IMultiReturn; //导入依赖的package包/类
@Alias("distance")
@ScriptCallable(returnTypes = { ReturnType.NUMBER, ReturnType.NUMBER, ReturnType.NUMBER })
public IMultiReturn getDistanceToTarget() {
EntityMagnet magnet = getMagnet();
Vec3d current = getRelativeDistance(magnet);
Vec3d target = magnetOwner.target;
return MultiReturn.wrap(current.x - target.x,
current.y - target.y,
current.z - target.z);
}
示例6: wrap
import openperipheral.api.adapter.method.IMultiReturn; //导入依赖的package包/类
public static IMultiReturn wrap(final Object... args) {
return new IMultiReturn() {
@Override
public Object[] getObjects() {
return args;
}
};
}
示例7: convertResult
import openperipheral.api.adapter.method.IMultiReturn; //导入依赖的package包/类
private Object[] convertResult(IConverter converter, Object result) {
if (result instanceof IMultiReturn) return convertMultiResult(converter, (IMultiReturn)result);
if (multipleReturn) {
if (result != null && result.getClass().isArray()) return convertArrayResult(converter, result);
if (result instanceof Collection) return convertCollectionResult(converter, (Collection<?>)result);
}
return convertVarResult(converter, result);
}
示例8: getItemAuthor
import openperipheral.api.adapter.method.IMultiReturn; //导入依赖的package包/类
@ScriptCallable(returnTypes = { ReturnType.STRING, ReturnType.TABLE }, description = "Find the mod name and mod authors")
public IMultiReturn getItemAuthor(final TileEntityDonationStation station) {
return MultiReturn.wrap(station.getModName(), station.getModAuthors());
}
示例9: convertMultiResult
import openperipheral.api.adapter.method.IMultiReturn; //导入依赖的package包/类
private static Object[] convertMultiResult(IConverter converter, IMultiReturn result) {
return convertVarResult(converter, result.getObjects());
}
示例10: test
import openperipheral.api.adapter.method.IMultiReturn; //导入依赖的package包/类
@ScriptCallable(returnTypes = { ReturnType.NUMBER, ReturnType.NUMBER })
public IMultiReturn test(B target, @Arg(name = "a") int a) {
return MultiReturn.wrap(a, a + 1);
}