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


Java InventoryPlayer.getHotbarSize方法代碼示例

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


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

示例1: processHeldItemChange

import net.minecraft.entity.player.InventoryPlayer; //導入方法依賴的package包/類
/**
 * Updates which quickbar slot is selected
 */
public void processHeldItemChange(C09PacketHeldItemChange packetIn)
{
    PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.playerEntity.getServerForPlayer());

    if (packetIn.getSlotId() >= 0 && packetIn.getSlotId() < InventoryPlayer.getHotbarSize())
    {
        this.playerEntity.inventory.currentItem = packetIn.getSlotId();
        this.playerEntity.markPlayerActive();
    }
    else
    {
        logger.warn(this.playerEntity.getName() + " tried to set an invalid carried item");
    }
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:18,代碼來源:NetHandlerPlayServer.java

示例2: handleHeldItemChange

import net.minecraft.entity.player.InventoryPlayer; //導入方法依賴的package包/類
/**
 * Updates which hotbar slot of the player is currently selected
 */
public void handleHeldItemChange(S09PacketHeldItemChange packetIn)
{
    PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);

    if (packetIn.getHeldItemHotbarIndex() >= 0 && packetIn.getHeldItemHotbarIndex() < InventoryPlayer.getHotbarSize())
    {
        this.gameController.thePlayer.inventory.currentItem = packetIn.getHeldItemHotbarIndex();
    }
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:13,代碼來源:NetHandlerPlayClient.java

示例3: handleHeldItemChange

import net.minecraft.entity.player.InventoryPlayer; //導入方法依賴的package包/類
/**
 * Updates which hotbar slot of the player is currently selected
 */
public void handleHeldItemChange(S09PacketHeldItemChange packetIn) {
	PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);

	if (packetIn.getHeldItemHotbarIndex() >= 0
			&& packetIn.getHeldItemHotbarIndex() < InventoryPlayer.getHotbarSize()) {
		this.gameController.thePlayer.inventory.currentItem = packetIn.getHeldItemHotbarIndex();
	}
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:12,代碼來源:NetHandlerPlayClient.java

示例4: processHeldItemChange

import net.minecraft.entity.player.InventoryPlayer; //導入方法依賴的package包/類
/**
 * Updates which quickbar slot is selected
 */
public void processHeldItemChange(CPacketHeldItemChange packetIn)
{
    PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.playerEntity.getServerWorld());

    if (packetIn.getSlotId() >= 0 && packetIn.getSlotId() < InventoryPlayer.getHotbarSize())
    {
        this.playerEntity.inventory.currentItem = packetIn.getSlotId();
        this.playerEntity.markPlayerActive();
    }
    else
    {
        LOGGER.warn("{} tried to set an invalid carried item", new Object[] {this.playerEntity.getName()});
    }
}
 
開發者ID:NSExceptional,項目名稱:Zombe-Modpack,代碼行數:18,代碼來源:NetHandlerPlayServer.java

示例5: isPlayerHasItemOnHotbar

import net.minecraft.entity.player.InventoryPlayer; //導入方法依賴的package包/類
public boolean isPlayerHasItemOnHotbar(InventoryPlayer inventory, Item item)
{
       for (int i = 0; i < inventory.getHotbarSize(); ++i) {
           if (inventory.mainInventory[i] != null && inventory.mainInventory[i].getItem() == item) {
               return true;
           }
       }

       return false;
}
 
開發者ID:TwilightWingsStudio,項目名稱:HazardsLib,代碼行數:11,代碼來源:ClientEventHandler.java

示例6: run

