Playing around with some gradle improvements
This commit is contained in:
parent
b1cad58550
commit
39a6db0dce
42
build.gradle
42
build.gradle
|
@ -17,50 +17,44 @@ buildscript {
|
||||||
|
|
||||||
apply plugin: 'forge'
|
apply plugin: 'forge'
|
||||||
|
|
||||||
version = "1.7.2-0.2.${System.getenv("BUILD_NUMBER") ?: 0}";
|
ext.configFile = file "build.properties"
|
||||||
|
|
||||||
|
configFile.withReader {
|
||||||
|
def prop = new Properties()
|
||||||
|
prop.load(it)
|
||||||
|
project.ext.config = new ConfigSlurper().parse prop
|
||||||
|
}
|
||||||
|
|
||||||
|
version = config.mod_version
|
||||||
group = "com.pahimar.ee3" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
|
group = "com.pahimar.ee3" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
|
||||||
archivesBaseName = "EquivalentExchange3"
|
archivesBaseName = "EquivalentExchange3"
|
||||||
|
|
||||||
minecraft {
|
minecraft {
|
||||||
version = "1.7.2-10.12.1.1095"
|
version = config.minecraft_version + "-" + config.forge_version
|
||||||
assetDir = "run/assets"
|
assetDir = "run/assets"
|
||||||
|
|
||||||
|
replaceIn "reference/Reference.java"
|
||||||
|
replace "@VERSION@", config.mod_version
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
version = "${config.minecraft_version}-${config.mod_version}.${System.getenv("BUILD_NUMBER") ?: 0}"
|
||||||
// you may put jars on which you depend on in ./libs
|
|
||||||
// or you may define them like so..
|
|
||||||
//compile "some.group:artifact:version:classifier"
|
|
||||||
//compile "some.group:artifact:version"
|
|
||||||
|
|
||||||
// real examples
|
|
||||||
//compile 'com.mod-buildcraft:buildcraft:6.0.8:dev' // adds buildcraft to the dev env
|
|
||||||
//compile 'com.googlecode.efficient-java-matrix-library:ejml:0.24' // adds ejml to the dev env
|
|
||||||
|
|
||||||
// for more info...
|
|
||||||
// http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
|
|
||||||
// http://www.gradle.org/docs/current/userguide/dependency_management.html
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
// exclude xcf files, as they are for development only
|
// exclude xcf files, as they are for development only
|
||||||
exclude '**/*.xcf'
|
exclude '**/*.xcf'
|
||||||
|
|
||||||
// replace stuff in mcmod.info, nothing else
|
// replace stuff in mcmod.info, nothing else
|
||||||
from(sourceSets.main.resources.srcDirs) {
|
from(sourceSets.main.resources.srcDirs) {
|
||||||
include 'mcmod.info'
|
include '*.info'
|
||||||
|
|
||||||
// replace version and mcversion
|
// replace version and mcversion
|
||||||
expand 'version': project.version, 'mcversion': project.minecraft.version
|
expand 'mod_version': project.version, 'minecraft_version': project.config.minecraft_version
|
||||||
}
|
}
|
||||||
|
|
||||||
// copy everything else, thats not the mcmod.info
|
// copy everything else, thats not the mcmod.info
|
||||||
from(sourceSets.main.resources.srcDirs) {
|
from(sourceSets.main.resources.srcDirs) {
|
||||||
exclude 'mcmod.info'
|
include '**/*.info'
|
||||||
|
include '**/*.properties'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#
|
#
|
||||||
#Sat Dec 28 00:14:08 EST 2013
|
#Sat Dec 28 00:14:08 EST 2013
|
||||||
minecraft_version=1.7.2
|
minecraft_version=1.7.2
|
||||||
forge_version=10.12.1.1082
|
forge_version=10.12.1.1095
|
||||||
mod_version=0.2
|
mod_version=0.2
|
||||||
|
|
|
@ -20,7 +20,7 @@ import cpw.mods.fml.common.registry.GameRegistry;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
@Mod(modid = Reference.MOD_ID, name = Reference.MOD_NAME, certificateFingerprint = Reference.FINGERPRINT, version = "0.2")
|
@Mod(modid = Reference.MOD_ID, name = Reference.MOD_NAME, certificateFingerprint = Reference.FINGERPRINT, version = Reference.VERSION)
|
||||||
public class EquivalentExchange3
|
public class EquivalentExchange3
|
||||||
{
|
{
|
||||||
@Instance(Reference.MOD_ID)
|
@Instance(Reference.MOD_ID)
|
||||||
|
|
175
src/main/java/com/pahimar/ee3/exchange/OreStack.java
Normal file
175
src/main/java/com/pahimar/ee3/exchange/OreStack.java
Normal file
|
@ -0,0 +1,175 @@
|
||||||
|
package com.pahimar.ee3.exchange;
|
||||||
|
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import com.google.gson.JsonParseException;
|
||||||
|
import com.google.gson.JsonSyntaxException;
|
||||||
|
import com.pahimar.ee3.reference.Compare;
|
||||||
|
import com.pahimar.ee3.util.LogHelper;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraftforge.oredict.OreDictionary;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class OreStack implements Comparable<OreStack>
|
||||||
|
{
|
||||||
|
// Gson serializer for serializing to/deserializing from json
|
||||||
|
private static final Gson gsonSerializer = new Gson();
|
||||||
|
|
||||||
|
private static final int ORE_DICTIONARY_NOT_FOUND = -1;
|
||||||
|
|
||||||
|
public String oreName;
|
||||||
|
public int stackSize;
|
||||||
|
public static Comparator<OreStack> comparator = new Comparator<OreStack>()
|
||||||
|
{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int compare(OreStack oreStack1, OreStack oreStack2)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (oreStack1 != null)
|
||||||
|
{
|
||||||
|
if (oreStack2 != null)
|
||||||
|
{
|
||||||
|
if (oreStack1.oreName.equalsIgnoreCase(oreStack2.oreName))
|
||||||
|
{
|
||||||
|
return oreStack1.stackSize - oreStack2.stackSize;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return oreStack1.oreName.compareToIgnoreCase(oreStack2.oreName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return Compare.LESSER_THAN;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (oreStack2 != null)
|
||||||
|
{
|
||||||
|
return Compare.GREATER_THAN;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return Compare.EQUALS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
public OreStack(String oreName, int stackSize)
|
||||||
|
{
|
||||||
|
this.oreName = oreName;
|
||||||
|
this.stackSize = stackSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
public OreStack(String oreName)
|
||||||
|
{
|
||||||
|
this(oreName, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public OreStack(ItemStack itemStack)
|
||||||
|
{
|
||||||
|
this(OreDictionary.getOreName(OreDictionary.getOreID(itemStack)), itemStack.stackSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean compareOreNames(OreStack oreStack1, OreStack oreStack2)
|
||||||
|
{
|
||||||
|
if (oreStack1 != null && oreStack2 != null)
|
||||||
|
{
|
||||||
|
if ((oreStack1.oreName != null) && (oreStack2.oreName != null))
|
||||||
|
{
|
||||||
|
return oreStack1.oreName.equalsIgnoreCase(oreStack2.oreName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deserializes a OreStack object from the given serialized json String
|
||||||
|
*
|
||||||
|
* @param jsonOreStack
|
||||||
|
* Json encoded String representing a OreStack object
|
||||||
|
*
|
||||||
|
* @return The OreStack that was encoded as json, or null if a valid OreStack could not be decoded from given String
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
public static OreStack createFromJson(String jsonOreStack)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return gsonSerializer.fromJson(jsonOreStack, OreStack.class);
|
||||||
|
}
|
||||||
|
catch (JsonSyntaxException exception)
|
||||||
|
{
|
||||||
|
LogHelper.warn(exception.getMessage());
|
||||||
|
}
|
||||||
|
catch (JsonParseException exception)
|
||||||
|
{
|
||||||
|
LogHelper.warn(exception.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static OreStack getOreStackFromList(Object... objects)
|
||||||
|
{
|
||||||
|
return getOreStackFromList(Arrays.asList(objects));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static OreStack getOreStackFromList(List<?> objectList)
|
||||||
|
{
|
||||||
|
for (Object listElement : objectList)
|
||||||
|
{
|
||||||
|
if (listElement instanceof ItemStack)
|
||||||
|
{
|
||||||
|
ItemStack stack = (ItemStack) listElement;
|
||||||
|
|
||||||
|
if (OreDictionary.getOreID(stack) != ORE_DICTIONARY_NOT_FOUND)
|
||||||
|
{
|
||||||
|
return new OreStack(stack);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int compare(OreStack oreStack1, OreStack oreStack2)
|
||||||
|
{
|
||||||
|
return comparator.compare(oreStack1, oreStack2);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString()
|
||||||
|
{
|
||||||
|
return String.format("%sxoreStack.%s", stackSize, oreName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object object)
|
||||||
|
{
|
||||||
|
return object instanceof OreStack && (comparator.compare(this, (OreStack) object) == Compare.EQUALS);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int compareTo(OreStack oreStack)
|
||||||
|
{
|
||||||
|
return comparator.compare(this, oreStack);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns this OreStack as a json serialized String
|
||||||
|
*
|
||||||
|
* @return Json serialized String of this OreStack
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
public String toJson()
|
||||||
|
{
|
||||||
|
return gsonSerializer.toJson(this);
|
||||||
|
}
|
||||||
|
}
|
10
src/main/java/com/pahimar/ee3/reference/Compare.java
Normal file
10
src/main/java/com/pahimar/ee3/reference/Compare.java
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
package com.pahimar.ee3.reference;
|
||||||
|
|
||||||
|
public class Compare
|
||||||
|
{
|
||||||
|
|
||||||
|
// Comparator stuff
|
||||||
|
public static final int LESSER_THAN = -1;
|
||||||
|
public static final int EQUALS = 0;
|
||||||
|
public static final int GREATER_THAN = 1;
|
||||||
|
}
|
|
@ -5,6 +5,7 @@ public class Reference
|
||||||
public static final String MOD_ID = "EE3";
|
public static final String MOD_ID = "EE3";
|
||||||
public static final String MOD_NAME = "Equivalent Exchange 3";
|
public static final String MOD_NAME = "Equivalent Exchange 3";
|
||||||
public static final String FINGERPRINT = "@FINGERPRINT@";
|
public static final String FINGERPRINT = "@FINGERPRINT@";
|
||||||
|
public static final String VERSION = "@VERSION@";
|
||||||
public static final String SERVER_PROXY_CLASS = "com.pahimar.ee3.proxy.ServerProxy";
|
public static final String SERVER_PROXY_CLASS = "com.pahimar.ee3.proxy.ServerProxy";
|
||||||
public static final String CLIENT_PROXY_CLASS = "com.pahimar.ee3.proxy.ClientProxy";
|
public static final String CLIENT_PROXY_CLASS = "com.pahimar.ee3.proxy.ClientProxy";
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,15 +3,15 @@
|
||||||
"modid": "EE3",
|
"modid": "EE3",
|
||||||
"name": "Equivalent Exchange 3",
|
"name": "Equivalent Exchange 3",
|
||||||
"description": "Transmute stuff into other stuff! Become a Minecraft God!",
|
"description": "Transmute stuff into other stuff! Become a Minecraft God!",
|
||||||
"version": "${version}",
|
"version": "${mod_version}",
|
||||||
"mcversion": ${mcversion}",
|
"mcversion": "${minecraft_version}",
|
||||||
"url": "http://www.minecraftforum.net/topic/1106178-",
|
"url": "http://www.minecraftforum.net/topic/1106178-",
|
||||||
"updateUrl": "",
|
"updateUrl": "",
|
||||||
"authorList": [
|
"authorList": [
|
||||||
"pahimar",
|
"pahimar",
|
||||||
"x3n0ph0b3"
|
"x3n0ph0b3"
|
||||||
],
|
],
|
||||||
"credits": "By pahimar, based (loosely) on Equivalent Exchange 1 & 2 by x3n0ph0b3",
|
"credits": "pahimar and x3n0ph0b3",
|
||||||
"logoFile": "assets/ee3/textures/logo/logo.png",
|
"logoFile": "assets/ee3/textures/logo/logo.png",
|
||||||
"screenshots": [
|
"screenshots": [
|
||||||
],
|
],
|
||||||
|
|
Loading…
Reference in a new issue