本文整理汇总了Java中scala.actors.threadpool.Arrays.copyOf方法的典型用法代码示例。如果您正苦于以下问题:Java Arrays.copyOf方法的具体用法?Java Arrays.copyOf怎么用?Java Arrays.copyOf使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类scala.actors.threadpool.Arrays
的用法示例。
在下文中一共展示了Arrays.copyOf方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addResearchRequirements
import scala.actors.threadpool.Arrays; //导入方法依赖的package包/类
@Override
public void addResearchRequirements(String techName, int[] requirements) throws InvalidArgumentException {
validateTechName(techName);
if (!techs.containsKey(techName)) {
throw new InvalidArgumentException("Cannot add research requirements to a tech with the name \"" + techName
+ "\" because no such tech exists!");
}
Tech t = techs.get(techName);
if (t.requirements.length < requirements.length) {
t.requirements = Arrays.copyOf(t.requirements, requirements.length);
}
for (int i = 0; i < requirements.length; i++) {
if (requirements[i] < 0) {
throw new InvalidArgumentException("The requirement " + requirements[i] + " was less than 0!");
}
t.requirements[i] += requirements[i];
}
}
示例2: subtractResearchRequirements
import scala.actors.threadpool.Arrays; //导入方法依赖的package包/类
@Override
public void subtractResearchRequirements(String techName, int[] requirements) throws InvalidArgumentException {
validateTechName(techName);
if (!techs.containsKey(techName)) {
throw new InvalidArgumentException("Cannot subtract research requirements from a tech with the name \"" + techName
+ "\" because no such tech exists!");
}
Tech t = techs.get(techName);
if (t.requirements.length < requirements.length) {
t.requirements = Arrays.copyOf(t.requirements, requirements.length);
}
for (int i = 0; i < requirements.length; i++) {
if (requirements[i] < 0) {
throw new InvalidArgumentException("The requirement " + requirements[i] + " was less than 0!");
}
if (t.requirements[i] - requirements[i] < 0) {
throw new InvalidArgumentException("The requirement " + requirements[i] + " negated from " + t.requirements[i] + " was less than 0!");
}
}
for (int i = 0; i < requirements.length; i++) {
t.requirements[i] -= requirements[i];
}
}
示例3: loadCraftingRecipes
import scala.actors.threadpool.Arrays; //导入方法依赖的package包/类
@Override
public void loadCraftingRecipes(ItemStack result) {
if (result == null || result.getItem() != CivItems.technology)
return;
// Technology Creation + Researching
Tech t0 = CivItems.technology.getTech(result);
EResearchState state = CivItems.technology.getState(result); // Made from other techs
Tech[] parents = t0.getParentTechs();
ItemStack[] parentItems = new ItemStack[parents.length];
for (int i = 0; i < parents.length; i++)
parentItems[i] = CivItems.technology.getItemForTech(parents[i], parents[i].getSciencePacksNeeded());
if (parentItems.length != 0)
arecipes.add(new CachedShapelessRecipe(parentItems, CivItems.technology.getItemForTech(t0, new int[0])));
if (state == EResearchState.RESEARCHING || state == EResearchState.RESEARCHED) {
int[] packsGot = CivItems.technology.getScienceCount(result);
for (int idx = 0; idx < packsGot.length; idx++) {
int beakersGot = packsGot[idx];
int max = Math.min(beakersGot, 8);
for (int i = max; i > 0; i--) {
int[] arr = Arrays.copyOf(packsGot, packsGot.length);
arr[idx] -= i;
List<ItemStack> stacks = new ArrayList<ItemStack>();
stacks.add(CivItems.technology.getItemForTech(t0, arr));
for (int b = 0; b < i; b++)
stacks.add(new ItemStack(CivItems.sciencePacks[idx]));
arecipes.add(new CachedShapelessRecipe(stacks, result));
}
}
}
}
示例4: registerMixingRecipe
import scala.actors.threadpool.Arrays; //导入方法依赖的package包/类
protected void registerMixingRecipe(Object[] inputs, FluidStack fluidInput, FluidStack fluidInput2,
ItemStack output, FluidStack liquidOutput, Condition condition, Set<ItemStack> catalyst) {
if (condition.temperature != Constants.STANDARD_TEMPERATURE) {
return;
}
if (fluidInput != null && (fluidInput.getFluid().isGaseous() ||
fluidInput.amount > FluidContainerRegistry.BUCKET_VOLUME) ||
fluidInput2 != null && (fluidInput2.getFluid().isGaseous() ||
fluidInput2.amount > FluidContainerRegistry.BUCKET_VOLUME)) {
return;
}
if (!catalyst.isEmpty()) {
return;
}
int offset = fluidInput2 != null ? 2 : fluidInput != null ? 1 : 0;
inputs = Arrays.copyOf(inputs, inputs.length + offset);
if (fluidInput != null) {
inputs[inputs.length - offset] = toBucket(fluidInput);
}
if (fluidInput2 != null) {
inputs[inputs.length - 1] = toBucket(fluidInput2);
}
if (output == null && liquidOutput.amount >= FluidContainerRegistry.BUCKET_VOLUME) {
inputs = Arrays.copyOf(inputs, inputs.length + 1);
inputs[inputs.length - 1] = new ItemStack(Items.bucket);
output = FluidContainerRegistry.fillFluidContainer(liquidOutput, new ItemStack(Items.bucket));
}
RecipeUtils.addShapelessRecipe(output, inputs);
}
示例5: getOutput
import scala.actors.threadpool.Arrays; //导入方法依赖的package包/类
public ItemStack getOutput(EntityPlayer player, InventoryCrafting craft, boolean edit) {
if (craft == null)
return null;
int[] packs = new int[CivItems.sciencePacks.length];
ItemStack t = null;
ArrayList<ItemStack> techs = new ArrayList<ItemStack>();
ArrayList<Integer> techPositions = new ArrayList<Integer>();
for (int p = 0; p < craft.getSizeInventory(); p++) {
ItemStack stack = craft.getStackInSlot(p);
if (stack == null)
continue;
if ((stack.getItem() == CivItems.technology && (stack.getItemDamage() == 0 || stack.getItemDamage() == 1)))
if (t == null)
t = stack;
else
return null;
else if ((stack.getItem() == CivItems.technology && stack.getItemDamage() == 2)) {
techs.add(stack.copy());
techPositions.add(p);
}
else {
boolean added = false;
for (int idx = 0; idx < packs.length; idx++)
if (stack.getItem() == CivItems.sciencePacks[idx]) {
packs[idx]++;
added = true;
break;
}
if (!added)
return null;
}
}
if (t == null)
if (techs.size() == 0)
return null;
else {
for (int pack : packs)
if (pack > 0)
return null;
ArrayList<Tech> ts = new ArrayList<Tech>();
for (ItemStack i : techs)
ts.add(((ItemTechnology) i.getItem()).getTech(i));
Tech tech = TechTree.currentTree.getResult(ts, techPositions.get(0));
if (tech == null)
return null;
int[] newPacks = null;
if (player != null)
if (TechUtils.hasTech(tech, player))
newPacks = tech.getSciencePacksNeeded();
if (newPacks == null)
newPacks = new int[0];
// if (edit) {
// for (int i : techPositions)
// craft.getStackInSlot(i).stackSize++;
// }
return CivItems.technology.getItemForTech(tech, newPacks);
}
int[] required = CivItems.technology.getSciencePacksRequired(t);
if (required.length < packs.length)
required = Arrays.copyOf(required, packs.length);
for (int idx = 0; idx < packs.length; idx++)
if (required[idx] < packs[idx])
return null;
ItemStack nT = t.copy();
CivItems.technology.addPackCount(nT, packs);
if (edit && CivItems.technology.getState(nT) == EResearchState.RESEARCHED)
MinecraftForge.EVENT_BUS.post(new ItemTechResearchedEvent(nT, player));
// if (edit)
// craft.decrStackSize(pos, 1);
return nT;
}