本文整理汇总了Java中codechicken.lib.inventory.InventoryUtils.canStack方法的典型用法代码示例。如果您正苦于以下问题:Java InventoryUtils.canStack方法的具体用法?Java InventoryUtils.canStack怎么用?Java InventoryUtils.canStack使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类codechicken.lib.inventory.InventoryUtils
的用法示例。
在下文中一共展示了InventoryUtils.canStack方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findIngred
import codechicken.lib.inventory.InventoryUtils; //导入方法依赖的package包/类
public DistributedIngred findIngred(final List<DistributedIngred> ingredStacks, final ItemStack pstack) {
for (final DistributedIngred istack : ingredStacks) {
if (istack.isSaw) {
if (this.sameSaw(pstack, istack.stack)) {
return istack;
}
continue;
}
else {
if (InventoryUtils.canStack(pstack, istack.stack)) {
return istack;
}
continue;
}
}
return null;
}
示例2: assignIngredients
import codechicken.lib.inventory.InventoryUtils; //导入方法依赖的package包/类
private List<IngredientDistribution> assignIngredients(List<PositionedStack> ingredients, List<DistributedIngred> ingredStacks)
{
ArrayList<IngredientDistribution> assignedIngredients = new ArrayList<IngredientDistribution>();
for(PositionedStack posstack : ingredients)//assign what we need and have
{
DistributedIngred biggestIngred = null;
ItemStack permutation = null;
int biggestSize = 0;
for(ItemStack pstack : posstack.items)
{
for(int j = 0; j < ingredStacks.size(); j++)
{
DistributedIngred istack = ingredStacks.get(j);
if(!InventoryUtils.canStack(pstack, istack.stack) || istack.invAmount-istack.distributed < pstack.stackSize)
continue;
int relsize = (istack.invAmount-istack.invAmount/istack.recipeAmount*istack.distributed)/pstack.stackSize;
if(relsize > biggestSize)
{
biggestSize = relsize;
biggestIngred = istack;
permutation = pstack;
break;
}
}
}
if(biggestIngred == null)//not enough ingreds
return null;
biggestIngred.distributed+=permutation.stackSize;
assignedIngredients.add(new IngredientDistribution(biggestIngred, permutation));
}
return assignedIngredients;
}
示例3: findIngred
import codechicken.lib.inventory.InventoryUtils; //导入方法依赖的package包/类
public DistributedIngred findIngred(List<DistributedIngred> ingredStacks, ItemStack pstack)
{
for(DistributedIngred istack : ingredStacks)
if(InventoryUtils.canStack(pstack, istack.stack))
return istack;
return null;
}
示例4: assignIngredients
import codechicken.lib.inventory.InventoryUtils; //导入方法依赖的package包/类
private List<IngredientDistribution> assignIngredients(List<PositionedStack> ingredients, List<DistributedIngred> ingredStacks) {
ArrayList<IngredientDistribution> assignedIngredients = new ArrayList<>();
for (PositionedStack posstack : ingredients)//assign what we need and have
{
DistributedIngred biggestIngred = null;
ItemStack permutation = null;
int biggestSize = 0;
for (ItemStack pstack : posstack.items) {
for (int j = 0; j < ingredStacks.size(); j++) {
DistributedIngred istack = ingredStacks.get(j);
if (!InventoryUtils.canStack(pstack, istack.stack) || istack.invAmount - istack.distributed < pstack.getCount()) {
continue;
}
int relsize = (istack.invAmount - istack.invAmount / istack.recipeAmount * istack.distributed) / pstack.getCount();
if (relsize > biggestSize) {
biggestSize = relsize;
biggestIngred = istack;
permutation = pstack;
break;
}
}
}
if (biggestIngred == null)//not enough ingreds
{
return null;
}
biggestIngred.distributed += permutation.getCount();
assignedIngredients.add(new IngredientDistribution(biggestIngred, permutation));
}
return assignedIngredients;
}
示例5: findIngred
import codechicken.lib.inventory.InventoryUtils; //导入方法依赖的package包/类
public DistributedIngred findIngred(List<DistributedIngred> ingredStacks, ItemStack pstack) {
for (DistributedIngred istack : ingredStacks) {
if (InventoryUtils.canStack(pstack, istack.stack)) {
return istack;
}
}
return null;
}
示例6: moveIngredients
import codechicken.lib.inventory.InventoryUtils; //导入方法依赖的package包/类
private void moveIngredients(final GuiContainer gui, final List<IngredientDistribution> assignedIngredients, final int quantity) {
for (final IngredientDistribution distrib : assignedIngredients) {
final ItemStack pstack = distrib.permutation;
int transferCap = quantity * pstack.stackSize;
int transferred = 0;
if (distrib.distrib.isSaw) {
transferCap = 1;
}
int destSlotIndex = 0;
Slot dest = distrib.slots[0];
int slotTransferred = 0;
final int slotTransferCap = pstack.getMaxStackSize();
for (final Slot slot : (Collection<Slot>) gui.inventorySlots.inventorySlots) {
if (slot.getHasStack()) {
if (!(slot.inventory instanceof InventoryPlayer)) {
continue;
}
final ItemStack stack = slot.getStack();
if (distrib.distrib.isSaw) {
if (!sameItemStack(stack, pstack)) {
continue;
}
}
else if (!InventoryUtils.canStack(stack, pstack)) {
continue;
}
FastTransferManager.clickSlot(gui, slot.slotNumber);
for (int amount = Math.min(transferCap - transferred, stack.stackSize), c = 0; c < amount; ++c) {
FastTransferManager.clickSlot(gui, dest.slotNumber, 1);
++transferred;
if (++slotTransferred >= slotTransferCap) {
if (++destSlotIndex == distrib.slots.length) {
dest = null;
break;
}
dest = distrib.slots[destSlotIndex];
slotTransferred = 0;
}
}
FastTransferManager.clickSlot(gui, slot.slotNumber);
if (transferred >= transferCap) {
break;
}
if (dest == null) {
break;
}
continue;
}
}
}
}
示例7: assignIngredients
import codechicken.lib.inventory.InventoryUtils; //导入方法依赖的package包/类
private List<IngredientDistribution> assignIngredients(final List<PositionedStack> ingredients, final List<DistributedIngred> ingredStacks) {
final ArrayList<IngredientDistribution> assignedIngredients = new ArrayList<IngredientDistribution>();
for (final PositionedStack posstack : ingredients) {
DistributedIngred biggestIngred = null;
ItemStack permutation = null;
int biggestSize = 0;
for (final ItemStack pstack : posstack.items) {
final boolean isSaw = isSaw(pstack);
for (int j = 0; j < ingredStacks.size(); ++j) {
final DistributedIngred istack = ingredStacks.get(j);
if (isSaw == istack.isSaw) {
if (isSaw) {
if (this.sameSaw(pstack, istack.stack)) {
if (istack.invAmount - istack.distributed >= pstack.stackSize) {
biggestSize = 1;
biggestIngred = istack;
permutation = pstack;
break;
}
}
}
else if (InventoryUtils.canStack(pstack, istack.stack)) {
if (istack.invAmount - istack.distributed >= pstack.stackSize) {
final int relsize = (istack.invAmount - istack.invAmount / istack.recipeAmount * istack.distributed) / pstack.stackSize;
if (relsize > biggestSize) {
biggestSize = relsize;
biggestIngred = istack;
permutation = pstack;
break;
}
}
}
}
}
}
if (biggestIngred == null) {
return null;
}
final DistributedIngred distributedIngred = biggestIngred;
distributedIngred.distributed += permutation.stackSize;
assignedIngredients.add(new IngredientDistribution(biggestIngred, permutation));
}
return assignedIngredients;
}
示例8: moveIngredients
import codechicken.lib.inventory.InventoryUtils; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private void moveIngredients(GuiContainer gui, List<IngredientDistribution> assignedIngredients, int quantity)
{
for(IngredientDistribution distrib : assignedIngredients)
{
ItemStack pstack = distrib.permutation;
int transferCap = quantity*pstack.stackSize;
int transferred = 0;
int destSlotIndex = 0;
Slot dest = distrib.slots[0];
int slotTransferred = 0;
int slotTransferCap = pstack.getMaxStackSize();
for(Slot slot : (List<Slot>)gui.inventorySlots.inventorySlots)
{
if(!slot.getHasStack() || !(slot.inventory instanceof InventoryPlayer))
continue;
ItemStack stack = slot.getStack();
if(!InventoryUtils.canStack(stack, pstack))
continue;
FastTransferManager.clickSlot(gui, slot.slotNumber);
int amount = Math.min(transferCap-transferred, stack.stackSize);
for(int c = 0; c < amount; c++)
{
FastTransferManager.clickSlot(gui, dest.slotNumber, 1);
transferred++;
slotTransferred++;
if(slotTransferred >= slotTransferCap)
{
destSlotIndex++;
if(destSlotIndex == distrib.slots.length)
{
dest = null;
break;
}
dest = distrib.slots[destSlotIndex];
slotTransferred = 0;
}
}
FastTransferManager.clickSlot(gui, slot.slotNumber);
if(transferred >= transferCap || dest == null)
break;
}
}
}
示例9: moveIngredients
import codechicken.lib.inventory.InventoryUtils; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private void moveIngredients(GuiContainer gui, List<IngredientDistribution> assignedIngredients, int quantity)
{
for(IngredientDistribution distrib : assignedIngredients)
{
ItemStack pstack = distrib.permutation;
int transferCap = quantity*pstack.stackSize;
int transferred = 0;
int destSlotIndex = 0;
Slot dest = distrib.slots[0];
int slotTransferred = 0;
int slotTransferCap = pstack.getMaxStackSize();
for(Slot slot : (List<Slot>)gui.inventorySlots.inventorySlots)
{
if(!slot.getHasStack() || !canMoveFrom(slot, gui))
continue;
ItemStack stack = slot.getStack();
if(!InventoryUtils.canStack(stack, pstack))
continue;
FastTransferManager.clickSlot(gui, slot.slotNumber);
int amount = Math.min(transferCap-transferred, stack.stackSize);
for(int c = 0; c < amount; c++)
{
FastTransferManager.clickSlot(gui, dest.slotNumber, 1);
transferred++;
slotTransferred++;
if(slotTransferred >= slotTransferCap)
{
destSlotIndex++;
if(destSlotIndex == distrib.slots.length)
{
dest = null;
break;
}
dest = distrib.slots[destSlotIndex];
slotTransferred = 0;
}
}
FastTransferManager.clickSlot(gui, slot.slotNumber);
if(transferred >= transferCap || dest == null)
break;
}
}
}
示例10: moveIngredients
import codechicken.lib.inventory.InventoryUtils; //导入方法依赖的package包/类
@SuppressWarnings ("unchecked")
private void moveIngredients(GuiContainer gui, List<IngredientDistribution> assignedIngredients, int quantity) {
for (IngredientDistribution distrib : assignedIngredients) {
ItemStack pstack = distrib.permutation;
int transferCap = quantity * pstack.getCount();
int transferred = 0;
int destSlotIndex = 0;
Slot dest = distrib.slots[0];
int slotTransferred = 0;
int slotTransferCap = pstack.getMaxStackSize();
for (Slot slot : gui.inventorySlots.inventorySlots) {
if (!slot.getHasStack() || !canMoveFrom(slot, gui)) {
continue;
}
ItemStack stack = slot.getStack();
if (!InventoryUtils.canStack(stack, pstack)) {
continue;
}
FastTransferManager.clickSlot(gui, slot.slotNumber);
int amount = Math.min(transferCap - transferred, stack.getCount());
for (int c = 0; c < amount; c++) {
FastTransferManager.clickSlot(gui, dest.slotNumber, 1);
transferred++;
slotTransferred++;
if (slotTransferred >= slotTransferCap) {
destSlotIndex++;
if (destSlotIndex == distrib.slots.length) {
dest = null;
break;
}
dest = distrib.slots[destSlotIndex];
slotTransferred = 0;
}
}
FastTransferManager.clickSlot(gui, slot.slotNumber);
if (transferred >= transferCap || dest == null) {
break;
}
}
}
}