You'll notice that there's an overload for the Class.forName method which takes a classLoader as its third argument, basically what you need to do is load a class using Class.forName but passing in Launch.classLoader as the third argument.
The issue is linkage, basically if you reference a class from another class, the first time it's referenced is when it gets loaded by the classLoader, however, I think that in this case because the issue is that it fails when it's already been loaded before in the parent classloader, it *might* be okay.
and assign to a local variable. The minor issue is that if the local variable itself is what causes the class load event, then your Class.forName call will be "too late" because the class load will have already been triggered. However there's a simple way around that:
Basically new classes loaded from within another "inherit" the class loading scope of the containing class (so for example if you cause a class to be loaded from inside your mod, it gets loaded in ModClassLoader) so this gives you a convenient work-around, namely make a simple helper class which contains all the references to the input dealio, and instance that class using Class.forName in the LaunchClassLoader context.
So basically, imagine you have:
public interface InputSystemAdapter
{
public abstract void initInputSystem(YourModClass mod);
}
public class InputSystemAdapterImpl implements InputSystemAdapter
{
public InputSystemAdapterImpl() // will need a default ctor for this!
{
}
@Override
public void initInputSystem(YourModClass mod)
{
// Can reference this directly since we're already in the correct classloader context
DirectAndRawInputEnvironmentPlugin.blah();
// In case you want to check that you're in the correct context
System.err.println("InputSystemAdapterImpl's classloader is " + this.getClass().getClassLoader().getClass().getSimpleName());
mod.callBack(controllers); // mod can't have a reference to us, but we can call methods on the mod to pass stuff back to it
}
}
Then in your mod
private void initInputSystem()
{
// Notice that we assign the concrete implementation to a variable
// typed by the interface, this is because the interface can be safely
// loaded in *this* classLoader context but we want the actual adapter
// to be loaded by LaunchClassLoader
InputSystemAdapter adapter = Class.forName("com.whatever.InputSystemAdapterImpl", true, Launch.classLoader).newInstance();
// Call the method on the interface which our concrete class (which was loaded in
// LaunchClassLoader) implements.
adapter.initInputSystem(this);
}
public void callBack(Controllers[] controllers)
{
// Some callback from the input system adapter
}
}
Does that kind of make sense? Basically it means that the mod class never directly references the input system, what it does is load a class which does in the LaunchClassLoader context and then leverages the fact that classLoader context is inherited to do all the initialisation stuff without resorting to reflection, the only reflection is the single call to newInstance() which is of course very cheap and fast.
Yes, that does make sense. And thanks for making it so clear! When I finish up my latest update I'll give your solution a try.
Ah yes that makes sense, there really is no way they can coexist when this issue will basically be always present if two systems using different classLoaders want to use that API. To be honest what I outlined above gives you the best fighting chance really since you're only "breaking out" of your classLoader context long enough to initialise the API. You could even submit a PR to forge itself to have the API initialised in the LaunchClassLoader (because the majority of the Forge API exists directly in LaunchClassLoader so it's much easier to do) and then any forge mods can use that method to obtain the controllers.
Another (controversial maybe) suggestion would actually be to make this into a litemod, I think you'll be surprised at how simple that could be. In fact if I have time I would happily look at it for you, since AbrarSyed is actually adding LiteLoader support into ForgeGradle so that people can use one build environment to build both kinds of mods, thus it would actually be possible very soon to have one project which can actually be compiled to two artefacts and thus loaded by either system.
I am considering the possibility of making this a litemod since what I'm doing in Joypad mod aligns more with the problems LiteLoader is trying to solve. When I get some more time I'll have a closer look at LiteLoader and see how much it would make sense to do that.
If you are interested we are on github https://github.com/ljsimin/MinecraftJoypadSplitscreenMod but the code has changed a lot from the main branch and I'm working mostly out of the sub branches for (1.7.2 / 1.6.4 )
.
The Meaning of Life, the Universe, and Everything.
Location:
Knife River Mn
Join Date:
10/27/2012
Posts:
45
Location:
46.95233 -91.80693
Minecraft:
Quantarious
Member Details
I have found a bug with joy pad mod and mo'creatures, You can start on a single player world with EVERY thing fine but once you Host a lan server or join an actual server you cant jump but then you can have to configure mo creatures jump from A to something else and then you wont be able to break anything until you change mo creatures dive to something else as well, its only a small bug but if someone that loves Mo creatures mod and your but isn't smart enough to look for control conflict.
I have found a bug with joy pad mod and mo'creatures, You can start on a single player world with EVERY thing fine but once you Host a lan server or join an actual server you cant jump but then you can have to configure mo creatures jump from A to something else and then you wont be able to break anything until you change mo creatures dive to something else as well, its only a small bug but if someone that loves Mo creatures mod and your but isn't smart enough to look for control conflict.
Thanks for the report. Which version of the joypad mod are you using?
Have you tried with the latest (experimental) version?
Thanks for the report. Which version of the joypad mod are you using?
Have you tried with the latest (experimental) version?
1.6.4 -0.09-Experimental Link Removed
1.7.2 -0.09-Experimental Link Removed
Sorry, didn't recognize that you posted earlier and that you're using the 0.09 experiemental. Are you seeing problems hosting / joining using the in-game lan or the server? Is this a problem with one player using the joypad or are both players using the joypad splitscreen?
Sorry, didn't recognize that you posted earlier and that you're using the 0.09 experiemental. Are you seeing problems hosting / joining using the in-game lan or the server? Is this a problem with one player using the joypad or are both players using the joypad splitscreen?
well my cousin is using joy pad mod but changing the keys for mo creature seems to work pretty well but I also noticed that after a certain amount of time he isn't able to break blocks until i click on his screen and break one for him but its fin after that for x amount of minutes.
well my cousin is using joy pad mod but changing the keys for mo creature seems to work pretty well but I also noticed that after a certain amount of time he isn't able to break blocks until i click on his screen and break one for him but its fin after that for x amount of minutes.
Yup, confirmed the bug in 1.6.4. Thats a pretty big deal breaker for splitscreen. Great find!
It happens whenever the player using the joypad doesn't have window focus and they open a container or menu. After this point they cannot break blocks.
Yup, confirmed the bug in 1.6.4. Thats a pretty big deal breaker for splitscreen. Great find!
It happens whenever the player using the joypad doesn't have window focus and they open a container or menu. After this point they cannot break blocks.
Otherwise, I'll have a fix for that and put it up over the experimental version sometime later today.
I've updated these:
1.6.4 -0.09-Experimental Link Removed
1.7.2 -0.09-Experimental Link Removed
It includes an early version of custom keys. Its a bit clunky at present but works.
To use this (in controls menu)
1) Press custom key button
2) Press the keyboard key you wish to bind
3) It will show up in the list box
4) Scroll down to it in the list box and double click it
5) Press the button on your controller to bind it to that key
This is an early version so there are many bugs around this but I'm pushing out an early version now to address another fix, and since it kinda works to give you guys something new and hopefully a better experience with some mods.
The biggest bug around this is that you can't remove old bindings from the menu (you can in the config file) and that if a particular controller input is mapped to another action, whichever one gets called first will be executed.
Also, it will send a single press of the key and not hold it but that will be an option in the future.
It includes an early version of custom keys. Its a bit clunky at present but works.
To use this (in controls menu)
1) Press custom key button
2) Press the keyboard key you wish to bind
3) It will show up in the list box
4) Scroll down to it in the list box and double click it
5) Press the button on your controller to bind it to that key
This is an early version so there are many bugs around this but I'm pushing out an early version now to address another fix, and since it kinda works to give you guys something new and hopefully a better experience with some mods.
The biggest bug around this is that you can't remove old bindings from the menu (you can in the config file) and that if a particular controller input is mapped to another action, whichever one gets called first will be executed.
Also, it will send a single press of the key and not hold it but that will be an option in the future.
1.6.4 -0.09-Experimental Link Removed
1.7.2 -0.09-Experimental Link Removed
And issues, bug reports, general experiences etc as usual are much appreciated!
can you please help me! my brother is trying to play minecraft splitscreen with me but every time he joins me his minecraft pauses and wont unpause! its ben happining since launcher version 1.3.11! please help! also my brother is using a xbox remote!
can you please help me! my brother is trying to play minecraft splitscreen with me but every time he joins me his minecraft pauses and wont unpause! its ben happining since launcher version 1.3.11! please help! also my brother is using a xbox remote!
Do you have the joypad mod installed properly? Can you select controllers?
The joypad mod turns off pausing the game, but if its not working for you, you can go into the .minecraft\options.txt and look for the line pauseOnLostFocus:true and change to pauseOnLostFocus:false
Do you have the joypad mod installed properly? Can you select controllers?
The joypad mod turns off pausing the game, but if its not working for you, you can go into the .minecraft\options.txt and look for the line pauseOnLostFocus:true and change to pauseOnLostFocus:false
You were right about the issue in 1.6.4. I have put up the fix on 1.6.4 -0.09-Experimental Link Removed
Tried two different gamepads. PS3 gamepad and another one called "Phillips Wireless PC Controller" both of them had this same result. The camera looks up into the sky and spins around and I couldnt get any response out of either controller.
I was also unable to rebind the controls to either gamepad. Because up on the right analog for attack really dosnt suit me. None of the buttons worked anyways.
Tried two different gamepads. PS3 gamepad and another one called "Phillips Wireless PC Controller" both of them had this same result. The camera looks up into the sky and spins around and I couldnt get any response out of either controller.
I was also unable to rebind the controls to either gamepad. Because up on the right analog for attack really dosnt suit me. None of the buttons worked anyways.
Thanks for the info. What version of the joypad mod were you using? What is your OS?
There is a pre-release version at 1.6.4 -0.09-Experimental Link Removed
1.7.2 -0.09-Experimental Link Removed
These include many changes for how joypad controls are handled/rebound etc.
Great!
But how i can change the the special mod keys? When I press a button on my joypad, the game think i press escape or left mousebutton for example. i tried it with a xbox 360 controller.
Can you give more detail about what you are trying to do and what you expect to happen?
Let's say for example you want the joypad "Start" button to use the "R" keyboard key. You would
1) Go into controls menu
2) Press "Add Custom key" button
3) Press "R" on the keyboard
4) Now you need to bind the R to a joypad button. With the R highlighted in the list, double click it or press the "Set" button on the right menu.
5) Press the Start button on the joypad
In some cases such as this, a button will have conflicts. Start button is also the menu key (ESC). To fix this, you need to "Unset" 'Menu' or change it to a different joypad button.
Every time I set the dead zone it gets restet to default I only have one problem and it's my control camra it only spins when I look left ever thing esle works fine and no my stick is not stuck its the dead zone. This is what I change it to S:joy.cameraX-=Look left,AXIS,3,-0.7,0.3
was S:joy.cameraX-=Look left,AXIS,3,-0.7,0.2
Hey can someone help me out here, I got the mod working it's just that I cannot connect to LAN or Hosted Servers using the version of the game with the controller use. I am using the proper version of Forge. Please help, thanks in advance.
Yes, that does make sense. And thanks for making it so clear! When I finish up my latest update I'll give your solution a try.
I am considering the possibility of making this a litemod since what I'm doing in Joypad mod aligns more with the problems LiteLoader is trying to solve. When I get some more time I'll have a closer look at LiteLoader and see how much it would make sense to do that.
If you are interested we are on github https://github.com/ljsimin/MinecraftJoypadSplitscreenMod but the code has changed a lot from the main branch and I'm working mostly out of the sub branches for (1.7.2 / 1.6.4 )
.
Thanks for the report. Which version of the joypad mod are you using?
Have you tried with the latest (experimental) version?
1.6.4 -0.09-Experimental
Link Removed
1.7.2 -0.09-Experimental
Link Removed
Sorry, didn't recognize that you posted earlier and that you're using the 0.09 experiemental. Are you seeing problems hosting / joining using the in-game lan or the server? Is this a problem with one player using the joypad or are both players using the joypad splitscreen?
Yup, confirmed the bug in 1.6.4. Thats a pretty big deal breaker for splitscreen. Great find!
It happens whenever the player using the joypad doesn't have window focus and they open a container or menu. After this point they cannot break blocks.
I'm pretty sure this does not occur in the release version if you want to go back to that for now:
http://retro-hack.blogspot.com/p/minecraft-joypad-mod.html
Otherwise, I'll have a fix for that and put it up over the experimental version sometime later today.
I've updated these:
1.6.4 -0.09-Experimental
Link Removed
1.7.2 -0.09-Experimental
Link Removed
It includes an early version of custom keys. Its a bit clunky at present but works.
To use this (in controls menu)
1) Press custom key button
2) Press the keyboard key you wish to bind
3) It will show up in the list box
4) Scroll down to it in the list box and double click it
5) Press the button on your controller to bind it to that key
This is an early version so there are many bugs around this but I'm pushing out an early version now to address another fix, and since it kinda works to give you guys something new and hopefully a better experience with some mods.
The biggest bug around this is that you can't remove old bindings from the menu (you can in the config file) and that if a particular controller input is mapped to another action, whichever one gets called first will be executed.
Also, it will send a single press of the key and not hold it but that will be an option in the future.
1.6.4 -0.09-Experimental
Link Removed
1.7.2 -0.09-Experimental
Link Removed
And issues, bug reports, general experiences etc as usual are much appreciated!
Do you have the joypad mod installed properly? Can you select controllers?
The joypad mod turns off pausing the game, but if its not working for you, you can go into the .minecraft\options.txt and look for the line pauseOnLostFocus:true and change to pauseOnLostFocus:false
You were right about the issue in 1.6.4. I have put up the fix on
1.6.4 -0.09-Experimental
Link Removed
And it will be in the next release. Thanks!
I was also unable to rebind the controls to either gamepad. Because up on the right analog for attack really dosnt suit me. None of the buttons worked anyways.
Thanks for the info. What version of the joypad mod were you using? What is your OS?
There is a pre-release version at
1.6.4 -0.09-Experimental
Link Removed
1.7.2 -0.09-Experimental
Link Removed
These include many changes for how joypad controls are handled/rebound etc.
What kind of help do you need? There is a youtube tutorial by stcrowe on the original post. If you need any other help then try to asking on the forums.New version out!
http://retro-hack.blogspot.com/p/minecraft-joypad-mod.html
v0.0952
Can you give more detail about what you are trying to do and what you expect to happen?
Let's say for example you want the joypad "Start" button to use the "R" keyboard key. You would
1) Go into controls menu
2) Press "Add Custom key" button
3) Press "R" on the keyboard
4) Now you need to bind the R to a joypad button. With the R highlighted in the list, double click it or press the "Set" button on the right menu.
5) Press the Start button on the joypad
In some cases such as this, a button will have conflicts. Start button is also the menu key (ESC). To fix this, you need to "Unset" 'Menu' or change it to a different joypad button.
was S:joy.cameraX-=Look left,AXIS,3,-0.7,0.2