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


Java IItemHandler.getStackInSlot方法代码示例

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


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

示例1: addInformation

import net.minecraftforge.items.IItemHandler; //导入方法依赖的package包/类
@Override
public void addInformation(World world, BlockPos pos, TileEntity te, List<String> infoList) {
    try {
        IItemHandler inventory = IOHelper.getInventoryForTE(te);
        if (inventory != null) {
            boolean empty = true;
            ItemStack[] inventoryStacks = new ItemStack[inventory.getSlots()];
            for (int i = 0; i < inventory.getSlots(); i++) {
                ItemStack iStack = inventory.getStackInSlot(i);
                if (!iStack.isEmpty()) {
                    empty = false;
                }
                inventoryStacks[i] = iStack;
            }
            if (empty) {
                infoList.add("Contents: Empty");
            } else {
                infoList.add("Contents:");
                PneumaticCraftUtils.sortCombineItemStacksAndToString(infoList, inventoryStacks);
            }
        }
    } catch (Throwable e) {
        addTileEntityToBlackList(te, e);
    }
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:26,代码来源:BlockTrackEntryInventory.java

示例2: getEvaluator

import net.minecraftforge.items.IItemHandler; //导入方法依赖的package包/类
@Override
protected DroneAIBlockCondition getEvaluator(IDroneBase drone, IProgWidget widget) {
    return new DroneAIBlockCondition(drone, (ProgWidgetAreaItemBase) widget) {

        @Override
        protected boolean evaluate(BlockPos pos) {
            if (drone.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null)) {
                int count = 0;
                IItemHandler handler = drone.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null);
                for (int i = 0; i < handler.getSlots(); i++) {
                    ItemStack stack = handler.getStackInSlot(i);
                    if (widget.isItemValidForFilters(stack)) {
                        count += stack.getCount();
                    }
                }
                return ((ICondition) widget).getOperator() == ICondition.Operator.EQUALS ?
                        count == ((ICondition) widget).getRequiredCount() :
                        count >= ((ICondition) widget).getRequiredCount();
            }

            return false;
        }

    };
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:26,代码来源:ProgWidgetItemInventoryCondition.java

示例3: validate

import net.minecraftforge.items.IItemHandler; //导入方法依赖的package包/类
void validate() {
    if (isValid) return;

    Arrays.fill(upgradeCount, 0);
    customUpgradeCount = null;
    IItemHandler inv = te.getUpgradesInventory();
    for (int i = 0; i < inv.getSlots(); i++) {
        ItemStack stack = inv.getStackInSlot(i);
        if (stack.getItem() instanceof ItemMachineUpgrade) {
            // native upgrade
            int idx = ((ItemMachineUpgrade) stack.getItem()).getUpgradeType().ordinal();
            upgradeCount[idx] += inv.getStackInSlot(i).getCount();
        } else if (!inv.getStackInSlot(i).isEmpty()) {
            // custom upgrade from another mod
            if (customUpgradeCount == null)
                customUpgradeCount = Maps.newHashMap();
            String key = makeUpgradeKey(stack);
            customUpgradeCount.put(key, customUpgradeCount.getOrDefault(key, 0) + stack.getCount());
        }
    }
    te.onUpgradesChanged();
    isValid = true;
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:24,代码来源:TileEntityBase.java

示例4: breakBlock

import net.minecraftforge.items.IItemHandler; //导入方法依赖的package包/类
@Override
public void breakBlock(World world, BlockPos pos, IBlockState state)
{
	TileEntityInfernalSmelter te = (TileEntityInfernalSmelter) world.getTileEntity(pos);
	IItemHandler cap = te.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null);
	for (int i = 0; i < cap.getSlots(); ++i)
	{
		ItemStack itemstack = cap.getStackInSlot(i);

		if (!itemstack.isEmpty())
		{
			InventoryHelper.spawnItemStack(world, pos.getX(), pos.getY(), pos.getZ(), itemstack);
		}
	}

	super.breakBlock(world, pos, state);
}
 
开发者ID:raphydaphy,项目名称:ArcaneMagic,代码行数:18,代码来源:BlockInfernalSmelter.java

示例5: breakBlock

import net.minecraftforge.items.IItemHandler; //导入方法依赖的package包/类
@Override
public void breakBlock(World worldIn, BlockPos pos, IBlockState state)
{
    TileEntity tile = worldIn.getTileEntity(pos);

    if (tile != null)
    {
        IItemHandler itemHandler = tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null);
        if (itemHandler != null)
        {
            for (int i = 0; i < itemHandler.getSlots(); i++)
            {
                ItemStack stack = itemHandler.getStackInSlot(i);
                if (!stack.isEmpty())
                {
                    InventoryHelper.spawnItemStack(worldIn, pos.getX(), pos.getY(), pos.getZ(), stack);
                }
            }
        }
    }

    super.breakBlock(worldIn, pos, state);
}
 
