• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java ItemWrittenBook类的典型用法和代码示例

java 1次浏览

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

ItemWrittenBook类属于net.minecraft.item包,在下文中一共展示了ItemWrittenBook类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getRemainingItems

点赞 3

import net.minecraft.item.ItemWrittenBook; //导入依赖的package包/类
public NonNullList<ItemStack> getRemainingItems(InventoryCrafting inv)
{
    NonNullList<ItemStack> nonnulllist = NonNullList.<ItemStack>func_191197_a(inv.getSizeInventory(), ItemStack.field_190927_a);

    for (int i = 0; i < nonnulllist.size(); ++i)
    {
        ItemStack itemstack = inv.getStackInSlot(i);

        if (itemstack.getItem() instanceof ItemWrittenBook)
        {
            ItemStack itemstack1 = itemstack.copy();
            itemstack1.func_190920_e(1);
            nonnulllist.set(i, itemstack1);
            break;
        }
    }

    return nonnulllist;
}
 

开发者ID:sudofox,
项目名称:Backmemed,
代码行数:20,
代码来源:RecipeBookCloning.java

示例2: getRemainingItems

点赞 3

import net.minecraft.item.ItemWrittenBook; //导入依赖的package包/类
public ItemStack[] getRemainingItems(InventoryCrafting inv)
{
    ItemStack[] aitemstack = new ItemStack[inv.getSizeInventory()];

    for (int i = 0; i < aitemstack.length; ++i)
    {
        ItemStack itemstack = inv.getStackInSlot(i);

        if (itemstack != null && itemstack.getItem() instanceof ItemWrittenBook)
        {
            aitemstack[i] = itemstack.copy();
            aitemstack[i].stackSize = 1;
            break;
        }
    }

    return aitemstack;
}
 

开发者ID:F1r3w477,
项目名称:CustomWorldGen,
代码行数:19,
代码来源:RecipeBookCloning.java

示例3: updateTick

点赞 2

import net.minecraft.item.ItemWrittenBook; //导入依赖的package包/类
@Override
   public void updateTick(World world, BlockPos pos, IBlockState state, Random rand) {
	
	if (this.getAge(state) >= getMaxAge() || world.isRemote)
		return;
	
	Iterable<BlockPos> getBox = BlockPos.getAllInBox(pos.add(-4, -2, -4), pos.add(4, 2, 4));
	Iterator it = getBox.iterator();
	while (it.hasNext()) {
		BlockPos fromIt = (BlockPos)it.next();
		IBlockState loopstate = world.getBlockState(fromIt);
		if (loopstate.getBlock() == Blocks.BOOKSHELF) {
			TileEntity te = world.getTileEntity(fromIt.add(0, 1, 0));
			if (te != null && te.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, EnumFacing.DOWN)) {
				IItemHandler cap = te.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, EnumFacing.DOWN);
				boolean found = false;
				for (int i = 0; i < cap.getSlots(); i++) {
					if (found)
						return;
					ItemStack book = cap.getStackInSlot(i);
					if (book != null && book.getItem() == Items.WRITTEN_BOOK) {
						NBTTagCompound tag = book.getTagCompound();
						if (ItemWrittenBook.validBookTagContents(tag) && !NBTUtils.getBoolean(book, "UC_tagRead", false) && ItemWrittenBook.getGeneration(book) == 0)
						{
							NBTTagList taglist = tag.getTagList("pages", 8);
							for (int j = 0; j < taglist.tagCount(); ++j)
							{
								String str = taglist.getStringTagAt(j);
								ITextComponent text = ITextComponent.Serializer.fromJsonLenient(str);
								try
								{
									if (str.length() >= 100 && str.length() <= 512)
										found = true;
								} 
								catch (Exception e) 
								{
									System.out.println("whoopsy doopsy");
								}
								if (found) {
									ITextComponent newStr = eatSomeLetters(text);
									taglist.set(j, new NBTTagString(newStr.getUnformattedText()));
									break;
								}
							}
							tag.setTag("pages", taglist);
							tag.setBoolean("UC_tagRead", true);
							
							if (found) {
								int addAge = taglist.tagCount();
								if (getAge(state) + addAge >= ((BlockCrops)state.getBlock()).getMaxAge())
									world.setBlockState(pos, ((BlockCrops)state.getBlock()).withAge(((BlockCrops)state.getBlock()).getMaxAge()), 2);
								else
									world.setBlockState(pos, ((BlockCrops)state.getBlock()).withAge(getAge(state) + addAge), 2);
							}
							return;
						}
					}
				}
			}
		}
	}
}
 

