Forums - Open Redstone Engineers
MCsim (pre-alpha release) - Printable Version

+- Forums - Open Redstone Engineers (https://forum.openredstone.org)
+-- Forum: Off-Topic (https://forum.openredstone.org/forum-4.html)
+--- Forum: Programming (https://forum.openredstone.org/forum-8.html)
+--- Thread: MCsim (pre-alpha release) (/thread-1606.html)

Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20


RE: Redstone lab (Open source) - Chibill - 08-18-2014

CX look at Forge's github they have a fake player for people how mod to pass to stuff when we don't have a player entity to pass you can look at that for ways to over come the problem.

This is the fake playerhttps://github.com/MinecraftForge/MinecraftForge/blob/master/src/main/java/net/minecraftforge/common/util/FakePlayer.java

This is the factory forge made for it so modders could make them this can help you make your fake player for this.https://github.com/MinecraftForge/MinecraftForge/blob/master/src/main/java/net/minecraftforge/common/util/FakePlayerFactory.java


RE: Redstone lab (Open source) - CX gamer - 08-20-2014

Brilliant find, that will definitely be useful! Definitely a relief after scouring through the class to see what needed to be done. The catch is that I will need to extend a dynamically loaded reflection class, so it's not something I can just copy/paste. If I have an interface, I can dynamically implement it using the Proxy API; I did so for the chunkloader already.

But EntityPlayerMP doesn't have an interface to implement, so I can't do it with proxies. Apparently, I'll have to use CGLIB to generate the java byecode that extends EntityPlayer. Looking forward to using that. Big Grin And that's great, because it will work for any right clicking, so it may be possible to open item containers as well, for example.

That's for right clicking stuff. For rotating it, I'll just cycle through possible orientations and check if a torch pops off until a valid orientation is found.


RE: Redstone lab (Open source) - Chibill - 08-20-2014

If you don't import or use the class the if the fake player (warp it) you can ext and the entityplayermp I think. At lest from my work. But I might be wrong.


RE: Redstone lab (Open source) - CX gamer - 08-21-2014

On my laptop right now so can't confirm from the code, but I get what you're saying. Extending EntityPlayerMP will need to happen at runtime, because before, it doesn't know what to extend yet. Doing so is definitely non-trivial, but should definitely be doable.


RE: Redstone lab (Open source) - Chibill - 09-02-2014

I am working on using FML's RuntimeDeobufcation to make a class to run before running any of your other code that will deobfuscated it to Normal Class names (that why the only thing obfuscated in mods are the functions and variables to srg names). That way you can extend any MC class that exists that the target MC version.

If this will help I will make a PR for you when I am finished.


RE: Redstone lab (Open source) - Chibill - 09-03-2014

This will use a mix of the Launchers Loading Code as a dynamicly loaded lybaray and also FML's tweakers.


RE: Redstone lab (Open source) - CX gamer - 09-03-2014

Sounds very interesting! That would make life easier if I understand everything correctly. If everything can easily be extended, I have much more freedom in what parts of code I want to run. Big Grin


RE: Redstone lab (Open source) - Chibill - 09-03-2014

I need to make my own version of LaunchClassLoader.java and also IClassNameTransformer.java and IClassTransformer.java. Thats to get it to load the class transformer. Then I need to make a version of DeobfuscationTransformer.java and then all the classes in deobf.Then I need to call the methods that activate the Transformers then load the rest of MC-Sim.


RE: Redstone lab (Open source) - CX gamer - 09-04-2014

Sorry for the late reply, but things are a little bit hectic seeing as I am preparing to switch to dorm-life in the near future. I have now educated myself a bit in ClassLoaders. Just to confirm that what I think I understand is correct:

Current system
  • The JAR is located and in a single pass, all required classes are loaded using reflection.
  • The translator is further used to call get method and field names of those classes.
  • All libraries are linked in a hacky way (sim.loading.ClassPathHack).
  • Only run-time linking is possible, so no extending classes without bytecode manipulation.

New system
  • The MC source is added to the project (but ofc git ignored) so that we can use its class names and have proper imports.
  • A ClassLoader will translate and load classes out of the JAR when needed.
  • Using MC's classes is trivial and automatic.

But I'm still wondering on how extending classes would work exactly. Your methods and fields need to be obfuscated, as you said is the case with mods, because otherwise it won't override the class'. But if it is obfuscated, how would you avoid compile-time errors? Also if they're obfuscated, it would require updating every release?


RE: Redstone lab (Open source) - Chibill - 09-04-2014

Yes, plus I am hoping to set it up so you run the function main in the "loader" which is in the actual code library the launcher uses that contains the two classes I was going to rewrite. I can write a Tweaker with the Sims main class as it what it says to run but include FML's deobf transformer and the patcher (so if you want you can patch normal mc code at run time to call your own functions.). I will be working on this to day and trying to get it to run using it.

Its obfuscated to srgnames after its compiled with a deobfed version of Minecraft. And they don't change every minor version they do every major version but there is a new MCP config every version that forge uses.