當前位置: 首頁>>代碼示例>>Java>>正文


Java Items.written_book方法代碼示例

本文整理匯總了Java中net.minecraft.init.Items.written_book方法的典型用法代碼示例。如果您正苦於以下問題:Java Items.written_book方法的具體用法?Java Items.written_book怎麽用?Java Items.written_book使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在net.minecraft.init.Items的用法示例。


在下文中一共展示了Items.written_book方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: displayGUIBook

import net.minecraft.init.Items; //導入方法依賴的package包/類
/**
 * Displays the GUI for interacting with a book.
 */
public void displayGUIBook(ItemStack bookStack)
{
    Item item = bookStack.getItem();

    if (item == Items.written_book)
    {
        this.playerNetServerHandler.sendPacket(new S3FPacketCustomPayload("MC|BOpen", new PacketBuffer(Unpooled.buffer())));
    }
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:13,代碼來源:EntityPlayerMP.java

示例2: matches

import net.minecraft.init.Items; //導入方法依賴的package包/類
/**
 * Used to check if a recipe matches current crafting inventory
 */
public boolean matches(InventoryCrafting inv, World worldIn)
{
    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 false;
                }

                itemstack = itemstack1;
            }
            else
            {
                if (itemstack1.getItem() != Items.writable_book)
                {
                    return false;
                }

                ++i;
            }
        }
    }

    return itemstack != null && i > 0;
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:38,代碼來源:RecipeBookCloning.java

示例3: handleCustomPayload

import net.minecraft.init.Items; //導入方法依賴的package包/類
/**
 * Handles packets that have room for a channel specification. Vanilla
 * implemented channels are "MC|TrList" to acquire a MerchantRecipeList trades
 * for a villager merchant, "MC|Brand" which sets the server brand? on the
 * player instance and finally "MC|RPack" which the server uses to communicate
 * the identifier of the default server resourcepack for the client to load.
 */
public void handleCustomPayload(S3FPacketCustomPayload packetIn) {
	PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);

	if ("MC|TrList".equals(packetIn.getChannelName())) {
		PacketBuffer packetbuffer = packetIn.getBufferData();

		try {
			int i = packetbuffer.readInt();
			GuiScreen guiscreen = this.gameController.currentScreen;

			if (guiscreen != null && guiscreen instanceof GuiMerchant
					&& i == this.gameController.thePlayer.openContainer.windowId) {
				IMerchant imerchant = ((GuiMerchant) guiscreen).getMerchant();
				MerchantRecipeList merchantrecipelist = MerchantRecipeList.readFromBuf(packetbuffer);
				imerchant.setRecipes(merchantrecipelist);
			}
		} catch (IOException ioexception) {
			logger.error((String) "Couldn\'t load trade info", (Throwable) ioexception);
		} finally {
			packetbuffer.release();
		}
	} else if ("MC|Brand".equals(packetIn.getChannelName())) {
		this.gameController.thePlayer.setClientBrand(packetIn.getBufferData().readStringFromBuffer(32767));
	} else if ("MC|BOpen".equals(packetIn.getChannelName())) {
		ItemStack itemstack = this.gameController.thePlayer.getCurrentEquippedItem();

		if (itemstack != null && itemstack.getItem() == Items.written_book) {
			this.gameController
					.displayGuiScreen(new GuiScreenBook(this.gameController.thePlayer, itemstack, false));
		}
	}
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:40,代碼來源:NetHandlerPlayClient.java

示例4: getCraftingResult

import net.minecraft.init.Items; //導入方法依賴的package包/類
/**
 * Returns an Item that is the result of this recipe
 */
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 && ItemEditableBook.getGeneration(itemstack) < 2)
    {
        ItemStack itemstack2 = new ItemStack(Items.written_book, i);
        itemstack2.setTagCompound((NBTTagCompound)itemstack.getTagCompound().copy());
        itemstack2.getTagCompound().setInteger("generation", ItemEditableBook.getGeneration(itemstack) + 1);

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

        return itemstack2;
    }
    else
    {
        return null;
    }
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:54,代碼來源:RecipeBookCloning.java

