• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java SPacketChat类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: handleChat

import net.minecraft.network.play.server.SPacketChat; //导入依赖的package包/类
/**
 * Prints a chatmessage in the chat GUI
 */
public void handleChat(SPacketChat packetIn)
{
    PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
    net.minecraft.util.text.ITextComponent message = net.minecraftforge.event.ForgeEventFactory.onClientChat(packetIn.getType(), packetIn.getChatComponent());
    if (message == null) return;

    if (packetIn.getType() == 2)
    {
        this.gameController.ingameGUI.setRecordPlaying(message, false);
    }
    else
    {
        this.gameController.ingameGUI.getChatGUI().printChatMessage(message);
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:19,代码来源:NetHandlerPlayClient.java


示例2: sendChatMessage

import net.minecraft.network.play.server.SPacketChat; //导入依赖的package包/类
/**
 * Sends a chat message to this channel and, if a child wants to
 * receive messages from its parent, also to all child channels.
 * 
 * @param message the message
 * @param msgType the message type
 */
public void sendChatMessage(ITextComponent message, ChatType msgType) {
	checkState();
	ITextComponent msgToSend = message;
	
	if (MoreCommandsConfig.prefixChannelName)
		msgToSend = new TextComponentString("[" + this.getName() + "] ").appendSibling(message);
	
	SPacketChat packet = new SPacketChat(msgToSend, msgType);
	
	for (EntityPlayerMP player : this.members)
		player.connection.sendPacket(packet);
	
	for (ChatChannel child : this.children)
		if (child.receiveParentMessages)
			child.sendChatMessage(message, msgType);
}
 
开发者ID:MrNobody98,项目名称:morecommands,代码行数:24,代码来源:ChatChannel.java


示例3: processRightClickBlock

import net.minecraft.network.play.server.SPacketChat; //导入依赖的package包/类
public void processRightClickBlock(CPacketPlayerTryUseItemOnBlock packetIn)
{
    PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.playerEntity.getServerWorld());
    WorldServer worldserver = this.serverController.worldServerForDimension(this.playerEntity.dimension);
    EnumHand enumhand = packetIn.getHand();
    ItemStack itemstack = this.playerEntity.getHeldItem(enumhand);
    BlockPos blockpos = packetIn.getPos();
    EnumFacing enumfacing = packetIn.getDirection();
    this.playerEntity.markPlayerActive();

    if (blockpos.getY() < this.serverController.getBuildLimit() - 1 || enumfacing != EnumFacing.UP && blockpos.getY() < this.serverController.getBuildLimit())
    {
        if (this.targetPos == null && this.playerEntity.getDistanceSq((double)blockpos.getX() + 0.5D, (double)blockpos.getY() + 0.5D, (double)blockpos.getZ() + 0.5D) < 64.0D && !this.serverController.isBlockProtected(worldserver, blockpos, this.playerEntity) && worldserver.getWorldBorder().contains(blockpos))
        {
            this.playerEntity.interactionManager.processRightClickBlock(this.playerEntity, worldserver, itemstack, enumhand, blockpos, enumfacing, packetIn.getFacingX(), packetIn.getFacingY(), packetIn.getFacingZ());
        }
    }
    else
    {
        TextComponentTranslation textcomponenttranslation = new TextComponentTranslation("build.tooHigh", new Object[] {Integer.valueOf(this.serverController.getBuildLimit())});
        textcomponenttranslation.getStyle().setColor(TextFormatting.RED);
        this.playerEntity.connection.sendPacket(new SPacketChat(textcomponenttranslation, (byte)2));
    }

    this.playerEntity.connection.sendPacket(new SPacketBlockChange(worldserver, blockpos));
    this.playerEntity.connection.sendPacket(new SPacketBlockChange(worldserver, blockpos.offset(enumfacing)));
}
 
开发者ID:NSExceptional,项目名称:Zombe-Modpack,代码行数:28,代码来源:NetHandlerPlayServer.java


示例4: sendPacket

import net.minecraft.network.play.server.SPacketChat; //导入依赖的package包/类
public void sendPacket(final Packet<?> packetIn)
{
    if (packetIn instanceof SPacketChat)
    {
        SPacketChat spacketchat = (SPacketChat)packetIn;
        EntityPlayer.EnumChatVisibility entityplayer$enumchatvisibility = this.playerEntity.getChatVisibility();

        if (entityplayer$enumchatvisibility == EntityPlayer.EnumChatVisibility.HIDDEN && spacketchat.getType() != 2)
        {
            return;
        }

        if (entityplayer$enumchatvisibility == EntityPlayer.EnumChatVisibility.SYSTEM && !spacketchat.isSystem())
        {
            return;
        }
    }

    try
    {
        this.netManager.sendPacket(packetIn);
    }
    catch (Throwable throwable)
    {
        CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Sending packet");
        CrashReportCategory crashreportcategory = crashreport.makeCategory("Packet being sent");
        crashreportcategory.setDetail("Packet class", new ICrashReportDetail<String>()
        {
            public String call() throws Exception
            {
                return packetIn.getClass().getCanonicalName();
            }
        });
        throw new ReportedException(crashreport);
    }
}
 
开发者ID:NSExceptional,项目名称:Zombe-Modpack,代码行数:37,代码来源:NetHandlerPlayServer.java


示例5: handleChat

import net.minecraft.network.play.server.SPacketChat; //导入依赖的package包/类
/**
 * Prints a chatmessage in the chat GUI
 */
public void handleChat(SPacketChat packetIn)
{
    PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);

    if (packetIn.getType() == 2)
    {
        this.gameController.ingameGUI.setRecordPlaying(packetIn.getChatComponent(), false);
    }
    else
    {
        this.gameController.ingameGUI.getChatGUI().printChatMessage(packetIn.getChatComponent());
    }
}
 
