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);
}
}
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;
}
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();
}
}
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);
}
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;
}
Aggregations