microsoft / vsminecraft

Visual Studio extension for developing MinecraftForge mods using Java.
Other
194 stars 25 forks source link

Upgrading forge and gradle #32

Open brezeeger opened 8 years ago

brezeeger commented 8 years ago

Hi, Forge had some bugs in it that prevented me from getting my mod working, and the solution was to upgrade forge to a newer version than the one included with 1.8. I've been attempting to get everything up and working, but the game crashes every time - all I get is:

Java HotSpot(TM) 64-Bit Server VM Warning: Using... Error: Could not find or load main class GradleStart

Absolutely nothing after this.

I downloaded the forge 1.8-11.14.4.1563 mdk zip. Replaced the gradlew, gradlew.bat, gradle-wrapper.jar, and gradle-wrapper.properties files. I then tried copy-pasting the eclipse folder over.

The references still pointed to the old forge, so I deleted that reference and added the reference: C:\Users\Dan.gradle\caches\minecraft\net\minecraftforge\forge\1.8-11.14.4.1563\snapshot\20141130\forgeSrc-1.8-11.14.4.1563.jar

I also renamed the forge-1.8-11.14.4.1563-mdk.zip to forge-1.8-11.14.4.1563-src.zip and put it in the packages/com.microsoft.minecraftmod.0.5.4.0/tools folder and added it to the project. Although, I could not figure out install.ps1 $forgeVersion=$project.Object.GetProjectProperty("MinecraftForgeVersion", 1) Not really sure how to update this project property.

I updated the build.gradle file as below. build.gradle.txt (note this is still build.gradle - needed .txt to upload to github)

In the .gradle folder in the project, I added the 2.7 files generated as ForgeGradle:2.0 required a newer version.

I found: build/tmp/extracted/GradleStart.java likewise: .gradle/caches/minecraft/net/minecraftforge/forge/1.8-11.14.4.1563/start/GradleStart.(class and java)

Everything is compiling fine. I just went from a running version of Minecraft to one that doesn't run because it can't find/load GradleStart. I am now thoroughly confused.

The only thing I can think of is that the GradleStart and GradleStartCommon may be different as gradle changed, but I would think that as I got everything, it should stay consistent.

It's also worth mentioning I have done numerous cleans/rebuilds from both visual studio and the command prompt.

So... any thoughts? What other steps are needed to upgrade Forge when using visual studio?

Thanks! ~Dan

brezeeger commented 8 years ago

OK, I figured it out. It's not completely straightforward - especially to a new mod maker. I'll try to make a step-by-step solution. Throughout this, I did a number of compiles, and closed/reopened visual studio (though closing the solution and reopening probably would've also worked).

Step 1) Back it all up. Just in case.

Step 2) Download the desired forge-version-mdk.zip file. Extract it somewhere safe. When you rebuild, it will probably download this all again, but it may yell at you because of gradle being a different version.

Step 3) Replace the gradlew and gradlew.bat in your solution directory with the gradlew and gradlew.bat from the forge src zip file.

Step 4) In your solution directory, there is the gradle directory leading to the gradle-wrapper.jar and gradle-wrapper.properties. Replace those with the equivalents in the downloaded forge src zip file.

Step 5) In the build.gradle file: change mavenCentral() to jcenter()

classpath 'net.minecraftforge.gradle:ForgeGradle:1.2-SNAPSHOT' to classpath 'net.minecraftforge.gradle:ForgeGradle:2.0-SNAPSHOT'

apply plugin: 'forge' to apply plugin: 'net.minecraftforge.gradle.forge'

version = "1.8-11.14.1.1357" to version = "1.8-11.14.4.1563"

Step 6) Go to your ProjectName.javaproc file. Look for all instances of 1.8-11.14.1.1357 and replace them with the forge version of your choice. Two JarReference tags, one Content tag, and MinecraftForgeVersion at the top. Note, these can not necessarily be edited in Visual Studio. In particular, the reference leading to GradleStart...

Step 7) Do the same thing as step 6 in the .classpath file. On compile, one of these may generate the other, but I don't know which way it goes.

Step 8) Same thing again, except for classpath.vs.build.xml

Step 9) Same thing again, except the .project file.

I believe steps 6-9 will properly update the 'references' code section in the solution.

Step 9) Copy the forge-version-mdk.zip file, and paste it into project/packages/com.microsoft.minecraftmod.0.5.4.0/tools and then replace the 'mdk' with 'src'

Step 10) In the solution - the .gradle folder. Add the 2.7 folder (or whichever newer version of gradle you are using) to the project, and exclude the 2.0 folder from the project (assuming gradle is updated). This may require an attempted clean/rebuild to create this folder.

Step 11) It may be necessary to copy the eclipse folder from the forge zip and replace the eclipse folder in your solution.

Step 12) Clean solution/project and rebuild.

I believe this is everything I did, and it works on my end. However, I may have missed a step. There was a lot of flailing as I've never worked with Java or gradle before. Basically, it is just a matter of replacing old files with new files, updating the build.gradle file, and catching all references to the old stuff and replacing it with the new. Best of luck!