Search in sources :

Example 31 with ITextComponent

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

the class ProgramCommand method loadProgram.

private void loadProgram(ICommandSender sender, String arg, ItemStack item) {
    // File file = new File("." + File.separator + "rftoolscontrol" + File.separator + arg);
    File file = new File(arg);
    String json;
    try (FileInputStream stream = new FileInputStream(file)) {
        byte[] data = new byte[(int) file.length()];
        stream.read(data);
        json = new String(data, "UTF-8");
    } catch (IOException e) {
        ITextComponent component = new TextComponentString(TextFormatting.RED + "Error opening file for reading!");
        if (sender instanceof EntityPlayer) {
            ((EntityPlayer) sender).sendStatusMessage(component, false);
        } else {
            sender.sendMessage(component);
        }
        return;
    }
    ProgramCardInstance program = ProgramCardInstance.readFromJson(json);
    program.writeToNBT(item);
    RFToolsCtrlMessages.INSTANCE.sendToServer(new PacketItemNBTToServer(item.getTagCompound()));
    ITextComponent component = new TextComponentString("Loaded program!");
    if (sender instanceof EntityPlayer) {
        ((EntityPlayer) sender).sendStatusMessage(component, false);
    } else {
        sender.sendMessage(component);
    }
}
Also used : ProgramCardInstance(mcjty.rftoolscontrol.logic.grid.ProgramCardInstance) ITextComponent(net.minecraft.util.text.ITextComponent) EntityPlayer(net.minecraft.entity.player.EntityPlayer) TextComponentString(net.minecraft.util.text.TextComponentString) PacketItemNBTToServer(mcjty.rftoolscontrol.network.PacketItemNBTToServer) TextComponentString(net.minecraft.util.text.TextComponentString)

Example 32 with ITextComponent

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

the class CmdFont method execute.

@Override
public void execute(ICommandSender sender, String[] args) {
    if (args.length < 3) {
        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 > 3) {
        ITextComponent component = new TextComponentString(TextFormatting.RED + "Too many parameters!");
        if (sender instanceof EntityPlayer) {
            ((EntityPlayer) sender).sendStatusMessage(component, false);
        } else {
            sender.sendMessage(component);
        }
        return;
    }
    ScreenConfiguration.font = fetchString(sender, args, 1, "rftools:fonts/ubuntu.ttf");
    ScreenConfiguration.fontSize = fetchFloat(sender, args, 2, 40);
    TrueTypeFont font = FontLoader.createFont(new ResourceLocation(ScreenConfiguration.font), ScreenConfiguration.fontSize, false);
    if (font == null) {
        ITextComponent component = new TextComponentString(TextFormatting.RED + "Could not load font!");
        if (sender instanceof EntityPlayer) {
            ((EntityPlayer) sender).sendStatusMessage(component, false);
        } else {
            sender.sendMessage(component);
        }
        return;
    }
    ClientProxy.font = font;
}
Also used : TrueTypeFont(mcjty.lib.font.TrueTypeFont) ResourceLocation(net.minecraft.util.ResourceLocation) ITextComponent(net.minecraft.util.text.ITextComponent) EntityPlayer(net.minecraft.entity.player.EntityPlayer) TextComponentString(net.minecraft.util.text.TextComponentString)

Example 33 with ITextComponent

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

the class CmdReset method execute.

@Override
public void execute(ICommandSender sender, String[] args) {
    if (args.length > 1) {
        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 preferencesProperties = McJtyLib.getPreferencesProperties(player);
    if (preferencesProperties != null) {
        preferencesProperties.reset();
    }
}
Also used : PreferencesProperties(mcjty.lib.preferences.PreferencesProperties) ITextComponent(net.minecraft.util.text.ITextComponent) EntityPlayer(net.minecraft.entity.player.EntityPlayer) TextComponentString(net.minecraft.util.text.TextComponentString)

Example 34 with ITextComponent

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

the class CmdSetBuffBar method execute.

@Override
public void execute(ICommandSender sender, String[] args) {
    if (args.length > 3) {
        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 < 3) {
        int buffX = properties.getBuffX();
        int buffY = properties.getBuffY();
        ITextComponent component = new TextComponentString(TextFormatting.YELLOW + "Current buffbar location: " + buffX + "," + buffY);
        if (sender instanceof EntityPlayer) {
            ((EntityPlayer) sender).sendStatusMessage(component, false);
        } else {
            sender.sendMessage(component);
        }
        return;
    }
    int x = fetchInt(sender, args, 1, 0);
    int y = fetchInt(sender, args, 2, 0);
    properties.setBuffXY(x, y);
}
Also used : PreferencesProperties(mcjty.lib.preferences.PreferencesProperties) ITextComponent(net.minecraft.util.text.ITextComponent) EntityPlayer(net.minecraft.entity.player.EntityPlayer) TextComponentString(net.minecraft.util.text.TextComponentString)

Example 35 with ITextComponent

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

the class BlockAltar method getDocumentation.

// IDocumentedBlock
@Override
public List<ITextComponent> getDocumentation(EntityPlayer player, World world, BlockPos pos, IBlockState state) {
    List<ITextComponent> docs = new ArrayList<>();
    IBloodAltar altar = ((IBloodAltar) world.getTileEntity(pos));
    Pair<BlockPos, ComponentType> missingBlock = AltarUtil.getFirstMissingComponent(world, pos, altar.getTier().toInt());
    if (missingBlock != null)
        docs.add(new TextComponentTranslation("chat.bloodmagic.altar.nextTier", new TextComponentTranslation(missingBlock.getRight().getKey()), Utils.prettifyBlockPosString(missingBlock.getLeft())));
    return docs;
}
Also used : TextComponentTranslation(net.minecraft.util.text.TextComponentTranslation) ITextComponent(net.minecraft.util.text.ITextComponent) ArrayList(java.util.ArrayList) BlockPos(net.minecraft.util.math.BlockPos)

Aggregations

ITextComponent (net.minecraft.util.text.ITextComponent)96 TextComponentString (net.minecraft.util.text.TextComponentString)54 EntityPlayer (net.minecraft.entity.player.EntityPlayer)26 TextComponentTranslation (net.minecraft.util.text.TextComponentTranslation)25 ClickEvent (net.minecraft.util.text.event.ClickEvent)16 ItemStack (net.minecraft.item.ItemStack)11 Style (net.minecraft.util.text.Style)8 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)8 HoverEvent (net.minecraft.util.text.event.HoverEvent)7 World (net.minecraft.world.World)7 ArrayList (java.util.ArrayList)6 BlockPos (net.minecraft.util.math.BlockPos)6 DimensionInformation (mcjty.rftoolsdim.dimensions.DimensionInformation)5 RfToolsDimensionManager (mcjty.rftoolsdim.dimensions.RfToolsDimensionManager)5 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)5 Minecraft (net.minecraft.client.Minecraft)4 Text (org.spongepowered.api.text.Text)4 MagicBook (cavern.magic.MagicBook)3 SpecialMagic (cavern.magic.SpecialMagic)3 Matcher (java.util.regex.Matcher)3