Search in sources :

Example 41 with TextComponentString

use of net.minecraft.util.text.TextComponentString in project Charset by CharsetMC.

the class PacketPoint method apply.

@Override
public void apply(INetHandler handler) {
    if (player == null)
        return;
    Notice notice = null;
    switch(type) {
        case COORD:
            notice = new Notice(new NotificationCoord(player.world, pos), new TextComponentString(message));
            break;
        case ENTITY:
            notice = new Notice(entity, new TextComponentString(message));
            break;
    }
    notice.withStyle(NoticeStyle.DRAWFAR, NoticeStyle.VERY_LONG, NoticeStyle.SCALE_SIZE, NoticeStyle.EXACTPOSITION);
    double maxDistSq = 256 * 256;
    for (EntityPlayer viewer : player.world.playerEntities) {
        if (player.getDistanceSq(viewer) >= maxDistSq)
            continue;
        notice.sendTo(viewer);
    }
}
Also used : EntityPlayer(net.minecraft.entity.player.EntityPlayer) TextComponentString(net.minecraft.util.text.TextComponentString)

Example 42 with TextComponentString

use of net.minecraft.util.text.TextComponentString in project Nutrition by WesCook.

the class ChatCommand method commandGetNutrition.

private void commandGetNutrition(ICommandSender sender, String[] args) {
    // If missing parameter, offer help
    if (args.length != 2) {
        sender.sendMessage(new TextComponentString("Invalid format.  /nutrition get <nutrient>"));
        return;
    }
    // Write nutrient name and percentage to chat
    EntityPlayer player = (EntityPlayer) sender;
    Nutrient nutrient = NutrientList.getByName(args[1]);
    if (nutrient != null) {
        Float nutrientValue = player.getCapability(CapProvider.NUTRITION_CAPABILITY, null).get(nutrient);
        sender.sendMessage(new TextComponentString(nutrient.name + ": " + String.format("%.2f", nutrientValue) + "%"));
    } else
        // Write error message
        sender.sendMessage(new TextComponentString("'" + args[1] + "' is not a valid nutrient."));
}
Also used : EntityPlayer(net.minecraft.entity.player.EntityPlayer) Nutrient(ca.wescook.nutrition.nutrients.Nutrient) TextComponentString(net.minecraft.util.text.TextComponentString)

Example 43 with TextComponentString

use of net.minecraft.util.text.TextComponentString in project ForestryMC by ForestryMC.

the class BlockStructure method onBlockActivated.

@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
    if (playerIn.isSneaking()) {
        return false;
    }
    MultiblockTileEntityForestry part = TileUtil.getTile(worldIn, pos, MultiblockTileEntityForestry.class);
    if (part == null) {
        return false;
    }
    IMultiblockController controller = part.getMultiblockLogic().getController();
    ItemStack heldItem = playerIn.getHeldItem(hand);
    // multiblock-debugging message if the machine is not assembled.
    if (heldItem.isEmpty()) {
        if (controller != null) {
            if (!controller.isAssembled()) {
                String validationError = controller.getLastValidationError();
                if (validationError != null) {
                    long tick = worldIn.getTotalWorldTime();
                    if (tick > previousMessageTick + 20) {
                        playerIn.sendMessage(new TextComponentString(validationError));
                        previousMessageTick = tick;
                    }
                    return true;
                }
            }
        } else {
            playerIn.sendMessage(new TextComponentTranslation("for.multiblock.error.notConnected"));
            return true;
        }
    }
    // Don't open the GUI if the multiblock isn't assembled
    if (controller == null || !controller.isAssembled()) {
        return false;
    }
    if (!worldIn.isRemote) {
        part.openGui(playerIn);
    }
    return true;
}
Also used : IMultiblockController(forestry.api.multiblock.IMultiblockController) TextComponentTranslation(net.minecraft.util.text.TextComponentTranslation) MultiblockTileEntityForestry(forestry.core.multiblock.MultiblockTileEntityForestry) TextComponentString(net.minecraft.util.text.TextComponentString) ItemStack(net.minecraft.item.ItemStack) TextComponentString(net.minecraft.util.text.TextComponentString)

Example 44 with TextComponentString

