Search in sources :

Example 76 with ITextComponent

use of net.minecraft.util.text.ITextComponent in project Cavern2 by kegare.

the class SpecialMagicMessage method process.

@Override
public IMessage process(EntityPlayerMP player) {
    MagicBook book = MagicBook.get(player);
    SpecialMagic magic = book.getSpecialMagic();
    if (magic != null) {
        ITextComponent message = magic.finishMagic();
        if (message != null) {
            player.sendStatusMessage(message, true);
        }
        SoundEvent sound = magic.getFinishSound();
        if (sound != null) {
            player.world.playSound(null, player.posX, player.posY + 0.25D, player.posZ, sound, SoundCategory.PLAYERS, 1.0F, 1.0F);
        }
        book.setSpecialMagic(null);
    }
    return null;
}
Also used : SpecialMagic(cavern.magic.SpecialMagic) SoundEvent(net.minecraft.util.SoundEvent) ITextComponent(net.minecraft.util.text.ITextComponent) MagicBook(cavern.magic.MagicBook)

Example 77 with ITextComponent

use of net.minecraft.util.text.ITextComponent in project Cavern2 by kegare.

the class MiningAssistMessage method process.

@Override
public IMessage process(EntityPlayerMP player) {
    IMinerStats stats = MinerStats.get(player);
    if (stats.getRank() < MiningAssistConfig.minerRank.getValue()) {
        ITextComponent component = new TextComponentTranslation(MinerRank.get(MiningAssistConfig.minerRank.getValue()).getUnlocalizedName());
        component.getStyle().setItalic(Boolean.valueOf(true));
        component = new TextComponentTranslation("cavern.miningassist.toggle.failed.message", component);
        component.getStyle().setColor(TextFormatting.RED);
        player.sendMessage(component);
    } else {
        stats.toggleMiningAssist();
        stats.adjustData();
        ITextComponent component = new TextComponentTranslation(MiningAssist.get(stats.getMiningAssist()).getUnlocalizedName());
        component.getStyle().setColor(TextFormatting.GRAY).setItalic(Boolean.valueOf(true));
        component = new TextComponentTranslation("cavern.miningassist.toggle.message", component);
        player.sendMessage(component);
    }
    return null;
}
Also used : TextComponentTranslation(net.minecraft.util.text.TextComponentTranslation) ITextComponent(net.minecraft.util.text.ITextComponent) IMinerStats(cavern.api.IMinerStats)

Example 78 with ITextComponent

use of net.minecraft.util.text.ITextComponent in project DynamicSurroundings by OreCruncher.

the class VersionChecker method playerLogin.

public void playerLogin(@Nonnull final PlayerLoggedInEvent event) {
    if (event.player instanceof EntityPlayer) {
        final String updateMessage = getUpdateMessage(this.modId);
        if (updateMessage != null) {
            try {
                final ITextComponent component = ITextComponent.Serializer.jsonToComponent(updateMessage);
                event.player.sendMessage(component);
            } catch (@Nonnull final Throwable t) {
                t.printStackTrace();
            }
        }
    }
}
Also used : ITextComponent(net.minecraft.util.text.ITextComponent) EntityPlayer(net.minecraft.entity.player.EntityPlayer)

Example 79 with ITextComponent

use of net.minecraft.util.text.ITextComponent in project BloodMagic by WayofTime.

the class ItemSanguineBook method onItemUse.

@Override
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
    if (world.isRemote)
        return super.onItemUse(player, world, pos, hand, facing, hitX, hitY, hitZ);
    IBlockState hitState = world.getBlockState(pos);
    if (player.isSneaking()) {
        if (hitState.getBlock() instanceof IDocumentedBlock) {
            trySetDisplayedTier(world, pos);
            IDocumentedBlock documentedBlock = (IDocumentedBlock) hitState.getBlock();
            List<ITextComponent> docs = documentedBlock.getDocumentation(player, world, pos, hitState);
            if (!docs.isEmpty()) {
                ChatUtil.sendNoSpam(player, docs.toArray(new ITextComponent[docs.size()]));
                return super.onItemUse(player, world, pos, hand, facing, hitX, hitY, hitZ);
            }
        }
    }
    return super.onItemUse(player, world, pos, hand, facing, hitX, hitY, hitZ);
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) IDocumentedBlock(WayofTime.bloodmagic.iface.IDocumentedBlock) ITextComponent(net.minecraft.util.text.ITextComponent)

Example 80 with ITextComponent

use of net.minecraft.util.text.ITextComponent in project BloodMagic by WayofTime.

the class ItemSigilDivination method onItemRightClick.

@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
    ItemStack stack = player.getHeldItem(hand);
    if (stack.getItem() instanceof ISigil.Holding)
        stack = ((Holding) stack.getItem()).getHeldItem(stack, player);
    if (PlayerHelper.isFakePlayer(player))
        return ActionResult.newResult(EnumActionResult.FAIL, stack);
    if (!world.isRemote) {
        super.onItemRightClick(world, player, hand);
        Binding binding = getBinding(stack);
        if (binding != null) {
            int currentEssence = NetworkHelper.getSoulNetwork(binding).getCurrentEssence();
            List<ITextComponent> toSend = Lists.newArrayList();
            if (!binding.getOwnerId().equals(player.getGameProfile().getId()))
                toSend.add(new TextComponentTranslation(tooltipBase + "otherNetwork", binding.getOwnerName()));
            toSend.add(new TextComponentTranslation(tooltipBase + "currentEssence", currentEssence));
            ChatUtil.sendNoSpam(player, toSend.toArray(new ITextComponent[toSend.size()]));
        }
    }
    return super.onItemRightClick(world, player, hand);
}
Also used : Binding(WayofTime.bloodmagic.core.data.Binding) TextComponentTranslation(net.minecraft.util.text.TextComponentTranslation) ITextComponent(net.minecraft.util.text.ITextComponent) ItemStack(net.minecraft.item.ItemStack)

Aggregations

ITextComponent (net.minecraft.util.text.ITextComponent)116 TextComponentString (net.minecraft.util.text.TextComponentString)53 TextComponentTranslation (net.minecraft.util.text.TextComponentTranslation)43 EntityPlayer (net.minecraft.entity.player.EntityPlayer)20 ItemStack (net.minecraft.item.ItemStack)17 Style (net.minecraft.util.text.Style)17 ClickEvent (net.minecraft.util.text.event.ClickEvent)16 HoverEvent (net.minecraft.util.text.event.HoverEvent)9 ArrayList (java.util.ArrayList)8 BlockPos (net.minecraft.util.math.BlockPos)8 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)8 Minecraft (net.minecraft.client.Minecraft)5 StringTextComponent (net.minecraft.util.text.StringTextComponent)4 Text (org.spongepowered.api.text.Text)4 MagicBook (cavern.magic.MagicBook)3 SpecialMagic (cavern.magic.SpecialMagic)3 Matcher (java.util.regex.Matcher)3 TileEntity (net.minecraft.tileentity.TileEntity)3 SoundEvent (net.minecraft.util.SoundEvent)3 TextFormatting (net.minecraft.util.text.TextFormatting)3