开发者ID:NSExceptional,项目名称:Zombe-Modpack,代码行数:17,代码来源:NetHandlerPlayClient.java


示例6: processRightClickBlock

import net.minecraft.network.play.server.SPacketChat; //导入依赖的package包/类
public void processRightClickBlock(CPacketPlayerTryUseItemOnBlock packetIn)
{
    PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.playerEntity.getServerWorld());
    WorldServer worldserver = this.serverController.worldServerForDimension(this.playerEntity.dimension);
    EnumHand enumhand = packetIn.getHand();
    ItemStack itemstack = this.playerEntity.getHeldItem(enumhand);
    BlockPos blockpos = packetIn.getPos();
    EnumFacing enumfacing = packetIn.getDirection();
    this.playerEntity.markPlayerActive();

    if (blockpos.getY() < this.serverController.getBuildLimit() - 1 || enumfacing != EnumFacing.UP && blockpos.getY() < this.serverController.getBuildLimit())
    {
        double dist = playerEntity.interactionManager.getBlockReachDistance() + 3;
        dist *= dist;
        if (this.targetPos == null && this.playerEntity.getDistanceSq((double)blockpos.getX() + 0.5D, (double)blockpos.getY() + 0.5D, (double)blockpos.getZ() + 0.5D) < dist && !this.serverController.isBlockProtected(worldserver, blockpos, this.playerEntity) && worldserver.getWorldBorder().contains(blockpos))
        {
            this.playerEntity.interactionManager.processRightClickBlock(this.playerEntity, worldserver, itemstack, enumhand, blockpos, enumfacing, packetIn.getFacingX(), packetIn.getFacingY(), packetIn.getFacingZ());
        }
    }
    else
    {
        TextComponentTranslation textcomponenttranslation = new TextComponentTranslation("build.tooHigh", new Object[] {Integer.valueOf(this.serverController.getBuildLimit())});
        textcomponenttranslation.getStyle().setColor(TextFormatting.RED);
        this.playerEntity.connection.sendPacket(new SPacketChat(textcomponenttranslation));
    }

    this.playerEntity.connection.sendPacket(new SPacketBlockChange(worldserver, blockpos));
    this.playerEntity.connection.sendPacket(new SPacketBlockChange(worldserver, blockpos.offset(enumfacing)));
    itemstack = this.playerEntity.getHeldItem(enumhand);

    if (itemstack != null && itemstack.stackSize == 0)
    {
        this.playerEntity.setHeldItem(enumhand, (ItemStack)null);
        net.minecraftforge.event.ForgeEventFactory.onPlayerDestroyItem(this.playerEntity, itemstack, enumhand);
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:37,代码来源:NetHandlerPlayServer.java


示例7: sendPacket

import net.minecraft.network.play.server.SPacketChat; //导入依赖的package包/类
public void sendPacket(final Packet<?> packetIn)
{
    if (packetIn instanceof SPacketChat)
    {
        SPacketChat spacketchat = (SPacketChat)packetIn;
        EntityPlayer.EnumChatVisibility entityplayer$enumchatvisibility = this.playerEntity.getChatVisibility();

        if (entityplayer$enumchatvisibility == EntityPlayer.EnumChatVisibility.HIDDEN)
        {
            return;
        }

        if (entityplayer$enumchatvisibility == EntityPlayer.EnumChatVisibility.SYSTEM && !spacketchat.isSystem())
        {
            return;
        }
    }

    try
    {
        this.netManager.sendPacket(packetIn);
    }
    catch (Throwable throwable)
    {
        CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Sending packet");
        CrashReportCategory crashreportcategory = crashreport.makeCategory("Packet being sent");
        crashreportcategory.setDetail("Packet class", new ICrashReportDetail<String>()
        {
            public String call() throws Exception
            {
                return packetIn.getClass().getCanonicalName();
            }
        });
        throw new ReportedException(crashreport);
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:37,代码来源:NetHandlerPlayServer.java


示例8: displayGUIChest

import net.minecraft.network.play.server.SPacketChat; //导入依赖的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


示例9: addChatComponentMessage

import net.minecraft.network.play.server.SPacketChat; //导入依赖的package包/类
public void addChatComponentMessage(ITextComponent chatComponent, boolean p_146105_2_)
{
    this.connection.sendPacket(new SPacketChat(chatComponent, (byte)(p_146105_2_ ? 2 : 0)));
}
 
开发者ID:NSExceptional,项目名称:Zombe-Modpack,代码行数:5,代码来源:EntityPlayerMP.java


示例10: addChatMessage

import net.minecraft.network.play.server.SPacketChat; //导入依赖的package包/类
/**
 * Send a chat message to the CommandSender
 */
public void addChatMessage(ITextComponent component)
{
    this.connection.sendPacket(new SPacketChat(component));
}
 
开发者ID:NSExceptional,项目名称:Zombe-Modpack,代码行数:8,代码来源:EntityPlayerMP.java


示例11: processChatMessage

import net.minecraft.network.play.server.SPacketChat; //导入依赖的package包/类
/**
 * Process chat messages (broadcast back to clients) and commands (executes)
 */
public void processChatMessage(CPacketChatMessage packetIn)
{
    PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.playerEntity.getServerWorld());

    if (this.playerEntity.getChatVisibility() == EntityPlayer.EnumChatVisibility.HIDDEN)
    {
        TextComponentTranslation textcomponenttranslation = new TextComponentTranslation("chat.cannotSend", new Object[0]);
        textcomponenttranslation.getStyle().setColor(TextFormatting.RED);
        this.sendPacket(new SPacketChat(textcomponenttranslation));
    }
    else
    {
        this.playerEntity.markPlayerActive();
        String s = packetIn.getMessage();
        s = StringUtils.normalizeSpace(s);

        for (int i = 0; i < s.length(); ++i)
        {
            if (!ChatAllowedCharacters.isAllowedCharacter(s.charAt(i)))
            {
                this.kickPlayerFromServer("Illegal characters in chat");
                return;
            }
        }

        if (s.startsWith("/"))
        {
            this.handleSlashCommand(s);
        }
        else
        {
            ITextComponent itextcomponent = new TextComponentTranslation("chat.type.text", new Object[] {this.playerEntity.getDisplayName(), s});
            this.serverController.getPlayerList().sendChatMsgImpl(itextcomponent, false);
        }

        this.chatSpamThresholdCount += 20;

        if (this.chatSpamThresholdCount > 200 && !this.serverController.getPlayerList().canSendCommands(this.playerEntity.getGameProfile()))
        {
            this.kickPlayerFromServer("disconnect.spam");
        }
    }
}
 
开发者ID:NSExceptional,项目名称:Zombe-Modpack,代码行数:47,代码来源:NetHandlerPlayServer.java


示例12: sendChatMsgImpl

import net.minecraft.network.play.server.SPacketChat; //导入依赖的package包/类
public void sendChatMsgImpl(ITextComponent component, boolean isSystem)
{
    this.mcServer.addChatMessage(component);
    byte b0 = (byte)(isSystem ? 1 : 0);
    this.sendPacketToAllPlayers(new SPacketChat(component, b0));
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:7,代码来源:PlayerList.java


示例13: displayGUIChest

import net.minecraft.network.play.server.SPacketChat; //导入依赖的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


示例14: addChatComponentMessage

import net.minecraft.network.play.server.SPacketChat; //导入依赖的package包/类
public void addChatComponentMessage(ITextComponent chatComponent)
{
    this.connection.sendPacket(new SPacketChat(chatComponent));
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:5,代码来源:EntityPlayerMP.java


示例15: processChatMessage

import net.minecraft.network.play.server.SPacketChat; //导入依赖的package包/类
/**
 * Process chat messages (broadcast back to clients) and commands (executes)
 */
public void processChatMessage(CPacketChatMessage packetIn)
{
    PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.playerEntity.getServerWorld());

    if (this.playerEntity.getChatVisibility() == EntityPlayer.EnumChatVisibility.HIDDEN)
    {
        TextComponentTranslation textcomponenttranslation = new TextComponentTranslation("chat.cannotSend", new Object[0]);
        textcomponenttranslation.getStyle().setColor(TextFormatting.RED);
        this.sendPacket(new SPacketChat(textcomponenttranslation));
    }
    else
    {
        this.playerEntity.markPlayerActive();
        String s = packetIn.getMessage();
        s = StringUtils.normalizeSpace(s);

        for (int i = 0; i < s.length(); ++i)
        {
            if (!ChatAllowedCharacters.isAllowedCharacter(s.charAt(i)))
            {
                this.kickPlayerFromServer("Illegal characters in chat");
                return;
            }
        }

        if (s.startsWith("/"))
        {
            this.handleSlashCommand(s);
        }
        else
        {
            ITextComponent itextcomponent = new TextComponentTranslation("chat.type.text", this.playerEntity.getDisplayName(), net.minecraftforge.common.ForgeHooks.newChatWithLinks(s));
            itextcomponent = net.minecraftforge.common.ForgeHooks.onServerChatEvent(this, s, itextcomponent);
            if (itextcomponent == null) return;
            this.serverController.getPlayerList().sendChatMsgImpl(itextcomponent, false);
        }

        this.chatSpamThresholdCount += 20;

        if (this.chatSpamThresholdCount > 200 && !this.serverController.getPlayerList().canSendCommands(this.playerEntity.getGameProfile()))
        {
            this.kickPlayerFromServer("disconnect.spam");
        }
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:49,代码来源:NetHandlerPlayServer.java


示例16: handleChat

import net.minecraft.network.play.server.SPacketChat; //导入依赖的package包/类
/**
 * Prints a chatmessage in the chat GUI
 */
void handleChat(SPacketChat packetIn);
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:5,代码来源:INetHandlerPlayClient.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java GraphMLWriter类代码示例发布时间:2022-05-22
下一篇:
Java SystemConfiguration类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap