当前位置: 首页>>代码示例>>Java>>正文


Java S2FPacketSetSlot类代码示例

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


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

示例1: onCraftMatrixChanged

import net.minecraft.network.play.server.S2FPacketSetSlot; //导入依赖的package包/类
public void onCraftMatrixChanged(IInventory p_75130_1_)
{
    // CraftBukkit start (Note: the following line would cause an error if called during construction)
    CraftingManager.getInstance().lastCraftView = getBukkitView();
    ItemStack craftResult = CraftingManager.getInstance().findMatchingRecipe(this.craftMatrix, this.thePlayer.worldObj);
    this.craftResult.setInventorySlotContents(0, craftResult);

    if (super.crafters.size() < 1)
    {
        return;
    }

    EntityPlayerMP player = (EntityPlayerMP) super.crafters.get(0); // TODO: Is this _always_ correct? Seems like it.
    player.playerNetServerHandler.sendPacket(new S2FPacketSetSlot(player.openContainer.windowId, 0, craftResult));
    // CraftBukkit end
}
 
开发者ID:xtrafrancyz,项目名称:Cauldron,代码行数:17,代码来源:ContainerPlayer.java

示例2: onCraftMatrixChanged

import net.minecraft.network.play.server.S2FPacketSetSlot; //导入依赖的package包/类
public void onCraftMatrixChanged(IInventory p_75130_1_)
{
    // CraftBukkit start
    CraftingManager.getInstance().lastCraftView = getBukkitView();
    ItemStack craftResult = CraftingManager.getInstance().findMatchingRecipe(this.craftMatrix, this.worldObj);
    this.craftResult.setInventorySlotContents(0, craftResult);

    if (super.crafters.size() < 1)
    {
        return;
    }

    EntityPlayerMP player = (EntityPlayerMP) super.crafters.get(0); // TODO: Is this _always_ correct? Seems like it.
    player.playerNetServerHandler.sendPacket(new S2FPacketSetSlot(player.openContainer.windowId, 0, craftResult));
    // CraftBukkit end
}
 
开发者ID:xtrafrancyz,项目名称:Cauldron,代码行数:17,代码来源:ContainerWorkbench.java

示例3: giveItemStackToPlayer

import net.minecraft.network.play.server.S2FPacketSetSlot; //导入依赖的package包/类
/**
 * Gives the player an ItemStack
 */
public static void giveItemStackToPlayer(EntityPlayer player, ItemStack itemStack) {
    int i = -1;
    for (int j = 0; j < player.inventory.mainInventory.length; j++) {
        if (player.inventory.mainInventory[j] == null) {
            i = j;
            break;
        }
    }
    if (i != -1) {
        player.inventory.mainInventory[i] = itemStack;
        // get the actual inventory Slot:
        Slot slot = player.openContainer.getSlotFromInventory(player.inventory, i);
        // send S2FPacketSetSlot to the player with the new / changed stack (or null)
        ((EntityPlayerMP) player).playerNetServerHandler.sendPacket(new S2FPacketSetSlot(player.openContainer.windowId, slot.slotNumber, player.inventory.mainInventory[i]));
    } else {
        WorldUtils.dropAsEntity(player.getEntityWorld(), (int) player.posX, (int) player.posY, (int) player.posZ, itemStack);
    }
}
 
开发者ID:MyEssentials,项目名称:MyEssentials-Core,代码行数:22,代码来源:PlayerUtils.java

示例4: sendSlotContents

import net.minecraft.network.play.server.S2FPacketSetSlot; //导入依赖的package包/类
/**
 * Sends the contents of an inventory slot to the client-side Container. This doesn't have to match the actual
 * contents of that slot. Args: Container, slot number, slot contents
 */