开发者ID:cubex2,项目名称:customstuff4,代码行数:24,代码来源:BlockMixin.java

示例6: amountRequested

import net.minecraftforge.items.IItemHandler; //导入方法依赖的package包/类
@Override
public int amountRequested(ItemStack stack) {
    int totalRequestingAmount = getTotalRequestedAmount(stack);
    if (totalRequestingAmount > 0) {
        IItemHandler inv = IOHelper.getInventoryForTE(getTileEntity());
        int count = 0;
        if (inv != null) {
            for (int i = 0; i < inv.getSlots(); i++) {
                ItemStack s = inv.getStackInSlot(i);
                if (!s.isEmpty() && isItemEqual(s, stack)) {
                    count += s.getCount();
                }
            }
            count += getIncomingItems(stack);
            return Math.max(0, Math.min(stack.getCount(), totalRequestingAmount - count));
        }
    }
    return 0;
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:20,代码来源:SemiBlockRequester.java

示例7: apply

import net.minecraftforge.items.IItemHandler; //导入方法依赖的package包/类
/** Applies the recipe to the storage provided, determining whether or not the output should be produced. Optionally
 * consumes the items.
 */
public boolean apply(FluidTank tank, IItemHandler inventory, boolean consume) {
	if (consume && !apply(tank, inventory, false)) return false; //Always dry-run before destructive ops
	if (tank.getFluid()==null) return false;
	//Next line shouldn't happen but it pays to plan for the impossible
	if (tank.getFluid().getFluid() != FluidRegistry.WATER) return false;
	if (tank.getFluidAmount()<water) return false;

	FluidStack fluidExtracted = tank.drainInternal(water, consume);
	if (fluidExtracted.amount<water) return false;
	
	int remaining = count;
	for(int i=0; i<inventory.getSlots(); i++) {
		ItemStack stack = inventory.getStackInSlot(i);
		if (stack.isEmpty()) continue;
		if (item.apply(stack)) {
			ItemStack extracted = inventory.extractItem(i, remaining, !consume);
			if (extracted.isEmpty()) continue;
			remaining -= extracted.getCount();
		}
	}
	return remaining<=0;
}
 
开发者ID:elytra,项目名称:Thermionics,代码行数:26,代码来源:MashTunRecipe.java

示例8: breakBlock

import net.minecraftforge.items.IItemHandler; //导入方法依赖的package包/类
@Override
public void breakBlock(World worldIn, BlockPos pos, IBlockState state) {
	TileEntityPhotoProcessor te = (TileEntityPhotoProcessor) worldIn.getTileEntity(pos);

	IItemHandler inv = te.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, EnumFacing.UP);

	for (int i = inv.getSlots() - 1; i >= 0; --i) {
		if (inv.getStackInSlot(i) != null) {
			Block.spawnAsEntity(worldIn, pos, inv.getStackInSlot(i));
			((IItemHandlerModifiable) inv).setStackInSlot(i, null);
		}
	}

	super.breakBlock(worldIn, pos, state);
}
 
开发者ID:PorPit,项目名称:MineCamera,代码行数:16,代码来源:BlockPhotoProcessor.java

示例9: doDisarm