import net.minecraft.entity.player.InventoryPlayer; //導入方法依賴的package包/類
@Override
public void run() {
    try {
        while (!stopped) {
            // check to see if we've finished the book
            if(!parser.hasNext()) {
                this.status = Status.FINISHED;
                break;
            }

            sleep();

            // wait for screen
            if (MC.currentScreen != null) {
                this.status = Status.AWAITING_GUI_CLOSE;
                continue;
            }

            // search for empty book
            int slot = -1;
            ItemStack selected = null;
            for (int i = 0; i < InventoryPlayer.getHotbarSize(); i++) {
                ItemStack stack = getLocalPlayer().inventory.getStackInSlot(i);
                if (stack != null
                        && !stack.equals(ItemStack.EMPTY)
                        && stack.getItem() instanceof ItemWritableBook) {
                    slot = i;
                    selected = stack;
                    break;
                }
            }

            // make sure we found a book
            if (slot == -1) {
                this.status = Status.NEED_EMPTY_BOOKS_IN_HOTBAR;
                continue;
            }

            // set selected item to that slot
            while(getLocalPlayer().inventory.currentItem != slot) {
                getLocalPlayer().inventory.currentItem = slot;
                this.status = Status.CHANGING_HELD_ITEM;
                sleep();
            }

            final ItemStack item = selected;

            // open the book gui screen
            this.status = Status.OPENING_BOOK;
            MC.addScheduledTask(() -> getLocalPlayer().openBook(item, EnumHand.MAIN_HAND));

            // wait for gui to open
            while(!(MC.currentScreen instanceof GuiScreenBook)) sleep();

            // send book to server
            this.status = Status.WRITING_BOOK;
            MC.addScheduledTask(() -> {
                sendBook(item);
                MC.displayGuiScreen(null);
            });

            // wait for screen to close
            while (MC.currentScreen != null) sleep();
        }
    } catch (Throwable t) {
        this.status = Status.ERROR;
    } finally {
        if(finalListener != null) {
            finalListener.accept(this);
            finalListener = null;
        }

        // set stopped to true
        this.stopped = true;

        if(!this.status.equals(Status.FINISHED) && !this.status.equals(Status.ERROR))
            this.status = Status.STOPPED;
    }
}
 
開發者ID:fr1kin,項目名稱:ForgeHax,代碼行數:80,代碼來源:BookBot.java

示例7: processCreativeInventoryAction

import net.minecraft.entity.player.InventoryPlayer; //導入方法依賴的package包/類
/**
 * Update the server with an ItemStack in a slot.
 */
public void processCreativeInventoryAction(C10PacketCreativeInventoryAction packetIn)
{
    PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.playerEntity.getServerForPlayer());

    if (this.playerEntity.theItemInWorldManager.isCreative())
    {
        boolean flag = packetIn.getSlotId() < 0;
        ItemStack itemstack = packetIn.getStack();

        if (itemstack != null && itemstack.hasTagCompound() && itemstack.getTagCompound().hasKey("BlockEntityTag", 10))
        {
            NBTTagCompound nbttagcompound = itemstack.getTagCompound().getCompoundTag("BlockEntityTag");

            if (nbttagcompound.hasKey("x") && nbttagcompound.hasKey("y") && nbttagcompound.hasKey("z"))
            {
                BlockPos blockpos = new BlockPos(nbttagcompound.getInteger("x"), nbttagcompound.getInteger("y"), nbttagcompound.getInteger("z"));
                TileEntity tileentity = this.playerEntity.worldObj.getTileEntity(blockpos);

                if (tileentity != null)
                {
                    NBTTagCompound nbttagcompound1 = new NBTTagCompound();
                    tileentity.writeToNBT(nbttagcompound1);
                    nbttagcompound1.removeTag("x");
                    nbttagcompound1.removeTag("y");
                    nbttagcompound1.removeTag("z");
                    itemstack.setTagInfo("BlockEntityTag", nbttagcompound1);
                }
            }
        }

        boolean flag1 = packetIn.getSlotId() >= 1 && packetIn.getSlotId() < 36 + InventoryPlayer.getHotbarSize();
        boolean flag2 = itemstack == null || itemstack.getItem() != null;
        boolean flag3 = itemstack == null || itemstack.getMetadata() >= 0 && itemstack.stackSize <= 64 && itemstack.stackSize > 0;

        if (flag1 && flag2 && flag3)
        {
            if (itemstack == null)
            {
                this.playerEntity.inventoryContainer.putStackInSlot(packetIn.getSlotId(), (ItemStack)null);
            }
            else
            {
                this.playerEntity.inventoryContainer.putStackInSlot(packetIn.getSlotId(), itemstack);
            }

            this.playerEntity.inventoryContainer.setCanCraft(this.playerEntity, true);
        }
        else if (flag && flag2 && flag3 && this.itemDropThreshold < 200)
        {
            this.itemDropThreshold += 20;
            EntityItem entityitem = this.playerEntity.dropPlayerItemWithRandomChoice(itemstack, true);

            if (entityitem != null)
            {
                entityitem.setAgeToCreativeDespawnTime();
            }
        }
    }
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:63,代碼來源:NetHandlerPlayServer.java


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