public void sendSlotContents(Container containerToSend, int slotInd, ItemStack stack)
{
    if (!(containerToSend.getSlot(slotInd) instanceof SlotCrafting))
    {
        if (!this.isChangingQuantityOnly)
        {
            this.playerNetServerHandler.sendPacket(new S2FPacketSetSlot(containerToSend.windowId, slotInd, stack));
        }
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:15,代码来源:EntityPlayerMP.java

示例5: updateHeldItem

import net.minecraft.network.play.server.S2FPacketSetSlot; //导入依赖的package包/类
/**
 * updates item held by mouse
 */
public void updateHeldItem()
{
    if (!this.isChangingQuantityOnly)
    {
        this.playerNetServerHandler.sendPacket(new S2FPacketSetSlot(-1, -1, this.inventory.getItemStack()));
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:11,代码来源:EntityPlayerMP.java

示例6: handleSetSlot

import net.minecraft.network.play.server.S2FPacketSetSlot; //导入依赖的package包/类
/**
 * Handles pickin up an ItemStack or dropping one in your inventory or an open (non-creative) container
 */
public void handleSetSlot(S2FPacketSetSlot packetIn)
{
    PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
    EntityPlayer entityplayer = this.gameController.thePlayer;

    if (packetIn.func_149175_c() == -1)
    {
        entityplayer.inventory.setItemStack(packetIn.func_149174_e());
    }
    else
    {
        boolean flag = false;

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

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

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

            entityplayer.inventoryContainer.putStackInSlot(packetIn.func_149173_d(), packetIn.func_149174_e());
        }
        else if (packetIn.func_149175_c() == entityplayer.openContainer.windowId && (packetIn.func_149175_c() != 0 || !flag))
        {
            entityplayer.openContainer.putStackInSlot(packetIn.func_149173_d(), packetIn.func_149174_e());
        }
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:40,代码来源:NetHandlerPlayClient.java

示例7: handleSetSlot

import net.minecraft.network.play.server.S2FPacketSetSlot; //导入依赖的package包/类
/**
 * Handles pickin up an ItemStack or dropping one in your inventory or an open
 * (non-creative) container
 */
public void handleSetSlot(S2FPacketSetSlot packetIn) {
	PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
	EntityPlayer entityplayer = this.gameController.thePlayer;

	if (packetIn.func_149175_c() == -1) {
		entityplayer.inventory.setItemStack(packetIn.func_149174_e());
	} else {
		boolean flag = false;

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

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

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

			entityplayer.inventoryContainer.putStackInSlot(packetIn.func_149173_d(), packetIn.func_149174_e());
		} else if (packetIn.func_149175_c() == entityplayer.openContainer.windowId
				&& (packetIn.func_149175_c() != 0 || !flag)) {
			entityplayer.openContainer.putStackInSlot(packetIn.func_149173_d(), packetIn.func_149174_e());
		}
	}
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:34,代码来源:NetHandlerPlayClient.java

示例8: resolveContents

import net.minecraft.network.play.server.S2FPacketSetSlot; //导入依赖的package包/类
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);
					Object object;

					try {
						IChatComponent ichatcomponent = IChatComponent.Serializer.jsonToComponent(s);
						object = ChatComponentProcessor.func_179985_a(player, ichatcomponent, player);
					} catch (Exception exception) {
						object = new ChatComponentText(s);
					}

					nbttaglist.set(i,
							new NBTTagString(IChatComponent.Serializer.componentToJson((IChatComponent) object)));
				}

				nbttagcompound.setTag("pages", nbttaglist);

				if (player instanceof EntityPlayerMP && player.getCurrentEquippedItem() == stack) {
					Slot slot = player.openContainer.getSlotFromInventory(player.inventory,
							player.inventory.currentItem);
					((EntityPlayerMP) player).playerNetServerHandler
							.sendPacket(new S2FPacketSetSlot(0, slot.slotNumber, stack));
				}
			}
		}
	}
}
 
开发者ID:firegodjr,项目名称:Alagaesias-Ancient-Language,代码行数:38,代码来源:Spellbook.java

示例9: placeAnything

