Java 类net.minecraft.network.play.server.SPacketSetSlot 实例源码

项目:Ender-Rift    文件:ContainerCraftingBrowser.java   
@Override
protected void slotChangedCraftingGrid(World world, EntityPlayer player, InventoryCrafting inventoryCrafting, InventoryCraftResult craftingResult)
{
    if (!world.isRemote)
    {
        EntityPlayerMP entityplayermp = (EntityPlayerMP)player;
        ItemStack itemstack = ItemStack.EMPTY;
        IRecipe irecipe = CraftingManager.findMatchingRecipe(inventoryCrafting, world);

        if (irecipe != null && (irecipe.isHidden() || !world.getGameRules().getBoolean("doLimitedCrafting") || entityplayermp.getRecipeBook().containsRecipe(irecipe)))
        {
            craftingResult.setRecipeUsed(irecipe);
            itemstack = irecipe.getCraftingResult(inventoryCrafting);
        }

        craftingResult.setInventorySlotContents(0, itemstack);
        entityplayermp.connection.sendPacket(new SPacketSetSlot(this.windowId, slotCraftResult.slotNumber, itemstack));
    }
}
项目:enderutilities    文件:ContainerLargeStacks.java   
@Override
public void addListener(IContainerListener listener)
{
    if (this.listeners.contains(listener))
    {
        throw new IllegalArgumentException("Listener already listening");
    }
    else
    {
        this.listeners.add(listener);

        if (listener instanceof EntityPlayerMP)
        {
            EntityPlayerMP player = (EntityPlayerMP) listener;
            player.connection.sendPacket(new SPacketSetSlot(-1, -1, player.inventory.getItemStack()));
            this.syncAllSlots(player);
        }

        this.detectAndSendChanges();
    }
}
项目:ForgeHax    文件:AntiHeldItemChangeMod.java   
@SubscribeEvent
public void onPacketReceived(PacketEvent.Incoming.Pre event) {
    if (event.getPacket() instanceof SPacketSetSlot && getLocalPlayer() != null) {
        int currentSlot = getLocalPlayer().inventory.currentItem;

        if (((SPacketSetSlot) event.getPacket()).getSlot() != currentSlot) {
            getNetworkManager().sendPacket(new CPacketHeldItemChange(currentSlot)); // set server's slot back to our slot
            FastReflection.Methods.KeyBinding_unPress.invoke(MC.gameSettings.keyBindUseItem); // likely will eating so stop right clicking

            event.setCanceled(true);
        }
    }
}
项目:Zombe-Modpack    文件:EntityPlayerMP.java   
/**
 * Sends the contents of an inventory slot to the client-side Container. This doesn't have to match the actual
 * contents of that slot.
 */
public void sendSlotContents(Container containerToSend, int slotInd, ItemStack stack)
{
    if (!(containerToSend.getSlot(slotInd) instanceof SlotCrafting))
    {
        if (!this.isChangingQuantityOnly)
        {
            this.connection.sendPacket(new SPacketSetSlot(containerToSend.windowId, slotInd, stack));
        }
    }
}
项目:Zombe-Modpack    文件:EntityPlayerMP.java   
/**
 * updates item held by mouse
 */
public void updateHeldItem()
{
    if (!this.isChangingQuantityOnly)
    {
        this.connection.sendPacket(new SPacketSetSlot(-1, -1, this.inventory.getItemStack()));
    }
}
项目:Backmemed    文件:EntityPlayerMP.java   
/**
 * Sends the contents of an inventory slot to the client-side Container. This doesn't have to match the actual
 * contents of that slot.
 */
public void sendSlotContents(Container containerToSend, int slotInd, ItemStack stack)
{
    if (!(containerToSend.getSlot(slotInd) instanceof SlotCrafting))
    {
        if (!this.isChangingQuantityOnly)
        {
            this.connection.sendPacket(new SPacketSetSlot(containerToSend.windowId, slotInd, stack));
        }
    }
}
项目:Backmemed    文件:EntityPlayerMP.java   
/**
 * updates item held by mouse
 */
public void updateHeldItem()
{
    if (!this.isChangingQuantityOnly)
    {
        this.connection.sendPacket(new SPacketSetSlot(-1, -1, this.inventory.getItemStack()));
    }
}
项目:CustomWorldGen    文件:EntityPlayerMP.java   
/**
 * Sends the contents of an inventory slot to the client-side Container. This doesn't have to match the actual
 * contents of that slot.
 */
