Fixed Casting

Added imbuing station
This commit is contained in:
Jared 2016-07-16 22:21:21 +02:00
parent 7dc059e92f
commit b2a289fd67
9 changed files with 17685 additions and 68 deletions

Binary file not shown.

8963
mcp/fields.csv Normal file

File diff suppressed because it is too large Load diff

8550
mcp/methods.csv Normal file

File diff suppressed because it is too large Load diff

View file

@ -5,15 +5,14 @@ import minetweaker.MineTweakerImplementationAPI.ReloadEvent;
import minetweaker.runtime.providers.ScriptProviderDirectory;
import minetweaker.util.IEventHandler;
import modtweaker2.mods.forestry.Forestry;
import modtweaker2.mods.randomthings.RandomThings;
import modtweaker2.mods.tconstruct.TConstruct;
import modtweaker2.proxy.CommonProxy;
import modtweaker2.utils.TweakerPlugin;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.*;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.Mod.Instance;
import net.minecraftforge.fml.common.SidedProxy;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
@ -46,6 +45,7 @@ public class ModTweaker2 {
logger.info("Starting Initialization for " + ModProps.modid);
TweakerPlugin.register("forestry", Forestry.class);
TweakerPlugin.register("tconstruct", TConstruct.class);
TweakerPlugin.register("randomthings", RandomThings.class);
if (FMLCommonHandler.instance().getSide() == Side.CLIENT) {
MinecraftForge.EVENT_BUS.register(new ClientEvents());

View file

@ -0,0 +1,15 @@
package modtweaker2.mods.randomthings;
import minetweaker.MineTweakerAPI;
import modtweaker2.mods.randomthings.handlers.ImbuingStation;
/**
* Created by Jared on 7/16/2016.
*/
public class RandomThings {
public RandomThings() {
MineTweakerAPI.registerClass(ImbuingStation.class);
}
}

View file

@ -0,0 +1,87 @@
package modtweaker2.mods.randomthings.handlers;
import lumien.randomthings.recipes.imbuing.ImbuingRecipe;
import lumien.randomthings.recipes.imbuing.ImbuingRecipeHandler;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IItemStack;
import modtweaker2.helpers.InputHelper;
import modtweaker2.helpers.LogHelper;
import modtweaker2.utils.BaseListAddition;
import modtweaker2.utils.BaseListRemoval;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
/**
* Created by Jared on 7/16/2016.
*/
@ZenClass("mods.randomthings.ImbuingStation")
public class ImbuingStation {
@ZenMethod
public static void add(IItemStack output, IItemStack input, IItemStack ingredient1, IItemStack ingredient2, IItemStack ingredient3) {
MineTweakerAPI.apply(new Add(new ImbuingRecipe(InputHelper.toStack(input), InputHelper.toStack(output), InputHelper.toStack(ingredient1), InputHelper.toStack(ingredient2), InputHelper.toStack(ingredient3))));
}
@ZenMethod
public static void remove(IItemStack output, IItemStack input, IItemStack ingredient1, IItemStack ingredient2, IItemStack ingredient3) {
MineTweakerAPI.apply(new Remove(new ImbuingRecipe(InputHelper.toStack(input), InputHelper.toStack(output), InputHelper.toStack(ingredient1), InputHelper.toStack(ingredient2), InputHelper.toStack(ingredient3))));
}
private static class Add extends BaseListAddition<ImbuingRecipe> {
protected Add(ImbuingRecipe recipe) {
super("ImbuingStation", ImbuingRecipeHandler.imbuingRecipes);
this.recipes.add(recipe);
}
@Override
protected String getRecipeInfo(ImbuingRecipe recipe) {
StringBuilder build = new StringBuilder();
build.append(LogHelper.getStackDescription(recipe.getResult()));
build.append(LogHelper.getStackDescription(recipe.toImbue()));
for (ItemStack stack : recipe.getIngredients()) {
build.append(LogHelper.getStackDescription(stack));
}
return build.toString();
}
}
private static class Remove extends BaseListRemoval<ImbuingRecipe> {
protected Remove(ImbuingRecipe recipe) {
super("ImbuingStation", ImbuingRecipeHandler.imbuingRecipes);
this.recipes.add(recipe);
}
@Override
public void apply() {
if (recipes.isEmpty()) {
return;
}
for (ImbuingRecipe recipe : this.recipes) {
if (recipe != null) {
if (ImbuingRecipeHandler.imbuingRecipes.remove(recipe)) {
successful.add(recipe);
} else {
LogHelper.logError(String.format("Error removing %s Recipe for %s", name, getRecipeInfo(recipe)));
}
} else {
LogHelper.logError(String.format("Error removing %s Recipe: null object", name));
}
}
}
@Override
protected String getRecipeInfo(ImbuingRecipe recipe) {
StringBuilder build = new StringBuilder();
build.append(LogHelper.getStackDescription(recipe.getResult()) + ", ");
build.append(LogHelper.getStackDescription(recipe.toImbue()) + ", ");
for (ItemStack stack : recipe.getIngredients()) {
build.append(LogHelper.getStackDescription(stack) + " ");
}
return build.toString();
}
}
}

View file

@ -1,15 +1,5 @@
package modtweaker2.mods.tconstruct.handlers;
import static modtweaker2.helpers.InputHelper.toFluid;
import static modtweaker2.helpers.InputHelper.toIItemStack;
import static modtweaker2.helpers.InputHelper.toILiquidStack;
import static modtweaker2.helpers.InputHelper.toStack;
import static modtweaker2.helpers.StackHelper.matches;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
@ -19,10 +9,18 @@ import modtweaker2.helpers.LogHelper;
import modtweaker2.mods.tconstruct.TConstructHelper;
import modtweaker2.utils.BaseListAddition;
import modtweaker2.utils.BaseListRemoval;
import slimeknights.mantle.util.RecipeMatch;
import slimeknights.tconstruct.library.smeltery.CastingRecipe;
import stanhebben.zenscript.annotations.Optional;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
import slimeknights.tconstruct.library.smeltery.CastingRecipe;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import static modtweaker2.helpers.InputHelper.*;
import static modtweaker2.helpers.StackHelper.matches;
@ZenClass("mods.tconstruct.Casting")
public class Casting {
@ -32,23 +30,23 @@ public class Casting {
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZenMethod
public static void addBasinRecipe(IItemStack output, ILiquidStack metal, @Optional IItemStack cast, @Optional boolean consume, int delay) {
if(metal == null || output == null) {
public static void addBasinRecipe(IItemStack output, ILiquidStack metal, @Optional IItemStack cast) {
if (metal == null || output == null) {
LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name));
return;
}
MineTweakerAPI.apply(new Add(new CastingRecipe(toStack(output), toFluid(metal), toStack(cast), consume, delay, null), TConstructHelper.basinCasting));
CastingRecipe rec = new CastingRecipe(toStack(output), RecipeMatch.of(toStack(cast)), toFluid(metal).getFluid(), metal.getAmount());
MineTweakerAPI.apply(new Add(rec, (ArrayList<CastingRecipe>) TConstructHelper.basinCasting));
}
@ZenMethod
public static void addTableRecipe(IItemStack output, ILiquidStack metal, @Optional IItemStack cast, @Optional boolean consume, int delay) {
if(metal == null || output == null) {
public static void addTableRecipe(IItemStack output, ILiquidStack metal, @Optional IItemStack cast) {
if (metal == null || output == null) {
LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name));
return;
}
MineTweakerAPI.apply(new Add(new CastingRecipe(toStack(output), toFluid(metal), toStack(cast), consume, delay, null), TConstructHelper.tableCasting));
CastingRecipe rec = new CastingRecipe(toStack(output), RecipeMatch.of(toStack(cast)), toFluid(metal).getFluid(), metal.getAmount());
MineTweakerAPI.apply(new Add(rec, (ArrayList<CastingRecipe>) TConstructHelper.tableCasting));
}
//Passes the list to the base list implementation, and adds the recipe
@ -61,7 +59,7 @@ public class Casting {
@Override
protected String getRecipeInfo(CastingRecipe recipe) {
return LogHelper.getStackDescription(recipe.output);
return LogHelper.getStackDescription(recipe.getResult());
}
}
@ -79,32 +77,31 @@ public class Casting {
}
public static void removeRecipe(IIngredient output, IIngredient material, IIngredient cast, List<CastingRecipe> list) {
if(output == null) {
if (output == null) {
LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name));
return;
}
if(material == null) {
if (material == null) {
material = IngredientAny.INSTANCE;
}
if(cast == null) {
if (cast == null) {
cast = IngredientAny.INSTANCE;
}
List<CastingRecipe> recipes = new LinkedList<CastingRecipe>();
for(CastingRecipe recipe : list) {
if(recipe != null) {
if (!matches(output, toIItemStack(recipe.output))) {
for (CastingRecipe recipe : list) {
if (recipe != null) {
if (!matches(output, toIItemStack(recipe.getResult()))) {
continue;
}
if (!matches(material, toILiquidStack(recipe.castingMetal))) {
if (!matches(material, toILiquidStack(recipe.getFluid()))) {
continue;
}
if(!matches(cast, toIItemStack(recipe.cast))) {
if (recipe.cast.matches(toStacks(cast.getItems().toArray(new IItemStack[0]))) != null) {
continue;
}
@ -112,9 +109,13 @@ public class Casting {
}
}
if(!recipes.isEmpty()) {
if (!recipes.isEmpty())
{
MineTweakerAPI.apply(new Remove(list, recipes));
} else {
} else
{
LogHelper.logWarning(String.format("No %s Recipe found for output %s, material %s and cast %s. Command ignored!", Casting.name, output.toString(), material.toString(), cast.toString()));
}
}
@ -127,7 +128,7 @@ public class Casting {
@Override
protected String getRecipeInfo(CastingRecipe recipe) {
return LogHelper.getStackDescription(recipe.output);
return LogHelper.getStackDescription(recipe.getResult());
}
}
}

View file

@ -1,11 +1,5 @@
package modtweaker2.mods.tconstruct.handlers;
import static modtweaker2.helpers.InputHelper.toIItemStack;
import static modtweaker2.helpers.InputHelper.toStack;
import java.util.LinkedList;
import java.util.List;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
@ -13,9 +7,16 @@ import modtweaker2.helpers.LogHelper;
import modtweaker2.mods.tconstruct.TConstructHelper;
import modtweaker2.utils.BaseListAddition;
import modtweaker2.utils.BaseListRemoval;
import slimeknights.tconstruct.library.DryingRecipe;
import slimeknights.tconstruct.library.TinkerRegistry;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
import slimeknights.tconstruct.library.DryingRecipe;
import java.util.LinkedList;
import java.util.List;
import static modtweaker2.helpers.InputHelper.toIItemStack;
import static modtweaker2.helpers.InputHelper.toStack;
@ZenClass("mods.tconstruct.Drying")
public class Drying {
@ -26,7 +27,7 @@ public class Drying {
@ZenMethod
public static void addRecipe(IItemStack input, IItemStack output, int time) {
if(input == null || output == null) {
if (input == null || output == null) {
LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name));
return;
}
@ -37,13 +38,13 @@ public class Drying {
//Passes the list to the base list implementation, and adds the recipe
private static class Add extends BaseListAddition<DryingRecipe> {
public Add(DryingRecipe recipe) {
super(Drying.name, DryingRackRecipes.recipes);
super(Drying.name, TinkerRegistry.getAllDryingRecipes());
this.recipes.add(recipe);
}
@Override
protected String getRecipeInfo(DryingRecipe recipe) {
return LogHelper.getStackDescription(recipe.result);
return LogHelper.getStackDescription(recipe.getResult());
}
}
@ -54,13 +55,13 @@ public class Drying {
public static void removeRecipe(IIngredient ingredient) {
List<DryingRecipe> recipes = new LinkedList<DryingRecipe>();
for (DryingRecipe recipe : DryingRackRecipes.recipes) {
if (recipe != null && recipe.result != null && ingredient.matches(toIItemStack(recipe.result))) {
for (DryingRecipe recipe : TinkerRegistry.getAllDryingRecipes()) {
if (recipe != null && recipe.getResult() != null && ingredient.matches(toIItemStack(recipe.getResult()))) {
recipes.add(recipe);
}
}
if(!recipes.isEmpty()) {
if (!recipes.isEmpty()) {
MineTweakerAPI.apply(new Remove(recipes));
} else {
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", Drying.name, ingredient.toString()));
@ -70,12 +71,12 @@ public class Drying {
//Removes a recipe, apply is never the same for anything, so will always need to override it
private static class Remove extends BaseListRemoval<DryingRecipe> {
public Remove(List<DryingRecipe> list) {
super(Drying.name, DryingRackRecipes.recipes, list);
super(Drying.name, TinkerRegistry.getAllDryingRecipes(), list);
}
@Override
protected String getRecipeInfo(DryingRecipe recipe) {
return LogHelper.getStackDescription(recipe.result);
return LogHelper.getStackDescription(recipe.getResult());
}
}
}

View file

@ -1,32 +1,32 @@
package modtweaker2.utils;
import java.util.List;
import modtweaker2.helpers.LogHelper;
import java.util.List;
public abstract class BaseListRemoval<T> extends BaseListModification<T> {
protected BaseListRemoval(String name, List<T> list) {
super(name, list);
}
protected BaseListRemoval(String name, List<T> list, List<T> recipies) {
this(name, list);
if(recipes != null) {
if (recipes != null) {
recipes.addAll(recipies);
}
}
@Override
public void apply() {
if(recipes.isEmpty()) {
if (recipes.isEmpty()) {
return;
}
for(T recipe : this.recipes) {
if(recipe != null) {
if(this.list.remove(recipe)) {
for (T recipe : this.recipes) {
if (recipe != null) {
if (this.list.remove(recipe)) {
successful.add(recipe);
} else {
LogHelper.logError(String.format("Error removing %s Recipe for %s", name, getRecipeInfo(recipe)));
@ -36,15 +36,15 @@ public abstract class BaseListRemoval<T> extends BaseListModification<T> {
}
}
}
@Override
public void undo() {
if(successful.isEmpty()) {
if (successful.isEmpty()) {
return;
}
for(T recipe : successful) {
if(recipe != null) {
if(!list.add(recipe)) {
for (T recipe : successful) {
if (recipe != null) {
if (!list.add(recipe)) {
LogHelper.logError(String.format("Error restoring %s Recipe for %s", name, getRecipeInfo(recipe)));
}
} else {
@ -62,4 +62,4 @@ public abstract class BaseListRemoval<T> extends BaseListModification<T> {
public String describeUndo() {
return String.format("[ModTweaker2] Restoring %d %s Recipe(s) for %s", this.recipes.size(), this.name, this.getRecipeInfo());
}
}
}