Search in sources :

Example 96 with ITextComponent

use of net.minecraft.util.text.ITextComponent in project RFTools by McJty.

the class CmdSetStyle method execute.

@Override
public void execute(ICommandSender sender, String[] args) {
    if (args.length > 2) {
        ITextComponent component = new TextComponentString(TextFormatting.RED + "Too many parameters!");
        if (sender instanceof EntityPlayer) {
            ((EntityPlayer) sender).sendStatusMessage(component, false);
        } else {
            sender.sendMessage(component);
        }
        return;
    }
    if (!(sender instanceof EntityPlayer)) {
        ITextComponent component = new TextComponentString(TextFormatting.RED + "This command only works as a player!");
        if (sender instanceof EntityPlayer) {
            ((EntityPlayer) sender).sendStatusMessage(component, false);
        } else {
            sender.sendMessage(component);
        }
        return;
    }
    EntityPlayer player = (EntityPlayer) sender;
    PreferencesProperties properties = McJtyLib.getPreferencesProperties(player);
    if (args.length < 2) {
        GuiStyle style = properties.getStyle();
        ITextComponent component = new TextComponentString(TextFormatting.YELLOW + "Current GUI style: " + style.getStyle());
        if (sender instanceof EntityPlayer) {
            ((EntityPlayer) sender).sendStatusMessage(component, false);
        } else {
            sender.sendMessage(component);
        }
        return;
    }
    String s = fetchString(sender, args, 1, "");
    boolean b = properties.setStyle(s);
    if (!b) {
        String buf = "";
        for (GuiStyle style : GuiStyle.values()) {
            buf = buf + " " + style.getStyle();
        }
        ITextComponent component = new TextComponentString(TextFormatting.RED + "Unknown style! Options:" + buf);
        if (sender instanceof EntityPlayer) {
            ((EntityPlayer) sender).sendStatusMessage(component, false);
        } else {
            sender.sendMessage(component);
        }
    }
}
Also used : PreferencesProperties(mcjty.lib.preferences.PreferencesProperties) GuiStyle(mcjty.lib.gui.GuiStyle) ITextComponent(net.minecraft.util.text.ITextComponent) EntityPlayer(net.minecraft.entity.player.EntityPlayer) TextComponentString(net.minecraft.util.text.TextComponentString) TextComponentString(net.minecraft.util.text.TextComponentString)

Example 97 with ITextComponent

use of net.minecraft.util.text.ITextComponent in project RFTools by McJty.

the class CmdTeleport method execute.

@Override
public void execute(ICommandSender sender, String[] args) {
    if (args.length < 5) {
        ITextComponent component = new TextComponentString(TextFormatting.RED + "Several parameters are missing!");
        if (sender instanceof EntityPlayer) {
            ((EntityPlayer) sender).sendStatusMessage(component, false);
        } else {
            sender.sendMessage(component);
        }
        return;
    } else if (args.length > 5) {
        ITextComponent component = new TextComponentString(TextFormatting.RED + "Too many parameters!");
        if (sender instanceof EntityPlayer) {
            ((EntityPlayer) sender).sendStatusMessage(component, false);
        } else {
            sender.sendMessage(component);
        }
        return;
    }
    int dim = fetchInt(sender, args, 1, 0);
    int x = fetchInt(sender, args, 2, 0);
    int y = fetchInt(sender, args, 3, 100);
    int z = fetchInt(sender, args, 4, 0);
    if (sender instanceof EntityPlayer) {
        EntityPlayer player = (EntityPlayer) sender;
        int currentId = player.getEntityWorld().provider.getDimension();
        if (currentId != dim) {
            mcjty.lib.varia.TeleportationTools.teleportToDimension(player, dim, x, y, z);
        } else {
            player.setPositionAndUpdate(x, y, z);
        }
    }
}
Also used : ITextComponent(net.minecraft.util.text.ITextComponent) EntityPlayer(net.minecraft.entity.player.EntityPlayer) TextComponentString(net.minecraft.util.text.TextComponentString)

Example 98 with ITextComponent

use of net.minecraft.util.text.ITextComponent in project RFTools by McJty.

the class PorterTools method checkTarget.

