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

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

java 2次浏览

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

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

示例1: handleConfirmTransaction

点赞 3

import net.minecraft.network.play.server.SPacketConfirmTransaction; //导入依赖的package包/类
/**
 * Verifies that the server and client are synchronized with respect to the inventory/container opened by the player
 * and confirms if it is the case.
 */
public void handleConfirmTransaction(SPacketConfirmTransaction packetIn)
{
    PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
    Container container = null;
    EntityPlayer entityplayer = this.gameController.player;

    if (packetIn.getWindowId() == 0)
    {
        container = entityplayer.inventoryContainer;
    }
    else if (packetIn.getWindowId() == entityplayer.openContainer.windowId)
    {
        container = entityplayer.openContainer;
    }

    if (container != null && !packetIn.wasAccepted())
    {
        this.sendPacket(new CPacketConfirmTransaction(packetIn.getWindowId(), packetIn.getActionNumber(), true));
    }
}
 

开发者ID:NSExceptional,
项目名称:Zombe-Modpack,
代码行数:25,
代码来源:NetHandlerPlayClient.java

示例2: handleConfirmTransaction

点赞 3

import net.minecraft.network.play.server.SPacketConfirmTransaction; //导入依赖的package包/类
/**
 * Verifies that the server and client are synchronized with respect to the inventory/container opened by the player
 * and confirms if it is the case.
 */
public void handleConfirmTransaction(SPacketConfirmTransaction packetIn)
{
    PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
    Container container = null;
    EntityPlayer entityplayer = this.gameController.thePlayer;

    if (packetIn.getWindowId() == 0)
    {
        container = entityplayer.inventoryContainer;
    }
    else if (packetIn.getWindowId() == entityplayer.openContainer.windowId)
    {
        container = entityplayer.openContainer;
    }

    if (container != null && !packetIn.wasAccepted())
    {
        this.sendPacket(new CPacketConfirmTransaction(packetIn.getWindowId(), packetIn.getActionNumber(), true));
    }
}
 

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

示例3: processClickWindow

点赞 2

import net.minecraft.network.play.server.SPacketConfirmTransaction; //导入依赖的package包/类
/**
 * Executes a container/inventory slot manipulation as indicated by the packet. Sends the serverside result if they
 * didn't match the indicated result and prevents further manipulation by the player until he confirms that it has
 * the same open container/inventory
 */
public void processClickWindow(CPacketClickWindow packetIn)
{
    PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.playerEntity.getServerWorld());
    this.playerEntity.markPlayerActive();

    if (this.playerEntity.openContainer.windowId == packetIn.getWindowId() && this.playerEntity.openContainer.getCanCraft(this.playerEntity))
    {
        if (this.playerEntity.isSpectator())
        {
            NonNullList<ItemStack> nonnulllist = NonNullList.<ItemStack>func_191196_a();

            for (int i = 0; i < this.playerEntity.openContainer.inventorySlots.size(); ++i)
            {
                nonnulllist.add(((Slot)this.playerEntity.openContainer.inventorySlots.get(i)).getStack());
            }

            this.playerEntity.updateCraftingInventory(this.playerEntity.openContainer, nonnulllist);
        }
        else
        {
            ItemStack itemstack2 = this.playerEntity.openContainer.slotClick(packetIn.getSlotId(), packetIn.getUsedButton(), packetIn.getClickType(), this.playerEntity);

            if (ItemStack.areItemStacksEqual(packetIn.getClickedItem(), itemstack2))
            {
                this.playerEntity.connection.sendPacket(new SPacketConfirmTransaction(packetIn.getWindowId(), packetIn.getActionNumber(), true));
                this.playerEntity.isChangingQuantityOnly = true;
                this.playerEntity.openContainer.detectAndSendChanges();
                this.playerEntity.updateHeldItem();
                this.playerEntity.isChangingQuantityOnly = false;
            }
            else
            {
                this.pendingTransactions.addKey(this.playerEntity.openContainer.windowId, Short.valueOf(packetIn.getActionNumber()));
                this.playerEntity.connection.sendPacket(new SPacketConfirmTransaction(packetIn.getWindowId(), packetIn.getActionNumber(), false));
                this.playerEntity.openContainer.setCanCraft(this.playerEntity, false);
                NonNullList<ItemStack> nonnulllist1 = NonNullList.<ItemStack>func_191196_a();

                for (int j = 0; j < this.playerEntity.openContainer.inventorySlots.size(); ++j)
                {
                    ItemStack itemstack = ((Slot)this.playerEntity.openContainer.inventorySlots.get(j)).getStack();
                    ItemStack itemstack1 = itemstack.func_190926_b() ? ItemStack.field_190927_a : itemstack;
                    nonnulllist1.add(itemstack1);
                }

                this.playerEntity.updateCraftingInventory(this.playerEntity.openContainer, nonnulllist1);
            }
        }
    }
}
 

开发者ID:NSExceptional,
项目名称:Zombe-Modpack,
代码行数:55,
代码来源:NetHandlerPlayServer.java

示例4: processClickWindow

点赞 2

import net.minecraft.network.play.server.SPacketConfirmTransaction; //导入依赖的package包/类
/**
 * Executes a container/inventory slot manipulation as indicated by the packet. Sends the serverside result if they
 * didn't match the indicated result and prevents further manipulation by the player until he confirms that it has
 * the same open container/inventory
 */
public void processClickWindow(CPacketClickWindow packetIn)
{
    PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.playerEntity.getServerWorld());
    this.playerEntity.markPlayerActive();

    if (this.playerEntity.openContainer.windowId == packetIn.getWindowId() && this.playerEntity.openContainer.getCanCraft(this.playerEntity))
    {
        if (this.playerEntity.isSpectator())
        {
            List<ItemStack> list = Lists.<ItemStack>newArrayList();

            for (int i = 0; i < this.playerEntity.openContainer.inventorySlots.size(); ++i)
            {
                list.add(((Slot)this.playerEntity.openContainer.inventorySlots.get(i)).getStack());
            }

            this.playerEntity.updateCraftingInventory(this.playerEntity.openContainer, list);
        }
        else
        {
            ItemStack itemstack2 = this.playerEntity.openContainer.slotClick(packetIn.getSlotId(), packetIn.getUsedButton(), packetIn.getClickType(), this.playerEntity);

            if (ItemStack.areItemStacksEqual(packetIn.getClickedItem(), itemstack2))
            {
                this.playerEntity.connection.sendPacket(new SPacketConfirmTransaction(packetIn.getWindowId(), packetIn.getActionNumber(), true));
                this.playerEntity.isChangingQuantityOnly = true;
                this.playerEntity.openContainer.detectAndSendChanges();
                this.playerEntity.updateHeldItem();
                this.playerEntity.isChangingQuantityOnly = false;
            }
            else
            {
                this.pendingTransactions.addKey(this.playerEntity.openContainer.windowId, Short.valueOf(packetIn.getActionNumber()));
                this.playerEntity.connection.sendPacket(new SPacketConfirmTransaction(packetIn.getWindowId(), packetIn.getActionNumber(), false));
                this.playerEntity.openContainer.setCanCraft(this.playerEntity, false);
                List<ItemStack> list1 = Lists.<ItemStack>newArrayList();

                for (int j = 0; j < this.playerEntity.openContainer.inventorySlots.size(); ++j)
                {
                    ItemStack itemstack = ((Slot)this.playerEntity.openContainer.inventorySlots.get(j)).getStack();
                    ItemStack itemstack1 = itemstack != null && itemstack.stackSize > 0 ? itemstack : null;
                    list1.add(itemstack1);
                }

                this.playerEntity.updateCraftingInventory(this.playerEntity.openContainer, list1);
            }
        }
    }
}
 

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

示例5: handleConfirmTransaction

点赞 1

import net.minecraft.network.play.server.SPacketConfirmTransaction; //导入依赖的package包/类
/**
 * Verifies that the server and client are synchronized with respect to the inventory/container opened by the player
 * and confirms if it is the case.
 */
void handleConfirmTransaction(SPacketConfirmTransaction packetIn);
 

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


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