feat: add Auracore infusion & research compat
This commit is contained in:
parent
bfb5c7d474
commit
c09e3dfe09
36
build.gradle
36
build.gradle
|
@ -18,6 +18,7 @@ buildscript {
|
|||
}
|
||||
|
||||
apply plugin: 'forge'
|
||||
apply plugin: 'maven-publish'
|
||||
apply plugin: 'java'
|
||||
|
||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||
|
@ -56,7 +57,7 @@ repositories {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
implementation "dev.tilera:auracore:1.2.0:deobf"
|
||||
implementation "dev.tilera:auracore:1.8.0:deobf"
|
||||
implementation "net.sengir.forestry:forestry_${config.minecraft.version}:${config.forestry.version}:api"
|
||||
}
|
||||
|
||||
|
@ -86,3 +87,36 @@ task deobfJar(type: Jar) {
|
|||
}
|
||||
|
||||
tasks.build.dependsOn deobfJar
|
||||
|
||||
task sourcesJar(type: Jar) {
|
||||
from sourceSets.main.allSource
|
||||
classifier = 'sources'
|
||||
}
|
||||
|
||||
publishing {
|
||||
tasks.publish.dependsOn 'build'
|
||||
publications {
|
||||
mavenJava(MavenPublication) {
|
||||
artifactId = project.archivesBaseName
|
||||
|
||||
artifact deobfJar
|
||||
artifact sourcesJar
|
||||
artifact jar
|
||||
}
|
||||
}
|
||||
|
||||
repositories {
|
||||
if (project.hasProperty('mvnURL')) {
|
||||
maven {
|
||||
credentials {
|
||||
username findProperty("mvnUsername")
|
||||
password findProperty("mvnPassword")
|
||||
}
|
||||
url = findProperty("mvnURL")
|
||||
}
|
||||
}
|
||||
else {
|
||||
mavenLocal()
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
minecraft.version=1.7.10
|
||||
forge.version=10.13.4.1614-1.7.10
|
||||
|
||||
mod.version=0.10.1
|
||||
mod.version=0.11.0
|
||||
|
||||
forestry.version=4.1.0.43
|
||||
|
|
|
@ -0,0 +1,68 @@
|
|||
package modtweaker2.mods.auracore;
|
||||
|
||||
import dev.tilera.auracore.api.AuracoreRecipes;
|
||||
import dev.tilera.auracore.api.crafting.CrucibleRecipe;
|
||||
import dev.tilera.auracore.api.research.ResearchPageCrucible;
|
||||
import minetweaker.IUndoableAction;
|
||||
import modtweaker2.mods.thaumcraft.ThaumcraftHelper;
|
||||
import thaumcraft.api.research.ResearchCategories;
|
||||
import thaumcraft.api.research.ResearchPage;
|
||||
|
||||
public class AddCruciblePage implements IUndoableAction {
|
||||
String key;
|
||||
String tab;
|
||||
ResearchPage page;
|
||||
ResearchPage[] oldPages;
|
||||
String recipeKey;
|
||||
|
||||
public AddCruciblePage(String research, String key) {
|
||||
this.key = research;
|
||||
this.tab = ThaumcraftHelper.getResearchTab(this.key);
|
||||
this.recipeKey = key;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
for (CrucibleRecipe rec : AuracoreRecipes.getCrucibleRecipes()) {
|
||||
if (rec.key.equals(recipeKey)) {
|
||||
page = new ResearchPageCrucible(rec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (page == null) return;
|
||||
oldPages = ResearchCategories.researchCategories.get(tab).research.get(key).getPages();
|
||||
if (oldPages == null) oldPages = new ResearchPage[0];
|
||||
ResearchPage[] newPages = new ResearchPage[oldPages.length + 1];
|
||||
for (int x = 0; x < oldPages.length; x++) {
|
||||
newPages[x] = oldPages[x];
|
||||
}
|
||||
newPages[oldPages.length] = page;
|
||||
ResearchCategories.researchCategories.get(tab).research.get(key).setPages(newPages);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describe() {
|
||||
return "Adding Research Page to " + key;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUndo() {
|
||||
return oldPages != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void undo() {
|
||||
ResearchCategories.researchCategories.get(tab).research.get(key).setPages(oldPages);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describeUndo() {
|
||||
return "Removing Page from " + key;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOverrideKey() {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,68 @@
|
|||
package modtweaker2.mods.auracore;
|
||||
|
||||
import dev.tilera.auracore.api.AuracoreRecipes;
|
||||
import dev.tilera.auracore.api.crafting.IInfusionRecipe;
|
||||
import dev.tilera.auracore.api.research.ResearchPageInfusion;
|
||||
import minetweaker.IUndoableAction;
|
||||
import modtweaker2.mods.thaumcraft.ThaumcraftHelper;
|
||||
import thaumcraft.api.research.ResearchCategories;
|
||||
import thaumcraft.api.research.ResearchPage;
|
||||
|
||||
public class AddInfusionPage implements IUndoableAction {
|
||||
String key;
|
||||
String tab;
|
||||
ResearchPage page;
|
||||
ResearchPage[] oldPages;
|
||||
String recipeKey;
|
||||
|
||||
public AddInfusionPage(String research, String key) {
|
||||
this.key = research;
|
||||
this.tab = ThaumcraftHelper.getResearchTab(this.key);
|
||||
this.recipeKey = key;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
for (IInfusionRecipe rec : AuracoreRecipes.getInfusionRecipes()) {
|
||||
if (rec.getKey().equals(recipeKey)) {
|
||||
page = new ResearchPageInfusion(rec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (page == null) return;
|
||||
oldPages = ResearchCategories.researchCategories.get(tab).research.get(key).getPages();
|
||||
if (oldPages == null) oldPages = new ResearchPage[0];
|
||||
ResearchPage[] newPages = new ResearchPage[oldPages.length + 1];
|
||||
for (int x = 0; x < oldPages.length; x++) {
|
||||
newPages[x] = oldPages[x];
|
||||
}
|
||||
newPages[oldPages.length] = page;
|
||||
ResearchCategories.researchCategories.get(tab).research.get(key).setPages(newPages);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describe() {
|
||||
return "Adding Research Page to " + key;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUndo() {
|
||||
return oldPages != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void undo() {
|
||||
ResearchCategories.researchCategories.get(tab).research.get(key).setPages(oldPages);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describeUndo() {
|
||||
return "Removing Page from " + key;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOverrideKey() {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
|
@ -2,12 +2,16 @@ package modtweaker2.mods.auracore;
|
|||
|
||||
import minetweaker.MineTweakerAPI;
|
||||
import modtweaker2.mods.auracore.handlers.Crucible;
|
||||
import modtweaker2.mods.auracore.handlers.Infusion;
|
||||
import modtweaker2.mods.auracore.handlers.Research;
|
||||
import modtweaker2.utils.TweakerPlugin;
|
||||
|
||||
public class AuraCore extends TweakerPlugin {
|
||||
|
||||
public AuraCore() {
|
||||
MineTweakerAPI.registerClass(Crucible.class);
|
||||
MineTweakerAPI.registerClass(Infusion.class);
|
||||
MineTweakerAPI.registerClass(Research.class);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,102 @@
|
|||
package modtweaker2.mods.auracore.handlers;
|
||||
|
||||
import static modtweaker2.helpers.InputHelper.toStacks;
|
||||
import static modtweaker2.helpers.InputHelper.toStack;
|
||||
import static modtweaker2.helpers.InputHelper.toIItemStack;
|
||||
import static modtweaker2.helpers.StackHelper.matches;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import dev.tilera.auracore.api.AuracoreRecipes;
|
||||
import dev.tilera.auracore.api.crafting.IInfusionRecipe;
|
||||
import dev.tilera.auracore.api.crafting.ShapedInfusionCraftingRecipe;
|
||||
import dev.tilera.auracore.api.crafting.ShapelessInfusionCraftingRecipe;
|
||||
import minetweaker.MineTweakerAPI;
|
||||
import minetweaker.api.item.IItemStack;
|
||||
import modtweaker2.helpers.LogHelper;
|
||||
import modtweaker2.mods.thaumcraft.ThaumcraftHelper;
|
||||
import modtweaker2.utils.BaseListAddition;
|
||||
import modtweaker2.utils.BaseListRemoval;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
|
||||
@ZenClass("mods.auracore.Infusion")
|
||||
public class Infusion {
|
||||
|
||||
public static final String name = "Auracore Infusion Altar";
|
||||
|
||||
@ZenMethod
|
||||
public static void addShaped(String key, String research, int cost, IItemStack output, String aspects, IItemStack[][] ingredients) {
|
||||
List<ItemStack> stacks = new ArrayList<>();
|
||||
int width = 0;
|
||||
int height = 0;
|
||||
for(IItemStack[] row : ingredients) {
|
||||
height++;
|
||||
width = Math.max(width, row.length);
|
||||
for (IItemStack i : row) {
|
||||
stacks.add(toStack(i));
|
||||
}
|
||||
}
|
||||
MineTweakerAPI.apply(new Add(new ShapedInfusionCraftingRecipe(key, research, width, height, stacks.toArray(new ItemStack[stacks.size()]), toStack(output), cost, ThaumcraftHelper.parseAspects(aspects))));
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void addShapeless(String key, String research, int cost, IItemStack output, String aspects, IItemStack[] ingredients) {
|
||||
MineTweakerAPI.apply(new Add(new ShapelessInfusionCraftingRecipe(key, research, toStack(output), Arrays.asList(toStacks(ingredients)), cost, ThaumcraftHelper.parseAspects(aspects))));
|
||||
}
|
||||
|
||||
private static class Add extends BaseListAddition<IInfusionRecipe> {
|
||||
public Add(IInfusionRecipe recipe) {
|
||||
super(Infusion.name, AuracoreRecipes.getInfusionRecipes());
|
||||
recipes.add(recipe);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getRecipeInfo(IInfusionRecipe recipe) {
|
||||
ItemStack stack = recipe.getRecipeOutput();
|
||||
|
||||
if(stack instanceof ItemStack)
|
||||
return LogHelper.getStackDescription(stack);
|
||||
else
|
||||
return "Unknown output";
|
||||
}
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void removeRecipe(IItemStack output) {
|
||||
List<IInfusionRecipe> recipes = new LinkedList<IInfusionRecipe>();
|
||||
|
||||
for(IInfusionRecipe recipe : AuracoreRecipes.getInfusionRecipes()) {
|
||||
if(recipe.getRecipeOutput() != null && matches(output, toIItemStack(recipe.getRecipeOutput()))) {
|
||||
recipes.add(recipe);
|
||||
}
|
||||
}
|
||||
|
||||
if(!recipes.isEmpty()) {
|
||||
MineTweakerAPI.apply(new Remove(recipes));
|
||||
} else {
|
||||
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command Ignored", Infusion.name, output.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
private static class Remove extends BaseListRemoval<IInfusionRecipe> {
|
||||
public Remove(List<IInfusionRecipe> recipes) {
|
||||
super(Infusion.name, AuracoreRecipes.getInfusionRecipes(), recipes);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getRecipeInfo(IInfusionRecipe recipe) {
|
||||
ItemStack stack = recipe.getRecipeOutput();
|
||||
|
||||
if(stack instanceof ItemStack)
|
||||
return LogHelper.getStackDescription(stack);
|
||||
else
|
||||
return "Unknown output";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
package modtweaker2.mods.auracore.handlers;
|
||||
|
||||
import minetweaker.MineTweakerAPI;
|
||||
import modtweaker2.mods.auracore.AddCruciblePage;
|
||||
import modtweaker2.mods.auracore.AddInfusionPage;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
|
||||
@ZenClass("mods.auracore.Research")
|
||||
public class Research {
|
||||
|
||||
@ZenMethod
|
||||
public static void addInfusionPage(String research, String recipe) {
|
||||
MineTweakerAPI.apply(new AddInfusionPage(research, recipe));
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void addCruciblePage(String research, String recipe) {
|
||||
MineTweakerAPI.apply(new AddCruciblePage(research, recipe));
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue