Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

I am kinda lost here.

 

Class<?> clazz = urlClassLoader.loadClass(name.substring(0, name.length() - 6).replaceAll("/", "."));

And it is SkillFireball for sure (I can print fields/method names)

System.out.println(clazz.isInstance(SkillCast.class));
System.out.println(SkillCast.class.isInstance(clazz));
System.out.println(SkillCast.class.isAssignableFrom(clazz));
System.out.println(clazz.isAssignableFrom(SkillCast.class));

public class SkillFireball extends SkillCast implements ISkillThrown
public abstract class SkillCast extends Skill

My prints are ALL false. Note: I am loading classes with ClassLoader (might be important).

 

Anyone has idea?

 

Goal: obviously, get 'true' if class is child of SkillCast.

 

1.7.10 is no longer supported by forge, you are on your own.

  • Author

Well, I know it makes no sense, I've been reading docs for past 30min, but it still is NOT working (made it to make sure).

 

I am using new ClassLoader for my Skill API. You can make skills compile them into jars and throw into gameDir/RoA/Skills/...

SkillLoader will read this dir for .jar-s and scan them for classes that are childs of Skill / SkillCast and register them into my SkillRegistry.

 

System is designed to dynamically load stuff and also send skills to client and load them in runtime (on both client/server).

 

EDIT:

Can this be caused that API is loded by Forge (as a mod) and Skill.jar-s are loaded by different loader?

 

Looking at this:

Why do you use a new ClassLoader? :o

I think that's the problem. How can I get forge's/Minecraft ClassLoader?

1.7.10 is no longer supported by forge, you are on your own.

It's better to make a system where users can make skills into text or JSON files, then you interpret them into Java.

Maker of the Craft++ mod.

  • Author

Okay, I am apparently totally green here. I know now that I need to load new classes (skills) into same classLoader as my mod.

 

How can I do that?

 

ClassLoader cl = Loader.instance().getModClassLoader();

 

I seriously have no idea how to ADD new classees to existing CL.

 

I know this will crash, obviously, I want to know how to put (load .jar-s) my urls list into mod's CL.

//urls are URI to my .jar-s
ClassLoader cl = Loader.instance().getModClassLoader();
urlClassLoader = URLClassLoader.newInstance(urls.toArray(new URL[urls.size()]), cl);

 

@Anon10W1z

Structure goes:

Mod - handles skills

API - allows to make new skills

Config - allows to script skills using coded skills via API. That means you can make new skills using ones coded in code (obviously, that is smarter than coding skill using forge methods inside json/txt).

1.7.10 is no longer supported by forge, you are on your own.

  • Author

Actually I've done it, it was more lack of knowledge about ClassLoaders and how Java loads classes.

 

skillClassLoader = URLClassLoader.newInstance(urls.toArray(new URL[urls.size()]), Loader.instance().getModClassLoader());

Loads skill.jar-s to child loader.

//where name is url to this class file
Class<?> clazz = Loader.instance().getModClassLoader().loadClass(name.substring(0, name.length() - 6).replaceAll("/", "."));
if (SkillCast.class.isAssignableFrom(clazz))
//do stuff

 

I was badly accessing created classes.

 

Problem solved.

 

And how it works:

Mod processes data and has API that allows you to make Skills.

There are build-in set of skills (like fireballs, some other stuff, will be more with every update), but also if there is lack of something, some dev might wanna create new skill - and he can.

Config allows you to without java interaction get ANY pre-made skill to be get and used to script custom one. Most of skills can still be made without any java interaction, API is only for advanced stuff and special rendering (which is also the reason I want to send skill.jar to client).

 

Thread closed.

 

 

1.7.10 is no longer supported by forge, you are on your own.

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.