Jump to content

Recommended Posts

Posted

Hi,

 

My code is as follows; when clicking the message in chat, I get the message below the code block. I've tried several methods on the File and can't get it to open it. Any ideas what might be causing this?

 

@SubscribeEvent
public void onScreenshot(ScreenshotEvent event)
{
	event.setResultMessage(new TextComponentString(""));
	
	ITextComponent text = new TextComponentString("\u00a7a[ClientImprovements] Screenshot taken!");
	Style style = new Style();

	style.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponentString("\u00a7aOpen " + event.getScreenshotFile().getName())));
	style.setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_FILE, event.getScreenshotFile().getAbsolutePath()));
	text.setStyle(style);
		
	mc.player.sendMessage(new TextComponentString(""));
	mc.player.sendMessage(text);
}

 

[21:00:10] [main/ERROR] [minecraft/GuiScreen]: Couldn't open link: Failed to open file:/C:/Users/xxx/AppData/Roaming/.minecraft/screenshots/2018-11-01_21.00.08.png. Error message: A device attached to the system is not functioning.

Posted (edited)

I'm just in the habit of using those codes because usually I just use one-liners such as mc.player.sendMessage(new TextComponentString("...")); and don't declare the style

 

When I click the link in chat, the file exists because I can go to that path and open the file normally, but not through minecraft.

Edited by AntiRix
Posted

Yes, getAbsolutePath() works fine if I go to that file on my system. Opening it through the link in chat doesn't work though, so it's not the issue that the path is incorrect.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.