public void sendSlotContents(Container containerToSend, int slotInd, ItemStack stack)
{
    if (!(containerToSend.getSlot(slotInd) instanceof SlotCrafting))
    {
        if (!this.isChangingQuantityOnly)
        {
            this.connection.sendPacket(new SPacketSetSlot(containerToSend.windowId, slotInd, stack));
        }
    }
}
项目:CustomWorldGen    文件:EntityPlayerMP.java   
/**
 * updates item held by mouse
 */
public void updateHeldItem()
{
    if (!this.isChangingQuantityOnly)
    {
        this.connection.sendPacket(new SPacketSetSlot(-1, -1, this.inventory.getItemStack()));
    }
}
项目:ItemDash    文件:LiteModItemDash.java   
@Override
public boolean handlePacket(INetHandler netHandler, Packet<?> packet) {
    if (!this.lastRequestedStack.isEmpty() && packet instanceof SPacketSetSlot) {
        SPacketSetSlot setslot = (SPacketSetSlot) packet;
        ItemStack stack = setslot.getStack();
        if (this.lastRequestedStack.isItemEqual(stack)) {
            this.pickSlot = true;
        }
    }
    return true;
}
项目:ExpandedRailsMod    文件:EntityPlayerMP.java   
/**
 * Sends the contents of an inventory slot to the client-side Container. This doesn't have to match the actual
 * contents of that slot.
 */
public void sendSlotContents(Container containerToSend, int slotInd, ItemStack stack)
{
    if (!(containerToSend.getSlot(slotInd) instanceof SlotCrafting))
    {
        if (!this.isChangingQuantityOnly)
        {
            this.connection.sendPacket(new SPacketSetSlot(containerToSend.windowId, slotInd, stack));
        }
    }
}
项目:ExpandedRailsMod    文件:EntityPlayerMP.java   
/**
 * updates item held by mouse
 */
public void updateHeldItem()
{
    if (!this.isChangingQuantityOnly)
    {
        this.connection.sendPacket(new SPacketSetSlot(-1, -1, this.inventory.getItemStack()));
    }
}
项目:Zombe-Modpack    文件:EntityPlayerMP.java   
/**
 * update the crafting window inventory with the items in the list
 */
public void updateCraftingInventory(Container containerToSend, NonNullList<ItemStack> itemsList)
{
    this.connection.sendPacket(new SPacketWindowItems(containerToSend.windowId, itemsList));
    this.connection.sendPacket(new SPacketSetSlot(-1, -1, this.inventory.getItemStack()));
}
项目:Zombe-Modpack    文件:NetHandlerPlayClient.java   
/**
 * Handles pickin up an ItemStack or dropping one in your inventory or an open (non-creative) container
 */
public void handleSetSlot(SPacketSetSlot packetIn)
{
    PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
    EntityPlayer entityplayer = this.gameController.player;
    ItemStack itemstack = packetIn.getStack();
    int i = packetIn.getSlot();

    if (packetIn.getWindowId() == -1)
    {
        entityplayer.inventory.setItemStack(itemstack);
    }
    else if (packetIn.getWindowId() == -2)
    {
        entityplayer.inventory.setInventorySlotContents(i, itemstack);
    }
    else
    {
        boolean flag = false;

        if (this.gameController.currentScreen instanceof GuiContainerCreative)
        {
            GuiContainerCreative guicontainercreative = (GuiContainerCreative)this.gameController.currentScreen;
            flag = guicontainercreative.getSelectedTabIndex() != CreativeTabs.INVENTORY.getTabIndex();
        }

        if (packetIn.getWindowId() == 0 && packetIn.getSlot() >= 36 && i < 45)
        {
            if (!itemstack.func_190926_b())
            {
                ItemStack itemstack1 = entityplayer.inventoryContainer.getSlot(i).getStack();

                if (itemstack1.func_190926_b() || itemstack1.func_190916_E() < itemstack.func_190916_E())
                {
                    itemstack.func_190915_d(5);
                }
            }

            entityplayer.inventoryContainer.putStackInSlot(i, itemstack);
        }
        else if (packetIn.getWindowId() == entityplayer.openContainer.windowId && (packetIn.getWindowId() != 0 || !flag))
        {
            entityplayer.openContainer.putStackInSlot(i, itemstack);
        }
    }
}
项目:Backmemed    文件:EntityPlayerMP.java   
/**
 * update the crafting window inventory with the items in the list
 */
public void updateCraftingInventory(Container containerToSend, NonNullList<ItemStack> itemsList)
{
    this.connection.sendPacket(new SPacketWindowItems(containerToSend.windowId, itemsList));
    this.connection.sendPacket(new SPacketSetSlot(-1, -1, this.inventory.getItemStack()));
}
项目:Backmemed    文件:NetHandlerPlayClient.java   
/**
 * Handles pickin up an ItemStack or dropping one in your inventory or an open (non-creative) container
 */
