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


Java ItemStack.grow方法代码示例

本文整理汇总了Java中net.minecraft.item.ItemStack.grow方法的典型用法代码示例。如果您正苦于以下问题:Java ItemStack.grow方法的具体用法?Java ItemStack.grow怎么用?Java ItemStack.grow使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.minecraft.item.ItemStack的用法示例。


在下文中一共展示了ItemStack.grow方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getRequestedAmount

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public static int getRequestedAmount(SemiBlockLogistics requester, ItemStack providingStack) {
    TileEntity te = requester.getTileEntity();
    if (te == null) return 0;

    int requestedAmount = requester instanceof ISpecificRequester ? ((ISpecificRequester) requester).amountRequested(providingStack) : providingStack.getCount();
    if (requestedAmount == 0) return 0;
    providingStack = providingStack.copy();
    providingStack.setCount(requestedAmount);
    ItemStack remainder = providingStack.copy();
    remainder.grow(requester.getIncomingItems(providingStack));
    for (EnumFacing d : EnumFacing.VALUES) {
        remainder = IOHelper.insert(te, remainder, d, true);
        if (remainder.isEmpty()) break;
    }
    providingStack.shrink(remainder.getCount());
    if (providingStack.getCount() <= 0) return 0;
    return providingStack.getCount();
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:19,代码来源:LogisticsManager.java

示例2: insertItemUnchecked

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public ItemStack insertItemUnchecked(int slot, ItemStack stack, boolean simulate) {
	ItemStack stackPresent = getStackInSlot(slot);
	if (stackPresent.isEmpty()) {
		if (!simulate) {
			setInventorySlotContents(slot, stack.copy());
			markDirty();
		}
		return ItemStack.EMPTY;
	} else {
		if (ItemStack.areItemsEqual(stack, stackPresent) && ItemStack.areItemStackTagsEqual(stack, stackPresent)) {
			int inserted = Math.min(stack.getCount(), stackPresent.getMaxStackSize() - stackPresent.getCount());
			if (inserted > 0) {
				if (simulate) {
					return stack.copy().splitStack(stack.getCount() - inserted);
				}
				stackPresent.grow(inserted);
				markDirty();
				return stack.copy().splitStack(stack.getCount() - inserted);
			}
		}
	}
	return stack;
}
 
开发者ID:Um-Mitternacht,项目名称:Bewitchment,代码行数:24,代码来源:AutomatableInventory.java

示例3: insertItem

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
@Override
public ItemStack insertItem(int slot, ItemStack stack, boolean simulate) {
	if(stack.isEmpty()) return ItemStack.EMPTY;
	if(!getKey().isPresent() || isEntangled(stack)) return stack;
	ItemStack existing = getStackInSlot(slot);
	int limit = stack.getMaxStackSize();
	if(!existing.isEmpty()) {
		if(!ItemHandlerHelper.canItemStacksStack(stack, existing)) {
			return stack;
		}
		limit -= existing.getCount();
	}
	if(limit <= 0) return stack;
	boolean reachedLimit = stack.getCount() > limit;
	if(!simulate) {
		if(existing.isEmpty()) {
			setStackInSlot(slot, reachedLimit ? ItemHandlerHelper.copyStackWithSize(stack, limit) : stack);
		} else {
			existing.grow(reachedLimit ? limit : stack.getCount());
			setStackInSlot(slot, existing);
		}
		onChange(slot);
	}
	return reachedLimit ? ItemHandlerHelper.copyStackWithSize(stack, stack.getCount() - limit) : ItemStack.EMPTY;
}
 
开发者ID:ArekkuusuJerii,项目名称:Solar,代码行数:26,代码来源:QuantumDataHandler.java

示例4: canInsertStack

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public static boolean canInsertStack(IInventory inventoryIn, ItemStack stackIn, int index, EnumFacing side) {
	boolean flag = false;
	ItemStack itemstack = inventoryIn.getStackInSlot(index);
	if (itemstack == null) {
		flag = true;
	}
	else {
		ItemStack stack = stackIn.copy();
		if (canInsertItemInSlot(inventoryIn, stack, index, side)) {
			if (canCombine(itemstack, stack)) {
				//Forge: BUGFIX: Again, make things respect max stack sizes.
				int max = Math.min(stack.getMaxStackSize(), inventoryIn.getInventoryStackLimit());
				if (max > itemstack.getCount()) {
					int i = max - itemstack.getCount();
					int j = Math.min(stack.getCount(), i);
					stack.shrink(j);
					itemstack.grow(j);
					flag = j > 0;
				}
			}

		}
	}
	return flag;
}
 
开发者ID:p455w0rd,项目名称:EndermanEvolution,代码行数:26,代码来源:FriendermanUtils.java

示例5: update

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
@Override
public void update() {
	if (!world.isRemote) {
		if (hasRecipe()) {
			BarrelRecipe currentRecipe = getRecipe();
			if (powerAbsorbed < currentRecipe.getPower()) {
				if (consumePower(1)) {
					powerAbsorbed++;
					markDirty();
					return;
				}
			} else {
				if (brewingTime < currentRecipe.getRequiredTime()) {
					brewingTime++;
					markDirty();
					return;
				} else {
					currentRecipe.onFinish(world, inv.getList().stream().skip(1).collect(Collectors.toList()), pos, internalTank.drain(1000, true));
					ItemStack output = inv.getStackInSlot(0);
					if (output.isEmpty()) inv.setInventorySlotContents(0, currentRecipe.getResult());
					else output.grow(currentRecipe.getResult().getCount());
					brewingTime = 0;
					powerAbsorbed = 0;
					recipeName = null;
					cachedRecipe = null;
					markDirty();
					checkRecipe();
					return;
				}
			}
		}
	}
}
 
开发者ID:Um-Mitternacht,项目名称:Bewitchment,代码行数:34,代码来源:TileEntityBarrel.java

示例6: addFilteredStackToDankNull

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public static boolean addFilteredStackToDankNull(InventoryDankNull inventory, ItemStack filteredStack) {
	if (getIndexForStack(inventory, filteredStack) >= 0) {
		ItemStack currentStack = getFilteredStack(inventory, filteredStack);
		currentStack.grow(filteredStack.getCount());
		if (currentStack.getCount() > DankNullUtils.getDankNullMaxStackSize(inventory)) {
			currentStack.setCount(DankNullUtils.getDankNullMaxStackSize(inventory));
		}
		inventory.setInventorySlotContents(getIndexForStack(inventory, filteredStack), currentStack);
		//getInventory(dankNull).serializeNBT();
		return true;
	}
	return false;
}
 
开发者ID:p455w0rd,项目名称:DankNull,代码行数:14,代码来源:DankNullUtils.java

示例7: onTake

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public ItemStack onTake(EntityPlayer thePlayer, ItemStack stack) {
    CraftiniumRecipe recipe = CraftiniumRecipeRegistry.findMatching(this.craftMatrix, thePlayer.world, this.table, thePlayer);
    if(recipe == null) {
        this.inventory.setInventorySlotContents(0, ItemStack.EMPTY);
        return ItemStack.EMPTY;
    } else {
        this.onCrafting(stack);
        net.minecraftforge.common.ForgeHooks.setCraftingPlayer(thePlayer);
        NonNullList<ItemStack> nonnulllist = recipe.remaining(this.craftMatrix, thePlayer.world, this.table, thePlayer);
        net.minecraftforge.common.ForgeHooks.setCraftingPlayer(null);

        for (int i = 0; i < nonnulllist.size(); ++i) {
            ItemStack itemstack = this.craftMatrix.getStackInSlot(i);
            ItemStack itemstack1 = nonnulllist.get(i);

            if (!itemstack.isEmpty()) {
                this.craftMatrix.decrStackSize(i, 1);
                itemstack = this.craftMatrix.getStackInSlot(i);
            }

            if (!itemstack1.isEmpty()) {
                if (itemstack.isEmpty()) {
                    this.craftMatrix.setInventorySlotContents(i, itemstack1);
                } else if (ItemStack.areItemsEqual(itemstack, itemstack1) && ItemStack.areItemStackTagsEqual(itemstack, itemstack1)) {
                    itemstack1.grow(itemstack.getCount());
                    this.craftMatrix.setInventorySlotContents(i, itemstack1);
                } else if (!this.player.inventory.addItemStackToInventory(itemstack1)) {
                    this.player.dropItem(itemstack1, false);
                }
            }
        }

        return stack;
    }
}
 
开发者ID:Randores,项目名称:Randores2,代码行数:36,代码来源:CraftiniumSlotCrafting.java

示例8: insertItem

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
@Override
public ItemStack insertItem(int slot, ItemStack stack, boolean simulate) {
    if(stack == null || stack.getCount() == 0)
        return null;
    
    validateSlotIndex(slot);
    
    ItemStack existing = this.stacks.get(slot);
    
    int limit = getStackLimit(slot, stack);
    
    if(existing != null) {
        if(!ItemHandlerHelper.canItemStacksStack(stack, existing))
            return stack;
        
        limit -= existing.getCount();
    }
    
    if(limit <= 0)
        return stack;
    
    boolean reachedLimit = stack.getCount() > limit;
    
    if(!simulate) {
        if(existing == null) {
            this.stacks.set(slot, reachedLimit ? ItemHandlerHelper.copyStackWithSize(stack, limit) : stack);
        } else {
            existing.grow(reachedLimit ? limit : stack.getCount());
        }
        onContentsChanged(slot);
    }
    
    return reachedLimit ? ItemHandlerHelper.copyStackWithSize(stack, stack.getCount() - limit) : null;
}
 
开发者ID:jaredlll08,项目名称:Machines-and-Stuff,代码行数:35,代码来源:ItemStackHandlerAdvanced.java

示例9: insertItem

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
@Override
public ItemStack insertItem(int slot, ItemStack stack, boolean simulate) {
    if(stack.isEmpty() || stack.getCount() == 0)
        return ItemStack.EMPTY;
    
    validateSlotIndex(slot);

    ItemStack existing = this.stacks.get(slot);
    
    int limit = getStackLimit(slot, stack);

    if(!existing.isEmpty()) {
        if(!ItemHandlerHelper.canItemStacksStack(stack, existing))
            return stack;
        
        limit -= existing.getCount();
    }
    
    if(slot == 0 && !tile.isValidInput(stack)) {
        return stack;
    }
    if(limit <= 0)
        return stack;
    
    boolean reachedLimit = stack.getCount() > limit;
    
    if(!simulate) {
        if(existing.isEmpty()) {
            this.stacks.set(slot, reachedLimit ? ItemHandlerHelper.copyStackWithSize(stack, limit) : stack);
        } else {
            existing.grow(reachedLimit ? limit : stack.getCount());
        }
        onContentsChanged(slot);
    }

    return reachedLimit ? ItemHandlerHelper.copyStackWithSize(stack, stack.getCount() - limit) : ItemStack.EMPTY;
}
 
开发者ID:jaredlll08,项目名称:Machines-and-Stuff,代码行数:38,代码来源:ItemStackHandlerMachine.java

示例10: smeltItem

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
/**
 * Turn one item from the furnace source stack into the appropriate smelted item in the furnace result stack
 */
private void smeltItem(int id)
{
    if (this.canSmelt(id))
    {
        int inputIndex = type.getFirstInputSlot(id);
        int outputIndex = type.getFirstOutputSlot(id);

        ItemStack input = itemHandler.getStackInSlot(inputIndex);
        ItemStack output = itemHandler.getStackInSlot(outputIndex);
        ItemStack result = FurnaceRecipes.instance().getSmeltingResult(input);

        if (output.isEmpty())
        {
            itemHandler.setStackInSlot(outputIndex, result.copy());
        } else if (output.isItemEqual(result))
        {
            output.grow(result.getCount());
        }

        if (input.getItem() == Item.getItemFromBlock(Blocks.SPONGE) && input.getMetadata() == 1)
        {
            fillBucketInFuelSlots();
        }

        input.shrink(1);

        if (input.isEmpty())
        {
            itemHandler.setStackInSlot(inputIndex, ItemStack.EMPTY);
        }
    }
}
 
开发者ID:cubex2,项目名称:morefurnaces,代码行数:36,代码来源:TileEntityIronFurnace.java

示例11: onTake

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
@Override
public ItemStack onTake(EntityPlayer playerIn, ItemStack stack) {
	if (stack.getItem() == TF2weapons.itemTF2 && stack.getMetadata() == 9) {
		stack = ItemFromData.getRandomWeapon(playerIn.getRNG(), ItemFromData.VISIBLE_WEAPON);
		//playerIn.addStat(TF2Achievements.HOME_MADE);
		playerIn.inventory.setItemStack(stack);
	} else if (stack.getItem() == TF2weapons.itemTF2 && stack.getMetadata() == 10) {
		stack = ItemFromData.getRandomWeaponOfClass("cosmetic", playerIn.getRNG(), false);
		playerIn.inventory.setItemStack(stack);
	}
	if(stack.hasTagCompound()&&stack.getTagCompound().getBoolean("Australium")){
		//playerIn.addStat(TF2Achievements.SHINY);
	}
	net.minecraftforge.fml.common.FMLCommonHandler.instance().firePlayerCraftingEvent(playerIn, stack, craftMatrix);
	this.onCrafting(stack);
	net.minecraftforge.common.ForgeHooks.setCraftingPlayer(playerIn);
	NonNullList<ItemStack> aitemstack = TF2CraftingManager.INSTANCE.getRemainingItems(this.craftMatrix, playerIn.world);
	net.minecraftforge.common.ForgeHooks.setCraftingPlayer(null);

	for (int i = 0; i < aitemstack.size(); ++i) {
		ItemStack itemstack = this.craftMatrix.getStackInSlot(i);
		ItemStack itemstack1 = aitemstack.get(i);

		if (!itemstack.isEmpty()) {
			this.craftMatrix.decrStackSize(i, 1);
			itemstack = this.craftMatrix.getStackInSlot(i);
		}

		if (!itemstack1.isEmpty())
			if (itemstack.isEmpty())
				this.craftMatrix.setInventorySlotContents(i, itemstack1);
			else if (ItemStack.areItemsEqual(itemstack, itemstack1)
					&& ItemStack.areItemStackTagsEqual(itemstack, itemstack1)) {
				itemstack1.grow(itemstack.getCount());
				this.craftMatrix.setInventorySlotContents(i, itemstack1);
			} else if (!this.player.inventory.addItemStackToInventory(itemstack1))
				this.player.dropItem(itemstack1, false);
	}
	return stack;
}
 
开发者ID:rafradek,项目名称:Mods,代码行数:41,代码来源:SlotCraftingTF2.java

示例12: update

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
@Override
public void update() {
    super.update();
    if (!getWorld().isRemote) {
        refillDyeBuffers();
        itemLogic.update();
        ItemStack inputStack = inventory.getStackInSlot(INV_INPUT);
        if (getWorld().getTotalWorldTime() % 20 == 0) { // We don't need to run _that_ often.
            if (inputStack.getCount() > lastTickInventoryStacksize) {
                int stackIncrease = inputStack.getCount() - lastTickInventoryStacksize;
                double ratio = (double) inputStack.getCount() / (inputStack.getCount() + stackIncrease);
                itemLogic.setTemperature((int) (ratio * itemLogic.getTemperature() + (1 - ratio) * BASE_TEMPERATURE));
            } else if (inputStack.isEmpty()) {
                itemLogic.setTemperature(BASE_TEMPERATURE);
            }

            if (itemLogic.getTemperature() >= PneumaticValues.PLASTIC_MIXER_MELTING_TEMP) {
                FluidStack moltenPlastic = new FluidStack(Fluids.PLASTIC, inputStack.getCount() * 1000);
                int maxFill = tank.fill(moltenPlastic, false) / 1000;
                if (maxFill > 0) {
                    inventory.extractItem(INV_INPUT, maxFill, false);
                    tank.fill(new FluidStack(moltenPlastic, maxFill * 1000), true);
                }
            }

            lastTickInventoryStacksize = inventory.getStackInSlot(INV_INPUT).getCount();
            itemLogic.setThermalCapacity(lastTickInventoryStacksize);
        }
        if (tank.getFluid() != null && selectedPlastic >= 0 && redstoneAllows()) {
            ItemStack solidifiedStack = new ItemStack(Itemss.PLASTIC, tank.getFluid().amount / 1000, selectedPlastic);
            if (solidifiedStack.getCount() > 0) {
                solidifiedStack.setCount(1);
                if (inventory.getStackInSlot(INV_OUTPUT).isEmpty()) {
                    solidifiedStack.setCount(useDye(solidifiedStack.getCount()));
                    if (solidifiedStack.getCount() > 0) {
                        inventory.setStackInSlot(INV_OUTPUT, solidifiedStack);
                        tank.drain(solidifiedStack.getCount() * 1000, true);
                        sendDescriptionPacket();
                    }
                } else if (solidifiedStack.isItemEqual(inventory.getStackInSlot(INV_OUTPUT))) {
                    int solidifiedItems = Math.min(64 - inventory.getStackInSlot(INV_OUTPUT).getCount(), solidifiedStack.getCount());
                    solidifiedItems = useDye(solidifiedItems);
                    ItemStack newStack = inventory.getStackInSlot(INV_OUTPUT);
                    newStack.grow(solidifiedItems);
                    inventory.setStackInSlot(INV_OUTPUT, newStack);
                    tank.drain(solidifiedItems * 1000, true);
                    sendDescriptionPacket();
                }
            }
        }
        if (!lockSelection) selectedPlastic = -1;
        if (redstoneMode == 3) selectedPlastic = poweredRedstone;
    }
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:55,代码来源:TileEntityPlasticMixer.java

示例13: processingLogic

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
@SuppressWarnings("ConstantConditions")
public boolean processingLogic(ItemStack stack) {
	if (!isBoiling() || hasIngredients() || stack.getCount() > 8192) return false;
	Map<Item, ItemValidator<ItemStack>> processing = CauldronRegistry.getItemProcessing(inv.getInnerFluid());
	if (processing != null && processing.containsKey(stack.getItem())) {
		ItemValidator<ItemStack> validator = processing.get(stack.getItem());
		Optional<ItemStack> optional = validator.getMatchFor(stack);
		if (optional.isPresent()) {
			ItemStack out = optional.get().copy();
			if (stack.isItemDamaged() && out.isItemStackDamageable())
				out.setItemDamage(stack.getItemDamage());
			int fluidAmount = inv.getFluidAmount();
			int fluidTaken = 250;
			out.setCount(0);

			if (stack.getCount() <= 16) {
				out.setCount(stack.getCount());
				stack.setCount(0);
			} else {
				while (stack.getCount() > 0 && fluidTaken <= fluidAmount) {
					stack.shrink(1);
					out.grow(1);
					if (out.getCount() % 16 == 0) {
						if (fluidTaken >= fluidAmount) {
							fluidTaken = fluidAmount;
							break;
						}
						fluidTaken += 250;
					}
				}
			}

			if (out.getCount() > 0) {
				final double x = getPos().getX();
				final double y = getPos().getY() + 1D;
				final double z = getPos().getZ();
				final EntityItem item = new EntityItem(world, x + 0.5D, y, z + 0.5D, out);
				item.motionX = world.rand.nextDouble() * 2 - 1;
				item.motionZ = world.rand.nextDouble() * 2 - 1;
				item.motionY = 0.1D;
				item.setPickupDelay(0);
				world.spawnEntity(item);

				play(SoundEvents.BLOCK_FIRE_EXTINGUISH, 1F, 1F);
				for (int i = 0; i < 4; i++) {
					PacketHandler.spawnParticle(ParticleF.STEAM, world, x + world.rand.nextFloat(), getParticleLevel(), z + world.rand.nextFloat(), 5, 0, 0, 0);
				}

				inv.drain(fluidTaken, true);
				return true;
			}
		}
	}
	return false;
}
 
开发者ID:Um-Mitternacht,项目名称:Bewitchment,代码行数:56,代码来源:TileCauldron.java

示例14: insertItem

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
@Override
public ItemStack insertItem(int slot, ItemStack stack, boolean simulate)
{
    if (!Config.isItemStackAllowed(stack))
        return stack;

    if (stack.getCount() <= 0)
        return ItemStack.EMPTY;

    validateSlotIndex(slot);

    ItemStack existing = getStackInSlot(slot);

    int limit = stack.getMaxStackSize();

    if (existing.getCount() > 0)
    {
        if (!ItemHandlerHelper.canItemStacksStack(stack, existing))
            return stack;

        limit -= existing.getCount();
    }

    if (limit <= 0)
        return stack;

    boolean reachedLimit = stack.getCount() > limit;

    if (!simulate)
    {
        if (existing.getCount() <= 0)
        {
            existing = reachedLimit ? ItemHandlerHelper.copyStackWithSize(stack, limit) : stack;
        }
        else
        {
            existing.grow(reachedLimit ? limit : stack.getCount());
        }
        setStackInSlot(slot, existing);
    }

    return reachedLimit ? ItemHandlerHelper.copyStackWithSize(stack, stack.getCount() - limit) : ItemStack.EMPTY;
}
 
开发者ID:gigaherz,项目名称:ToolBelt,代码行数:44,代码来源:ToolBeltInventory.java

示例15: incrementStack

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public static void incrementStack(IItemHandlerModifiable handler, int slot, int amount)
{
	ItemStack stack = handler.getStackInSlot(slot).copy();
	stack.grow(amount);
	handler.setStackInSlot(slot, stack);
}
 
开发者ID:einsteinsci,项目名称:BetterBeginningsReborn,代码行数:7,代码来源:CapUtils.java


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