示例5: handleCustomPayload

import net.minecraft.init.Items; //導入方法依賴的package包/類
/**
 * Handles packets that have room for a channel specification. Vanilla implemented channels are "MC|TrList" to
 * acquire a MerchantRecipeList trades for a villager merchant, "MC|Brand" which sets the server brand? on the
 * player instance and finally "MC|RPack" which the server uses to communicate the identifier of the default server
 * resourcepack for the client to load.
 */
public void handleCustomPayload(S3FPacketCustomPayload packetIn)
{
    PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);

    if ("MC|TrList".equals(packetIn.getChannelName()))
    {
        PacketBuffer packetbuffer = packetIn.getBufferData();

        try
        {
            int i = packetbuffer.readInt();
            GuiScreen guiscreen = this.gameController.currentScreen;

            if (guiscreen != null && guiscreen instanceof GuiMerchant && i == this.gameController.thePlayer.openContainer.windowId)
            {
                IMerchant imerchant = ((GuiMerchant)guiscreen).getMerchant();
                MerchantRecipeList merchantrecipelist = MerchantRecipeList.readFromBuf(packetbuffer);
                imerchant.setRecipes(merchantrecipelist);
            }
        }
        catch (IOException ioexception)
        {
            logger.error((String)"Couldn\'t load trade info", (Throwable)ioexception);
        }
        finally
        {
            packetbuffer.release();
        }
    }
    else if ("MC|Brand".equals(packetIn.getChannelName()))
    {
        this.gameController.thePlayer.setClientBrand(packetIn.getBufferData().readStringFromBuffer(32767));
    }
    else if ("MC|BOpen".equals(packetIn.getChannelName()))
    {
        ItemStack itemstack = this.gameController.thePlayer.getCurrentEquippedItem();

        if (itemstack != null && itemstack.getItem() == Items.written_book)
        {
            this.gameController.displayGuiScreen(new GuiScreenBook(this.gameController.thePlayer, itemstack, false));
        }
    }
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:50,代碼來源:NetHandlerPlayClient.java

示例6: isNameOnWhitelist

import net.minecraft.init.Items; //導入方法依賴的package包/類
public static boolean isNameOnWhitelist(Entity_AA turret, String nameOrCmd)
{
	if (turret.storage == null) { return false; }	// Has no space to store anything in
	int counter = 0;
	
	// Step 1, find a book in our inventory
	
	while (counter < turret.storage.length)
	{
		if (turret.storage[counter] != null)
		{
			if (turret.storage[counter].getItem() == Items.writable_book || turret.storage[counter].getItem() == Items.written_book)
			{
				//System.out.println("[TURRET] Checking writable book for whitelist against " + playerName);
				
				if (turret.storage[counter].hasTagCompound())
				{
					NBTTagList pageList = turret.storage[counter].getTagCompound().getTagList("pages", 8);
					
					int pageCount = 0;
					
					String currentPage = pageList.getStringTagAt(pageCount);
					
					while (currentPage != null && !currentPage.isEmpty())
					{
						String[] lines = currentPage.split("\n");
						
						int lineCount = 0;
						
						while (lineCount < lines.length)
						{
							//System.out.println("[TURRET] Book page " + pageCount + " - line " + lineCount + ": " + lines[lineCount]);
							
							if (lines[lineCount].equals(nameOrCmd)) { return true;	} // Found it!
							// else, not on this line
							
							lineCount += 1;
						}
						
						pageCount += 1;
						currentPage = pageList.getStringTagAt(pageCount);	// Next!
					}
					// Done with all known pages (will stop when there's empty pages inbetween)
				}
				// else, no tag, so can't have anything in it
			}
			// else, not a book
		}
		// else, nothing in that slot
		
		
		counter += 1;
	}
	
	return false;	// Fallback. Didn't find a book with this name
}
 
開發者ID:Domochevsky,項目名稱:minecraft-quiverbow,代碼行數:57,代碼來源:AI_Targeting.java


注:本文中的net.minecraft.init.Items.written_book方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。