本文整理汇总了Java中net.minecraft.network.play.server.SPacketOpenWindow类的典型用法代码示例。如果您正苦于以下问题:Java SPacketOpenWindow类的具体用法?Java SPacketOpenWindow怎么用?Java SPacketOpenWindow使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SPacketOpenWindow类属于net.minecraft.network.play.server包,在下文中一共展示了SPacketOpenWindow类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: displayVillagerTradeGui
import net.minecraft.network.play.server.SPacketOpenWindow; //导入依赖的package包/类
public void displayVillagerTradeGui(IMerchant villager)
{
this.getNextWindowId();
this.openContainer = new ContainerMerchant(this.inventory, villager, this.world);
this.openContainer.windowId = this.currentWindowId;
this.openContainer.addListener(this);
IInventory iinventory = ((ContainerMerchant)this.openContainer).getMerchantInventory();
ITextComponent itextcomponent = villager.getDisplayName();
this.connection.sendPacket(new SPacketOpenWindow(this.currentWindowId, "minecraft:villager", itextcomponent, iinventory.getSizeInventory()));
MerchantRecipeList merchantrecipelist = villager.getRecipes(this);
if (merchantrecipelist != null)
{
PacketBuffer packetbuffer = new PacketBuffer(Unpooled.buffer());
packetbuffer.writeInt(this.currentWindowId);
merchantrecipelist.writeToBuf(packetbuffer);
this.connection.sendPacket(new SPacketCustomPayload("MC|TrList", packetbuffer));
}
}
开发者ID:NSExceptional,项目名称:Zombe-Modpack,代码行数:20,代码来源:EntityPlayerMP.java
示例2: displayGui
import net.minecraft.network.play.server.SPacketOpenWindow; //导入依赖的package包/类
public void displayGui(IInteractionObject guiOwner)
{
if (guiOwner instanceof ILootContainer && ((ILootContainer)guiOwner).getLootTable() != null && this.isSpectator())
{
this.addChatMessage((new TextComponentTranslation("container.spectatorCantOpen", new Object[0])).setStyle((new Style()).setColor(TextFormatting.RED)));
}
else
{
this.getNextWindowId();
this.connection.sendPacket(new SPacketOpenWindow(this.currentWindowId, guiOwner.getGuiID(), guiOwner.getDisplayName()));
this.openContainer = guiOwner.createContainer(this.inventory, this);
this.openContainer.windowId = this.currentWindowId;
this.openContainer.addListener(this);
net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.player.PlayerContainerEvent.Open(this, this.openContainer));
}
}
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:17,代码来源:EntityPlayerMP.java
示例3: displayVillagerTradeGui
import net.minecraft.network.play.server.SPacketOpenWindow; //导入依赖的package包/类
public void displayVillagerTradeGui(IMerchant villager)
{
this.getNextWindowId();
this.openContainer = new ContainerMerchant(this.inventory, villager, this.worldObj);
this.openContainer.windowId = this.currentWindowId;
this.openContainer.addListener(this);
net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.player.PlayerContainerEvent.Open(this, this.openContainer));
IInventory iinventory = ((ContainerMerchant)this.openContainer).getMerchantInventory();
ITextComponent itextcomponent = villager.getDisplayName();
this.connection.sendPacket(new SPacketOpenWindow(this.currentWindowId, "minecraft:villager", itextcomponent, iinventory.getSizeInventory()));
MerchantRecipeList merchantrecipelist = villager.getRecipes(this);
if (merchantrecipelist != null)
{
PacketBuffer packetbuffer = new PacketBuffer(Unpooled.buffer());
packetbuffer.writeInt(this.currentWindowId);
merchantrecipelist.writeToBuf(packetbuffer);
this.connection.sendPacket(new SPacketCustomPayload("MC|TrList", packetbuffer));
}
}
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:21,代码来源:EntityPlayerMP.java
示例4: Open
import net.minecraft.network.play.server.SPacketOpenWindow; //导入依赖的package包/类
public CommandResult Open(CommandSource src, Container opencon, String inventoryTypeIn, String title) {
final Player player = Tools.getPlayer(src, vt);
final EntityPlayerMP MPlayer = (EntityPlayerMP) player;
MPlayer.getNextWindowId();
MPlayer.connection.sendPacket(new SPacketOpenWindow(MPlayer.currentWindowId, inventoryTypeIn, new TextComponentString(title)));
MPlayer.openContainer = opencon;
MPlayer.openContainer.windowId = MPlayer.currentWindowId;
MPlayer.openContainer.addListener(MPlayer);
return CommandResult.success();
}
开发者ID:poqdavid,项目名称:VirtualTool,代码行数:12,代码来源:Invs.java
示例5: displayGui
import net.minecraft.network.play.server.SPacketOpenWindow; //导入依赖的package包/类
public void displayGui(IInteractionObject guiOwner)
{
if (guiOwner instanceof ILootContainer && ((ILootContainer)guiOwner).getLootTable() != null && this.isSpectator())
{
this.addChatComponentMessage((new TextComponentTranslation("container.spectatorCantOpen", new Object[0])).setStyle((new Style()).setColor(TextFormatting.RED)), true);
}
else
{
this.getNextWindowId();
this.connection.sendPacket(new SPacketOpenWindow(this.currentWindowId, guiOwner.getGuiID(), guiOwner.getDisplayName()));
this.openContainer = guiOwner.createContainer(this.inventory, this);
this.openContainer.windowId = this.currentWindowId;
this.openContainer.addListener(this);
}
}
开发者ID:NSExceptional,项目名称:Zombe-Modpack,代码行数:16,代码来源:EntityPlayerMP.java
示例6: openGuiHorseInventory
import net.minecraft.network.play.server.SPacketOpenWindow; //导入依赖的package包/类
public void openGuiHorseInventory(AbstractHorse horse, IInventory inventoryIn)
{
if (this.openContainer != this.inventoryContainer)
{
this.closeScreen();
}
this.getNextWindowId();
this.connection.sendPacket(new SPacketOpenWindow(this.currentWindowId, "EntityHorse", inventoryIn.getDisplayName(), inventoryIn.getSizeInventory(), horse.getEntityId()));
this.openContainer = new ContainerHorseInventory(this.inventory, inventoryIn, horse, this);
this.openContainer.windowId = this.currentWindowId;
this.openContainer.addListener(this);
}
开发者ID:NSExceptional,项目名称:Zombe-Modpack,代码行数:14,代码来源:EntityPlayerMP.java
示例7: handleOpenWindow
import net.minecraft.network.play.server.SPacketOpenWindow; //导入依赖的package包/类
/**
* Displays a GUI by ID. In order starting from id 0: Chest, Workbench, Furnace, Dispenser, Enchanting table,
* Brewing stand, Villager merchant, Beacon, Anvil, Hopper, Dropper, Horse
*/
public void handleOpenWindow(SPacketOpenWindow packetIn)
{
PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
EntityPlayerSP entityplayersp = this.gameController.player;
if ("minecraft:container".equals(packetIn.getGuiId()))
{
entityplayersp.displayGUIChest(new InventoryBasic(packetIn.getWindowTitle(), packetIn.getSlotCount()));
entityplayersp.openContainer.windowId = packetIn.getWindowId();
}
else if ("minecraft:villager".equals(packetIn.getGuiId()))
{
entityplayersp.displayVillagerTradeGui(new NpcMerchant(entityplayersp, packetIn.getWindowTitle()));
entityplayersp.openContainer.windowId = packetIn.getWindowId();
}
else if ("EntityHorse".equals(packetIn.getGuiId()))
{
Entity entity = this.clientWorldController.getEntityByID(packetIn.getEntityId());
if (entity instanceof AbstractHorse)
{
entityplayersp.openGuiHorseInventory((AbstractHorse)entity, new ContainerHorseChest(packetIn.getWindowTitle(), packetIn.getSlotCount()));
entityplayersp.openContainer.windowId = packetIn.getWindowId();
}
}
else if (!packetIn.hasSlots())
{
entityplayersp.displayGui(new LocalBlockIntercommunication(packetIn.getGuiId(), packetIn.getWindowTitle()));
entityplayersp.openContainer.windowId = packetIn.getWindowId();
}
else
{
IInventory iinventory = new ContainerLocalMenu(packetIn.getGuiId(), packetIn.getWindowTitle(), packetIn.getSlotCount());
entityplayersp.displayGUIChest(iinventory);
entityplayersp.openContainer.windowId = packetIn.getWindowId();
}
}
开发者ID:NSExceptional,项目名称:Zombe-Modpack,代码行数:42,代码来源:NetHandlerPlayClient.java
示例8: openGuiHorseInventory
import net.minecraft.network.play.server.SPacketOpenWindow; //导入依赖的package包/类
public void openGuiHorseInventory(EntityHorse horse, IInventory inventoryIn)
{
if (this.openContainer != this.inventoryContainer)
{
this.closeScreen();
}
this.getNextWindowId();
this.connection.sendPacket(new SPacketOpenWindow(this.currentWindowId, "EntityHorse", inventoryIn.getDisplayName(), inventoryIn.getSizeInventory(), horse.getEntityId()));
this.openContainer = new ContainerHorseInventory(this.inventory, inventoryIn, horse, this);
this.openContainer.windowId = this.currentWindowId;
this.openContainer.addListener(this);
}
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:14,代码来源:EntityPlayerMP.java
示例9: handleOpenWindow
import net.minecraft.network.play.server.SPacketOpenWindow; //导入依赖的package包/类
/**
* Displays a GUI by ID. In order starting from id 0: Chest, Workbench, Furnace, Dispenser, Enchanting table,
* Brewing stand, Villager merchant, Beacon, Anvil, Hopper, Dropper, Horse
*/
public void handleOpenWindow(SPacketOpenWindow packetIn)
{
PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
EntityPlayerSP entityplayersp = this.gameController.thePlayer;
if ("minecraft:container".equals(packetIn.getGuiId()))
{
entityplayersp.displayGUIChest(new InventoryBasic(packetIn.getWindowTitle(), packetIn.getSlotCount()));
entityplayersp.openContainer.windowId = packetIn.getWindowId();
}
else if ("minecraft:villager".equals(packetIn.getGuiId()))
{
entityplayersp.displayVillagerTradeGui(new NpcMerchant(entityplayersp, packetIn.getWindowTitle()));
entityplayersp.openContainer.windowId = packetIn.getWindowId();
}
else if ("EntityHorse".equals(packetIn.getGuiId()))
{
Entity entity = this.clientWorldController.getEntityByID(packetIn.getEntityId());
if (entity instanceof EntityHorse)
{
entityplayersp.openGuiHorseInventory((EntityHorse)entity, new AnimalChest(packetIn.getWindowTitle(), packetIn.getSlotCount()));
entityplayersp.openContainer.windowId = packetIn.getWindowId();
}
}
else if (!packetIn.hasSlots())
{
entityplayersp.displayGui(new LocalBlockIntercommunication(packetIn.getGuiId(), packetIn.getWindowTitle()));
entityplayersp.openContainer.windowId = packetIn.getWindowId();
}
else
{
IInventory iinventory = new ContainerLocalMenu(packetIn.getGuiId(), packetIn.getWindowTitle(), packetIn.getSlotCount());
entityplayersp.displayGUIChest(iinventory);
entityplayersp.openContainer.windowId = packetIn.getWindowId();
}
}
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:42,代码来源:NetHandlerPlayClient.java
示例10: execute
import net.minecraft.network.play.server.SPacketOpenWindow; //导入依赖的package包/类
public CommandResult execute(CommandSource src, CommandContext ctx) throws CommandException
{
Player target = ctx.<Player> getOne("target").get();
if (src instanceof Player)
{
Player player = (Player) src;
EntityPlayerMP playerMP = ((EntityPlayerMP) (Object) player);
EntityPlayerMP targetMP = ((EntityPlayerMP) (Object) target);
InventoryPlayer inventory = targetMP.inventory;
ContainerChest container = new ContainerChest(playerMP.inventory, inventory, playerMP);
if (playerMP.openContainer != playerMP.inventoryContainer)
{
playerMP.closeScreen();
}
playerMP.getNextWindowId();
playerMP.connection.sendPacket(new SPacketOpenWindow(playerMP.currentWindowId, "minecraft:container", inventory.getDisplayName(), inventory.getSizeInventory()));
playerMP.openContainer = container;
playerMP.openContainer.windowId = playerMP.currentWindowId;
playerMP.openContainer.addListener(playerMP);
}
else
{
src.sendMessage(Text.of(TextColors.DARK_RED, "Error! ", TextColors.RED, "You must be a player to see other inventories."));
}
return CommandResult.success();
}
开发者ID:hsyyid,项目名称:EssentialCmds,代码行数:34,代码来源:InvSeeExecutor.java
示例11: displayGUIChest
import net.minecraft.network.play.server.SPacketOpenWindow; //导入依赖的package包/类
/**
* Displays the GUI for interacting with a chest inventory.
*/
public void displayGUIChest(IInventory chestInventory)
{
if (chestInventory instanceof ILootContainer && ((ILootContainer)chestInventory).getLootTable() != null && this.isSpectator())
{
this.addChatComponentMessage((new TextComponentTranslation("container.spectatorCantOpen", new Object[0])).setStyle((new Style()).setColor(TextFormatting.RED)), true);
}
else
{
if (this.openContainer != this.inventoryContainer)
{
this.closeScreen();
}
if (chestInventory instanceof ILockableContainer)
{
ILockableContainer ilockablecontainer = (ILockableContainer)chestInventory;
if (ilockablecontainer.isLocked() && !this.canOpen(ilockablecontainer.getLockCode()) && !this.isSpectator())
{
this.connection.sendPacket(new SPacketChat(new TextComponentTranslation("container.isLocked", new Object[] {chestInventory.getDisplayName()}), (byte)2));
this.connection.sendPacket(new SPacketSoundEffect(SoundEvents.BLOCK_CHEST_LOCKED, SoundCategory.BLOCKS, this.posX, this.posY, this.posZ, 1.0F, 1.0F));
return;
}
}
this.getNextWindowId();
if (chestInventory instanceof IInteractionObject)
{
this.connection.sendPacket(new SPacketOpenWindow(this.currentWindowId, ((IInteractionObject)chestInventory).getGuiID(), chestInventory.getDisplayName(), chestInventory.getSizeInventory()));
this.openContainer = ((IInteractionObject)chestInventory).createContainer(this.inventory, this);
}
else
{
this.connection.sendPacket(new SPacketOpenWindow(this.currentWindowId, "minecraft:container", chestInventory.getDisplayName(), chestInventory.getSizeInventory()));
this.openContainer = new ContainerChest(this.inventory, chestInventory, this);
}
this.openContainer.windowId = this.currentWindowId;
this.openContainer.addListener(this);
}
}
开发者ID:NSExceptional,项目名称:Zombe-Modpack,代码行数:46,代码来源:EntityPlayerMP.java
示例12: displayGUIChest
import net.minecraft.network.play.server.SPacketOpenWindow; //导入依赖的package包/类
/**
* Displays the GUI for interacting with a chest inventory.
*/
public void displayGUIChest(IInventory chestInventory)
{
if (chestInventory instanceof ILootContainer && ((ILootContainer)chestInventory).getLootTable() != null && this.isSpectator())
{
this.addChatMessage((new TextComponentTranslation("container.spectatorCantOpen", new Object[0])).setStyle((new Style()).setColor(TextFormatting.RED)));
}
else
{
if (this.openContainer != this.inventoryContainer)
{
this.closeScreen();
}
if (chestInventory instanceof ILockableContainer)
{
ILockableContainer ilockablecontainer = (ILockableContainer)chestInventory;
if (ilockablecontainer.isLocked() && !this.canOpen(ilockablecontainer.getLockCode()) && !this.isSpectator())
{
this.connection.sendPacket(new SPacketChat(new TextComponentTranslation("container.isLocked", new Object[] {chestInventory.getDisplayName()}), (byte)2));
this.connection.sendPacket(new SPacketSoundEffect(SoundEvents.BLOCK_CHEST_LOCKED, SoundCategory.BLOCKS, this.posX, this.posY, this.posZ, 1.0F, 1.0F));
return;
}
}
this.getNextWindowId();
if (chestInventory instanceof IInteractionObject)
{
this.connection.sendPacket(new SPacketOpenWindow(this.currentWindowId, ((IInteractionObject)chestInventory).getGuiID(), chestInventory.getDisplayName(), chestInventory.getSizeInventory()));
this.openContainer = ((IInteractionObject)chestInventory).createContainer(this.inventory, this);
}
else
{
this.connection.sendPacket(new SPacketOpenWindow(this.currentWindowId, "minecraft:container", chestInventory.getDisplayName(), chestInventory.getSizeInventory()));
this.openContainer = new ContainerChest(this.inventory, chestInventory, this);
}
this.openContainer.windowId = this.currentWindowId;
this.openContainer.addListener(this);
net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.player.PlayerContainerEvent.Open(this, this.openContainer));
}
}
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:47,代码来源:EntityPlayerMP.java
示例13: handleOpenWindow
import net.minecraft.network.play.server.SPacketOpenWindow; //导入依赖的package包/类
/**
* Displays a GUI by ID. In order starting from id 0: Chest, Workbench, Furnace, Dispenser, Enchanting table,
* Brewing stand, Villager merchant, Beacon, Anvil, Hopper, Dropper, Horse
*/
void handleOpenWindow(SPacketOpenWindow packetIn);
开发者ID:sudofox,项目名称:Backmemed,代码行数:6,代码来源:INetHandlerPlayClient.java
注:本文中的net.minecraft.network.play.server.SPacketOpenWindow类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论