import net.minecraftforge.items.IItemHandler; //导入方法依赖的package包/类
private void doDisarm(EntityLiving entity, Random rand, IItemHandler handler, float[] dropChances) {
    for (int i = 0; i < handler.getSlots(); i++) {
        ItemStack stack = handler.getStackInSlot(i);
        boolean flag1 = dropChances[i] > 1.0F;
        if (!stack.isEmpty() && rand.nextFloat() < dropChances[i]) {
            if (!flag1 && stack.isItemStackDamageable()) {
                int k = Math.max(stack.getMaxDamage() - 25, 1);
                int l = stack.getMaxDamage() - rand.nextInt(rand.nextInt(k) + 1);
                stack.setItemDamage(MathHelper.clamp(l, 1, k));
            }
            entity.entityDropItem(stack, 0f);
        }
        handler.extractItem(i, stack.getCount(), false);
    }
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:16,代码来源:HackableLivingDisarm.java

示例10: dropInventory

import net.minecraftforge.items.IItemHandler; //导入方法依赖的package包/类
public static void dropInventory(World world, BlockPos pos, IItemHandler itemHandler)
   {
for(int i = 0; i < itemHandler.getSlots(); i++)
{
    if(itemHandler.getStackInSlot(i) != null)
    {
	InventoryHelper.spawnItemStack(world, pos.getX(), pos.getY(), pos.getZ(), itemHandler.getStackInSlot(i));
    }
}
   }
 
开发者ID:einsteinsci,项目名称:BetterBeginningsReborn,代码行数:11,代码来源:Util.java

示例11: update

import net.minecraftforge.items.IItemHandler; //导入方法依赖的package包/类
@Override
public void update() {
    super.update();
    IItemHandler handler = getConnectedInventory();
    if (handler != null) {
        for (int i = 0; i < (upgraded ? 10 : 1) * PneumaticValues.CHARGING_STATION_CHARGE_RATE; i++) {
            boolean charged = false;
            for (int slot = 0; slot < handler.getSlots(); slot++) {
                ItemStack chargedItem = handler.getStackInSlot(slot);
                if (chargedItem.getItem() instanceof IPressurizable) {
                    IPressurizable chargingItem = (IPressurizable) chargedItem.getItem();
                    IAirHandler airHandler = pressureTube.getAirHandler(null);
                    if (chargingItem.getPressure(chargedItem) > airHandler.getPressure() + 0.01F && chargingItem.getPressure(chargedItem) > 0F) {
                        chargingItem.addAir(chargedItem, -1);
                        airHandler.addAir(1);
                        charged = true;
                    } else if (chargingItem.getPressure(chargedItem) < airHandler.getPressure() - 0.01F && chargingItem.getPressure(chargedItem) < chargingItem.maxPressure(chargedItem)) {// if there is pressure, and the item isn't fully charged yet..
                        chargingItem.addAir(chargedItem, 1);
                        airHandler.addAir(-1);
                        charged = true;
                    }
                }
            }
            if (!charged) break;
        }
    }
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:28,代码来源:ModuleCharging.java

示例12: renderTool

import net.minecraftforge.items.IItemHandler; //导入方法依赖的package包/类
private void renderTool(TileEntityInfusionRepair te, double x, double y, double z, float partialTicks)
   {
IItemHandler itemHandler = CapUtils.getItemHandler(te);
ItemStack stack = itemHandler.getStackInSlot(TileEntityInfusionRepair.SLOT_ENCH_ITEM);
if(Prep1_11.isEmpty(stack)) return;
GlStateManager.pushMatrix();
    GlStateManager.rotate(90.0F, 1.0F, 0.0F, 0.0F);
    GlStateManager.translate(-0.25F * PIXEL_SIZE, -1.5F * PIXEL_SIZE, 0.15F);
    mc.getRenderItem().renderItem(stack, TransformType.GROUND);
GlStateManager.popMatrix();
   }
 
开发者ID:einsteinsci,项目名称:BetterBeginningsReborn,代码行数:12,代码来源:InfusionRender.java

示例13: getFirstItem

import net.minecraftforge.items.IItemHandler; //导入方法依赖的package包/类
public static ItemStack getFirstItem(IItemHandler inventory, Predicate<ItemStack> pred) {
	
	for (int i = 0; i<inventory.getSlots(); i++) {
		ItemStack stack=inventory.getStackInSlot(i);
		if (!stack.isEmpty() && pred.apply(stack))
			return stack;
	}
	return ItemStack.EMPTY;
}
 
开发者ID:rafradek,项目名称:Mods,代码行数:10,代码来源:TF2Util.java

示例14: hasEnoughPuzzleStacks

import net.minecraftforge.items.IItemHandler; //导入方法依赖的package包/类
public boolean hasEnoughPuzzleStacks(EntityPlayer player, ItemStack stack) {
    int amountLeft = stack.getCount();
    if (player != null) {
        for (int i = 0; i < player.inventory.getSizeInventory(); i++) {
            ItemStack playerStack = player.inventory.getStackInSlot(i);
            if (PneumaticCraftUtils.areStacksEqual(playerStack, stack, true, true, false, false)) {
                amountLeft -= playerStack.getCount();
                if (amountLeft <= 0) return true;
            }
        }
    }

    for (EnumFacing d : EnumFacing.VALUES) {
        TileEntity te = getWorld().getTileEntity(getPos().offset(d));
        if (te != null && te.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, d.getOpposite())) {
            IItemHandler handler = te.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, d.getOpposite());
            for (int slot = 0; slot < handler.getSlots(); slot++) {
                ItemStack neighborStack = handler.getStackInSlot(slot);
                if (PneumaticCraftUtils.areStacksEqual(neighborStack, stack, true, true, false, false)) {
                    amountLeft -= neighborStack.getCount();
                    if (amountLeft <= 0) return true;
                }
            }
        }
    }

    return false;
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:29,代码来源:TileEntityProgrammer.java

示例15: breakBlock

import net.minecraftforge.items.IItemHandler; //导入方法依赖的package包/类
@Override
public void breakBlock(World world, BlockPos pos, IBlockState state) {
	TileEntityBlockBreaker te = (TileEntityBlockBreaker) world.getTileEntity(pos);
	IItemHandler handler = te.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null);
	for (int slot = 0; slot < handler.getSlots(); slot++) {
		ItemStack stack = handler.getStackInSlot(slot);
		InventoryHelper.spawnItemStack(world, pos.getX(), pos.getY(), pos.getZ(), stack);
	}
	super.breakBlock(world, pos, state);
}
 
开发者ID:IvanSteklow,项目名称:VanillaExtras,代码行数:11,代码来源:BlockBreaker.java


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