开发者ID:bafomdad,
项目名称:uniquecrops,
代码行数:63,
代码来源:Knowledge.java

示例4: getCraftingResult

点赞 2

import net.minecraft.item.ItemWrittenBook; //导入依赖的package包/类
/**
 * Returns an Item that is the result of this recipe
 */
public ItemStack getCraftingResult(InventoryCrafting inv)
{
    int i = 0;
    ItemStack itemstack = ItemStack.field_190927_a;

    for (int j = 0; j < inv.getSizeInventory(); ++j)
    {
        ItemStack itemstack1 = inv.getStackInSlot(j);

        if (!itemstack1.func_190926_b())
        {
            if (itemstack1.getItem() == Items.WRITTEN_BOOK)
            {
                if (!itemstack.func_190926_b())
                {
                    return ItemStack.field_190927_a;
                }

                itemstack = itemstack1;
            }
            else
            {
                if (itemstack1.getItem() != Items.WRITABLE_BOOK)
                {
                    return ItemStack.field_190927_a;
                }

                ++i;
            }
        }
    }

    if (!itemstack.func_190926_b() && itemstack.hasTagCompound() && i >= 1 && ItemWrittenBook.getGeneration(itemstack) < 2)
    {
        ItemStack itemstack2 = new ItemStack(Items.WRITTEN_BOOK, i);
        itemstack2.setTagCompound(itemstack.getTagCompound().copy());
        itemstack2.getTagCompound().setInteger("generation", ItemWrittenBook.getGeneration(itemstack) + 1);

        if (itemstack.hasDisplayName())
        {
            itemstack2.setStackDisplayName(itemstack.getDisplayName());
        }

        return itemstack2;
    }
    else
    {
        return ItemStack.field_190927_a;
    }
}
 

开发者ID:sudofox,
项目名称:Backmemed,
代码行数:54,
代码来源:RecipeBookCloning.java

示例5: getCraftingResult

点赞 2

import net.minecraft.item.ItemWrittenBook; //导入依赖的package包/类
/**
 * Returns an Item that is the result of this recipe
 */
@Nullable
public ItemStack getCraftingResult(InventoryCrafting inv)
{
    int i = 0;
    ItemStack itemstack = null;

    for (int j = 0; j < inv.getSizeInventory(); ++j)
    {
        ItemStack itemstack1 = inv.getStackInSlot(j);

        if (itemstack1 != null)
        {
            if (itemstack1.getItem() == Items.WRITTEN_BOOK)
            {
                if (itemstack != null)
                {
                    return null;
                }

                itemstack = itemstack1;
            }
            else
            {
                if (itemstack1.getItem() != Items.WRITABLE_BOOK)
                {
                    return null;
                }

                ++i;
            }
        }
    }

    if (itemstack != null && i >= 1 && ItemWrittenBook.getGeneration(itemstack) < 2)
    {
        ItemStack itemstack2 = new ItemStack(Items.WRITTEN_BOOK, i);
        itemstack2.setTagCompound(itemstack.getTagCompound().copy());
        itemstack2.getTagCompound().setInteger("generation", ItemWrittenBook.getGeneration(itemstack) + 1);

        if (itemstack.hasDisplayName())
        {
            itemstack2.setStackDisplayName(itemstack.getDisplayName());
        }

        return itemstack2;
    }
    else
    {
        return null;
    }
}
 

开发者ID:F1r3w477,
项目名称:CustomWorldGen,
代码行数:55,
代码来源:RecipeBookCloning.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)