本文整理汇总了Java中net.minecraft.network.play.server.SPacketChat类的典型用法代码示例。如果您正苦于以下问题:Java SPacketChat类的具体用法?Java SPacketChat怎么用?Java SPacketChat使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SPacketChat类属于net.minecraft.network.play.server包,在下文中一共展示了SPacketChat类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
}
示例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);
}
示例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)));
}
示例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);
}
}
示例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());
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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)));
}
示例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));
}
示例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");
}
}
}
示例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));
}
示例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));
}
}
示例14: addChatComponentMessage
import net.minecraft.network.play.server.SPacketChat; //导入依赖的package包/类
public void addChatComponentMessage(ITextComponent chatComponent)
{
this.connection.sendPacket(new SPacketChat(chatComponent));
}
示例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");
}
}
}