public void handleSetSlot(SPacketSetSlot packetIn)
{
    PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
    EntityPlayer entityplayer = this.gameController.player;
    ItemStack itemstack = packetIn.getStack();
    int i = packetIn.getSlot();

    if (packetIn.getWindowId() == -1)
    {
        entityplayer.inventory.setItemStack(itemstack);
    }
    else if (packetIn.getWindowId() == -2)
    {
        entityplayer.inventory.setInventorySlotContents(i, itemstack);
    }
    else
    {
        boolean flag = false;

        if (this.gameController.currentScreen instanceof GuiContainerCreative)
        {
            GuiContainerCreative guicontainercreative = (GuiContainerCreative)this.gameController.currentScreen;
            flag = guicontainercreative.getSelectedTabIndex() != CreativeTabs.INVENTORY.getTabIndex();
        }

        if (packetIn.getWindowId() == 0 && packetIn.getSlot() >= 36 && i < 45)
        {
            if (!itemstack.func_190926_b())
            {
                ItemStack itemstack1 = entityplayer.inventoryContainer.getSlot(i).getStack();

                if (itemstack1.func_190926_b() || itemstack1.func_190916_E() < itemstack.func_190916_E())
                {
                    itemstack.func_190915_d(5);
                }
            }

            entityplayer.inventoryContainer.putStackInSlot(i, itemstack);
        }
        else if (packetIn.getWindowId() == entityplayer.openContainer.windowId && (packetIn.getWindowId() != 0 || !flag))
        {
            entityplayer.openContainer.putStackInSlot(i, itemstack);
        }
    }
}
项目:CustomWorldGen    文件:EntityPlayerMP.java   
/**
 * update the crafting window inventory with the items in the list
 */
public void updateCraftingInventory(Container containerToSend, List<ItemStack> itemsList)
{
    this.connection.sendPacket(new SPacketWindowItems(containerToSend.windowId, itemsList));
    this.connection.sendPacket(new SPacketSetSlot(-1, -1, this.inventory.getItemStack()));
}
项目:CustomWorldGen    文件:NetHandlerPlayClient.java   
/**
 * Handles pickin up an ItemStack or dropping one in your inventory or an open (non-creative) container
 */
public void handleSetSlot(SPacketSetSlot packetIn)
{
    PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
    EntityPlayer entityplayer = this.gameController.thePlayer;

    if (packetIn.getWindowId() == -1)
    {
        entityplayer.inventory.setItemStack(packetIn.getStack());
    }
    else if (packetIn.getWindowId() == -2)
    {
        entityplayer.inventory.setInventorySlotContents(packetIn.getSlot(), packetIn.getStack());
    }
    else
    {
        boolean flag = false;

        if (this.gameController.currentScreen instanceof GuiContainerCreative)
        {
            GuiContainerCreative guicontainercreative = (GuiContainerCreative)this.gameController.currentScreen;
            flag = guicontainercreative.getSelectedTabIndex() != CreativeTabs.INVENTORY.getTabIndex();
        }

        if (packetIn.getWindowId() == 0 && packetIn.getSlot() >= 36 && packetIn.getSlot() < 45)
        {
            ItemStack itemstack = entityplayer.inventoryContainer.getSlot(packetIn.getSlot()).getStack();

            if (packetIn.getStack() != null && (itemstack == null || itemstack.stackSize < packetIn.getStack().stackSize))
            {
                packetIn.getStack().animationsToGo = 5;
            }

            entityplayer.inventoryContainer.putStackInSlot(packetIn.getSlot(), packetIn.getStack());
        }
        else if (packetIn.getWindowId() == entityplayer.openContainer.windowId && (packetIn.getWindowId() != 0 || !flag))
        {
            entityplayer.openContainer.putStackInSlot(packetIn.getSlot(), packetIn.getStack());
        }
    }
}
项目:ItemDash    文件:LiteModItemDash.java   
@Override
public List<Class<? extends Packet<?>>> getHandledPackets() {
    return ImmutableList.of(SPacketSetSlot.class);
}
项目:Industrialization    文件:ImplUtil.java   
public static void forceSlotUpdate(Container container, int slot, ItemStack stack) {
    EntityPlayerMP player = (EntityPlayerMP) containerToPlayer(container);
    player.connection.sendPacket(new SPacketSetSlot(
            ((net.minecraft.inventory.Container) container).windowId, slot, ItemStackUtil.toNative(stack)));
}
项目:Ender-Rift    文件:ContainerBrowser.java   
private void sendStackInCursor(EntityPlayerMP player, ItemStack newStack)
{
    stackInCursor = newStack.copy();

    player.connection.sendPacket(new SPacketSetSlot(-1, -1, newStack));
}
项目:ExpandedRailsMod    文件:EntityPlayerMP.java   
/**
 * update the crafting window inventory with the items in the list
 */