use of net.minecraft.util.text.TextComponentString in project ForestryMC by ForestryMC.

the class BlockGreenhouse method onBlockActivated.

@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
    if (playerIn.isSneaking()) {
        return false;
    }
    MultiblockTileEntityForestry part = TileUtil.getTile(worldIn, pos, MultiblockTileEntityForestry.class);
    if (part == null) {
        return false;
    }
    IMultiblockController controller = part.getMultiblockLogic().getController();
    ItemStack mainHand = playerIn.getHeldItemMainhand();
    if (mainHand.isEmpty()) {
        if (playerIn.getHeldItemOffhand().isEmpty()) {
            // multiblock-debugging message if the machine is not assembled.
            if (!controller.isAssembled()) {
                String validationError = controller.getLastValidationError();
                if (validationError != null) {
                    long tick = worldIn.getTotalWorldTime();
                    if (tick > previousMessageTick + 20) {
                        playerIn.sendMessage(new TextComponentString(validationError));
                        previousMessageTick = tick;
                    }
                    return true;
                }
            }
        }
    }
    // Don't open the GUI if the multiblock isn't assembled
    if (!controller.isAssembled()) {
        return false;
    }
    if (!worldIn.isRemote) {
        part.openGui(playerIn);
    }
    return true;
}
Also used : IMultiblockController(forestry.api.multiblock.IMultiblockController) MultiblockTileEntityForestry(forestry.core.multiblock.MultiblockTileEntityForestry) TextComponentString(net.minecraft.util.text.TextComponentString) ItemStack(net.minecraft.item.ItemStack) TextComponentString(net.minecraft.util.text.TextComponentString)

Example 45 with TextComponentString

use of net.minecraft.util.text.TextComponentString in project TechReborn by TechReborn.

the class ItemFrequencyTransmitter method onItemUse.

@Override
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
    ItemStack stack = player.getHeldItem(hand);
    stack.setTagCompound(new NBTTagCompound());
    stack.getTagCompound().setInteger("x", pos.getX());
    stack.getTagCompound().setInteger("y", pos.getY());
    stack.getTagCompound().setInteger("z", pos.getZ());
    stack.getTagCompound().setInteger("dim", world.provider.getDimension());
    if (!world.isRemote) {
        ChatUtils.sendNoSpamMessages(MessageIDs.freqTransmitterID, new TextComponentString(TextFormatting.GRAY + I18n.format("techreborn.message.setTo") + " X: " + TextFormatting.GOLD + pos.getX() + TextFormatting.GRAY + " Y: " + TextFormatting.GOLD + pos.getY() + TextFormatting.GRAY + " Z: " + TextFormatting.GOLD + pos.getZ() + TextFormatting.GRAY + " " + I18n.format("techreborn.message.in") + " " + TextFormatting.GOLD + DimensionManager.getProviderType(world.provider.getDimension()).getName() + " (" + world.provider.getDimension() + ")"));
    }
    return EnumActionResult.SUCCESS;
}
Also used : NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ItemStack(net.minecraft.item.ItemStack) TextComponentString(net.minecraft.util.text.TextComponentString)

Aggregations

TextComponentString (net.minecraft.util.text.TextComponentString)343 EntityPlayer (net.minecraft.entity.player.EntityPlayer)79 ItemStack (net.minecraft.item.ItemStack)68 BlockPos (net.minecraft.util.math.BlockPos)60 ITextComponent (net.minecraft.util.text.ITextComponent)48 TileEntity (net.minecraft.tileentity.TileEntity)41 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)35 TextComponentTranslation (net.minecraft.util.text.TextComponentTranslation)32 Colony (com.minecolonies.coremod.colony.Colony)26 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)26 IBlockState (net.minecraft.block.state.IBlockState)23 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)21 Style (net.minecraft.util.text.Style)21 IColony (com.minecolonies.api.colony.IColony)19 ClickEvent (net.minecraft.util.text.event.ClickEvent)19 Entity (net.minecraft.entity.Entity)18 Block (net.minecraft.block.Block)17 World (net.minecraft.world.World)17 ArrayList (java.util.ArrayList)16 ActionResult (net.minecraft.util.ActionResult)13