Java Code Examples for net.minecraft.entity.player.EntityPlayer.sendMessage()

The following are Jave code examples for showing how to use sendMessage() of the net.minecraft.entity.player.EntityPlayer class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: Loot-Slash-Conquer   File: ItemLEMagical.java   View Source Code Vote up 6 votes
@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand)
{
	Stats statsCap = (Stats) player.getCapability(CapabilityPlayerStats.STATS, null);
	PlayerInformation playerInfo = (PlayerInformation) player.getCapability(CapabilityPlayerInformation.PLAYER_INFORMATION, null);
	
	if (statsCap != null && playerInfo != null)
	{
		if (statsCap.getMana() - this.manaPerUse >= 0 && playerInfo.getPlayerLevel() >= NBTHelper.loadStackNBT(player.inventory.getCurrentItem()).getInteger("Level"))
		{	
			player.setActiveHand(hand);
			return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, player.inventory.getCurrentItem());
		}
	}
	
	if (playerInfo.getPlayerLevel() < NBTHelper.loadStackNBT(player.inventory.getCurrentItem()).getInteger("Level"))
	{
		player.sendMessage(new TextComponentString(TextFormatting.RED + "WARNING: You are using a high-leveled item. It will be useless and will take significantly more damage if it is not removed."));
	}
	
	return new ActionResult<ItemStack>(EnumActionResult.FAIL, player.inventory.getCurrentItem());
}
 
Example 2
Project: Loot-Slash-Conquer   File: ItemLEBauble.java   View Source Code Vote up 6 votes
@Override
public void onEquipped(ItemStack stack, EntityLivingBase entity) 
{
	if (entity.getEntityWorld().isRemote) entity.playSound(SoundEvents.ITEM_ARMOR_EQUIP_DIAMOND, 0.1F, 1.3f);
	else
	{
		if (entity instanceof EntityPlayer)
		{
			EntityPlayer player = (EntityPlayer) entity;
			PlayerInformation info = (PlayerInformation) player.getCapability(CapabilityPlayerInformation.PLAYER_INFORMATION, null);
			
			if (info != null && info.getPlayerLevel() >= NBTHelper.loadStackNBT(stack).getInteger("Level"))
			{
				EventPlayerTick.updateStats(player, info);
			}
			else player.sendMessage(new TextComponentString(TextFormatting.RED + "WARNING: You are using a high-leveled item. It will be useless and will not provide any bonuses."));
		}
	}
}
 
Example 3
Project: Game-Stages   File: CommandAddStage.java   View Source Code Vote up 6 votes
@Override
public void execute (MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {

    if (args.length == 2) {

        final EntityPlayer player = getPlayer(server, sender, args[0]);
        final String stageName = args[1];

        PlayerDataHandler.getStageData(player).unlockStage(stageName);

        if (player instanceof EntityPlayerMP) {
            GameStages.NETWORK.sendTo(new PacketStage(stageName, true), (EntityPlayerMP) player);
        }

        player.sendMessage(new TextComponentTranslation("commands.gamestage.add.target", stageName));

        if (player != sender) {
            sender.sendMessage(new TextComponentTranslation("commands.gamestage.add.sender", stageName, player.getDisplayNameString()));
        }
    }
    else {
        throw new WrongUsageException("commands.gamestage.add.usage", new Object[0]);
    }
}
 
Example 4
Project: BetterBeginningsReborn   File: ItemInfusionScroll.java   View Source Code Vote up 6 votes
@Override
public EnumActionResult onItemUseFirst(EntityPlayer player, World world, BlockPos pos,
    EnumFacing side, float hitX, float hitY, float hitZ, EnumHand hand)
{
    TileEntity te = world.getTileEntity(pos);
    if(te instanceof TileEntityInfusionRepair)
    {
        Stack<RecipeElement> pendingIngredients = ((TileEntityInfusionRepair)te).getPendingIngredients();
        if(!pendingIngredients.isEmpty())
        {
            RecipeElement element = pendingIngredients.peek();
            player.sendMessage(new TextComponentString(element.toFriendlyString()));
        }
    }
    return EnumActionResult.SUCCESS;
}
 
Example 5
Project: Defier   File: EnergyProviderBlock.java   View Source Code Vote up 6 votes
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
	if (world.isRemote) {
		return true;
	}
	EnergyProviderTileEntity te = (EnergyProviderTileEntity) world.getTileEntity(pos);
	if(te.getSpeedUpgrades() < 8 && !player.inventory.getCurrentItem().isEmpty() && player.inventory.getCurrentItem().getItem() == ModItems.speedstar){
		te.addSpeedUpgrade();
		player.inventory.getCurrentItem().setCount(player.inventory.getCurrentItem().getCount()-1);
		player.sendMessage(new TextComponentString("Added Speed Upgrade " + te.getSpeedUpgrades() + "/8"));
	}
	if(te.getSpeedUpgrades() < 4 && !player.inventory.getCurrentItem().isEmpty() && player.inventory.getCurrentItem().getItem() == ModItems.energystar && te.getStorageUpgrades() == player.inventory.getCurrentItem().getMetadata()){
		te.addStorageUpgrade();
		player.inventory.getCurrentItem().setCount(player.inventory.getCurrentItem().getCount()-1);
		player.sendMessage(new TextComponentString("Added Storage Upgrade " + te.getStorageUpgrades() + "/4"));
	}
	return true;
}
 
