当前位置: 首页>>代码示例>>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;未经允许,请勿转载。