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


Java ItemStack.isItemEnchantable方法代码示例

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


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

示例1: getRecipeIngredients

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
private ItemStack[] getRecipeIngredients(ItemStackHandler inputStacks) {
    List<ItemStack> enchantedBooks = new ItemStackHandlerIterable(inputStacks)
                                                .stream()
                                                .filter(book -> book.getItem() == Items.ENCHANTED_BOOK)
                                                .collect(Collectors.toList());

    if (enchantedBooks.isEmpty()) return null;

    for (ItemStack inputStack : new ItemStackHandlerIterable(inputStacks)) {
        if ((inputStack.isItemEnchantable() || inputStack.isItemEnchanted()) && inputStack.getItem() != Items.ENCHANTED_BOOK) {
            for (ItemStack enchantedBook : enchantedBooks) {
                Map<Enchantment, Integer> bookMap = EnchantmentHelper.getEnchantments(enchantedBook);
                for (Map.Entry<Enchantment, Integer> entry : bookMap.entrySet()) {
                    if (entry.getKey().canApply(inputStack)) {
                        return new ItemStack[]{ inputStack, enchantedBook};
                    }
                }
            }
        }
    }
    return null;
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:23,代码来源:PressureChamberPressureEnchantHandler.java

示例2: setCurrentItem

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public void setCurrentItem(Item itemIn, int p_146030_2_, boolean p_146030_3_, boolean p_146030_4_)
{
    ItemStack itemstack = this.getCurrentItem();
    int i = p_146030_3_ ? this.getInventorySlotContainItemAndDamage(itemIn, p_146030_2_) : this.getInventorySlotContainItem(itemIn);

    if (i >= 0 && i < 9)
    {
        this.currentItem = i;
    }
    else if (p_146030_4_ && itemIn != null)
    {
        int j = this.getFirstEmptyStack();

        if (j >= 0 && j < 9)
        {
            this.currentItem = j;
        }

        if (itemstack == null || !itemstack.isItemEnchantable() || this.getInventorySlotContainItemAndDamage(itemstack.getItem(), itemstack.getItemDamage()) != this.currentItem)
        {
            int k = this.getInventorySlotContainItemAndDamage(itemIn, p_146030_2_);
            int l;

            if (k >= 0)
            {
                l = this.mainInventory[k].stackSize;
                this.mainInventory[k] = this.mainInventory[this.currentItem];
            }
            else
            {
                l = 1;
            }

            this.mainInventory[this.currentItem] = new ItemStack(itemIn, l, p_146030_2_);
        }
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:38,代码来源:InventoryPlayer.java

示例3: onCraftMatrixChanged

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
/**
 * Callback for when the crafting matrix is changed.
 */
@Override
public void onCraftMatrixChanged(IInventory p_75130_1_) {
	if (p_75130_1_ == tableInventory) {
		ItemStack var2 = p_75130_1_.getStackInSlot(0);
		int power;

		if (var2 != null && var2.isItemEnchantable()) {
			if (!world.isRemote) {
				power = 0;
				int j;

				for (j = -1; j <= 1; ++j)
					for (int k = -1; k <= 1; ++k)
						if ((j != 0 || k != 0) && world.isAirBlock(posX + k, posY, posZ + j) && world.isAirBlock(posX + k, posY + 1, posZ + j)) {
							power += ForgeHooks.getEnchantPower(world, posX + k * 2, posY, posZ + j * 2);
							power += ForgeHooks.getEnchantPower(world, posX + k * 2, posY + 1, posZ + j * 2);

							if (k != 0 && j != 0) {
								power += ForgeHooks.getEnchantPower(world, posX + k * 2, posY, posZ + j);
								power += ForgeHooks.getEnchantPower(world, posX + k * 2, posY + 1, posZ + j);
								power += ForgeHooks.getEnchantPower(world, posX + k, posY, posZ + j * 2);
								power += ForgeHooks.getEnchantPower(world, posX + k, posY + 1, posZ + j * 2);
							}
						}

				rand.setSeed(enchantmentSeed);

				for (j = 0; j < 3; ++j) {
					enchantLevels[j] = EnchantmentHelper.calcItemStackEnchantability(rand, j, power, var2);
					field_178151_h[j] = -1;

					if (enchantLevels[j] < j + 1)
						enchantLevels[j] = 0;
				}

				for (j = 0; j < 3; ++j)
					if (enchantLevels[j] > 0) {
						List<EnchantmentData> var7 = func_178148_a(var2, j, enchantLevels[j]);

						if (var7 != null && !var7.isEmpty()) {
							EnchantmentData var6 = var7.get(rand.nextInt(var7.size()));
							field_178151_h[j] = var6.enchantmentobj.effectId | var6.enchantmentLevel << 8;
						}
					}

				detectAndSendChanges();
			}
		} else
			for (power = 0; power < 3; ++power) {
				enchantLevels[power] = 0;
				field_178151_h[power] = -1;
			}
	}
}
 
开发者ID:jm-organization,项目名称:connor41-etfuturum2,代码行数:58,代码来源:ContainerEnchantment.java

示例4: onUpdate

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public void onUpdate(ItemStack itemStack, World world, Entity player, int par4, boolean par5) {
	if(itemStack.isItemEnchantable())
		TechnicalTools.enchantTool(itemStack, ((TechnicalHoe) itemStack.getItem()).theToolMaterial);
}
 
开发者ID:viddeno,项目名称:Technical,代码行数:5,代码来源:TechnicalHoe.java

示例5: onUpdate

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public void onUpdate(ItemStack itemStack, World world, Entity player, int par4, boolean par5) {
	if(itemStack.isItemEnchantable())
		TechnicalTools.enchantTool(itemStack, ((TechnicalSword) itemStack.getItem()).toolMaterial);
}
 
开发者ID:viddeno,项目名称:Technical,代码行数:5,代码来源:TechnicalSword.java

示例6: onUpdate

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public void onUpdate(ItemStack itemStack, World world, Entity player, int par4, boolean par5) {
	if(itemStack.isItemEnchantable())
		TechnicalTools.enchantTool(itemStack, ((TechnicalCrusher) itemStack.getItem()).toolMaterial);
}
 
开发者ID:viddeno,项目名称:Technical,代码行数:5,代码来源:TechnicalCrusher.java

示例7: onUpdate

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public void onUpdate(ItemStack itemStack, World world, Entity player, int par4, boolean par5) {
	if(itemStack.isItemEnchantable())
		TechnicalTools.enchantTool(itemStack, ((TechnicalShovel) itemStack.getItem()).toolMaterial);
}
 
开发者ID:viddeno,项目名称:Technical,代码行数:5,代码来源:TechnicalShovel.java

示例8: onUpdate

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public void onUpdate(ItemStack itemStack, World world, Entity player, int par4, boolean par5) {
	if(itemStack.isItemEnchantable())
		TechnicalTools.enchantTool(itemStack, ((TechnicalAxe) itemStack.getItem()).toolMaterial);
}
 
开发者ID:viddeno,项目名称:Technical,代码行数:5,代码来源:TechnicalAxe.java

示例9: onUpdate

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public void onUpdate(ItemStack itemStack, World world, Entity player, int par4, boolean par5) {
	if(itemStack.isItemEnchantable())
		TechnicalTools.enchantTool(itemStack, ((TechnicalPickaxe) itemStack.getItem()).toolMaterial);
}
 
开发者ID:viddeno,项目名称:Technical,代码行数:5,代码来源:TechnicalPickaxe.java

示例10: onCraftMatrixChanged

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
/**
 * Callback for when the crafting matrix is changed.
 */
public void onCraftMatrixChanged(IInventory inventoryIn)
{
    if (inventoryIn == this.tableInventory)
    {
        ItemStack itemstack = inventoryIn.getStackInSlot(0);

        if (itemstack != null && itemstack.isItemEnchantable())
        {
            if (!this.worldPointer.isRemote)
            {
                int l = 0;
                float power = 0;

                for (int j = -1; j <= 1; ++j)
                {
                    for (int k = -1; k <= 1; ++k)
                    {
                        if ((j != 0 || k != 0) && this.worldPointer.isAirBlock(this.position.add(k, 0, j)) && this.worldPointer.isAirBlock(this.position.add(k, 1, j)))
                        {
                            power += net.minecraftforge.common.ForgeHooks.getEnchantPower(worldPointer, position.add(k * 2, 0, j * 2));
                            power += net.minecraftforge.common.ForgeHooks.getEnchantPower(worldPointer, position.add(k * 2, 1, j * 2));
                            if (k != 0 && j != 0)
                            {
                                power += net.minecraftforge.common.ForgeHooks.getEnchantPower(worldPointer, position.add(k * 2, 0, j));
                                power += net.minecraftforge.common.ForgeHooks.getEnchantPower(worldPointer, position.add(k * 2, 1, j));
                                power += net.minecraftforge.common.ForgeHooks.getEnchantPower(worldPointer, position.add(k, 0, j * 2));
                                power += net.minecraftforge.common.ForgeHooks.getEnchantPower(worldPointer, position.add(k, 1, j * 2));
                            }
                        }
                    }
                }

                this.rand.setSeed((long)this.xpSeed);

                for (int i1 = 0; i1 < 3; ++i1)
                {
                    this.enchantLevels[i1] = EnchantmentHelper.calcItemStackEnchantability(this.rand, i1, (int)power, itemstack);
                    this.enchantClue[i1] = -1;
                    this.worldClue[i1] = -1;

                    if (this.enchantLevels[i1] < i1 + 1)
                    {
                        this.enchantLevels[i1] = 0;
                    }
                }

                for (int j1 = 0; j1 < 3; ++j1)
                {
                    if (this.enchantLevels[j1] > 0)
                    {
                        List<EnchantmentData> list = this.getEnchantmentList(itemstack, j1, this.enchantLevels[j1]);

                        if (list != null && !list.isEmpty())
                        {
                            EnchantmentData enchantmentdata = (EnchantmentData)list.get(this.rand.nextInt(list.size()));
                            this.enchantClue[j1] = Enchantment.getEnchantmentID(enchantmentdata.enchantmentobj);
                            this.worldClue[j1] = enchantmentdata.enchantmentLevel;
                        }
                    }
                }

                this.detectAndSendChanges();
            }
        }
        else
        {
            for (int i = 0; i < 3; ++i)
            {
                this.enchantLevels[i] = 0;
                this.enchantClue[i] = -1;
                this.worldClue[i] = -1;
            }
        }
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:79,代码来源:ContainerEnchantment.java


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