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


Java Arguments.checkInteger方法代码示例

本文整理汇总了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"};
}
 
开发者ID:Avaja,项目名称:OpenTechnology,代码行数:18,代码来源:TileEntityWorldInterface.java

示例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};
}
 
开发者ID:Avaja,项目名称:OpenTechnology,代码行数:20,代码来源:TileEntityPIB.java

示例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};
}
 
开发者ID:Avaja,项目名称:OpenTechnology,代码行数:17,代码来源:TileEntityEnergyController.java

示例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};
}
 
开发者ID:Avaja,项目名称:OpenTechnology,代码行数:20,代码来源:TileEntityPIM.java

示例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;
    }
}
 
开发者ID:Avaja,项目名称:OpenTechnology,代码行数:8,代码来源:EnvRadarUpgrade.java

示例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"};
}
 
开发者ID:Avaja,项目名称:OpenTechnology,代码行数:31,代码来源:TileEntityWorldInterface.java

示例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"};
}
 
开发者ID:Avaja,项目名称:OpenTechnology,代码行数:15,代码来源:TileEntityWorldInterface.java

示例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};
}
 
开发者ID:Avaja,项目名称:OpenTechnology,代码行数:12,代码来源:TileEntityLDA.java

示例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};
}
 
开发者ID:Avaja,项目名称:OpenTechnology,代码行数:12,代码来源:TileEntityLDA.java

示例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[]{};
}
 
开发者ID:Avaja,项目名称:OpenTechnology,代码行数:9,代码来源:TileEntityChatBox.java

示例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;
}
 
开发者ID:xbony2,项目名称:Nuclear-Control,代码行数:9,代码来源:DriverThermalMonitor.java

示例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;
}
 
开发者ID:xbony2,项目名称:Nuclear-Control,代码行数:9,代码来源:DriverAdvancedInfoPanel.java

示例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;
}
 
开发者ID:xbony2,项目名称:Nuclear-Control,代码行数:9,代码来源:DriverAdvancedInfoPanel.java

示例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;
}
 
开发者ID:xbony2,项目名称:Nuclear-Control,代码行数:9,代码来源:DriverAdvancedInfoPanel.java


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