Example 6
Project: ProgressiveDifficulty   File: ServerCommand.java   View Source Code Vote up 5 votes
private void sendChat(ICommandSender sender, String[] msg){
    EntityPlayer player = (EntityPlayer)sender.getCommandSenderEntity();
    for (String str : msg)
    {
        TextComponentString line = new TextComponentString(str);
        player.sendMessage(line);
    }
}
 
Example 7
Project: modName   File: EventHandlerCommon.java   View Source Code Vote up 5 votes
@SubscribeEvent
public void onPlayerLogsIn(PlayerLoggedInEvent e)
{
	EntityPlayer player = e.player;
	World world = player.world;
	
	if(world.isRemote == false) 
	{
		WorldTurn turn = WorldTurn.get(world);
	
		int currentTurn = turn.getTurn();
		String message = String.format("Hello there, the World Turn is currently %s", currentTurn);
		player.sendMessage(new TextComponentString(message));
	}
}
 
Example 8
Project: harshencastle   File: HarshenDimensionalGlass.java   View Source Code Vote up 5 votes
@Override
public void onBlockHarvested(World worldIn, BlockPos pos, IBlockState state, EntityPlayer player) 
{
	if(player.capabilities.isCreativeMode)
	{
		super.onBlockHarvested(worldIn, pos, state, player);
		return;
	}
	player.attackEntityFrom(DamageSource.MAGIC, 21);
	if(!worldIn.isRemote)
	{
		player.sendMessage((ITextComponent) new TextComponentTranslation("message.broken"));
	}
}
 
Example 9
Project: harshencastle   File: HarshenSoulOre.java   View Source Code Vote up 5 votes
@Override
public void onBlockHarvested(World worldIn, BlockPos pos, IBlockState state, EntityPlayer player) 
{
	if(player.capabilities.isCreativeMode)
	{
		super.onBlockHarvested(worldIn, pos, state, player);
		return;
	}
	ItemStack item = player.inventory.getCurrentItem();
	if(item.getItem() instanceof SoulHarsherPickaxe)
	{
		if(!worldIn.isRemote)
		{
			InventoryHelper.spawnItemStack(worldIn, pos.getX(), pos.getY(), pos.getZ(), new ItemStack(HarshenItems.HARSHEN_SOUL_FRAGMENT));
			super.onBlockHarvested(worldIn, pos, state, player);
			player.sendMessage((ITextComponent) new TextComponentTranslation("message.success"));
		}	
	}
	else
	{
		player.attackEntityFrom(DamageSource.MAGIC, 21);
		if(!worldIn.isRemote)
		{
			player.sendMessage((ITextComponent) new TextComponentTranslation("message.failed"));
		}
	}

}
 