import net.minecraft.network.play.server.S2FPacketSetSlot; //导入依赖的package包/类
public void placeAnything(PlayerInteractEvent event)
{
    // Server side and on block only.
    if (event.isCanceled() || event.world.isRemote || event.action != RIGHT_CLICK_BLOCK) return;
    ItemStack heldItem = event.entityPlayer.inventory.getCurrentItem();
    // Only tools, not null
    if (heldItem == null || !(heldItem.getItem() instanceof ItemTool)) return;
    if (event.world.getTileEntity(event.x, event.y, event.z) != null) return;
    // old slot
    int oldSlot = event.entityPlayer.inventory.currentItem;
    // Avoid invalid array indexes
    if (oldSlot < 0 || oldSlot > 8) return;
    // new slot
    int newSlot = slots[oldSlot];
    // Avoid invalid slots indexes
    if (newSlot < 0 || newSlot > 8) return;
    // Get new item
    ItemStack slotStack = event.entityPlayer.inventory.getStackInSlot(newSlot);
    // No null please
    if (slotStack == null) return;
    // Set current slot to new slot to fool Minecraft
    event.entityPlayer.inventory.currentItem = newSlot;
    // Place block
    boolean b = ((EntityPlayerMP) event.entityPlayer).theItemInWorldManager.activateBlockOrUseItem(event.entityPlayer, event.world, slotStack, event.x, event.y, event.z, event.face, 0.5f, 0.5f, 0.5f);
    // Remove empty stacks
    if (slotStack.stackSize <= 0) slotStack = null;
    // Set old slot back properly
    event.entityPlayer.inventory.currentItem = oldSlot;
    // Update client
    event.entityPlayer.inventory.setInventorySlotContents(newSlot, slotStack);
    ((EntityPlayerMP) event.entityPlayer).playerNetServerHandler.sendPacket(new S2FPacketSetSlot(0, newSlot + 36, slotStack));
    // Prevent derpy doors
    event.setCanceled(true);
}
 
开发者ID:gigabit101,项目名称:Torchieeeeness,代码行数:35,代码来源:TorchEventHandler.java

示例10: sendSlotContents

import net.minecraft.network.play.server.S2FPacketSetSlot; //导入依赖的package包/类
/**
 * Sends the contents of an inventory slot to the client-side Container. This doesn't have to match the actual
 * contents of that slot. Args: Container, slot number, slot contents
 */
public void sendSlotContents(Container par1Container, int par2, ItemStack par3ItemStack)
{
    if (!(par1Container.getSlot(par2) instanceof SlotCrafting))
    {
        if (!this.isChangingQuantityOnly)
        {
            this.playerNetServerHandler.sendPacket(new S2FPacketSetSlot(par1Container.windowId, par2, par3ItemStack));
        }
    }
}
 
开发者ID:MinecraftModdedClients,项目名称:Resilience-Client-Source,代码行数:15,代码来源:EntityPlayerMP.java

示例11: handleSetSlot

import net.minecraft.network.play.server.S2FPacketSetSlot; //导入依赖的package包/类
/**
 * Handles pickin up an ItemStack or dropping one in your inventory or an open (non-creative) container
 */
public void handleSetSlot(S2FPacketSetSlot p_147266_1_)
{
    EntityClientPlayerMP var2 = this.gameController.thePlayer;

    if (p_147266_1_.func_149175_c() == -1)
    {
        var2.inventory.setItemStack(p_147266_1_.func_149174_e());
    }
    else
    {
        boolean var3 = false;

        if (this.gameController.currentScreen instanceof GuiContainerCreative)
        {
            GuiContainerCreative var4 = (GuiContainerCreative)this.gameController.currentScreen;
            var3 = var4.func_147056_g() != CreativeTabs.tabInventory.getTabIndex();
        }

        if (p_147266_1_.func_149175_c() == 0 && p_147266_1_.func_149173_d() >= 36 && p_147266_1_.func_149173_d() < 45)
        {
            ItemStack var5 = var2.inventoryContainer.getSlot(p_147266_1_.func_149173_d()).getStack();

            if (p_147266_1_.func_149174_e() != null && (var5 == null || var5.stackSize < p_147266_1_.func_149174_e().stackSize))
            {
                p_147266_1_.func_149174_e().animationsToGo = 5;
            }

            var2.inventoryContainer.putStackInSlot(p_147266_1_.func_149173_d(), p_147266_1_.func_149174_e());
        }
        else if (p_147266_1_.func_149175_c() == var2.openContainer.windowId && (p_147266_1_.func_149175_c() != 0 || !var3))
        {
            var2.openContainer.putStackInSlot(p_147266_1_.func_149173_d(), p_147266_1_.func_149174_e());
        }
    }
}
 
