aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbartimaeusnek <33183715+bartimaeusnek@users.noreply.github.com>2021-03-03 19:02:06 +0100
committerDreamMasterXXL <dream-master@gmx.net>2021-03-03 19:35:41 +0100
commit208e3044d9dbd39957e65d73bfc22b0c755affbf (patch)
treeaca67276e7d9963c1cd644e8b17212371beeaa18
parent029ac0f5f4df8b18810642db139ddd385e484962 (diff)
downloadGT5-Unofficial-208e3044d9dbd39957e65d73bfc22b0c755affbf.tar.gz
GT5-Unofficial-208e3044d9dbd39957e65d73bfc22b0c755affbf.tar.bz2
GT5-Unofficial-208e3044d9dbd39957e65d73bfc22b0c755affbf.zip
Added TGregworks integration (#126)
(cherry picked from commit e6f4a1453afece3e68c750684a225be415b40584 [formerly 44aa12c5de2f8e1487e5f5d140668ba559d31ab1]) Former-commit-id: 08379a6fa1c8961e288f6da614ba536d4af7af21
-rw-r--r--build.gradle.kts14
-rw-r--r--gradle.properties2
-rw-r--r--src/main/java/com/github/bartimaeusnek/bartworks/API/LoaderReference.java2
-rw-r--r--src/main/java/com/github/bartimaeusnek/crossmod/BartWorksCrossmod.java4
-rw-r--r--src/main/java/com/github/bartimaeusnek/crossmod/tgregworks/MaterialsInjector.java145
5 files changed, 166 insertions, 1 deletions
diff --git a/build.gradle.kts b/build.gradle.kts
index 5351995bcf..4cd7e8c3a7 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -52,8 +52,10 @@ java {
this.sourceCompatibility = JavaVersion.VERSION_1_8
this.targetCompatibility = JavaVersion.VERSION_1_8
}
+
configurations.all {
resolutionStrategy.cacheChangingModulesFor(0, TimeUnit.SECONDS)
+ isTransitive = false
}
tasks.withType<JavaCompile> {
@@ -103,6 +105,10 @@ repositories {
this.name = "BuildCraft"
this.artifactPattern("http://www.mod-buildcraft.com/releases/BuildCraft/[revision]/[module]-[revision](-[classifier]).[ext]")
}
+ ivy {
+ this.name = "vexatos"
+ this.artifactPattern("https://files.vexatos.com/[organisation]/[module]-[revision]-[classifier].[ext]")
+ }
maven("http://maven.cil.li/") { this.name = "OpenComputers" }
maven("http://default.mobiusstrip.eu/maven") { this.name = "Jabba" }
maven("http://chickenbones.net/maven/") { this.name = "CodeChicken" }
@@ -118,12 +124,19 @@ dependencies {
val applecoreVersion: String by project
val enderCoreVersion: String by project
val enderioVersion: String by project
+
//hard deps
compile("net.industrial-craft:industrialcraft-2:$ic2Version:dev")
//jitpack
compile("com.github.GTNewHorizons:GT5-Unofficial:experimental-SNAPSHOT:dev") {
this.isChanging = true
}
+ compile("com.github.GTNewHorizons:TinkersConstruct:master-SNAPSHOT:deobf") {
+ this.isChanging = true
+ }
+ compileOnly("com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-1.7.10-SNAPSHOT:dev") {
+ this.isChanging = true
+ }
//soft deps
compileOnly("com.azanor.baubles:Baubles:1.7.10-1.0.1.10:deobf")
compileOnly("thaumcraft:Thaumcraft:1.7.10-4.2.3.5:dev")
@@ -133,6 +146,7 @@ dependencies {
compile("micdoodle8.mods:Galacticraft-Planets:$galacticraftVersion:Dev")
compileOnly("li.cil.oc:OpenComputers:MC1.7.10-1.5.+:api")
compileOnly("net.sengir.forestry:forestry_1.7.10:4.2.16.64:dev")
+ compileOnly("TGregworks:TGregworks:1.7.10-GTNH-1.0.19:deobf")
//jitpack
compileOnly("com.github.GTNewHorizons:GalacticGregGT5:master-SNAPSHOT") {
this.isChanging = true
diff --git a/gradle.properties b/gradle.properties
index 79e967b70c..e40fde0e49 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -21,7 +21,7 @@
#
majorUpdate=0
minorUpdate=5
-buildNumber=15
+buildNumber=16
apiVersion=11
ic2Version=2.2.828-experimental
applecoreVersion=1.7.10-3.1.1
diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/API/LoaderReference.java b/src/main/java/com/github/bartimaeusnek/bartworks/API/LoaderReference.java
index 16ec04b43e..4cc8ad45c1 100644
--- a/src/main/java/com/github/bartimaeusnek/bartworks/API/LoaderReference.java
+++ b/src/main/java/com/github/bartimaeusnek/bartworks/API/LoaderReference.java
@@ -56,6 +56,7 @@ public class LoaderReference {
public static boolean EnderIO;
public static boolean HardcoreEnderExpension;
public static boolean betterloadingscreen;
+ public static boolean TGregworks;
public static void init() {
Natura = Loader.isModLoaded("Natura");
@@ -84,5 +85,6 @@ public class LoaderReference {
EnderIO = Loader.isModLoaded("EnderIO");
HardcoreEnderExpension = Loader.isModLoaded("HardcoreEnderExpension");
betterloadingscreen = Loader.isModLoaded("betterloadingscreen");
+ TGregworks = Loader.isModLoaded("TGregworks");
}
}
diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/BartWorksCrossmod.java b/src/main/java/com/github/bartimaeusnek/crossmod/BartWorksCrossmod.java
index c5376dbf3b..ee6f09d4ee 100644
--- a/src/main/java/com/github/bartimaeusnek/crossmod/BartWorksCrossmod.java
+++ b/src/main/java/com/github/bartimaeusnek/crossmod/BartWorksCrossmod.java
@@ -28,6 +28,7 @@ import com.github.bartimaeusnek.crossmod.GTpp.loader.RadioHatchCompat;
import com.github.bartimaeusnek.crossmod.galacticraft.GalacticraftProxy;
import com.github.bartimaeusnek.crossmod.tectech.TecTechResearchLoader;
import com.github.bartimaeusnek.crossmod.tectech.tileentites.multi.GT_Replacement.*;
+import com.github.bartimaeusnek.crossmod.tgregworks.MaterialsInjector;
import com.github.bartimaeusnek.crossmod.thaumcraft.CustomAspects;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.event.FMLInitializationEvent;
@@ -46,6 +47,7 @@ import java.io.StringReader;
dependencies = "required-after:IC2; "
+ "required-after:gregtech; "
+ "required-after:bartworks;"
+ + "before:TGregworks; "
+ "after:GalacticraftMars; "
+ "after:GalacticraftCore; "
+ "after:Micdoodlecore; "
@@ -87,6 +89,8 @@ public class BartWorksCrossmod {
new BW_TT_HeatExchanger(null, null);
}
+ if (LoaderReference.TGregworks)
+ MaterialsInjector.run();
}
@Mod.EventHandler
diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/tgregworks/MaterialsInjector.java b/src/main/java/com/github/bartimaeusnek/crossmod/tgregworks/MaterialsInjector.java
new file mode 100644
index 0000000000..2234347045
--- /dev/null
+++ b/src/main/java/com/github/bartimaeusnek/crossmod/tgregworks/MaterialsInjector.java
@@ -0,0 +1,145 @@
+package com.github.bartimaeusnek.crossmod.tgregworks;
+
+import com.github.bartimaeusnek.bartworks.MainMod;
+import com.github.bartimaeusnek.bartworks.system.material.Werkstoff;
+import cpw.mods.fml.common.FMLCommonHandler;
+import gregtech.api.enums.Materials;
+import gregtech.api.enums.OrePrefixes;
+import net.minecraftforge.common.config.Property;
+import tconstruct.library.TConstructRegistry;
+import vexatos.tgregworks.TGregworks;
+import vexatos.tgregworks.integration.TGregRegistry;
+import vexatos.tgregworks.item.ItemTGregPart;
+import vexatos.tgregworks.reference.Config;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.HashMap;
+
+@SuppressWarnings("unchecked")
+public class MaterialsInjector {
+ private static HashMap<Materials, Property> configProps;
+ private static ArrayList<Integer> configIDs;
+ private static Method getGlobalMultiplierMethod;
+ private static Method getGlobalMultiplierMethodTwoArguments;
+ private static Method getMultiplierMethod;
+ private static Method getMaterialIDMethod;
+ private static Method getReinforcedLevelMethod;
+ private static Method getStoneboundLevelMethod;
+
+ static {
+ try {
+ getFields();
+ getMethodes();
+ } catch (
+ IllegalArgumentException
+ | IllegalAccessException
+ | NoSuchFieldException
+ | NoSuchMethodException
+ | SecurityException
+ e) {
+ MainMod.LOGGER.catching(e);
+ FMLCommonHandler.instance().exitJava(1, true);
+ }
+ }
+
+ private static void getFields() throws IllegalArgumentException, IllegalAccessException, NoSuchFieldException {
+ Field configPropsField = TGregRegistry.class.getDeclaredField("configProps");
+ configPropsField.setAccessible(true);
+ configProps = (HashMap<Materials, Property>) configPropsField.get(TGregworks.registry);
+
+ Field configIDsField = TGregRegistry.class.getDeclaredField("configIDs");
+ configIDsField.setAccessible(true);
+ configIDs = (ArrayList<Integer>) configIDsField.get(TGregworks.registry);
+ }
+
+ private static void getMethodes() throws NoSuchMethodException, SecurityException {
+ getGlobalMultiplierMethod = TGregRegistry.class.getDeclaredMethod("getGlobalMultiplier", String.class);
+ getGlobalMultiplierMethod.setAccessible(true);
+
+ getGlobalMultiplierMethodTwoArguments = TGregRegistry.class.getDeclaredMethod("getGlobalMultiplier", String.class, double.class);
+ getGlobalMultiplierMethodTwoArguments.setAccessible(true);
+
+ getMultiplierMethod = TGregRegistry.class.getDeclaredMethod("getMultiplier", Materials.class, String.class);
+ getMultiplierMethod.setAccessible(true);
+
+ getMaterialIDMethod = TGregRegistry.class.getDeclaredMethod("getMaterialID", Materials.class);
+ getMaterialIDMethod.setAccessible(true);
+
+ getReinforcedLevelMethod = TGregRegistry.class.getDeclaredMethod("getReinforcedLevel", Materials.class);
+ getReinforcedLevelMethod.setAccessible(true);
+
+ getStoneboundLevelMethod = TGregRegistry.class.getDeclaredMethod("getStoneboundLevel", Materials.class);
+ getStoneboundLevelMethod.setAccessible(true);
+ }
+
+ public static void run() {
+ MainMod.LOGGER.info("Registering TGregworks - BartWorks tool parts.");
+ Werkstoff.werkstoffHashSet.stream()
+ .filter(x -> x.hasItemType(OrePrefixes.gem) || x.hasItemType(OrePrefixes.plate))
+ .map(Werkstoff::getBridgeMaterial)
+ .filter(x -> x.mMetaItemSubID == -1)
+ .filter(x -> x.mDurability != 0)
+ .forEach(m -> {
+ setConfigProps(m);
+ registerParts(m);
+ });
+
+ configProps.clear();
+ configIDs.clear();
+
+ ItemTGregPart.toolMaterialNames = TGregworks.registry.toolMaterialNames;
+ }
+
+ private static void registerParts(Materials m) {
+ try {
+ TGregworks.registry.toolMaterialNames.add(m.mDefaultLocalName);
+ int matID = (int) getMaterialIDMethod.invoke(TGregworks.registry, m);
+
+ addToolMaterial(matID, m);
+ addBowMaterial(matID, m);
+ addArrowMaterial(matID, m);
+
+ TGregworks.registry.matIDs.put(m, matID);
+ TGregworks.registry.materialIDMap.put(matID, m);
+ } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
+ MainMod.LOGGER.catching(e);
+ FMLCommonHandler.instance().exitJava(1, true);
+ }
+ }
+
+ private static void setConfigProps(Materials m){
+ if (TGregworks.config.get(Config.Category.Enable, m.mName, true).getBoolean(true)) {
+ TGregworks.registry.toolMaterials.add(m);
+ Property configProp = TGregworks.config.get(Config.onMaterial(Config.MaterialID), m.mName, 0, null, 0, 100000);
+ configProps.put(m, configProp);
+ configIDs.add(configProp.getInt());
+ }
+ }
+
+ private static void addToolMaterial(int matID, Materials m)
+ throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {
+ TConstructRegistry.addToolMaterial(matID, m.mName, m.mLocalizedName, m.mToolQuality,
+ (int) (m.mDurability * (float) getGlobalMultiplierMethod.invoke(TGregworks.registry, Config.Durability) * (float) getMultiplierMethod.invoke(TGregworks.registry, m, Config.Durability)), // Durability
+ (int) (m.mToolSpeed * 100F * (float) getGlobalMultiplierMethod.invoke(TGregworks.registry, Config.MiningSpeed) * (float) getMultiplierMethod.invoke(TGregworks.registry, m, Config.MiningSpeed)), // Mining speed
+ (int) (m.mToolQuality * (float) getGlobalMultiplierMethod.invoke(TGregworks.registry, Config.Attack) * (float) getMultiplierMethod.invoke(TGregworks.registry, m, Config.Attack)), // Attack
+ (m.mToolQuality - 0.5F) * (float) getGlobalMultiplierMethod.invoke(TGregworks.registry, Config.HandleModifier) * (float) getMultiplierMethod.invoke(TGregworks.registry, m, Config.HandleModifier), // Handle Modifier
+ (int) getReinforcedLevelMethod.invoke(TGregworks.registry, m), (float) getStoneboundLevelMethod.invoke(TGregworks.registry, m), "", (m.getRGBA()[0] << 16) | (m.getRGBA()[1] << 8) | (m.getRGBA()[2]));
+ }
+
+ private static void addBowMaterial(int matID, Materials m)
+ throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {
+ TConstructRegistry.addBowMaterial(matID,
+ (int) ((float) m.mToolQuality * 10F * (float) getGlobalMultiplierMethod.invoke(TGregworks.registry, Config.BowDrawSpeed) * (float) getMultiplierMethod.invoke(TGregworks.registry, m, Config.BowDrawSpeed)),
+ (((float) m.mToolQuality) - 0.5F) * (float) getGlobalMultiplierMethod.invoke(TGregworks.registry, Config.BowFlightSpeed) * (float) getMultiplierMethod.invoke(TGregworks.registry, m, Config.BowFlightSpeed));
+ }
+
+ private static void addArrowMaterial(int matID, Materials m)
+ throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {
+ TConstructRegistry.addArrowMaterial(matID,
+ (float) ((((double) m.getMass()) / 10F) * (float) getGlobalMultiplierMethod.invoke(TGregworks.registry, Config.ArrowMass) * (float) getMultiplierMethod.invoke(TGregworks.registry, m, Config.ArrowMass)),
+ (float) getGlobalMultiplierMethodTwoArguments.invoke(TGregworks.registry, Config.ArrowBreakChance, 0.9) * (float) getMultiplierMethod.invoke(TGregworks.registry, m, Config.ArrowBreakChance));
+ }
+}