Example 10
Project: Game-Stages   File: CommandStageClear.java   View Source Code Vote up 5 votes
@Override
public void execute (MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {

    if (args.length == 1) {

        final EntityPlayer player = getPlayer(server, sender, args[0]);
        final IStageData stageInfo = PlayerDataHandler.getStageData(player);
        final int stageCount = stageInfo.getUnlockedStages().size();

        for (final String stage : stageInfo.getUnlockedStages()) {
            if (player instanceof EntityPlayerMP) {
                GameStages.NETWORK.sendTo(new PacketStage(stage, false), (EntityPlayerMP) player);
            }
        }

        stageInfo.clear();

        player.sendMessage(new TextComponentTranslation("commands.gamestage.clear.target", stageCount));

        if (player != sender) {
            sender.sendMessage(new TextComponentTranslation("commands.gamestage.clear.sender", stageCount, player.getDisplayNameString()));
        }
    }
    else {
        throw new WrongUsageException("commands.gamestage.clear.usage", new Object[0]);
    }
}
 
Example 11
Project: Game-Stages   File: CommandTransferStages.java   View Source Code Vote up 5 votes
@Override
public void execute (MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {

    if (args.length == 2) {

        final EntityPlayer originalPlayer = getPlayer(server, sender, args[0]);
        final EntityPlayer secondPlayer = getPlayer(server, sender, args[1]);

        if (originalPlayer instanceof EntityPlayerMP && secondPlayer instanceof EntityPlayerMP) {

            final IStageData originalData = PlayerDataHandler.getStageData(originalPlayer);
            final IStageData secondData = PlayerDataHandler.getStageData(secondPlayer);

            if (originalData != null && secondData != null) {
                for (final String stage : originalData.getUnlockedStages()) {

                    // Transfers stages
                    originalData.lockStage(stage);
                    secondData.unlockStage(stage);

                    // Sends stage changes to the client
                    GameStages.NETWORK.sendTo(new PacketStage(stage, false), (EntityPlayerMP) originalPlayer);
                    GameStages.NETWORK.sendTo(new PacketStage(stage, true), (EntityPlayerMP) secondPlayer);

                    // Sends update messages
                    originalPlayer.sendMessage(new TextComponentTranslation("commands.gamestage.remove.target", stage));
                    secondPlayer.sendMessage(new TextComponentTranslation("commands.gamestage.add.target", stage));
                }
            }
        }
    }
    else {
        throw new WrongUsageException("commands.gamestage.transfer.usage", new Object[0]);
    }
}
 
Example 12
Project: Game-Stages   File: CommandMirrorStages.java   View Source Code Vote up 5 votes
@Override
public void execute (MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {

    if (args.length == 2) {

        final EntityPlayer originalPlayer = getPlayer(server, sender, args[0]);
        final EntityPlayer secondPlayer = getPlayer(server, sender, args[1]);

        if (originalPlayer instanceof EntityPlayerMP && secondPlayer instanceof EntityPlayerMP) {

            final IStageData originalData = PlayerDataHandler.getStageData(originalPlayer);
            final IStageData secondData = PlayerDataHandler.getStageData(secondPlayer);

            if (originalData != null && secondData != null) {
                for (final String stage : originalData.getUnlockedStages()) {

                    // Transfers stages
                    secondData.unlockStage(stage);

                    // Sends stage changes to the client
                    GameStages.NETWORK.sendTo(new PacketStage(stage, false), (EntityPlayerMP) secondPlayer);

                    // Sends update messages
                    secondPlayer.sendMessage(new TextComponentTranslation("commands.gamestage.add.target", stage));
                }
            }
        }
    }
    else {
        throw new WrongUsageException("commands.gamestage.mirror.usage", new Object[0]);
    }
}
 
Example 13
Project: ModularMachinery   File: DataLoadProfiler.java   View Source Code Vote up 5 votes
public void printLines(@Nullable EntityPlayer additionalReceiver) {
    for (StatusLine sl : statusLines) {
        String out = sl.toString();
        ModularMachinery.log.info(out);
        if(additionalReceiver != null) {
            additionalReceiver.sendMessage(new TextComponentString(out));
        }
    }
}
 
Example 14
Project: modName   File: BlockModBanner.java   View Source Code Vote up 5 votes
@Override
public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack)
   {
	if(!worldIn.isRemote)
	{
		return;
	}
	if(!(placer instanceof EntityPlayer))
	{
		return;
	}
	
	EntityPlayer player = (EntityPlayer)placer;
	TileList tileList = TileList.get(worldIn);
	Tile placedOn = tileList.getTileByPos(new TilePos(pos));
	PlayerEmpire empire = (PlayerEmpire)CapPlayerEmpire.getEmpire(player);
	
	if(placedOn.isOwned())
	{
		if(placedOn.getCurrentOwner()!=empire.getUUID())
		{
			player.sendMessage(new TextComponentString("That tile is owned by someone else!"));
			return;
		}
	}
	
	if(empire.getUUID()==null)
	{
		
	}
	System.out.println(empire.getUUID());
	
   }
 
Example 15
Project: Never-Enough-Currency   File: ItemLinkingCard.java   View Source Code Vote up 5 votes
@Override
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn) {
	ItemStack stack = playerIn.getHeldItem(handIn);

	if (playerIn.isSneaking() && stack.hasTagCompound()) {
		stack.getTagCompound().setBoolean("automatic", !stack.getTagCompound().getBoolean("automatic"));
		if (worldIn.isRemote) {
			playerIn.sendMessage(new TextComponentString("Automatic mode has been toggled to " + stack.getTagCompound().getBoolean("automatic") + "."));
		}
		return ActionResult.newResult(EnumActionResult.SUCCESS, stack);
	}

	return ActionResult.newResult(EnumActionResult.FAIL, stack);
}
 
Example 16
Project: BetterBeginningsReborn   File: TileEntityInfusionRepair.java   View Source Code Vote up 4 votes
public void activate(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, @Nullable ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ)
   {
if(player.isSneaking())
{
    if(Prep1_11.isEmpty(heldItem))
    {
	if(hasEnchItem())
	{
	    if(!world.isRemote)
	    {
		world.spawnEntity(new EntityItem(world, pos.getX(), pos.getY() + 1, pos.getZ(), mainHandler.getStackInSlot(SLOT_ENCH_ITEM)));
	    }
	    mainHandler.setStackInSlot(SLOT_ENCH_ITEM, null);
	    mode = Mode.NONE;
	    pendingIngredients.clear();
	    markDirty();
	    world.notifyBlockUpdate(pos, state, state, 8);
	}
	else if(world.isRemote)
	{
	    ITextComponent link1 = new TextComponentString("Infusion Repair");
	    link1.setStyle(new Style().setBold(true).setUnderlined(true).setClickEvent(new ClickEvent(Action.OPEN_URL, "https://github.com/einsteinsci/betterbeginnings/wiki/Infusion-Repair")));
	    ITextComponent link2 = new TextComponentString("Enchantment Diffusion");
	    link2.setStyle(new Style().setBold(true).setUnderlined(true).setClickEvent(new ClickEvent(Action.OPEN_URL, "https://github.com/einsteinsci/betterbeginnings/wiki/Enchantment-Diffusion")));
	    ITextComponent message = new TextComponentString("See the BB wiki articles on ");
	    message.appendSibling(link1);
	    player.sendMessage(message);
	    player.sendMessage(new TextComponentString("and ").appendSibling(link2));
	}
    }
}
else
{
    if(Prep1_11.isEmpty(heldItem) || hasEnchItem() || mode != Mode.NONE) return;
    if(heldItem.getItem() == RegisterItems.cloth)
    {
	mode = Mode.DIFFUSION;
    }
    else if(heldItem.isItemEnchanted())
    {
	if(heldItem.getEnchantmentTagList().tagCount() > 8)
	{
	    player.sendMessage(new TextComponentTranslation("diffusion.toomanyenchants"));
	    mode = Mode.NONE;
	    return;
	}
	mode = Mode.REPAIR;
	pendingIngredients.clear();
	pendingIngredients.addAll(InfusionRepairUtil.getRequiredStacks(heldItem));
	xpLevelsNeeded = InfusionRepairUtil.getTakenLevels(heldItem);
	markDirty();
    }
    else
	return;
    ItemStack newStack = heldItem.copy();
    newStack.setCount(1);
    mainHandler.setStackInSlot(heldItem.isItemEnchanted() ? SLOT_ENCH_ITEM : 1, newStack);
    heldItem.shrink(1);
}
   }
 
Example 17
Project: Mods   File: EntityTF2Boss.java   View Source Code Vote up 4 votes
@Override
public IEntityLivingData onInitialSpawn(DifficultyInstance diff, IEntityLivingData p_110161_1_) {
	int players = 0;
	int highestLevel = 0;
	int statmult=0;
	for (EntityLivingBase living : this.world.getEntitiesWithinAABB(EntityLivingBase.class,
			this.getEntityBoundingBox().grow(64, 64, 64),new Predicate<EntityLivingBase>(){

				@Override
				public boolean apply(EntityLivingBase input) {
					// TODO Auto-generated method stub
					return input.hasCapability(TF2weapons.WEAPONS_CAP, null);
				}
		
	})) {
		
		statmult++;
		if(living instanceof EntityPlayer){
			players++;
			statmult+=2;
			EntityPlayer player=(EntityPlayer) living;
			if(player.getCapability(TF2weapons.PLAYER_CAP, null).highestBossLevel.get(this.getClass())==null){
				player.getCapability(TF2weapons.PLAYER_CAP, null).highestBossLevel.put(this.getClass(), (short)0);
			}
			int level = player.getCapability(TF2weapons.PLAYER_CAP, null)
					.highestBossLevel
					.get(this.getClass());
			if (level > highestLevel)
				highestLevel = level;
			player.sendMessage(new TextComponentTranslation("tf2boss.appear",new Object[] {this.getDisplayName(),Math.min(30, highestLevel+1)}));
		}
	}
	highestLevel++;
	this.level = Math.min(30, highestLevel);
	//System.out.println("Level: " + this.level + " player: " + players);
	float desiredHealth=(float)this.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).getBaseValue() * (0.6f + statmult * 0.13333f) * (0.6f + highestLevel * 0.4f);
	this.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH)
			.setBaseValue(Math.min(1000,desiredHealth));
	this.damageMult=Math.min(1f, 1000f/desiredHealth);
	this.setHealth(this.getMaxHealth());
	TF2Attribute.setAttribute(this.getHeldItemMainhand(), TF2Attribute.attributes[19],
			1 * (0.85f + this.level * 0.15f));
	this.experienceValue = (int) (200 * (0.5f + players * 0.5f) * (0.45f + highestLevel * 0.55f));
	this.playersAttacked=players;
	this.playSound(this.getAppearSound(), 4F, 1);
	return p_110161_1_;
}
 
Example 18
Project: Halloween   File: EntityTreater.java   View Source Code Vote up 4 votes
/**
 * Sends a chat message to the target player.
 * The message sent is chosen at random from those available for the message type, and where appropriate the treater type.
 */
public void chatItUp(EntityPlayer player, EnumTreaterMessage messageType)
{
	player.sendMessage(new TextComponentTranslation(messageType.getTranslationKey(this.getTreaterType())));
}
 
Example 19
Project: TheOink   File: OinkWand.java   View Source Code Vote up 4 votes
private void chatMessage(EntityPlayer player){
    player.sendMessage(new TextComponentString("Bacon and Sausage already exist in this world, they are too special to exist more than once!"));
}
 
Example 20
Project: ProgressiveDifficulty   File: ChatUtil.java   View Source Code Vote up 3 votes
/**
 * Sends all passed chat components to the player.
 *
 * @param player
 *        The player to send the chat lines to.
 * @param lines
 *        The {@link ITextComponent chat components} to send.yes
 */
public static void sendChat(EntityPlayer player, ITextComponent... lines)
{
    for (ITextComponent c : lines)
    {
        player.sendMessage(c);
    }
}