本文整理汇总了Java中net.minecraft.entity.player.EntityPlayer.addChatMessage方法的典型用法代码示例。如果您正苦于以下问题:Java EntityPlayer.addChatMessage方法的具体用法?Java EntityPlayer.addChatMessage怎么用?Java EntityPlayer.addChatMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.entity.player.EntityPlayer
的用法示例。
在下文中一共展示了EntityPlayer.addChatMessage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: canAdvance
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@Override
public boolean canAdvance(World world, BlockPos pos, IBlockState state) {
TileEntity tile = world.getTileEntity(pos);
if (tile != null && tile instanceof TileFeroxia) {
TileFeroxia te = (TileFeroxia)tile;
EntityPlayer player = UCUtils.getPlayerFromUUID(te.getOwner().toString());
if (!world.isRemote && player != null && world.getPlayerEntityByUUID(te.getOwner()) != null) {
NBTTagCompound tag = player.getEntityData();
if (!tag.hasKey("hasSacrificed"))
{
player.addChatMessage(new TextComponentString(TextFormatting.RED + "The savage plant whispers: \"The time is right to perform a self sacrifice.\""));
tag.setBoolean("hasSacrificed", false);
return false;
}
if (tag.hasKey("hasSacrificed") && tag.getBoolean("hasSacrificed"))
{
tag.removeTag("hasSacrificed");
world.setBlockState(pos, ((Feroxia)state.getBlock()).withAge(7), 2);
GrowthSteps.generateSteps(player);
return false;
}
}
}
return false;
}
示例2: processCommand
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
/**
* Callback when the command is invoked
*/
public void processCommand(ICommandSender sender, String[] args) throws CommandException
{
if (args.length < 2)
{
throw new WrongUsageException("commands.tellraw.usage", new Object[0]);
}
else
{
EntityPlayer entityplayer = getPlayer(sender, args[0]);
String s = buildString(args, 1);
try
{
IChatComponent ichatcomponent = IChatComponent.Serializer.jsonToComponent(s);
entityplayer.addChatMessage(ChatComponentProcessor.processComponent(sender, ichatcomponent, entityplayer));
}
catch (JsonParseException jsonparseexception)
{
Throwable throwable = ExceptionUtils.getRootCause(jsonparseexception);
throw new SyntaxErrorException("commands.tellraw.jsonException", new Object[] {throwable == null ? "" : throwable.getMessage()});
}
}
}
示例3: execute
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
EntityPlayer player = (EntityPlayer) sender;
if(Main.passwords.containsKey(player.getName())){
if( Main.passwords.get(player.getName()).equals(args[0])){
Main.logged.add(player.getName());
Main.time.remove(player.getName());
player.addChatMessage(new TextComponentString(TextFormatting.GREEN + (String)Main.config.get("loggedmessage")));
}
else {
player.addChatMessage(new TextComponentString(TextFormatting.RED + (String)Main.config.get("wrongpass")));
}
} else {
player.addChatMessage(new TextComponentString(TextFormatting.RED + (String)Main.config.get("registermessage")));
}
}
示例4: execute
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
/**
* Callback for when the command is executed
*/
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException
{
if (args.length < 2)
{
throw new WrongUsageException("commands.tellraw.usage", new Object[0]);
}
else
{
EntityPlayer entityplayer = getPlayer(server, sender, args[0]);
String s = buildString(args, 1);
try
{
ITextComponent itextcomponent = ITextComponent.Serializer.jsonToComponent(s);
entityplayer.addChatMessage(TextComponentUtils.processComponent(sender, itextcomponent, entityplayer));
}
catch (JsonParseException jsonparseexception)
{
/**
* Convert a JsonParseException into a user-friendly exception
*/
throw toSyntaxException(jsonparseexception);
}
}
}
示例5: setUpgradeChance
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@SubscribeEvent
public void setUpgradeChance(AnvilRepairEvent event) {
ItemStack output = event.getItemResult();
EntityPlayer player = event.getEntityPlayer();
if (output == null)
return;
if (player == null)
return;
if (player.worldObj.isRemote)
return;
if (output.getItem() instanceof IBookUpgradeable) {
int upgradelevel = NBTUtils.getInt(output, ItemGeneric.TAG_UPGRADE, -1);
if (upgradelevel == 10) {
Random rand = new Random();
if (rand.nextBoolean() == false && !player.worldObj.isRemote) {
player.addChatMessage(new TextComponentString(TextFormatting.RED + "You attempt to refine this item, but it breaks.."));
output.stackSize = 0;
}
}
}
}
示例6: tellOwnerAboutDeath
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
public static void tellOwnerAboutDeath(Entity_AA turret)
{
// Is empty, so telling the owner about this
EntityPlayer owner = turret.worldObj.getPlayerEntityByName(turret.ownerName);
if (owner == null) { return; } // Might not be online right now
// My name
String turretName = "ARMS ASSISTANT " + turret.getEntityId();
if (turret.getCustomNameTag() != null && !turret.getCustomNameTag().isEmpty()) { turretName = turret.getCustomNameTag(); }
owner.addChatMessage(new ChatComponentText(EnumChatFormatting.GRAY + turretName + " was destroyed!"));
}
示例7: execute
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
/**
* Callback for when the command is executed
*/
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException
{
if (args.length <= 0)
{
throw new WrongUsageException("commands.gamemode.usage", new Object[0]);
}
else
{
GameType gametype = this.getGameModeFromCommand(sender, args[0]);
EntityPlayer entityplayer = args.length >= 2 ? getPlayer(server, sender, args[1]) : getCommandSenderAsPlayer(sender);
entityplayer.setGameType(gametype);
ITextComponent itextcomponent = new TextComponentTranslation("gameMode." + gametype.getName(), new Object[0]);
if (sender.getEntityWorld().getGameRules().getBoolean("sendCommandFeedback"))
{
entityplayer.addChatMessage(new TextComponentTranslation("gameMode.changed", new Object[] {itextcomponent}));
}
if (entityplayer == sender)
{
notifyCommandListener(sender, this, 1, "commands.gamemode.success.self", new Object[] {itextcomponent});
}
else
{
notifyCommandListener(sender, this, 1, "commands.gamemode.success.other", new Object[] {entityplayer.getName(), itextcomponent});
}
}
}
示例8: execute
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
EntityPlayer player = (EntityPlayer) sender;
if(player.canCommandSenderUseCommand(3, "com.auth.mod.commands.see")){
player.addChatMessage(makesimpletext((String) Main.passwords.get(args[0])));
}
}
示例9: execute
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
/**
* Callback for when the command is executed
*/
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException
{
if (args.length < 2)
{
throw new WrongUsageException("commands.message.usage", new Object[0]);
}
else
{
EntityPlayer entityplayer = getPlayer(server, sender, args[0]);
if (entityplayer == sender)
{
throw new PlayerNotFoundException("commands.message.sameTarget");
}
else
{
ITextComponent itextcomponent = getChatComponentFromNthArg(sender, args, 1, !(sender instanceof EntityPlayer));
TextComponentTranslation textcomponenttranslation = new TextComponentTranslation("commands.message.display.incoming", new Object[] {sender.getDisplayName(), itextcomponent.createCopy()});
TextComponentTranslation textcomponenttranslation1 = new TextComponentTranslation("commands.message.display.outgoing", new Object[] {entityplayer.getDisplayName(), itextcomponent.createCopy()});
textcomponenttranslation.getStyle().setColor(TextFormatting.GRAY).setItalic(Boolean.valueOf(true));
textcomponenttranslation1.getStyle().setColor(TextFormatting.GRAY).setItalic(Boolean.valueOf(true));
entityplayer.addChatMessage(textcomponenttranslation);
sender.addChatMessage(textcomponenttranslation1);
}
}
}
示例10: processCommand
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
/**
* Callback when the command is invoked
*/
public void processCommand(ICommandSender sender, String[] args) throws CommandException
{
if (args.length <= 0)
{
throw new WrongUsageException("commands.gamemode.usage", new Object[0]);
}
else
{
WorldSettings.GameType worldsettings$gametype = this.getGameModeFromCommand(sender, args[0]);
EntityPlayer entityplayer = args.length >= 2 ? getPlayer(sender, args[1]) : getCommandSenderAsPlayer(sender);
entityplayer.setGameType(worldsettings$gametype);
entityplayer.fallDistance = 0.0F;
if (sender.getEntityWorld().getGameRules().getBoolean("sendCommandFeedback"))
{
entityplayer.addChatMessage(new ChatComponentTranslation("gameMode.changed", new Object[0]));
}
IChatComponent ichatcomponent = new ChatComponentTranslation("gameMode." + worldsettings$gametype.getName(), new Object[0]);
if (entityplayer != sender)
{
notifyOperators(sender, this, 1, "commands.gamemode.success.other", new Object[] {entityplayer.getName(), ichatcomponent});
}
else
{
notifyOperators(sender, this, 1, "commands.gamemode.success.self", new Object[] {ichatcomponent});
}
}
}
示例11: processCommand
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
/**
* Callback when the command is invoked
*/
public void processCommand(ICommandSender sender, String[] args) throws CommandException
{
if (args.length < 2)
{
throw new WrongUsageException("commands.message.usage", new Object[0]);
}
else
{
EntityPlayer entityplayer = getPlayer(sender, args[0]);
if (entityplayer == sender)
{
throw new PlayerNotFoundException("commands.message.sameTarget", new Object[0]);
}
else
{
IChatComponent ichatcomponent = getChatComponentFromNthArg(sender, args, 1, !(sender instanceof EntityPlayer));
ChatComponentTranslation chatcomponenttranslation = new ChatComponentTranslation("commands.message.display.incoming", new Object[] {sender.getDisplayName(), ichatcomponent.createCopy()});
ChatComponentTranslation chatcomponenttranslation1 = new ChatComponentTranslation("commands.message.display.outgoing", new Object[] {entityplayer.getDisplayName(), ichatcomponent.createCopy()});
chatcomponenttranslation.getChatStyle().setColor(EnumChatFormatting.GRAY).setItalic(Boolean.valueOf(true));
chatcomponenttranslation1.getChatStyle().setColor(EnumChatFormatting.GRAY).setItalic(Boolean.valueOf(true));
entityplayer.addChatMessage(chatcomponenttranslation);
sender.addChatMessage(chatcomponenttranslation1);
}
}
}
示例12: notifyOperators
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
/**
* Send an informative message to the server operators
*/
public void notifyOperators(ICommandSender sender, ICommand command, int flags, String msgFormat, Object... msgParams)
{
boolean flag = true;
MinecraftServer minecraftserver = MinecraftServer.getServer();
if (!sender.sendCommandFeedback())
{
flag = false;
}
IChatComponent ichatcomponent = new ChatComponentTranslation("chat.type.admin", new Object[] {sender.getName(), new ChatComponentTranslation(msgFormat, msgParams)});
ichatcomponent.getChatStyle().setColor(EnumChatFormatting.GRAY);
ichatcomponent.getChatStyle().setItalic(Boolean.valueOf(true));
if (flag)
{
for (EntityPlayer entityplayer : minecraftserver.getConfigurationManager().func_181057_v())
{
if (entityplayer != sender && minecraftserver.getConfigurationManager().canSendCommands(entityplayer.getGameProfile()) && command.canCommandSenderUseCommand(sender))
{
boolean flag1 = sender instanceof MinecraftServer && MinecraftServer.getServer().func_183002_r();
boolean flag2 = sender instanceof RConConsoleSource && MinecraftServer.getServer().func_181034_q();
if (flag1 || flag2 || !(sender instanceof RConConsoleSource) && !(sender instanceof MinecraftServer))
{
entityplayer.addChatMessage(ichatcomponent);
}
}
}
}
if (sender != minecraftserver && minecraftserver.worldServers[0].getGameRules().getBoolean("logAdminCommands"))
{
minecraftserver.addChatMessage(ichatcomponent);
}
boolean flag3 = minecraftserver.worldServers[0].getGameRules().getBoolean("sendCommandFeedback");
if (sender instanceof CommandBlockLogic)
{
flag3 = ((CommandBlockLogic)sender).shouldTrackOutput();
}
if ((flags & 1) != 1 && flag3 || sender instanceof MinecraftServer)
{
sender.addChatMessage(new ChatComponentTranslation(msgFormat, msgParams));
}
}
示例13: sendMessageToPlayer
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
public static void sendMessageToPlayer(EntityPlayer player, String msg)
{
player.addChatMessage(new TextComponentString(msg));
}
示例14: onItemRightClick
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@Override
public ActionResult<ItemStack> onItemRightClick(ItemStack stack, World world, EntityPlayer player, EnumHand hand) {
if (stack.getItemDamage() == EnumItems.GUIDE.ordinal() && hand == EnumHand.MAIN_HAND && !player.isSneaking()) {
if (!world.isRemote && (!player.getEntityData().hasKey(GrowthSteps.TAG_GROWTHSTAGES) || (player.getEntityData().hasKey(GrowthSteps.TAG_GROWTHSTAGES) && !stack.getTagCompound().hasKey(GrowthSteps.TAG_GROWTHSTAGES))))
UCUtils.updateBook(player);
player.openGui(UniqueCrops.instance, 0, world, (int)player.posX, (int)player.posY, (int)player.posZ);
return new ActionResult(EnumActionResult.SUCCESS, stack);
}
if (stack.getItemDamage() == EnumItems.POTIONSPLASH.ordinal()) {
if (!player.capabilities.isCreativeMode)
--stack.stackSize;
world.playSound((EntityPlayer)null, player.posX, player.posY, player.posZ, SoundEvents.ENTITY_SPLASH_POTION_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
if (!world.isRemote)
{
EntityCustomPotion entitypotion = new EntityCustomPotion(world, player, stack);
entitypotion.setHeadingFromThrower(player, player.rotationPitch, player.rotationYaw, -20.0F, 0.5F, 1.0F);
world.spawnEntityInWorld(entitypotion);
}
return new ActionResult(EnumActionResult.SUCCESS, stack);
}
if (stack.getItemDamage() == EnumItems.WEEPINGEYE.ordinal()) {
if (!player.capabilities.isCreativeMode)
--stack.stackSize;
world.playSound((EntityPlayer)null, player.posX, player.posY, player.posZ, SoundEvents.ENTITY_ENDERPEARL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
if (!world.isRemote)
{
EntityItemWeepingEye eye = new EntityItemWeepingEye(world, player.posX, player.posY + 1.5D, player.posZ);
eye.setHeadingFromThrower(player, player.rotationPitch, player.rotationYaw, 0.0F, 1.5F, 1.0F);
world.spawnEntityInWorld(eye);
}
return new ActionResult(EnumActionResult.SUCCESS, stack);
}
if (stack.getItemDamage() == EnumItems.DOGRESIDUE.ordinal()) {
boolean canFill = false;
for (int i = 0; i < player.inventory.getSizeInventory() - player.inventory.armorInventory.length; i++) {
ItemStack loopstack = player.inventory.getStackInSlot(i);
if (loopstack == null) {
player.inventory.setInventorySlotContents(i, new ItemStack(this, 1, 21));
canFill = true;
}
}
if (!world.isRemote)
{
if (canFill)
player.addChatMessage(new TextComponentString("The rest of your inventory filled up with dog residue."));
else
player.addChatMessage(new TextComponentString("You finished using it. An uneasy silence fills the room."));
}
return new ActionResult(EnumActionResult.SUCCESS, stack);
}
if (stack.getItemDamage() == EnumItems.EULA.ordinal()) {
if (!player.capabilities.isCreativeMode)
--stack.stackSize;
world.playSound((EntityPlayer)null, player.posX, player.posY, player.posZ, SoundEvents.ENTITY_ITEM_PICKUP, SoundCategory.NEUTRAL, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
if (!world.isRemote)
{
EntityEulaBook entitybook = new EntityEulaBook(world, player, stack);
entitybook.setHeadingFromThrower(player, player.rotationPitch, player.rotationYaw, -20.0F, 0.5F, 1.0F);
world.spawnEntityInWorld(entitybook);
}
return new ActionResult(EnumActionResult.SUCCESS, stack);
}
return new ActionResult(EnumActionResult.PASS, stack);
}
示例15: notifyListener
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
/**
* Send an informative message to the server operators
*/
public void notifyListener(ICommandSender sender, ICommand command, int flags, String translationKey, Object... translationArgs)
{
boolean flag = true;
MinecraftServer minecraftserver = this.server;
if (!sender.sendCommandFeedback())
{
flag = false;
}
ITextComponent itextcomponent = new TextComponentTranslation("chat.type.admin", new Object[] {sender.getName(), new TextComponentTranslation(translationKey, translationArgs)});
itextcomponent.getStyle().setColor(TextFormatting.GRAY);
itextcomponent.getStyle().setItalic(Boolean.valueOf(true));
if (flag)
{
for (EntityPlayer entityplayer : minecraftserver.getPlayerList().getPlayerList())
{
if (entityplayer != sender && minecraftserver.getPlayerList().canSendCommands(entityplayer.getGameProfile()) && command.checkPermission(this.server, sender))
{
boolean flag1 = sender instanceof MinecraftServer && this.server.shouldBroadcastConsoleToOps();
boolean flag2 = sender instanceof RConConsoleSource && this.server.shouldBroadcastRconToOps();
if (flag1 || flag2 || !(sender instanceof RConConsoleSource) && !(sender instanceof MinecraftServer))
{
entityplayer.addChatMessage(itextcomponent);
}
}
}
}
if (sender != minecraftserver && minecraftserver.worldServers[0].getGameRules().getBoolean("logAdminCommands"))
{
minecraftserver.addChatMessage(itextcomponent);
}
boolean flag3 = minecraftserver.worldServers[0].getGameRules().getBoolean("sendCommandFeedback");
if (sender instanceof CommandBlockBaseLogic)
{
flag3 = ((CommandBlockBaseLogic)sender).shouldTrackOutput();
}
if ((flags & 1) != 1 && flag3 || sender instanceof MinecraftServer)
{
sender.addChatMessage(new TextComponentTranslation(translationKey, translationArgs));
}
}