本文整理汇总了Java中li.cil.oc.api.machine.Arguments.checkInteger方法的典型用法代码示例。如果您正苦于以下问题:Java Arguments.checkInteger方法的具体用法?Java Arguments.checkInteger怎么用?Java Arguments.checkInteger使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类li.cil.oc.api.machine.Arguments
的用法示例。
在下文中一共展示了Arguments.checkInteger方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: destroyStackInSlot
import li.cil.oc.api.machine.Arguments; //导入方法依赖的package包/类
@Callback(doc = "function(name:string, slot:integer); destroy stack.")
public Object[] destroyStackInSlot(Context context, Arguments arguments) throws Exception{
String name = arguments.checkString(0);
int slot = arguments.checkInteger(1);
EntityPlayer player = Utils.findPlayer(name);
if(player != null){
if(player.getCommandSenderName().equals(name)) {
if (slot > 0 && slot < player.inventory.getSizeInventory()) {
player.inventory.setInventorySlotContents(slot - 1, null);
return new Object[]{true};
}else{
return new Object[]{false, "invalid slot"};
}
}
}
return new Object[]{false, "player not found"};
}
示例2: getStackInSlot
import li.cil.oc.api.machine.Arguments; //导入方法依赖的package包/类
@Callback(doc="function(slot:int):table, get itemstack in player inventory slot.")
public Object[] getStackInSlot(Context context, Arguments arguments) throws Exception{
if(!isConnected())
return new Object[]{false};
int slot = arguments.checkInteger(0) - 1;
ItemStack itemStack = target.inventory.getStackInSlot(slot);
if(itemStack != null){
Map<String, Object> entry = new HashMap<String, Object>();
entry.put("name", Item.itemRegistry.getNameForObject(itemStack));
entry.put("damage", itemStack.getItemDamage());
entry.put("hasTag", itemStack.hasTagCompound());
entry.put("size", itemStack.stackSize);
entry.put("label", itemStack.getDisplayName());
return new Object[]{entry};
}
return new Object[]{null};
}
示例3: transfer
import li.cil.oc.api.machine.Arguments; //导入方法依赖的package包/类
@Callback(doc="")
public Object[] transfer(Context context, Arguments arguments) throws Exception{
int count = arguments.checkInteger(0);
if(count > 0){
if(count > energyInputBuffer)
count = energyInputBuffer;
if(outputBufferCapacity - energyOutputBuffer >= count){
energyInputBuffer -= count;
energyOutputBuffer += count;
}else{
return new Object[]{false};
}
}
return new Object[]{true};
}
示例4: getStackInSlot
import li.cil.oc.api.machine.Arguments; //导入方法依赖的package包/类
@Callback(doc="function(slot:int):table, get itemstack in player inventory slot.")
public Object[] getStackInSlot(Context context, Arguments arguments) throws Exception{
if(checkPlayer())
return new Object[]{false};
int slot = arguments.checkInteger(0) - 1;
ItemStack itemStack = player.inventory.getStackInSlot(slot);
if(itemStack != null){
Map<String, Object> entry = new HashMap<String, Object>();
entry.put("name", Item.itemRegistry.getNameForObject(itemStack));
entry.put("damage", itemStack.getItemDamage());
entry.put("hasTag", itemStack.hasTagCompound());
entry.put("size", itemStack.stackSize);
entry.put("label", itemStack.getDisplayName());
return new Object[]{entry};
}
return new Object[]{null};
}
示例5: getDistance
import li.cil.oc.api.machine.Arguments; //导入方法依赖的package包/类
private int getDistance(Arguments args) {
if(args.isInteger(0)) {
return args.checkInteger(0);
} else {
return Config.radarRange;
}
}
示例6: getStackInSlot
import li.cil.oc.api.machine.Arguments; //导入方法依赖的package包/类
@Callback(doc="function(name:string, slot:integer); get information about the stack from the player by name.")
public Object[] getStackInSlot(Context context, Arguments arguments) throws Exception{
String name = arguments.checkString(0);
int slot = arguments.checkInteger(1);
EntityPlayer player = Utils.findPlayer(name);
if(player != null){
if(player.getCommandSenderName().equals(name)){
if(slot > 0 && slot < player.inventory.getSizeInventory()){
ItemStack itemStack = player.inventory.getStackInSlot(slot - 1);
if(itemStack != null){
HashMap values = Utils.createStringTable(
"name", Utils.getForgeName(itemStack.getItem()),
"damage", itemStack.getItemDamage(),
"maxDamage", itemStack.getMaxDamage(),
"size", itemStack.stackSize,
"label", itemStack.getItem().getItemStackDisplayName(itemStack),
"hasTag", itemStack.hasTagCompound()
);
return new Object[]{values};
}else{
return new Object[]{null};
}
}else{
return new Object[]{false, "invalid slot"};
}
}
}
return new Object[]{false, "player not found"};
}
示例7: getSpawnLocation
import li.cil.oc.api.machine.Arguments; //导入方法依赖的package包/类
@Callback(doc="function(player:string, dimension:integer); get bed location.")
public Object[] getSpawnLocation(Context machine, Arguments args) throws Exception{
String name = args.checkString(0);
EntityPlayer player = Utils.findPlayer(name);
if(player != null){
int dimention = args.checkInteger(1);
ChunkCoordinates chunkCoordinates = player.getBedLocation(dimention);
if(chunkCoordinates != null)
return new Object[]{chunkCoordinates.posX, chunkCoordinates.posY, chunkCoordinates.posZ};
else
return new Object[]{false, "spawn location not found"};
}
return new Object[]{false, "player not found"};
}
示例8: open
import li.cil.oc.api.machine.Arguments; //导入方法依赖的package包/类
@Callback(doc="function(channel:int), open channel.")
public Object[] open(Context context, Arguments arguments) throws Exception{
if(!isStructure) return new Object[]{false};
int channel = arguments.checkInteger(0);
if(channel >= 0 && channel <= Math.pow(2, 16)){
context.pause(3);
this.channel = channel;
return new Object[]{true};
}
return new Object[]{false};
}
示例9: setDistance
import li.cil.oc.api.machine.Arguments; //导入方法依赖的package包/类
@Callback(doc="function(distance:int), set current distance.")
public Object[] setDistance(Context context, Arguments arguments) throws Exception{
if(!isStructure) return new Object[]{false};
int dist = arguments.checkInteger(0);
if(dist >= 0 && dist < Config.ldaMaxDistance){
distance = dist;
context.pause(3);
return new Object[]{true};
}
return new Object[]{false};
}
示例10: setRadius
import li.cil.oc.api.machine.Arguments; //导入方法依赖的package包/类
@Callback
public Object[] setRadius(Context context, Arguments arguments) throws Exception{
int tmp = arguments.checkInteger(0);
if (tmp > Config.chatboxMaxRadius) tmp = Config.chatboxMaxRadius;
if(tmp < 0) tmp = 0;
radius = tmp;
return new Object[]{};
}
示例11: setHeatLevel
import li.cil.oc.api.machine.Arguments; //导入方法依赖的package包/类
@Callback(doc = "function(number) -- sets the heat level of the reactor")
public Object[] setHeatLevel(final Context context, final Arguments args){
final int newHeatLevel = args.checkInteger(0);
if(newHeatLevel == tileEntity.getHeatLevel() || newHeatLevel < 0 || newHeatLevel > 1000000)
return null;
tileEntity.setHeatLevel(newHeatLevel);
return null;
}
示例12: setThickness
import li.cil.oc.api.machine.Arguments; //导入方法依赖的package包/类
@Callback(doc = "function(value:number) -- sets the thickness of the panel. Only input 1-16, otherwise nothing will happen")
public Object[] setThickness(final Context context, final Arguments args){
final int newThickness = args.checkInteger(0);
if(newThickness <= 0 || newThickness > 16) return null; //invalid input
if(newThickness == tileEntity.getThickness()) return null; //same as the current thickness
tileEntity.setThickness((byte) newThickness);
return null;
}
示例13: rotateHorizonally
import li.cil.oc.api.machine.Arguments; //导入方法依赖的package包/类
@Callback(doc = "function(value:number) -- sets the horizonal rotation of the panel. Only input 1-16, otherwise nothing will happen")
public Object[] rotateHorizonally(final Context context, final Arguments args){
final int newRotation = args.checkInteger(0);
if(newRotation <= 0 || newRotation > 16) return null; //invalid input
if(newRotation == tileEntity.getRotationHor()) return null; //same as the current rotation
tileEntity.setRotateHor((byte) newRotation);
return null;
}
示例14: rotateVertically
import li.cil.oc.api.machine.Arguments; //导入方法依赖的package包/类
@Callback(doc = "function(value:number) -- sets the vertical rotation of the panel. Only input 1-16, otherwise nothing will happen")
public Object[] rotateVertically(final Context context, final Arguments args){
final int newRotation = args.checkInteger(0);
if(newRotation <= 0 || newRotation > 16) return null; //invalid input
if(newRotation == tileEntity.getRotationVert()) return null; //same as the current rotation
tileEntity.setRotateVert((byte) newRotation);
return null;
}