Jump to content

FireController1847

Members
  • Posts

    290
  • Joined

  • Last visited

Everything posted by FireController1847

  1. Is it possible to get the world and player from the ClientConnectedToServerEvent? Both mc.player and mc.world are null. I need to get the UUID and I want to send a chat message on launch (a client side chat message, I'm making a mostly client side mod).
  2. Thanks so much! (If you want proof of verification on why I needed this I can link you to the first release of the mod when I release it)
  3. Also, if I were to use WorldEvent.Load, how would I detect if it's a singleplayer world vs a multiplayer world, as it seems the event fires multiple times on the client, as well as having world.isRemote true at one point. Another issue with the WorldEvent.Load is how would I be able to filter out changing dimension? Why can't I just use PlayerLoggedInEvent?
  4. There is no .getPlayer() and .player is null when the event gets called. This also doesn't solve my issue of the PlayerLoggedInEvent not being called when I connect to a server.
  5. Ahh, okay, that makes sense. So now my question is what events would I use to be able to seperate the two? I can use PlayerLoggedInEvent for singleplayer, obviously, as it seems to only happen during singleplayer, but what other event will run for first time login on multiplayer? I can't use WorldEvent.Load, as that fires also on changing dimension (as far as I've read & tested), as well as being unable to fetch the player within that event.
  6. I know this isn't helpful and if I get asked I'll delete this response, but I really, really do not suggest using Fluctis, especially if you plan on keeping this server long term. Click here to see my reasons why.
  7. I'm trying to make a mod that requires me to detect when the Client joins a Singleplayer world, and when the Client joins a Multiplayer world. I've used PlayerLoggedInEvent, and have checked if world.isRemote (that being said, I'm not sure I fully understand what isRemote is, as it was false every time I connected to a singleplayer world and was never true even when connecting to a server), and that works fine for singleplayer worlds. When I connect to a server, though, the event doesn't even seem to be called. Here's the code I've been testing: @SubscribeEvent public void onLogin(PlayerLoggedInEvent event) { MCDRP.logger.info("WORKING"); World world = event.player.getEntityWorld(); if (!world.isRemote) { MCDRP.logger.info("World loaded."); // Do stuff for singleplayer world return; } MCDRP.logger.info("Server loaded."); System.out.println(world.getMinecraftServer().getName()); } @SubscribeEvent public void onLogout(PlayerLoggedOutEvent event) { // Handle leaving the server / exiting the world } What events do I use to separate the singleplayer load from the multiplayer connect?
  8. Is there an event for when a song ends? I've been looking all over and I can't seem to find one. I'm looking for when a piece of music ends (say the menu music, ex. Mutation (Menu)), to do something.
  9. I want to add a new entry to the list variable I just set above, but I just noticed that the rpr.getRepositoryEntriesAll() returns an ImmutableList, so I'm not sure what to do.
  10. I'll explain the lines one by one. ResourcePackRepository rpr = Minecraft.getMinecraft().getResourcePackRepository(); Class cls = ResourcePackRepository.class; Method md = cls.getDeclaredMethod("getResourcePack", File.class); md.setAccessible(true); IResourcePack myNewPack = (IResourcePack) md.invoke(rpr, new File("E:\\Users\\FireController1847\\Desktop\\Faithful 1.12.2-rv4.zip")); This creates a new valid ResourcePack by getting the private method "getResourcePack" from ResourcePackRepository. Class cls2 = Entry.class; Constructor cn = cls2.getDeclaredConstructor(ResourcePackRepository.class, IResourcePack.class); cn.setAccessible(true); Entry entry = (Entry) cn.newInstance(rpr, myNewPack); System.out.println(entry); This gets the private constructor of Entry and creates a new instance of it using the IResourcePack we made above. List<Entry> repos = rpr.getRepositoryEntriesAll(); repos.add(entry); rpr.setRepositories(repos) This is where I didn't really know where to go. I attempted to add the Entry into all of the entries (therefore enabling the resource pack), but it comes up with the error listed in the comment above.
  11. Actually, I've managed to successfully load and improve the class (the second you posted this lol). I do have a new issue now, though. Here's my current code: try { ResourcePackRepository rpr = Minecraft.getMinecraft().getResourcePackRepository(); Class cls = ResourcePackRepository.class; Method md = cls.getDeclaredMethod("getResourcePack", File.class); md.setAccessible(true); IResourcePack myNewPack = (IResourcePack) md.invoke(rpr, new File( "E:\\\\Users\\\\FireController1847\\\\Desktop\\\\Forge\\\\Testing\\\\run\\\\resourcepacks\\\\Faithful1.12.2-rv4.zip")); Class cls2 = Entry.class; Constructor cn = cls2.getDeclaredConstructor(ResourcePackRepository.class, IResourcePack.class); cn.setAccessible(true); Entry entry = (Entry) cn.newInstance(rpr, myNewPack); System.out.println(entry); List<Entry> repos = rpr.getRepositoryEntriesAll(); repos.add(entry); rpr.setRepositories(repos); } catch (Exception e) { LogManager.getLogger().error(e); StackTraceElement[] stack = e.getStackTrace(); for (StackTraceElement trace : stack) { LogManager.getLogger().error(trace); } } The error comes on the repos.add(entry) line. [21:21:14] [main/ERROR] [com.firecontrol.testmod.Handlers.BlockHandler]: java.lang.UnsupportedOperationException [21:21:14] [main/ERROR] [com.firecontrol.testmod.Handlers.BlockHandler]: com.google.common.collect.ImmutableCollection.add(ImmutableCollection.java:218) [21:21:14] [main/ERROR] [com.firecontrol.testmod.Handlers.BlockHandler]: com.firecontrol.testmod.Handlers.BlockHandler.onActionPerformed(BlockHandler.java:106) [21:21:14] [main/ERROR] [com.firecontrol.testmod.Handlers.BlockHandler]: net.minecraftforge.fml.common.eventhandler.ASMEventHandler_11_BlockHandler_onActionPerformed_Pre.invoke(.dynamic) [21:21:14] [main/ERROR] [com.firecontrol.testmod.Handlers.BlockHandler]: net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:90) [21:21:14] [main/ERROR] [com.firecontrol.testmod.Handlers.BlockHandler]: net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:179) [21:21:14] [main/ERROR] [com.firecontrol.testmod.Handlers.BlockHandler]: net.minecraft.client.gui.GuiScreen.mouseClicked(GuiScreen.java:489) [21:21:14] [main/ERROR] [com.firecontrol.testmod.Handlers.BlockHandler]: net.minecraft.client.gui.GuiMultiplayer.mouseClicked(GuiMultiplayer.java:441) [21:21:14] [main/ERROR] [com.firecontrol.testmod.Handlers.BlockHandler]: net.minecraft.client.gui.GuiScreen.handleMouseInput(GuiScreen.java:611) [21:21:14] [main/ERROR] [com.firecontrol.testmod.Handlers.BlockHandler]: net.minecraft.client.gui.GuiMultiplayer.handleMouseInput(GuiMultiplayer.java:90) [21:21:14] [main/ERROR] [com.firecontrol.testmod.Handlers.BlockHandler]: net.minecraft.client.gui.GuiScreen.handleInput(GuiScreen.java:576) [21:21:14] [main/ERROR] [com.firecontrol.testmod.Handlers.BlockHandler]: net.minecraft.client.Minecraft.runTick(Minecraft.java:1884) [21:21:14] [main/ERROR] [com.firecontrol.testmod.Handlers.BlockHandler]: net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1186) [21:21:14] [main/ERROR] [com.firecontrol.testmod.Handlers.BlockHandler]: net.minecraft.client.Minecraft.run(Minecraft.java:441) [21:21:14] [main/ERROR] [com.firecontrol.testmod.Handlers.BlockHandler]: net.minecraft.client.main.Main.main(Main.java:118) [21:21:14] [main/ERROR] [com.firecontrol.testmod.Handlers.BlockHandler]: sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [21:21:14] [main/ERROR] [com.firecontrol.testmod.Handlers.BlockHandler]: sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) [21:21:14] [main/ERROR] [com.firecontrol.testmod.Handlers.BlockHandler]: sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) [21:21:14] [main/ERROR] [com.firecontrol.testmod.Handlers.BlockHandler]: java.lang.reflect.Method.invoke(Unknown Source) [21:21:14] [main/ERROR] [com.firecontrol.testmod.Handlers.BlockHandler]: net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [21:21:14] [main/ERROR] [com.firecontrol.testmod.Handlers.BlockHandler]: net.minecraft.launchwrapper.Launch.main(Launch.java:28) [21:21:14] [main/ERROR] [com.firecontrol.testmod.Handlers.BlockHandler]: sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [21:21:14] [main/ERROR] [com.firecontrol.testmod.Handlers.BlockHandler]: sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) [21:21:14] [main/ERROR] [com.firecontrol.testmod.Handlers.BlockHandler]: sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) [21:21:14] [main/ERROR] [com.firecontrol.testmod.Handlers.BlockHandler]: java.lang.reflect.Method.invoke(Unknown Source) [21:21:14] [main/ERROR] [com.firecontrol.testmod.Handlers.BlockHandler]: net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) [21:21:14] [main/ERROR] [com.firecontrol.testmod.Handlers.BlockHandler]: GradleStart.main(GradleStart.java:26)
  12. It might help if I noted, to get the code to run you have to click "Explode" on the Multiplayer menu.
  13. So I'm attempting the Reflection method, but it's saying it cannot find the constructor? (Sorry, this is my first time with relfections and AHHHHHHHHH) Constructor entry = ReflectionHelper.findConstructor(Entry.class, File.class); System.out.println(entry); Error [19:49:40] [main/ERROR] [FML]: Exception caught during firing event net.minecraftforge.client.event.GuiScreenEvent$ActionPerformedEvent$Pre@65b11833: net.minecraftforge.fml.relauncher.ReflectionHelper$UnknownConstructorException: Could not find constructor 'Entry(java.io.File)' in class net.minecraft.client.resources.ResourcePackRepository$Entry at net.minecraftforge.fml.relauncher.ReflectionHelper.findConstructor(ReflectionHelper.java:270) ~[forgeSrc-1.12.2-14.23.0.2503.jar:?] at com.firecontrol.testmod.Handlers.BlockHandler.onActionPerformed(BlockHandler.java:92) ~[BlockHandler.class:?] at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_9_BlockHandler_onActionPerformed_Pre.invoke(.dynamic) ~[?:?] at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:90) ~[ASMEventHandler.class:?] at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:179) [EventBus.class:?] at net.minecraft.client.gui.GuiScreen.mouseClicked(GuiScreen.java:489) [GuiScreen.class:?] at net.minecraft.client.gui.GuiMultiplayer.mouseClicked(GuiMultiplayer.java:441) [GuiMultiplayer.class:?] at net.minecraft.client.gui.GuiScreen.handleMouseInput(GuiScreen.java:611) [GuiScreen.class:?] at net.minecraft.client.gui.GuiMultiplayer.handleMouseInput(GuiMultiplayer.java:90) [GuiMultiplayer.class:?] at net.minecraft.client.gui.GuiScreen.handleInput(GuiScreen.java:576) [GuiScreen.class:?] at net.minecraft.client.Minecraft.runTick(Minecraft.java:1884) [Minecraft.class:?] at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1186) [Minecraft.class:?] at net.minecraft.client.Minecraft.run(Minecraft.java:441) [Minecraft.class:?] at net.minecraft.client.main.Main.main(Main.java:118) [Main.class:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_144] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_144] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_144] at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_144] at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.12.jar:?] at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.12.jar:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_144] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_144] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_144] at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_144] at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) [start/:?] at GradleStart.main(GradleStart.java:26) [start/:?] [19:49:40] [main/ERROR] [FML]: Index: 1 Listeners: [19:49:40] [main/ERROR] [FML]: 0: NORMAL [19:49:40] [main/ERROR] [FML]: 1: ASM: com.firecontrol.testmod.Handlers.BlockHandler@16858bf6 onActionPerformed(Lnet/minecraftforge/client/event/GuiScreenEvent$ActionPerformedEvent$Pre;)V
  14. Wait, what wiki are we talking about? If we're talking about the Forge Documentation, where is it? -- From what I've read online, how does this tie into what I'm doing? -- Do you have any examples of people doing this? (I work best that way. I know, lame)
  15. To be honest, my first issue comes into place where I'm not exactly sure if I'm even using the right components. As of right now, I'm attempting to create a new "Entry" (ResourcePackRepository$Entry) and insert it into Minecraft.getMinecraft().getResourcePackRepository(). But due to the fact the constructor of Entry is private, I can't create a new Entry therefore I can't test by adding a new element into the ResourcePackRepository net.minecraft.client.resources.ResourcePackRepository$Entry @SideOnly(Side.CLIENT) public class Entry { private final IResourcePack reResourcePack; private PackMetadataSection rePackMetadataSection; private ResourceLocation locationTexturePackIcon; // Private private Entry(File resourcePackFileIn) { this(ResourcePackRepository.this.getResourcePack(resourcePackFileIn)); } // Private private Entry(IResourcePack reResourcePackIn) { this.reResourcePack = reResourcePackIn; }
  16. But you can see why I'd want to do this, I assume. Either way, this is also good knowledge for future plans that I might have that I'd prefer not to state yet.
  17. Think of it this way: You have some modpacks on technic, ftb, some custom mods on the main thing, and ATLauncher, but you want all of them to access the same resourcepack file. This file would have to be literally copied (on windows) to each resourcepack file, and if it's a large resourcepack this could take quite a bit of space. This is supposed to allow you to load only one file without the need to copy it at all.
  18. The only resource packs that show up in that menu are those located at the minecraft profile/resourcepacks. My implimentation will open a popup menu where you could have resourcepacks in your downloads folder, your desktop, wherever you want. This means that you can select resourcepacks manually from anywhere on your PC instead of just located to your profile/resourcepacks.
  19. I've been poking around the ResourcePackRepository files and a bunch similar to it, and I have yet to find a way to insert my own resource pack manually into the list. This is what I'm attempting to do: I'll add a button to the resource pack screen that says "Add External Pack...", and when the user clicks this button it will load a ResourcePack from wherever the file was. This provides temporary or permanent ways to not have to find the .resourcepacks folder. For example, if you don't want to copy the same resource pack over and over and over again. I know how to get the file path and location, but I'm having issues adding it manually. I've tested by creating a new ResourcePackRepository$Entry, and due to the fact that the constructors are private, I cannot do this. Am I looking through the wrong files? Is there something else I should be doing entirely? How do I do this? Here's what I've got so far (ignore the fact the button is in the Multiplayer screen, I was messing around): @SubscribeEvent public void onActionPerformed(ActionPerformedEvent.Pre event) { if (event.getGui() instanceof GuiMultiplayer && event.getButton().id == 9) { // JFileChooser fc = new JFileChooser(); // fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); // fc.getActionMap().get("viewTypeDetails").actionPerformed(null); // fc.setPreferredSize(new Dimension(1200, 900)); // try { // UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); // } catch (Exception e) { // } // if (fc.showOpenDialog(fc) == JFileChooser.APPROVE_OPTION) { // System.out.println(fc.getSelectedFile().getAbsolutePath()); // } ResourcePackRepository rpr = Minecraft.getMinecraft().getResourcePackRepository(); List<Entry> repos = rpr.getRepositoryEntriesAll(); System.out.println(repos); for (Entry repo : repos) { System.out.println(repo); } Entry e = new Entry(new File("E:\\Users\\xxxx\\Desktop\\xxxx\\xxxx\\run\\resourcepacks\\Faithful 1.12.2-rv4.zip")); System.out.println(e); // repos.add(e); // rpr.setRepositories(repos); } }
  20. Well, it seems the problem happened to solve itself I guess. Mine stops when I shut off my resource pack (64x), so obviously that's from my GPU on my laptop not being powerful enough. My friend's stops after about 10-15 minutes of playing, so I guess it's fixed. Unless you still want those logs.
  21. Sorry, I forgot to note that I tried this without any mods installed too *whoops*
×
×
  • Create New...

Important Information

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