本文整理匯總了Java中net.minecraft.entity.player.EntityPlayerMP.addChatComponentMessage方法的典型用法代碼示例。如果您正苦於以下問題:Java EntityPlayerMP.addChatComponentMessage方法的具體用法?Java EntityPlayerMP.addChatComponentMessage怎麽用?Java EntityPlayerMP.addChatComponentMessage使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類net.minecraft.entity.player.EntityPlayerMP
的用法示例。
在下文中一共展示了EntityPlayerMP.addChatComponentMessage方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onMessage
import net.minecraft.entity.player.EntityPlayerMP; //導入方法依賴的package包/類
@Override
public IMessage onMessage(MessagePictureBookInput message, MessageContext ctx) {
if (ctx.side == Side.SERVER) {
EntityPlayerMP player = ctx.getServerHandler().playerEntity;
if (player != null && player.openContainer != null
&& player.openContainer instanceof ContainerPictureBook) {
ContainerPictureBook contaner = (ContainerPictureBook) player.openContainer;
if (contaner.getSlot(0).getHasStack() && contaner.getSlot(0).getStack().hasTagCompound()
&& contaner.getSlot(0).getStack().getTagCompound().hasKey("pid")) {
ItemStack itemStack = contaner.getSlot(0).getStack();
String pid = itemStack.getTagCompound().getString("pid");
if (contaner.getTotalPictureNum() <= 100) {
contaner.getListPid().add(pid);
contaner.setTotalPictureNum(contaner.getTotalPictureNum() + 1);
if (contaner.getTotalPictureNum() == 1) {
contaner.setIndex(0);
}
} else {
player.addChatComponentMessage(new TextComponentTranslation("chat.picturebook.tomany"));
return null;
}
}
contaner.getSlot(0).decrStackSize(64);
}
}
return null;
}
示例2: sendErrorMessage
import net.minecraft.entity.player.EntityPlayerMP; //導入方法依賴的package包/類
private void sendErrorMessage(EntityPlayerMP player) {
TextComponentString msg = new TextComponentString("this is not a command");
player.addChatComponentMessage(msg, false);
}