public void updateCraftingInventory(Container containerToSend, List<ItemStack> itemsList)
{
    this.connection.sendPacket(new SPacketWindowItems(containerToSend.windowId, itemsList));
    this.connection.sendPacket(new SPacketSetSlot(-1, -1, this.inventory.getItemStack()));
}
项目:ExpandedRailsMod    文件:ItemWrittenBook.java   
private void resolveContents(ItemStack stack, EntityPlayer player)
{
    if (stack != null && stack.getTagCompound() != null)
    {
        NBTTagCompound nbttagcompound = stack.getTagCompound();

        if (!nbttagcompound.getBoolean("resolved"))
        {
            nbttagcompound.setBoolean("resolved", true);

            if (validBookTagContents(nbttagcompound))
            {
                NBTTagList nbttaglist = nbttagcompound.getTagList("pages", 8);

                for (int i = 0; i < nbttaglist.tagCount(); ++i)
                {
                    String s = nbttaglist.getStringTagAt(i);
                    ITextComponent lvt_7_1_;

                    try
                    {
                        lvt_7_1_ = ITextComponent.Serializer.fromJsonLenient(s);
                        lvt_7_1_ = TextComponentUtils.processComponent(player, lvt_7_1_, player);
                    }
                    catch (Exception var9)
                    {
                        lvt_7_1_ = new TextComponentString(s);
                    }

                    nbttaglist.set(i, new NBTTagString(ITextComponent.Serializer.componentToJson(lvt_7_1_)));
                }

                nbttagcompound.setTag("pages", nbttaglist);

                if (player instanceof EntityPlayerMP && player.getHeldItemMainhand() == stack)
                {
                    Slot slot = player.openContainer.getSlotFromInventory(player.inventory, player.inventory.currentItem);
                    ((EntityPlayerMP)player).connection.sendPacket(new SPacketSetSlot(0, slot.slotNumber, stack));
                }
            }
        }
    }
}
项目:ExpandedRailsMod    文件:NetHandlerPlayClient.java   
/**
 * Handles pickin up an ItemStack or dropping one in your inventory or an open (non-creative) container
 */
public void handleSetSlot(SPacketSetSlot packetIn)
{
    PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
    EntityPlayer entityplayer = this.gameController.thePlayer;

    if (packetIn.getWindowId() == -1)
    {
        entityplayer.inventory.setItemStack(packetIn.getStack());
    }
    else if (packetIn.getWindowId() == -2)
    {
        entityplayer.inventory.setInventorySlotContents(packetIn.getSlot(), packetIn.getStack());
    }
    else
    {
        boolean flag = false;

        if (this.gameController.currentScreen instanceof GuiContainerCreative)
        {
            GuiContainerCreative guicontainercreative = (GuiContainerCreative)this.gameController.currentScreen;
            flag = guicontainercreative.getSelectedTabIndex() != CreativeTabs.INVENTORY.getTabIndex();
        }

        if (packetIn.getWindowId() == 0 && packetIn.getSlot() >= 36 && packetIn.getSlot() < 45)
        {
            ItemStack itemstack = entityplayer.inventoryContainer.getSlot(packetIn.getSlot()).getStack();

            if (packetIn.getStack() != null && (itemstack == null || itemstack.stackSize < packetIn.getStack().stackSize))
            {
                packetIn.getStack().animationsToGo = 5;
            }

            entityplayer.inventoryContainer.putStackInSlot(packetIn.getSlot(), packetIn.getStack());
        }
        else if (packetIn.getWindowId() == entityplayer.openContainer.windowId && (packetIn.getWindowId() != 0 || !flag))
        {
            entityplayer.openContainer.putStackInSlot(packetIn.getSlot(), packetIn.getStack());
        }
    }
}
项目:Backmemed    文件:INetHandlerPlayClient.java   
/**
 * Handles pickin up an ItemStack or dropping one in your inventory or an open (non-creative) container
 */
void handleSetSlot(SPacketSetSlot packetIn);
项目:CustomWorldGen    文件:INetHandlerPlayClient.java   
/**
 * Handles pickin up an ItemStack or dropping one in your inventory or an open (non-creative) container
 */
void handleSetSlot(SPacketSetSlot packetIn);