开发者ID:MinecraftModdedClients,项目名称:Resilience-Client-Source,代码行数:39,代码来源:NetHandlerPlayClient.java

示例12: onPlayerDestroyItem

import net.minecraft.network.play.server.S2FPacketSetSlot; //导入依赖的package包/类
@SubscribeEvent
public void onPlayerDestroyItem(PlayerDestroyItemEvent event) {
	
	if (!(event.entity instanceof EntityPlayerMP) ||
	    event.entity.worldObj.isRemote) return;
	
	EntityPlayerMP player = (EntityPlayerMP)event.entityPlayer;
	InventoryPlayer inv = player.inventory;
	
	ItemStack currentItem = inv.getCurrentItem();
	if ((currentItem != null) &&
	    (currentItem != event.original)) return;
	
	int row;
	for (row = 2; row >= 0; row--) {
		int slot = inv.currentItem + row * 9 + 9;
		ItemStack stackAbove = inv.getStackInSlot(slot);
		if (!canReplace(stackAbove, event.original)) break;
		int targetSlot = ((slot < 27) ? (slot + 9) : (slot - 27));
		inv.setInventorySlotContents(targetSlot, stackAbove);
		inv.setInventorySlotContents(slot, null);
		player.playerNetServerHandler.sendPacket(
				new S2FPacketSetSlot(0, slot + 9, stackAbove));
	}
	
	if (row < 2)
		player.playerNetServerHandler.sendPacket(
				new S2FPacketSetSlot(0, inv.currentItem + row * 9 + 18, null));
	
}
 
开发者ID:copygirl,项目名称:copycore,代码行数:31,代码来源:TweakAutoReplace.java

示例13: sendSlotContents

import net.minecraft.network.play.server.S2FPacketSetSlot; //导入依赖的package包/类
public void sendSlotContents(Container p_71111_1_, int p_71111_2_, ItemStack p_71111_3_)
{
    if (!(p_71111_1_.getSlot(p_71111_2_) instanceof SlotCrafting))
    {
        if (!this.isChangingQuantityOnly)
        {
            this.playerNetServerHandler.sendPacket(new S2FPacketSetSlot(p_71111_1_.windowId, p_71111_2_, p_71111_3_));
        }
    }
}
 
开发者ID:xtrafrancyz,项目名称:Cauldron,代码行数:11,代码来源:EntityPlayerMP.java

示例14: sendContainerAndContentsToPlayer

import net.minecraft.network.play.server.S2FPacketSetSlot; //导入依赖的package包/类
public void sendContainerAndContentsToPlayer(Container p_71110_1_, List p_71110_2_)
{
    this.playerNetServerHandler.sendPacket(new S30PacketWindowItems(p_71110_1_.windowId, p_71110_2_));
    this.playerNetServerHandler.sendPacket(new S2FPacketSetSlot(-1, -1, this.inventory.getItemStack()));

    if (p_71110_1_.getBukkitView() == null) return; // Cauldron - allow vanilla mods to bypass
    // CraftBukkit start - Send a Set Slot to update the crafting result slot
    if (java.util.EnumSet.of(InventoryType.CRAFTING, InventoryType.WORKBENCH).contains(p_71110_1_.getBukkitView().getType()))
    {
        this.playerNetServerHandler.sendPacket(new S2FPacketSetSlot(p_71110_1_.windowId, 0, p_71110_1_.getSlot(0).getStack()));
    }

    // CraftBukkit end
}
 
开发者ID:xtrafrancyz,项目名称:Cauldron,代码行数:15,代码来源:EntityPlayerMP.java

示例15: updateHeldItem

import net.minecraft.network.play.server.S2FPacketSetSlot; //导入依赖的package包/类
public void updateHeldItem()
{
    if (!this.isChangingQuantityOnly)
    {
        this.playerNetServerHandler.sendPacket(new S2FPacketSetSlot(-1, -1, this.inventory.getItemStack()));
    }
}
 
开发者ID:xtrafrancyz,项目名称:Cauldron,代码行数:8,代码来源:EntityPlayerMP.java


注:本文中的net.minecraft.network.play.server.S2FPacketSetSlot类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。