本文整理汇总了Java中li.cil.oc.api.Driver.driverFor方法的典型用法代码示例。如果您正苦于以下问题:Java Driver.driverFor方法的具体用法?Java Driver.driverFor怎么用?Java Driver.driverFor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类li.cil.oc.api.Driver
的用法示例。
在下文中一共展示了Driver.driverFor方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: recomputeMemory
import li.cil.oc.api.Driver; //导入方法依赖的package包/类
public boolean recomputeMemory(Iterable<ItemStack> components) {
numMappedRamBanks = 0;
ramTier = 3;
for(ItemStack stack : components) {
Item driver = Driver.driverFor(stack);
if(driver instanceof li.cil.oc.api.driver.item.Memory) {
double amount = ((li.cil.oc.api.driver.item.Memory)driver).amount(stack);
int tier = (int)Math.floor(amount);
if(tier < 0) tier = 0;
else if(tier > 2) tier = 2;
if(tier < ramTier) ramTier = tier;
numMappedRamBanks += MainClass.instance.getMemoryModuleBankCount(amount);
}
else if(driver instanceof Processor) {
cpuTier = driver.tier(stack);
parent.cpuCyclesPerTick = MainClass.instance.getCPUCyclesPerTick(cpuTier);
}
}
if(numMappedRamBanks > 0x1FFF) numMappedRamBanks = 0x1FFF;
remapMemory();
return true;
}
示例2: calculateMemory
import li.cil.oc.api.Driver; //导入方法依赖的package包/类
private int calculateMemory(Iterable<ItemStack> components) {
int memorySize = 0;
for (ItemStack component : components) {
if (Driver.driverFor(component) instanceof Memory) {
Memory driver = (Memory) Driver.driverFor(component);
memorySize += driver.amount(component) * 1024;
}
}
return Math.min(Math.max(memorySize, 0), Config.ARM_MAX_MEMORY);
}