Jump to content

frxtn

Members
  • Posts

    18
  • Joined

  • Last visited

Everything posted by frxtn

  1. Hence I didnt ask about asm but how to run in obf without bulding first. This is purely a convenience question, love how people here dig aorund in questions just to find a way to not contribute anything helpful.
  2. To debug transformed bytecode in an obf environment.
  3. Heya, I would like to run my client obfuscated without building it first but can't find shit while googling. Is that possible and if yes, how?
  4. I'm not disagreeing with you as this is somewhat exactly what i meant when I said "but as long as nobody searches for injection nodes by opcode without verifying context". I also understand that i have to retract from my initial statement a bit, since having my shit messed up is really easy no matter how well I think i'm doing it. i'm still standing with having it done decently (on a technical level), but i will remove the entity class patches for the mount dismount events and i will see if i missed any other forge events for which i injected custom bytecode. i want to keep my mod as unobstrusive as possible after all.
  5. i have no idea how i missed that in the event type hierarchy. seriously ... lol. i know that if people inject shitty bytecode it could mess up shit, but as long as nobody searches for injection nodes by opcode without verifying context there shouldnt be any problems. i always insert pre-events as closed if's (if cancelable) and post events as single method invokes.
  6. damn, now that's news. i gotta say i was struggling with finding readables about anything going beyond standard forge coding so i didnt come across this at all. my coremod doesnt only supply events from networkmanager though, i also injected a bunch of other events which i need (player mounted rideable/player dismounted rideable yadda yadda) so i guess having my coremod isn't too bad after all. and, dont worry, i'm handling it carefully. i'm only injecting enclosed code which cant possibly interfere with other people's code.
  7. i couldnt find another way of injecting custom cancelable and stageable events edit:// with "intercepting" packages i meant also being able to get the event stage and having the option to cancel both sending packages and processing received packages
  8. knowing that the 2nd method is gone with 1.13 i will use method nr 1. my coremod is already separated from my main mod (and yes i needed one to intercept vanilla packets but i did that and it works like a charm and shouldnt conflict with other mods either, since i injected unintrusive bytecode only.) thank you nonetheless!
  9. Heya, I'm kinda conflicted on how to implement my accesstransformer. I read a lot of stuff and i ended up with two ways: 1. by telling my build.gradle to move my *_at.cfg to meta-inf and adding a manifest attribute FMLAT specifying my accesstransformer cfg and running setupDecompWorkspace everytime i change something about it 2. by extending AccessTransformer and linking my *_at.cfg in the superconstructor (and link to it from my coremod-class?). so which is the right way?
  10. well i can't even intercept it anyways with forge standard means right?
  11. This is one of the most powerful tools of a programmer
  12. it definitely can, i have seen mods that do this, the server sends a packet instanceof SPacketTimeUpdate on every tick.
  13. Hello, i am trying to make a little info-hud including useful information such as FPS and Ping. I also want to include the server-TPS in the hud but I can't find a way to do it in "vanilla forge". i don't think there is an event that lets me count server ticks from the client. If i had a packet received event I could check if it was instanceof SPacketTimeUpdate and could probably calculate the time between receiving those but afaik the only way of getting such event was to use ASM which i don't think i am knowledgeable enough for. am i missing a very obvious and easy solution?? EDIT: To avoid any misconceptions: The mod is supposed to run on the client only!
  14. After reading through this I must say I haven't gotten anything from it that really helps me continue. My problem actually lies way before the class loading itself, my code can't seem to locate the classes in the first place, although i'm giving the right package. I will include sample code which I used and how I failed so far: public static Collection<Class<?>> find(String path) { String scannedPath = path.replace(PKG_SEPARATOR, DIR_SEPARATOR); URL scannedUrl = Thread.currentThread().getContextClassLoader().getResource(scannedPath); if (scannedUrl == null) { throw new IllegalArgumentException(String.format(BAD_PACKAGE_ERROR, scannedPath, path)); } File scannedDir = new File(scannedUrl.getFile()); List<Class<?>> classes = new ArrayList<Class<?>>(); for (File file : scannedDir.listFiles()) { Logger.info("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!MODULE FOUND!!!!!!!!!!!!!!!!!!!!!!!!"); //this was just to debug if a class was found classes.addAll(find(file, path)); } return classes; } private static List<Class<?>> find(File file, String scannedPackage) { List<Class<?>> classes = new ArrayList<Class<?>>(); String resource = scannedPackage + PKG_SEPARATOR + file.getName(); if (file.isDirectory()) { for (File child : file.listFiles()) { classes.addAll(find(child, resource)); } } else if (resource.endsWith(CLASS_FILE_SUFFIX)) { int endIndex = resource.length() - CLASS_FILE_SUFFIX.length(); String className = resource.substring(0, endIndex); try { classes.add(Class.forName(className)); } catch (ClassNotFoundException ignore) { } } return classes; } I put "com.mymod.modules" and "com.mymod.modules.*" as the package (which, as i checked, is the package my module classes are in). It didn't find them. Neither did this implementation: /** * Private helper method * * @param directory * The directory to start with * @param pckgname * The package name to search for. Will be needed for getting the * Class object. * @param classes * if a file isn't loaded but still is in the directory * @throws ClassNotFoundException */ private static void checkDirectory(File directory, String pckgname, ArrayList<Class<?>> classes) throws ClassNotFoundException { File tmpDirectory; if (directory.exists() && directory.isDirectory()) { final String[] files = directory.list(); for (final String file : files) { if (file.endsWith(".class")) { try { classes.add(Class.forName(pckgname + '.' + file.substring(0, file.length() - 6))); } catch (final NoClassDefFoundError e) { // do nothing. this class hasn't been found by the // loader, and we don't care. } } else if ((tmpDirectory = new File(directory, file)) .isDirectory()) { checkDirectory(tmpDirectory, pckgname + "." + file, classes); } } } } /** * Private helper method. * * @param connection * the connection to the jar * @param pckgname * the package name to search for * @param classes * the current ArrayList of all classes. This method will simply * add new classes. * @throws ClassNotFoundException * if a file isn't loaded but still is in the jar file * @throws IOException * if it can't correctly read from the jar file. */ private static void checkJarFile(JarURLConnection connection, String pckgname, ArrayList<Class<?>> classes) throws ClassNotFoundException, IOException { final JarFile jarFile = connection.getJarFile(); final Enumeration<JarEntry> entries = jarFile.entries(); String name; for (JarEntry jarEntry = null; entries.hasMoreElements() && ((jarEntry = entries.nextElement()) != null);) { name = jarEntry.getName(); if (name.contains(".class")) { name = name.substring(0, name.length() - 6).replace('/', '.'); if (name.contains(pckgname)) { classes.add(Class.forName(name)); } } } } /** * Attempts to list all the classes in the specified package as determined * by the context class loader * * @param pckgname * the package name to search * @return a list of classes that exist within that package * @throws ClassNotFoundException * if something went wrong */ public static ArrayList<Class<?>> getClassesForPackage(String pckgname) throws ClassNotFoundException { final ArrayList<Class<?>> classes = new ArrayList<Class<?>>(); try { final ClassLoader cld = Thread.currentThread() .getContextClassLoader(); if (cld == null) throw new ClassNotFoundException("Can't get class loader."); final Enumeration<URL> resources = cld.getResources(pckgname .replace('.', '/')); URLConnection connection; for (URL url = null; resources.hasMoreElements() && ((url = resources.nextElement()) != null);) { try { connection = url.openConnection(); if (connection instanceof JarURLConnection) { checkJarFile((JarURLConnection) connection, pckgname, classes); } else { try { checkDirectory( new File(URLDecoder.decode(url.getPath(), "UTF-8")), pckgname, classes); } catch (final UnsupportedEncodingException ex) { throw new ClassNotFoundException( pckgname + " does not appear to be a valid package (Unsupported encoding)", ex); } } } catch (final IOException ioex) { throw new ClassNotFoundException( "IOException was thrown when trying to get all resources for " + pckgname, ioex); } } } catch (final NullPointerException ex) { throw new ClassNotFoundException( pckgname + " does not appear to be a valid package (Null pointer exception)", ex); } catch (final IOException ioex) { throw new ClassNotFoundException( "IOException was thrown when trying to get all resources for " + pckgname, ioex); } return classes; } I also tried half a dozen other implementations of any form of package scanning. I have no idea why i cant find any classes.
  15. For convenience sake, right now the number of module classes is still overviewable yet with time i plan on adding a great amount of modules. If i have 100 modules i really don't want to manually instaniate every single one of them. upon removing one i'd have to manually remove the instantiation too. i can imagine that classpath scanning can result in problems, yet i really want to implement this. i might ofc, like you said, find out that it is causing me more problems than good, and i will gladly accept it but i want to at least get it to work so I can personally make the experience. Who knows, even if it is not directly useful, i might at least learn something new. so if you (from the little info i could provide rn) could give me a starting step (or tell me to write up a sample implementation the way i tried it before so you can better see what my mistake is) I would really appreciate it. regards
  16. Heya, I am working on a utility mod for minecraft. So far I have loaded the mod classes through plain instantiation in the manager constructor. I decided that I wanted to load classes dynamically from the mod package so that i don't have to manually instantiate them (and remove them when i decide i dont want to use them). So far I tried literally a dozen methods i found on stackoverflow or in this forum, but none would find any class in my class package although it definitely contains them. A selection of methods i tried using: I am somewhat new to java,having a background in c++/c#. I am really desperately looking for a solution. I am trying to load all classes from my package "com.mymod.mods.*" (i tried using the package name with and without the .*). I tried implementing the methods in the preInit and also in the init. I am losing my mind over this and i can't bring myself to continue working on the actual mod until i resolved this issue and believe me, i spent hours over hours trying to fix this on my own through googling and trying. Right now i really feel like i am missing a vital bit of understanding that's keeping me from progressing in this issue. I am aware that the information i'm presenting might be lacking, I just can't put my finger on what exactly i should provide in terms of information. I am gladly providing you any info you need if you could specify what you need to know in order to help me (or in order to understand my issue better!) I would really appreciate any help you guys can give me!!
×
×
  • Create New...

Important Information

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