private static int checkTarget(EntityPlayer playerEntity, NBTTagCompound tagCompound, TeleportDestinations destinations, int curtarget, int donext, int tgt) {
    if (tagCompound.hasKey("target" + tgt)) {
        int target = tagCompound.getInteger("target" + tgt);
        GlobalCoordinate gc = destinations.getCoordinateForId(target);
        if (gc != null) {
            TeleportDestination destination = destinations.getDestination(gc);
            if (destination != null) {
                if (donext == 1) {
                    String name = destination.getName() + " (dimension " + destination.getDimension() + ")";
                    tagCompound.setInteger("target", target);
                    ITextComponent component = new TextComponentString(TextFormatting.GREEN + "Target: " + TextFormatting.WHITE + name);
                    if (playerEntity != null) {
                        playerEntity.sendStatusMessage(component, false);
                    }
                    donext = 2;
                } else if (target == curtarget) {
                    donext = 1;
                }
            }
        }
    }
    return donext;
}
Also used : ITextComponent(net.minecraft.util.text.ITextComponent) GlobalCoordinate(mcjty.lib.varia.GlobalCoordinate) TextComponentString(net.minecraft.util.text.TextComponentString) TeleportDestination(mcjty.rftools.blocks.teleporter.TeleportDestination) TextComponentString(net.minecraft.util.text.TextComponentString)

Example 99 with ITextComponent

use of net.minecraft.util.text.ITextComponent in project minecolonies by Minecolonies.

the class WindowTownHall method teleportToColony.

/**
 * On Button click teleport to the colony..
 *
 * @param button the clicked button.
 */
private void teleportToColony(@NotNull final Button button) {
    final int row = alliesList.getListElementIndexByPane(button);
    final ColonyView ally = allies.get(row);
    final ITextComponent teleport = new TextComponentString(LanguageHandler.format(DO_REALLY_WANNA_TP, ally.getName())).setStyle(new Style().setBold(true).setColor(TextFormatting.GOLD).setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, TELEPORT_COMMAND + ally.getID())));
    Minecraft.getMinecraft().player.sendMessage(teleport);
}
Also used : ColonyView(com.minecolonies.coremod.colony.ColonyView) ClickEvent(net.minecraft.util.text.event.ClickEvent) ITextComponent(net.minecraft.util.text.ITextComponent) Style(net.minecraft.util.text.Style) TextComponentString(net.minecraft.util.text.TextComponentString)

Example 100 with ITextComponent

use of net.minecraft.util.text.ITextComponent in project minecolonies by Minecolonies.

the class TileEntityInfoPosterRenderer method renderText.

private void renderText(final IBlockState actualState, final double addZ, final double addX, final TileEntityInfoPoster te, final double x, final double y, final double z) {
    GlStateManager.pushMatrix();
    final FontRenderer fontrenderer = this.getFontRenderer();
    double plusX = addX;
    double plusZ = addZ;
    int facing = (int) actualState.getValue(BlockWallSign.FACING).getHorizontalAngle();
    switch(facing) {
        case NINETY_DEGREE:
            facing = THREE_QUARTERS;
            plusZ -= BLOCK_MIDDLE;
            plusX -= SLIGHTLY_IN_FRONT;
            break;
        case HALF_ROTATION:
            plusX += BLOCK_MIDDLE;
            plusZ -= SLIGHTLY_IN_FRONT;
            break;
        case THREE_QUARTERS:
            facing = NINETY_DEGREE;
            plusZ += BLOCK_MIDDLE;
            plusX += SLIGHTLY_IN_FRONT;
            break;
        default:
            plusX -= BLOCK_MIDDLE;
            plusZ += SLIGHTLY_IN_FRONT;
            break;
    }
    GlStateManager.translate(x + plusX, y + YOFFSET * 2, z + plusZ);
    GlStateManager.rotate(facing, 0.0F, 1.0F, 0.0F);
    GlStateManager.scale(SCALING_FACTOR, -SCALING_FACTOR, SCALING_FACTOR);
    GlStateManager.depthMask(false);
    for (int j = 0; j < te.signText.length; ++j) {
        if (te.signText[j] != null) {
            final List<ITextComponent> list = GuiUtilRenderComponents.splitText(te.signText[j], MAX_TEXT_LENGTH, fontrenderer, false, true);
            final String text = list != null && !list.isEmpty() ? list.get(0).getFormattedText() : "";
            fontrenderer.drawString(text, -fontrenderer.getStringWidth(text) / 2, j * TEXT_OFFSET_X - te.signText.length * TEXT_OFFSET_Y, 0);
        }
    }
    GlStateManager.depthMask(true);
    GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
    GlStateManager.popMatrix();
}
Also used : ITextComponent(net.minecraft.util.text.ITextComponent) FontRenderer(net.minecraft.client.gui.FontRenderer)

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