diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..8ae3a61 --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +.gradle/gradle.log +.gradle/ +.idea/ +*.iml +debug/ +classes/ +output/ diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..2acb883 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "lib/MobiusCore"] + path = lib/MobiusCore + url = https://github.com/Gamealition/MobiusCore.git diff --git a/.hgtags b/.hgtags deleted file mode 100644 index 5a302a0..0000000 --- a/.hgtags +++ /dev/null @@ -1,10 +0,0 @@ -0be170f35b4fd24a3f72899e5cd6d4083ea79890 1.0.3b -2c553dd6eb0764815d08ba54b40a13bacff06bfb 1.0.6 -3eab4e1b0b6c343231168643c0f21433b6634140 1.1.0 -6fd1e671fa7dc2ff953a29e5c0bcf854cf422215 1.1.1 -4896ce18bb251993d78a75b559f9cccec03c0fae 1.1.3 -f2106a6a2a9d4718eea61deb08463ffada6f2523 v1.2.0 -2fc13f1bdbbf9f13496af60edbdbf7240d829fb9 v1.2.1 -cf0ea71bfd7f710dd234d8fc04b217566d01c4ac v1.2.2a_1.7.2 -6649e6c3ae4aecf403ff07878274834bc7a036d8 v1.2.2a_1.7.10 -29d3123e9bddd5124e11e640c8db5e5ba7baa200 v1.2.3_1.7.10 diff --git a/LICENSE.md b/LICENSE.md index 99d6ee6..5f8771c 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -2,6 +2,8 @@ This mod is licensed under [Creative Commons Attribution-NonCommercial-ShareAlik This mod was created by [ProfMobius](http://www.mobiusstrip.eu/), with license determined from the mod's [CurseForge page](http://minecraft.curseforge.com/projects/opis). +For any commercial usage, please contact ProfMobius at profmobius@mobiusstrip.eu + ----- *This is a human-readable summary of (and not a substitute for) the [license](https://creativecommons.org/licenses/by-nc-sa/4.0/legalcode).* diff --git a/README.md b/README.md new file mode 100644 index 0000000..36ba1b8 --- /dev/null +++ b/README.md @@ -0,0 +1,21 @@ +# Building + +## Requirements + +* [Gradle installation with gradle binary in PATH](http://www.gradle.org/installation). +Unlike the source package provided by Forge, this repository does not include a gradle +wrapper or distribution. + +## Simple build + +Execute `gradle setupCIWorkspace` in the root directory of this repository. Then execute +`gradle build`. If subsequent builds cause problems, do `gradle clean`. + +## IntelliJ + +* Open `build.gradle` as a project +* Execute the `setupDecompWorkspace` task +* Click the refresh button in the "Gradle" tab +* Execute the `genIntellijRuns` task +* For both the "Minecraft Client" and "Minecraft Server" run configurations, add the JVM +option `-Dfml.coreMods.load=mcp.mobius.mobiuscore.asm.CoreDescription` \ No newline at end of file diff --git a/build.gradle b/build.gradle index 3b2085d..a0aa2e6 100644 --- a/build.gradle +++ b/build.gradle @@ -1,39 +1,44 @@ buildscript { + // Repositories and plugins used by this buildscript. For internal Gradle use only. repositories { mavenCentral() - //jcenter() maven { name = "forge" url = "http://files.minecraftforge.net/maven" } + maven { name = "sonatype" url = "https://oss.sonatype.org/content/repositories/snapshots/" } } + dependencies { classpath 'net.minecraftforge.gradle:ForgeGradle:1.2-SNAPSHOT' } } -apply plugin: 'java' -apply plugin: 'maven' +// Applies the custom Gradle plugin Forge uses, for Forge-specific tasks apply plugin: 'forge' +// Gradle project metadata version = "1.2.5_1.7.10" -group= "mcp.mobius.opis" // http://maven.apache.org/guides/mini/guide-naming-conventions.html -archivesBaseName = "Opis" +group = "mcp.mobius.opis" minecraft { - version = "1.7.10-10.13.0.1208" - assetDir = "eclipse/assets" + // Forge version + version = "1.7.10-10.13.1.1217" + runDir = "debug" + + // Shading - https://forgegradle.readthedocs.org/en/latest/user-guide/shading/ + // math3 is shaded in case another mod decides to use a differing version srgExtra "PK: org/apache/commons/math3 opisapache/math3" } configurations { deployerJars shade - compile.extendsFrom shade + compile.extendsFrom shade } repositories { @@ -42,63 +47,77 @@ repositories { maven { name "Mobius Repo" url "http://mobiusstrip.eu/maven" - } + } } dependencies { + // Custom-built Netty for Opis + shade 'io.netty-opis:Netty-opis:4.0.23' + + // Standard Maven repository dependencies shade 'org.apache.commons:commons-math3:3.2' shade 'org.jfree:jcommon:1.0.21' shade 'org.jfree:jfreechart:1.0.17' shade 'com.miglayout:miglayout-swing:4.2' - shade 'net.sf.opencsv:opencsv:2.3' - shade 'io.netty-opis:Netty-opis:4.0.23' -// shade 'io.netty:netty-all:4.0.23.Final' -// compile 'io.netty:netty-all:4.0.15.Final' - compile "mcp.mobius.mobiuscore:MobiusCore:1.2.4_1.7.10:dev" + shade 'net.sf.opencsv:opencsv:2.3' + + // Necessary for deployment deployerJars "org.apache.maven.wagon:wagon-ssh:2.2" } -def root = project.projectDir.parentFile -sourceSets { - main { - java { - srcDir new File(root, "src") - } - resources { - srcDir new File(root, "resources") - } - } +// Includes MobiusCore submodule directory into the built jar as coremod +sourceSets.main { + java.srcDir project.projectDir.path + '/lib/MobiusCore/src/main/java' + resources.srcDir project.projectDir.path + '/lib/MobiusCore/src/main/resources' } +// Enforce use of Java 1.7 language level +compileJava { + sourceCompatibility = "1.7" + targetCompatibility = "1.7" +} + +def commonManifest = { + // Allows Forge to find MobuisCore's coremod + attributes 'FMLCorePlugin': 'mcp.mobius.mobiuscore.asm.CoreDescription' + // Without this, Forge ignores Opis as it thinks there is only a coremod + attributes 'FMLCorePluginContainsFMLMod': 'true' +} + +jar { + // Attach FMLCorePlugin attribute + manifest commonManifest + + // Sets the output directory of the mod's jar file + destinationDir = file 'output' +} + +// Extra task for building a "sources" jar, for uncompiled code + comments task sourceJar(type: Jar) { from sourceSets.main.java - from new File(root, "dev") + // Attaches the name 'sources' to the jar classifier = 'sources' } +// Extra task for building a "dev" jar; built code pre-obsfucation task devJar(type: Jar) { from sourceSets.main.output + + // Attaches the name 'dev' to the jar classifier = 'dev' + + // Attach FMLCorePlugin attribute + manifest commonManifest } -// some crazy stuff to make sure the chicken stuff is in the mods folder... -// because it wont work otherwise... because FML doesnt laod coremods from the classpath -task copyCoreMods(type: Copy, dependsOn: "extractUserDev") { - from configurations.compile - include "**/*Mobius*.jar" - //include "**/*Chicken*.jar", "**/*NotEnoughItems*.jar" - //exclude "**/CodeChickenLib*" // because CCC downloads it anyways.. -_- - into file(minecraft.runDir + "/../mods") // paralell to the assets dir -} -tasks.setupDevWorkspace.dependsOn copyCoreMods -tasks.setupDecompWorkspace.dependsOn copyCoreMods +// Fixes issues with debugging in IntelliJ +idea.module.inheritOutputDirs = true artifacts { archives sourceJar, devJar } -processResources -{ +processResources { // this will ensure that this task is redone when the versions change. inputs.property "version", project.version inputs.property "mcversion", project.minecraft.version @@ -106,11 +125,11 @@ processResources // replace stuff in mcmod.info, nothing else from(sourceSets.main.resources.srcDirs) { include 'mcmod.info' - + // replace version and mcversion - expand 'version':project.version, 'mcversion':project.minecraft.version + expand 'version': project.version, 'mcversion': project.minecraft.version } - + // copy everything else, thats not the mcmod.info from(sourceSets.main.resources.srcDirs) { exclude 'mcmod.info' @@ -121,29 +140,26 @@ uploadArchives { dependsOn 'reobf' repositories.mavenDeployer { configuration = configurations.deployerJars - repository(url: "scp://mobiusstrip.eu/home/mobius/web/maven"){ + repository(url: "scp://mobiusstrip.eu/home/mobius/web/maven") { authentication(userName: "mobius") } pom { groupId = project.group version = project.version - artifactId = project.archivesBaseName + artifactId = project.name project { - name project.archivesBaseName + name project.name packaging 'jar' description 'Opis ' - url 'http://mobiusstrip.eu' + url 'http://mobiusstrip.eu' } } } -jar { - configurations.shade.each { dep -> - from(project.zipTree(dep)){ - exclude 'META-INF', 'META-INF/**' + jar { + configurations.shade.each { dep -> + from(project.zipTree(dep)) exclude 'META-INF', 'META-INF/**' } } } - -} diff --git a/lib/MobiusCore b/lib/MobiusCore new file mode 160000 index 0000000..9d3fc5a --- /dev/null +++ b/lib/MobiusCore @@ -0,0 +1 @@ +Subproject commit 9d3fc5affab5dadbd7f81f50a25d671bbd6430e8 diff --git a/src/main/java/mcp/mobius/opis/data/managers/TileEntityManager.java b/src/main/java/mcp/mobius/opis/data/managers/TileEntityManager.java index 3d9a226..7bf3316 100644 --- a/src/main/java/mcp/mobius/opis/data/managers/TileEntityManager.java +++ b/src/main/java/mcp/mobius/opis/data/managers/TileEntityManager.java @@ -141,7 +141,7 @@ public enum TileEntityManager { Block block = world.getBlock(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord); if (block == Blocks.air || block == null - || !block.hasTileEntity() + || !block.hasTileEntity(0) || world.getTileEntity(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord) == null || world.getTileEntity(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord).getClass() != tileEntity.getClass()){ diff --git a/src/main/java/mcp/mobius/opis/helpers/ModIdentification.java b/src/main/java/mcp/mobius/opis/helpers/ModIdentification.java index 163172d..4157f57 100644 --- a/src/main/java/mcp/mobius/opis/helpers/ModIdentification.java +++ b/src/main/java/mcp/mobius/opis/helpers/ModIdentification.java @@ -3,11 +3,12 @@ package mcp.mobius.opis.helpers; import java.io.UnsupportedEncodingException; import java.net.URLDecoder; import java.util.HashMap; + +import cpw.mods.fml.common.registry.*; import net.minecraft.block.Block; import net.minecraft.item.ItemStack; import cpw.mods.fml.common.Loader; import cpw.mods.fml.common.ModContainer; -import cpw.mods.fml.common.registry.GameData; public class ModIdentification { @@ -60,9 +61,9 @@ public class ModIdentification { public static String nameFromStack(ItemStack stack){ try{ - //String modID = itemMap.get(itemstack.itemID); - //ModContainer mod = ModIdentification.findModContainer(modID); - ModContainer mod = GameData.findModOwner(GameData.itemRegistry.getNameForObject(stack.getItem())); + String name = GameData.getItemRegistry().getNameForObject(stack.getItem()); + GameRegistry.UniqueIdentifier ui = new GameRegistry.UniqueIdentifier(name); + ModContainer mod = Loader.instance().getIndexedModList().get(ui.modId); String modname = mod == null ? "Minecraft" : mod.getName(); return modname; } catch (NullPointerException e){ diff --git a/src/main/resources/LICENSE.txt b/src/main/resources/LICENSE-Opis.txt similarity index 100% rename from src/main/resources/LICENSE.txt rename to src/main/resources/LICENSE-Opis.txt