Jump to content

AntiRix

Members
  • Posts

    69
  • Joined

  • Last visited

Everything posted by AntiRix

  1. Very strange issue indeed - found a workaround. There's an issue opening files if mspaint is associated with .png files. Changing it to Photos works, but like all modern Windows apps, it's horribly slow. https://bugs.mojang.com/browse/MC-31787?focusedCommentId=106111&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-106111
  2. My system is perfectly fine. Everything's set up as default. Brand new computer and no issues whatsoever with anything.
  3. 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.
  4. 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.
  5. 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.
  6. Yep, I thought I might have to resort to that.
  7. Ok great, I'll have a look into that. I'm trying to remove the default message, and instead, write an empty line, a message, then another empty line to the chat. I've tried setting the result message to null, new TextComponentString(null), but the former simply doesn't work and the latter crashes the game. Is there any way to actually remove that message apart from either canceling everything, saving the file myself and then displaying my message, or setting the result message to null, sending one blank line and my message, then allowing the event to write that final empty line from the result message?
  8. While I'm here, on the topic, are you aware of any way to detect any message being placed in chat for any reason, and a way to remove specific messages from chat? I'd like to remove any instances of multiple empty lines to avoid big spaces in chat, and just allow one empty line between two sets of text.
  9. Oh excellent, I couldn't find anything about it on the internet. I'll have to look at the files directly in future.
  10. Hi, I'm trying to cancel the default screenshot message "Screenshot saved as xxx.png" and write something else to chat. Unfortunately, because it's client-side, ClientChatReceivedEvent isn't fired. Is there a simple way rather than perhaps overriding ScreenshotHelper or capturing keypresses and handling the screenshot-taking myself?
  11. Hi, On servers, it's common to see custom inventories opened for menus and such. How can I get the inventory title? By the time this code runs, I know for sure that an inventory is open and that its contents have been populated by the server. GuiScreen screen = Minecraft.getMinecraft().currentScreen; GuiContainer cont = (GuiContainer) screen; IInteractionObject obj = ((IInteractionObject)cont); // crashes the game ExampleMod.logger.info("Inventory loaded: " + obj.getName()); I've tried casting the GuiContainer to so many things to no avail.
  12. How can I have anything to compare against? All I can go by is the inventory title, or by checking every item inside the inventory. These are custom inventories opened by server plugins.
  13. Ok, I've got that working now, but I really need to know the inventory title so I can perform actions on the correct inventory.
  14. Right, I've changed that to GuiContainer and it's working for those inventories now. The only issue is that when changing inventories by clicking through the custom inventories, there's no tick where the currentScreen isn't an instance of GuiContainer. As such, I either need to compare all of the inventory contents to detect a change, or much easier, detect a change in the inventory title because each has a unique title. I can't find any methods in GuiContainer to get the name or title; are you aware of a way to get it? private boolean inventory_open = false; private boolean inventory_populated = false; @SubscribeEvent public void onPlayerTick(TickEvent.PlayerTickEvent event) { GuiScreen screen = Minecraft.getMinecraft().currentScreen; boolean inventory_open_in_tick = screen instanceof GuiContainer; if (!inventory_open && inventory_open_in_tick) { inventory_open = true; ExampleMod.logger.info("> Inventory opened"); } if (inventory_open && !inventory_open_in_tick) { inventory_open = false; inventory_populated = false; ExampleMod.logger.info("> Inventory closed"); return; } if (!inventory_open_in_tick || inventory_populated) return; // inventory must be open and unpopulated by this point Container cont = ((GuiContainer) screen).inventorySlots; for (int i = 0; i < cont.inventorySlots.size(); i++) { ItemStack stack = cont.inventorySlots.get(i).getStack(); String name = stack.getItem().getRegistryName().getResourcePath(); if (name != "air") { inventory_populated = true; ExampleMod.logger.info("> Inventory populated"); break; } } if (!inventory_populated) return; // inventory is now populated for (int i = 0; i < cont.inventorySlots.size(); i++) { ItemStack stack = cont.inventorySlots.get(i).getStack(); String name = stack.getItem().getRegistryName().getResourcePath(); ExampleMod.logger.info("> Slot " + i + ": " + name); } }
  15. I'm already registering the event handler. I'm dealing with custom inventories which servers show, not the normal player inventory
  16. I now have a simple setup which is able to detect the inventory opening and closing, but it always says the inventory is empty, probably because the server hasn't sent the items over yet. Should I keep waiting for the inventory to be populated, and if so, how can I know? I can't see any methods related to it. private boolean inventory_open = false; @SubscribeEvent public void onPlayerTick(TickEvent.PlayerTickEvent event) { GuiScreen screen = Minecraft.getMinecraft().currentScreen; if (screen instanceof GuiInventory) { if (inventory_open) return; inventory_open = true; ExampleMod.logger.info("> Inventory opened"); } else { if (!inventory_open) return; inventory_open = false; ExampleMod.logger.info("> Inventory closed"); return; } Container cont = ((GuiInventory) screen).inventorySlots; for (int i = 0; i < cont.inventorySlots.size(); i++) { ExampleMod.logger.info("Slot " + i + ": " + cont.inventorySlots.get(i).getSlotTexture()); } }
  17. Ok, I've read that, but I can't find the right event type - it seems Forge doesn't support it. Isn't the idea to be able to modify the game, ie. change anything you want?
  18. Hi, I'm new to modding but experienced in server plugin development. I have no idea where to start. I'm trying to capture the InventoryOpenEvent so I can output some metadata of the items to a file. This is what I have so far - I can't seem to use @EventHandler . How can I achieve this? package com.example.examplemod; import org.apache.logging.log4j.Logger; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod.EventHandler; import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; @Mod(modid = ExampleMod.MODID, name = ExampleMod.NAME, version = ExampleMod.VERSION) public class ExampleMod { public static final String MODID = "examplemod"; public static final String NAME = "Example Mod"; public static final String VERSION = "1.0"; private static Logger logger; @EventHandler public void preInit(FMLPreInitializationEvent event) { logger = event.getModLog(); } @EventHandler public void init(FMLInitializationEvent event) { logger.info("Client Started"); // ? } }
×
×
  • Create New...

Important Information

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