mirror of
https://github.com/GTNewHorizons/ModTweaker.git
synced 2026-11-20 04:19:44 +00:00
[ci skip] spotlessApply with the new settings
This commit is contained in:
1 parent
0cc3fa06c2
commit
655636b7e9
231 files changed
+10024
-8585
No files matched your search
@@ -9,6 +9,7 @@ import modtweaker2.mods.tconstruct.handlers.TiCTweaks;
|
||||
import modtweaker2.mods.tconstruct.handlers.ToolStats;
|
||||
|
||||
public class TConstruct {
|
||||
|
||||
public TConstruct() {
|
||||
MineTweakerAPI.registerClass(Casting.class);
|
||||
MineTweakerAPI.registerClass(Drying.class);
|
||||
|
||||
@@ -7,20 +7,21 @@ import java.util.Map;
|
||||
|
||||
import mantle.utils.ItemMetaWrapper;
|
||||
import modtweaker2.helpers.ReflectionHelper;
|
||||
import net.minecraft.item.Item;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import tconstruct.library.crafting.AlloyMix;
|
||||
import tconstruct.library.crafting.CastingRecipe;
|
||||
import tconstruct.library.crafting.DryingRackRecipes.DryingRecipe;
|
||||
import tconstruct.library.crafting.ModifyBuilder;
|
||||
import tconstruct.library.crafting.PatternBuilder.ItemKey;
|
||||
import tconstruct.library.modifier.ItemModifier;
|
||||
import tconstruct.library.tools.ToolMaterial;
|
||||
|
||||
public class TConstructHelper {
|
||||
|
||||
public static HashMap<String, Integer> mappings = new HashMap<String, Integer>();
|
||||
public static List<AlloyMix> alloys = null;
|
||||
public static ArrayList<CastingRecipe> basinCasting = null;
|
||||
@@ -46,7 +47,7 @@ public class TConstructHelper {
|
||||
for (Map.Entry<Integer, ToolMaterial> entry : TConstructRegistry.toolMaterials.entrySet()) {
|
||||
mappings.put(entry.getValue().materialName, entry.getKey());
|
||||
}
|
||||
|
||||
|
||||
fuelList = ReflectionHelper.getObject(tconstruct.library.crafting.Smeltery.instance, "smelteryFuels");
|
||||
} catch (Exception e) {}
|
||||
}
|
||||
@@ -59,9 +60,10 @@ public class TConstructHelper {
|
||||
} else return mappings.get(material);
|
||||
}
|
||||
|
||||
//Returns a Drying Recipe, using reflection as the constructor is not visible
|
||||
// Returns a Drying Recipe, using reflection as the constructor is not visible
|
||||
public static DryingRecipe getDryingRecipe(ItemStack input, int time, ItemStack output) {
|
||||
return ReflectionHelper.getInstance(ReflectionHelper.getConstructor(DryingRecipe.class, ItemStack.class, int.class, ItemStack.class),
|
||||
return ReflectionHelper.getInstance(
|
||||
ReflectionHelper.getConstructor(DryingRecipe.class, ItemStack.class, int.class, ItemStack.class),
|
||||
input,
|
||||
time,
|
||||
output);
|
||||
|
||||
@@ -1,22 +1,23 @@
|
||||
package modtweaker2.mods.tconstruct.commands;
|
||||
|
||||
import static modtweaker2.helpers.LogHelper.logPrinted;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import minetweaker.MineTweakerAPI;
|
||||
import minetweaker.api.player.IPlayer;
|
||||
import minetweaker.api.server.ICommandFunction;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import tconstruct.library.tools.ToolMaterial;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import static modtweaker2.helpers.LogHelper.logPrinted;
|
||||
|
||||
public class MaterialLogger implements ICommandFunction {
|
||||
@Override
|
||||
public void execute(String[] arguments, IPlayer player) {
|
||||
MineTweakerAPI.logCommand(TConstructRegistry.toolMaterialStrings.entrySet().size() + " Materials:");
|
||||
for (Map.Entry<String, ToolMaterial> entry : TConstructRegistry.toolMaterialStrings.entrySet()) {
|
||||
MineTweakerAPI.logCommand(entry.getKey());
|
||||
}
|
||||
logPrinted(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(String[] arguments, IPlayer player) {
|
||||
MineTweakerAPI.logCommand(TConstructRegistry.toolMaterialStrings.entrySet().size() + " Materials:");
|
||||
for (Map.Entry<String, ToolMaterial> entry : TConstructRegistry.toolMaterialStrings.entrySet()) {
|
||||
MineTweakerAPI.logCommand(entry.getKey());
|
||||
}
|
||||
logPrinted(player);
|
||||
}
|
||||
}
|
||||
@@ -1,21 +1,21 @@
|
||||
package modtweaker2.mods.tconstruct.commands;
|
||||
|
||||
import static modtweaker2.helpers.LogHelper.logPrinted;
|
||||
|
||||
import minetweaker.MineTweakerAPI;
|
||||
import minetweaker.api.player.IPlayer;
|
||||
import minetweaker.api.server.ICommandFunction;
|
||||
import modtweaker2.mods.tconstruct.TConstructHelper;
|
||||
import tconstruct.library.modifier.ItemModifier;
|
||||
|
||||
import static modtweaker2.helpers.LogHelper.logPrinted;
|
||||
public class ModifierLogger implements ICommandFunction {
|
||||
|
||||
public class ModifierLogger implements ICommandFunction{
|
||||
@Override
|
||||
public void execute(String[] arguments, IPlayer player) {
|
||||
MineTweakerAPI.logCommand(TConstructHelper.modifiers.size() + " Tinker's Construct modifiers:");
|
||||
for (ItemModifier modifier : TConstructHelper.modifiers) {
|
||||
if (!modifier.key.equals(""))
|
||||
MineTweakerAPI.logCommand(modifier.key);
|
||||
}
|
||||
logPrinted(player);
|
||||
}
|
||||
@Override
|
||||
public void execute(String[] arguments, IPlayer player) {
|
||||
MineTweakerAPI.logCommand(TConstructHelper.modifiers.size() + " Tinker's Construct modifiers:");
|
||||
for (ItemModifier modifier : TConstructHelper.modifiers) {
|
||||
if (!modifier.key.equals("")) MineTweakerAPI.logCommand(modifier.key);
|
||||
}
|
||||
logPrinted(player);
|
||||
}
|
||||
}
|
||||
@@ -13,90 +13,111 @@ import minetweaker.api.server.ICommandFunction;
|
||||
import modtweaker2.helpers.LogHelper;
|
||||
import modtweaker2.helpers.StringHelper;
|
||||
import modtweaker2.mods.tconstruct.TConstructHelper;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import tconstruct.library.crafting.AlloyMix;
|
||||
import tconstruct.library.crafting.CastingRecipe;
|
||||
import tconstruct.library.crafting.DryingRackRecipes;
|
||||
import tconstruct.library.crafting.DryingRackRecipes.DryingRecipe;
|
||||
|
||||
public class TConstructLogger implements ICommandFunction {
|
||||
|
||||
private static final List<String> validArguments = new LinkedList<String>();
|
||||
|
||||
|
||||
static {
|
||||
validArguments.add("Casting");
|
||||
validArguments.add("Drying");
|
||||
validArguments.add("Smeltery");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void execute(String[] arguments, IPlayer player) {
|
||||
List<String> args = StringHelper.toLowerCase(Arrays.asList(arguments));
|
||||
|
||||
if(!validArguments.containsAll(args)) {
|
||||
if(player != null) {
|
||||
player.sendChat(MineTweakerImplementationAPI.platform.getMessage("Invalid arguments for command. Valid arguments: " + StringHelper.join(validArguments, ", ")));
|
||||
|
||||
if (!validArguments.containsAll(args)) {
|
||||
if (player != null) {
|
||||
player.sendChat(
|
||||
MineTweakerImplementationAPI.platform.getMessage(
|
||||
"Invalid arguments for command. Valid arguments: "
|
||||
+ StringHelper.join(validArguments, ", ")));
|
||||
}
|
||||
} else {
|
||||
if(args.isEmpty() || args.contains("Casting")) {
|
||||
for(CastingRecipe recipe : TConstructHelper.basinCasting) {
|
||||
MineTweakerAPI.logCommand(String.format("mods.tconstruct.Casting.addBasinRecipe(%s, %s, %s, %s, %d);",
|
||||
LogHelper.getStackDescription(recipe.output),
|
||||
LogHelper.getStackDescription(recipe.castingMetal),
|
||||
LogHelper.getStackDescription(recipe.cast),
|
||||
recipe.consumeCast,
|
||||
recipe.coolTime));
|
||||
if (args.isEmpty() || args.contains("Casting")) {
|
||||
for (CastingRecipe recipe : TConstructHelper.basinCasting) {
|
||||
MineTweakerAPI.logCommand(
|
||||
String.format(
|
||||
"mods.tconstruct.Casting.addBasinRecipe(%s, %s, %s, %s, %d);",
|
||||
LogHelper.getStackDescription(recipe.output),
|
||||
LogHelper.getStackDescription(recipe.castingMetal),
|
||||
LogHelper.getStackDescription(recipe.cast),
|
||||
recipe.consumeCast,
|
||||
recipe.coolTime));
|
||||
}
|
||||
|
||||
for(CastingRecipe recipe : TConstructHelper.tableCasting) {
|
||||
MineTweakerAPI.logCommand(String.format("mods.tconstruct.Casting.addTableRecipe(%s, %s, %s, %s, %d);",
|
||||
LogHelper.getStackDescription(recipe.output),
|
||||
LogHelper.getStackDescription(recipe.castingMetal),
|
||||
LogHelper.getStackDescription(recipe.cast),
|
||||
recipe.consumeCast,
|
||||
recipe.coolTime));
|
||||
|
||||
for (CastingRecipe recipe : TConstructHelper.tableCasting) {
|
||||
MineTweakerAPI.logCommand(
|
||||
String.format(
|
||||
"mods.tconstruct.Casting.addTableRecipe(%s, %s, %s, %s, %d);",
|
||||
LogHelper.getStackDescription(recipe.output),
|
||||
LogHelper.getStackDescription(recipe.castingMetal),
|
||||
LogHelper.getStackDescription(recipe.cast),
|
||||
recipe.consumeCast,
|
||||
recipe.coolTime));
|
||||
}
|
||||
}
|
||||
|
||||
if(args.isEmpty() || args.contains("Drying")) {
|
||||
for(DryingRecipe recipe : DryingRackRecipes.recipes) {
|
||||
MineTweakerAPI.logCommand(String.format("mods.tconstruct.Drying.addRecipe(%s, %s, %d);",
|
||||
LogHelper.getStackDescription(recipe.input),
|
||||
LogHelper.getStackDescription(recipe.result),
|
||||
recipe.time));
|
||||
|
||||
if (args.isEmpty() || args.contains("Drying")) {
|
||||
for (DryingRecipe recipe : DryingRackRecipes.recipes) {
|
||||
MineTweakerAPI.logCommand(
|
||||
String.format(
|
||||
"mods.tconstruct.Drying.addRecipe(%s, %s, %d);",
|
||||
LogHelper.getStackDescription(recipe.input),
|
||||
LogHelper.getStackDescription(recipe.result),
|
||||
recipe.time));
|
||||
}
|
||||
}
|
||||
|
||||
if(args.isEmpty() || args.contains("Smeltery")) {
|
||||
|
||||
for(Entry<ItemMetaWrapper, FluidStack> recipe : TConstructHelper.smeltingList.entrySet()) {
|
||||
|
||||
if (args.isEmpty() || args.contains("Smeltery")) {
|
||||
|
||||
for (Entry<ItemMetaWrapper, FluidStack> recipe : TConstructHelper.smeltingList.entrySet()) {
|
||||
int temperature = TConstructHelper.temperatureList.get(recipe.getKey());
|
||||
ItemStack renderItem = TConstructHelper.renderIndex.get(recipe.getKey());
|
||||
|
||||
MineTweakerAPI.logCommand(String.format("mods.tconstruct.Smeltery.addMelting(%s, %s, %d, %s);",
|
||||
LogHelper.getStackDescription(new ItemStack(recipe.getKey().item, 1, recipe.getKey().meta)),
|
||||
LogHelper.getStackDescription(recipe.getValue()),
|
||||
temperature,
|
||||
LogHelper.getStackDescription(renderItem)));
|
||||
|
||||
MineTweakerAPI.logCommand(
|
||||
String.format(
|
||||
"mods.tconstruct.Smeltery.addMelting(%s, %s, %d, %s);",
|
||||
LogHelper.getStackDescription(
|
||||
new ItemStack(recipe.getKey().item, 1, recipe.getKey().meta)),
|
||||
LogHelper.getStackDescription(recipe.getValue()),
|
||||
temperature,
|
||||
LogHelper.getStackDescription(renderItem)));
|
||||
}
|
||||
|
||||
for(AlloyMix recipe : TConstructHelper.alloys) {
|
||||
MineTweakerAPI.logCommand(String.format("mods.tconstruct.Smeltery.addAlloy(%s, %s);",
|
||||
LogHelper.getStackDescription(recipe.result),
|
||||
LogHelper.getListDescription(recipe.mixers)));
|
||||
|
||||
for (AlloyMix recipe : TConstructHelper.alloys) {
|
||||
MineTweakerAPI.logCommand(
|
||||
String.format(
|
||||
"mods.tconstruct.Smeltery.addAlloy(%s, %s);",
|
||||
LogHelper.getStackDescription(recipe.result),
|
||||
LogHelper.getListDescription(recipe.mixers)));
|
||||
}
|
||||
|
||||
for(Entry<Fluid, Integer[]> fuel : TConstructHelper.fuelList.entrySet()) {
|
||||
MineTweakerAPI.logCommand(String.format("mods.tconstruct.Smeltery.addFuel(%s, %d, %d);",
|
||||
LogHelper.getStackDescription(new FluidStack(fuel.getKey(), 1)),
|
||||
fuel.getValue()[0],
|
||||
fuel.getValue()[1]));
|
||||
|
||||
for (Entry<Fluid, Integer[]> fuel : TConstructHelper.fuelList.entrySet()) {
|
||||
MineTweakerAPI.logCommand(
|
||||
String.format(
|
||||
"mods.tconstruct.Smeltery.addFuel(%s, %d, %d);",
|
||||
LogHelper.getStackDescription(new FluidStack(fuel.getKey(), 1)),
|
||||
fuel.getValue()[0],
|
||||
fuel.getValue()[1]));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (player != null) {
|
||||
player.sendChat(MineTweakerImplementationAPI.platform.getMessage("List generated; see minetweaker.log in your minecraft dir"));
|
||||
player.sendChat(
|
||||
MineTweakerImplementationAPI.platform
|
||||
.getMessage("List generated; see minetweaker.log in your minecraft dir"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,36 +26,45 @@ import tconstruct.library.crafting.CastingRecipe;
|
||||
|
||||
@ZenClass("mods.tconstruct.Casting")
|
||||
public class Casting {
|
||||
|
||||
|
||||
protected static final String name = "TConstruct 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,
|
||||
@Optional boolean consume, int delay) {
|
||||
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));
|
||||
|
||||
MineTweakerAPI.apply(
|
||||
new Add(
|
||||
new CastingRecipe(toStack(output), toFluid(metal), toStack(cast), consume, delay, null),
|
||||
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,
|
||||
@Optional boolean consume, int delay) {
|
||||
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));
|
||||
|
||||
MineTweakerAPI.apply(
|
||||
new Add(
|
||||
new CastingRecipe(toStack(output), toFluid(metal), toStack(cast), consume, delay, null),
|
||||
TConstructHelper.tableCasting));
|
||||
}
|
||||
|
||||
//Passes the list to the base list implementation, and adds the recipe
|
||||
// Passes the list to the base list implementation, and adds the recipe
|
||||
private static class Add extends BaseListAddition<CastingRecipe> {
|
||||
|
||||
public Add(CastingRecipe recipe, ArrayList<CastingRecipe> list) {
|
||||
super(Casting.name, list);
|
||||
|
||||
|
||||
this.recipes.add(recipe);
|
||||
}
|
||||
|
||||
@@ -68,62 +77,72 @@ public class Casting {
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@ZenMethod
|
||||
public static void removeTableRecipe(IIngredient output, @Optional IIngredient material, @Optional IIngredient cast) {
|
||||
public static void removeTableRecipe(IIngredient output, @Optional IIngredient material,
|
||||
@Optional IIngredient cast) {
|
||||
removeRecipe(output, material, cast, TConstructHelper.tableCasting);
|
||||
}
|
||||
|
||||
|
||||
@ZenMethod
|
||||
public static void removeBasinRecipe(IIngredient output, @Optional IIngredient material, @Optional IIngredient cast) {
|
||||
public static void removeBasinRecipe(IIngredient output, @Optional IIngredient material,
|
||||
@Optional IIngredient cast) {
|
||||
|
||||
removeRecipe(output, material, cast, TConstructHelper.basinCasting);
|
||||
}
|
||||
|
||||
public static void removeRecipe(IIngredient output, IIngredient material, IIngredient cast, List<CastingRecipe> list) {
|
||||
if(output == null) {
|
||||
|
||||
public static void removeRecipe(IIngredient output, IIngredient material, IIngredient cast,
|
||||
List<CastingRecipe> list) {
|
||||
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) {
|
||||
|
||||
for (CastingRecipe recipe : list) {
|
||||
if (recipe != null) {
|
||||
if (!matches(output, toIItemStack(recipe.output))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if (!matches(material, toILiquidStack(recipe.castingMetal))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if(!matches(cast, toIItemStack(recipe.cast))) {
|
||||
|
||||
if (!matches(cast, toIItemStack(recipe.cast))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
recipes.add(recipe);
|
||||
}
|
||||
}
|
||||
|
||||
if(!recipes.isEmpty()) {
|
||||
|
||||
if (!recipes.isEmpty()) {
|
||||
MineTweakerAPI.apply(new Remove(list, recipes));
|
||||
} 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()));
|
||||
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()));
|
||||
}
|
||||
}
|
||||
|
||||
// Removes all matching recipes, apply is never the same for anything, so will always need to override it
|
||||
private static class Remove extends BaseListRemoval<CastingRecipe> {
|
||||
|
||||
public Remove(List<CastingRecipe> list, List<CastingRecipe> recipes) {
|
||||
super(Casting.name, list, recipes);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getRecipeInfo(CastingRecipe recipe) {
|
||||
|
||||
@@ -20,23 +20,24 @@ import tconstruct.library.crafting.DryingRackRecipes.DryingRecipe;
|
||||
|
||||
@ZenClass("mods.tconstruct.Drying")
|
||||
public class Drying {
|
||||
|
||||
|
||||
protected static final String name = "TConstruct Drying Rack";
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
@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;
|
||||
}
|
||||
|
||||
|
||||
MineTweakerAPI.apply(new Add(TConstructHelper.getDryingRecipe(toStack(input), time, toStack(output))));
|
||||
}
|
||||
|
||||
//Passes the list to the base list implementation, and adds the recipe
|
||||
// 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);
|
||||
this.recipes.add(recipe);
|
||||
@@ -50,26 +51,28 @@ public class Drying {
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//Removing a TConstruct Drying Rack recipe
|
||||
// Removing a TConstruct Drying Rack recipe
|
||||
@ZenMethod
|
||||
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))) {
|
||||
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()));
|
||||
LogHelper.logWarning(
|
||||
String.format("No %s Recipe found for %s. Command ignored!", Drying.name, ingredient.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
//Removes a recipe, apply is never the same for anything, so will always need to override it
|
||||
// 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);
|
||||
}
|
||||
|
||||
@@ -13,29 +13,30 @@ import tconstruct.library.modifier.ItemModifier;
|
||||
|
||||
@ZenClass("mods.tconstruct.Modifiers")
|
||||
public class Modifiers {
|
||||
|
||||
|
||||
protected static final String name = "TConstruct Modifier";
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
@ZenMethod
|
||||
public static void remove(String mod) {
|
||||
List<ItemModifier> recipes = new LinkedList<ItemModifier>();
|
||||
|
||||
|
||||
for (ItemModifier recipe : TConstructHelper.modifiers) {
|
||||
if (recipe.key.equals(mod)) {
|
||||
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!", Modifiers.name, mod));
|
||||
}
|
||||
}
|
||||
|
||||
private static class Remove extends BaseListRemoval<ItemModifier>{
|
||||
private static class Remove extends BaseListRemoval<ItemModifier> {
|
||||
|
||||
public Remove(List<ItemModifier> recipes) {
|
||||
super(Modifiers.name, TConstructHelper.modifiers, recipes);
|
||||
}
|
||||
|
||||
@@ -27,10 +27,12 @@ import modtweaker2.utils.BaseListAddition;
|
||||
import modtweaker2.utils.BaseListRemoval;
|
||||
import modtweaker2.utils.BaseMapAddition;
|
||||
import modtweaker2.utils.BaseMapRemoval;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import stanhebben.zenscript.annotations.Optional;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
@@ -38,263 +40,300 @@ import tconstruct.library.crafting.AlloyMix;
|
||||
|
||||
@ZenClass("mods.tconstruct.Smeltery")
|
||||
public class Smeltery {
|
||||
|
||||
|
||||
public static final String nameFuel = "TConstruct Smeltery - Fuel";
|
||||
public static final String nameMelting = "TConstruct Smeltery - Melting";
|
||||
public static final String nameAlloy = "TConstruct Smeltery - Alloy";
|
||||
|
||||
/********************************************** TConstruct Alloy Recipes **********************************************/
|
||||
/**********************************************
|
||||
* TConstruct Alloy Recipes
|
||||
**********************************************/
|
||||
|
||||
// Adding a TConstruct Alloy recipe
|
||||
@ZenMethod
|
||||
public static void addAlloy(ILiquidStack output, ILiquidStack[] input) {
|
||||
if(input == null || output == null) {
|
||||
// Adding a TConstruct Alloy recipe
|
||||
@ZenMethod
|
||||
public static void addAlloy(ILiquidStack output, ILiquidStack[] input) {
|
||||
if (input == null || output == null) {
|
||||
LogHelper.logError(String.format("Required parameters missing for %s Recipe.", nameAlloy));
|
||||
return;
|
||||
}
|
||||
|
||||
MineTweakerAPI.apply(new AddAlloy(new AlloyMix(toFluid(output), new ArrayList<FluidStack>(Arrays.asList(toFluids(input))))));
|
||||
}
|
||||
|
||||
// Passes the list to the base list implementation, and adds the recipe
|
||||
private static class AddAlloy extends BaseListAddition<AlloyMix> {
|
||||
public AddAlloy(AlloyMix recipe) {
|
||||
super("TConstruct Smeltery - Alloy", TConstructHelper.alloys);
|
||||
this.recipes.add(recipe);
|
||||
}
|
||||
MineTweakerAPI.apply(
|
||||
new AddAlloy(new AlloyMix(toFluid(output), new ArrayList<FluidStack>(Arrays.asList(toFluids(input))))));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getRecipeInfo(AlloyMix recipe) {
|
||||
return LogHelper.getStackDescription(recipe.result);
|
||||
}
|
||||
}
|
||||
// Passes the list to the base list implementation, and adds the recipe
|
||||
private static class AddAlloy extends BaseListAddition<AlloyMix> {
|
||||
|
||||
// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Removing a TConstruct Alloy recipe
|
||||
@ZenMethod
|
||||
public static void removeAlloy(IIngredient output) {
|
||||
List<AlloyMix> recipes = new LinkedList<AlloyMix>();
|
||||
|
||||
for(AlloyMix r : TConstructHelper.alloys) {
|
||||
if(r != null && matches(output, toILiquidStack(r.result))) {
|
||||
recipes.add(r);
|
||||
}
|
||||
}
|
||||
|
||||
if(!recipes.isEmpty()) {
|
||||
MineTweakerAPI.apply(new RemoveAlloy(recipes));
|
||||
} else {
|
||||
LogHelper.logError(String.format("No %s recipes found for %s. Command ignored!", nameAlloy, output.toString()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Removes a recipe, apply is never the same for anything, so will always
|
||||
// need to override it
|
||||
private static class RemoveAlloy extends BaseListRemoval<AlloyMix> {
|
||||
public RemoveAlloy(List<AlloyMix> recipes) {
|
||||
super(nameAlloy, TConstructHelper.alloys, recipes);
|
||||
}
|
||||
public AddAlloy(AlloyMix recipe) {
|
||||
super("TConstruct Smeltery - Alloy", TConstructHelper.alloys);
|
||||
this.recipes.add(recipe);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getRecipeInfo(AlloyMix recipe) {
|
||||
return LogHelper.getStackDescription(recipe.result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/********************************************** TConstruct Melting Recipes **********************************************/
|
||||
// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Adding a TConstruct Melting recipe
|
||||
@ZenMethod
|
||||
public static void addMelting(IIngredient input, ILiquidStack output, int temp, @Optional IItemStack block) {
|
||||
|
||||
if(input == null || output == null) {
|
||||
// Removing a TConstruct Alloy recipe
|
||||
@ZenMethod
|
||||
public static void removeAlloy(IIngredient output) {
|
||||
List<AlloyMix> recipes = new LinkedList<AlloyMix>();
|
||||
|
||||
for (AlloyMix r : TConstructHelper.alloys) {
|
||||
if (r != null && matches(output, toILiquidStack(r.result))) {
|
||||
recipes.add(r);
|
||||
}
|
||||
}
|
||||
|
||||
if (!recipes.isEmpty()) {
|
||||
MineTweakerAPI.apply(new RemoveAlloy(recipes));
|
||||
} else {
|
||||
LogHelper.logError(
|
||||
String.format("No %s recipes found for %s. Command ignored!", nameAlloy, output.toString()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Removes a recipe, apply is never the same for anything, so will always
|
||||
// need to override it
|
||||
private static class RemoveAlloy extends BaseListRemoval<AlloyMix> {
|
||||
|
||||
public RemoveAlloy(List<AlloyMix> recipes) {
|
||||
super(nameAlloy, TConstructHelper.alloys, recipes);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getRecipeInfo(AlloyMix recipe) {
|
||||
return LogHelper.getStackDescription(recipe.result);
|
||||
}
|
||||
}
|
||||
|
||||
/**********************************************
|
||||
* TConstruct Melting Recipes
|
||||
**********************************************/
|
||||
|
||||
// Adding a TConstruct Melting recipe
|
||||
@ZenMethod
|
||||
public static void addMelting(IIngredient input, ILiquidStack output, int temp, @Optional IItemStack block) {
|
||||
|
||||
if (input == null || output == null) {
|
||||
LogHelper.logError(String.format("Required parameters missing for %s Recipe.", nameMelting));
|
||||
return;
|
||||
}
|
||||
|
||||
List<MeltingRecipe> recipes = new LinkedList<MeltingRecipe>();
|
||||
|
||||
for(IItemStack in : input.getItems()) {
|
||||
if(block == null && !isABlock(toStack(in))) {
|
||||
LogHelper.logWarning(String.format("Item %s is not a block and no block renderer is provided for %s recipe. Input ignored!", in.toString(), nameMelting));
|
||||
} else {
|
||||
recipes.add(new MeltingRecipe(toStack(in), toFluid(output), temp, block == null ? toStack(in) : toStack(block)));
|
||||
}
|
||||
}
|
||||
|
||||
if(!recipes.isEmpty()) {
|
||||
MineTweakerAPI.apply(new AddMelting(recipes));
|
||||
} else {
|
||||
LogHelper.logError(String.format("No %s recipes could be added for input %s.", nameMelting, input.toString()));
|
||||
}
|
||||
}
|
||||
List<MeltingRecipe> recipes = new LinkedList<MeltingRecipe>();
|
||||
|
||||
private static class AddMelting extends BaseListAddition<MeltingRecipe> {
|
||||
for (IItemStack in : input.getItems()) {
|
||||
if (block == null && !isABlock(toStack(in))) {
|
||||
LogHelper.logWarning(
|
||||
String.format(
|
||||
"Item %s is not a block and no block renderer is provided for %s recipe. Input ignored!",
|
||||
in.toString(),
|
||||
nameMelting));
|
||||
} else {
|
||||
recipes.add(
|
||||
new MeltingRecipe(
|
||||
toStack(in),
|
||||
toFluid(output),
|
||||
temp,
|
||||
block == null ? toStack(in) : toStack(block)));
|
||||
}
|
||||
}
|
||||
|
||||
public AddMelting(List<MeltingRecipe> recipes) {
|
||||
super(nameMelting, null, recipes);
|
||||
}
|
||||
if (!recipes.isEmpty()) {
|
||||
MineTweakerAPI.apply(new AddMelting(recipes));
|
||||
} else {
|
||||
LogHelper.logError(
|
||||
String.format("No %s recipes could be added for input %s.", nameMelting, input.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
for(MeltingRecipe recipe : recipes) {
|
||||
tconstruct.library.crafting.Smeltery.addMelting(recipe.input, recipe.getRendererBlock(), recipe.getRendererMeta(), recipe.temperature, recipe.fluid);
|
||||
private static class AddMelting extends BaseListAddition<MeltingRecipe> {
|
||||
|
||||
public AddMelting(List<MeltingRecipe> recipes) {
|
||||
super(nameMelting, null, recipes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
for (MeltingRecipe recipe : recipes) {
|
||||
tconstruct.library.crafting.Smeltery.addMelting(
|
||||
recipe.input,
|
||||
recipe.getRendererBlock(),
|
||||
recipe.getRendererMeta(),
|
||||
recipe.temperature,
|
||||
recipe.fluid);
|
||||
successful.add(recipe);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void undo() {
|
||||
for (MeltingRecipe recipe : successful) {
|
||||
TConstructHelper.smeltingList.remove(recipe.meta);
|
||||
TConstructHelper.temperatureList.remove(recipe.meta);
|
||||
TConstructHelper.renderIndex.remove(recipe.meta);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void undo() {
|
||||
for(MeltingRecipe recipe : successful) {
|
||||
TConstructHelper.smeltingList.remove(recipe.meta);
|
||||
TConstructHelper.temperatureList.remove(recipe.meta);
|
||||
TConstructHelper.renderIndex.remove(recipe.meta);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeInfo(MeltingRecipe recipe) {
|
||||
return LogHelper.getStackDescription(recipe.input);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Removing a TConstruct Melting recipe
|
||||
@ZenMethod
|
||||
public static void removeMelting(IIngredient input) {
|
||||
List<MeltingRecipe> recipes = new LinkedList<MeltingRecipe>();
|
||||
|
||||
for(ItemMetaWrapper meta : TConstructHelper.smeltingList.keySet()) {
|
||||
ItemStack in = new ItemStack(meta.item, 1, meta.meta);
|
||||
if(matches(input, toIItemStack(in))) {
|
||||
recipes.add(new MeltingRecipe(
|
||||
in,
|
||||
TConstructHelper.smeltingList.get(meta),
|
||||
TConstructHelper.temperatureList.get(meta),
|
||||
TConstructHelper.renderIndex.get(meta)));
|
||||
}
|
||||
}
|
||||
|
||||
if(!recipes.isEmpty()) {
|
||||
MineTweakerAPI.apply(new RemoveMelting(recipes));
|
||||
} else {
|
||||
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", nameMelting, input.toString()));
|
||||
}
|
||||
}
|
||||
// Removing a TConstruct Melting recipe
|
||||
@ZenMethod
|
||||
public static void removeMelting(IIngredient input) {
|
||||
List<MeltingRecipe> recipes = new LinkedList<MeltingRecipe>();
|
||||
|
||||
private static class RemoveMelting extends BaseListRemoval<MeltingRecipe> {
|
||||
|
||||
public RemoveMelting(List<MeltingRecipe> recipes) {
|
||||
super(nameMelting, null, recipes);
|
||||
}
|
||||
for (ItemMetaWrapper meta : TConstructHelper.smeltingList.keySet()) {
|
||||
ItemStack in = new ItemStack(meta.item, 1, meta.meta);
|
||||
if (matches(input, toIItemStack(in))) {
|
||||
recipes.add(
|
||||
new MeltingRecipe(
|
||||
in,
|
||||
TConstructHelper.smeltingList.get(meta),
|
||||
TConstructHelper.temperatureList.get(meta),
|
||||
TConstructHelper.renderIndex.get(meta)));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
for(MeltingRecipe recipe : recipes) {
|
||||
TConstructHelper.smeltingList.remove(recipe.meta);
|
||||
TConstructHelper.temperatureList.remove(recipe.meta);
|
||||
TConstructHelper.renderIndex.remove(recipe.meta);
|
||||
|
||||
successful.add(recipe);
|
||||
}
|
||||
}
|
||||
if (!recipes.isEmpty()) {
|
||||
MineTweakerAPI.apply(new RemoveMelting(recipes));
|
||||
} else {
|
||||
LogHelper.logWarning(
|
||||
String.format("No %s Recipe found for %s. Command ignored!", nameMelting, input.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
private static class RemoveMelting extends BaseListRemoval<MeltingRecipe> {
|
||||
|
||||
public RemoveMelting(List<MeltingRecipe> recipes) {
|
||||
super(nameMelting, null, recipes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void undo() {
|
||||
for(MeltingRecipe recipe : successful) {
|
||||
tconstruct.library.crafting.Smeltery.addMelting(recipe.input, recipe.getRendererBlock(), recipe.getRendererMeta(), recipe.temperature, recipe.fluid);
|
||||
}
|
||||
}
|
||||
public void apply() {
|
||||
for (MeltingRecipe recipe : recipes) {
|
||||
TConstructHelper.smeltingList.remove(recipe.meta);
|
||||
TConstructHelper.temperatureList.remove(recipe.meta);
|
||||
TConstructHelper.renderIndex.remove(recipe.meta);
|
||||
|
||||
@Override
|
||||
public String getRecipeInfo(MeltingRecipe recipe) {
|
||||
return LogHelper.getStackDescription(recipe.input);
|
||||
}
|
||||
}
|
||||
|
||||
protected static class MeltingRecipe {
|
||||
public final ItemMetaWrapper meta;
|
||||
public final ItemStack input;
|
||||
public final FluidStack fluid;
|
||||
public final Integer temperature;
|
||||
public final ItemStack renderer;
|
||||
|
||||
protected MeltingRecipe(ItemStack input, FluidStack fluid, int temperature, ItemStack renderer) {
|
||||
this.input = input;
|
||||
this.fluid = fluid;
|
||||
this.temperature = temperature;
|
||||
this.renderer = renderer;
|
||||
this.meta = new ItemMetaWrapper(input);
|
||||
}
|
||||
|
||||
public Block getRendererBlock() {
|
||||
return Block.getBlockFromItem(renderer.getItem());
|
||||
}
|
||||
|
||||
public int getRendererMeta() {
|
||||
return renderer.getItemDamage();
|
||||
}
|
||||
}
|
||||
|
||||
/********************************************** TConstruct Fuel Recipes **********************************************/
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@ZenMethod
|
||||
public static void removeFuel(IIngredient input) {
|
||||
Map<Fluid, Integer[]> recipes = new HashMap<Fluid, Integer[]>();
|
||||
|
||||
for(Entry<Fluid, Integer[]> fuel : TConstructHelper.fuelList.entrySet()) {
|
||||
if(fuel != null && fuel.getKey() != null && matches(input, toILiquidStack(new FluidStack(fuel.getKey(), 1)))) {
|
||||
recipes.put(fuel.getKey(), fuel.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
if(!recipes.isEmpty()) {
|
||||
MineTweakerAPI.apply(new RemoveFuel(recipes));
|
||||
} else {
|
||||
LogHelper.logWarning(String.format("No %s Recipe for %s found. Command ignored!", Smeltery.nameFuel, input.toString()));
|
||||
}
|
||||
successful.add(recipe);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void undo() {
|
||||
for (MeltingRecipe recipe : successful) {
|
||||
tconstruct.library.crafting.Smeltery.addMelting(
|
||||
recipe.input,
|
||||
recipe.getRendererBlock(),
|
||||
recipe.getRendererMeta(),
|
||||
recipe.temperature,
|
||||
recipe.fluid);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeInfo(MeltingRecipe recipe) {
|
||||
return LogHelper.getStackDescription(recipe.input);
|
||||
}
|
||||
}
|
||||
|
||||
public static class RemoveFuel extends BaseMapRemoval<Fluid, Integer[]> {
|
||||
public RemoveFuel(Map<Fluid, Integer[]> recipes) {
|
||||
super(Smeltery.nameFuel, TConstructHelper.fuelList, recipes);
|
||||
|
||||
protected static class MeltingRecipe {
|
||||
|
||||
public final ItemMetaWrapper meta;
|
||||
public final ItemStack input;
|
||||
public final FluidStack fluid;
|
||||
public final Integer temperature;
|
||||
public final ItemStack renderer;
|
||||
|
||||
protected MeltingRecipe(ItemStack input, FluidStack fluid, int temperature, ItemStack renderer) {
|
||||
this.input = input;
|
||||
this.fluid = fluid;
|
||||
this.temperature = temperature;
|
||||
this.renderer = renderer;
|
||||
this.meta = new ItemMetaWrapper(input);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeInfo(Entry<Fluid, Integer[]> recipe) {
|
||||
return LogHelper.getStackDescription(new FluidStack(recipe.getKey(), 1));
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@ZenMethod
|
||||
public static void addFuel(ILiquidStack liquid, int power, int duration) {
|
||||
if(liquid == null) {
|
||||
LogHelper.logError(String.format("Required parameters missing for %s Recipe.", nameFuel));
|
||||
return;
|
||||
|
||||
public Block getRendererBlock() {
|
||||
return Block.getBlockFromItem(renderer.getItem());
|
||||
}
|
||||
|
||||
Map<Fluid, Integer[]> recipes = new HashMap<Fluid, Integer[]>();
|
||||
|
||||
recipes.put(toFluid(liquid).getFluid(), new Integer[] {power, duration});
|
||||
|
||||
MineTweakerAPI.apply(new AddFuel(recipes));
|
||||
}
|
||||
|
||||
public static class AddFuel extends BaseMapAddition<Fluid, Integer[]> {
|
||||
public AddFuel(Map<Fluid, Integer[]> recipes) {
|
||||
super(Smeltery.nameFuel, TConstructHelper.fuelList, recipes);
|
||||
}
|
||||
|
||||
|
||||
public int getRendererMeta() {
|
||||
return renderer.getItemDamage();
|
||||
}
|
||||
}
|
||||
|
||||
/**********************************************
|
||||
* TConstruct Fuel Recipes
|
||||
**********************************************/
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@ZenMethod
|
||||
public static void removeFuel(IIngredient input) {
|
||||
Map<Fluid, Integer[]> recipes = new HashMap<Fluid, Integer[]>();
|
||||
|
||||
for (Entry<Fluid, Integer[]> fuel : TConstructHelper.fuelList.entrySet()) {
|
||||
if (fuel != null && fuel.getKey() != null
|
||||
&& matches(input, toILiquidStack(new FluidStack(fuel.getKey(), 1)))) {
|
||||
recipes.put(fuel.getKey(), fuel.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
if (!recipes.isEmpty()) {
|
||||
MineTweakerAPI.apply(new RemoveFuel(recipes));
|
||||
} else {
|
||||
LogHelper.logWarning(
|
||||
String.format("No %s Recipe for %s found. Command ignored!", Smeltery.nameFuel, input.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
public static class RemoveFuel extends BaseMapRemoval<Fluid, Integer[]> {
|
||||
|
||||
public RemoveFuel(Map<Fluid, Integer[]> recipes) {
|
||||
super(Smeltery.nameFuel, TConstructHelper.fuelList, recipes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeInfo(Entry<Fluid, Integer[]> recipe) {
|
||||
return LogHelper.getStackDescription(new FluidStack(recipe.getKey(), 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@ZenMethod
|
||||
public static void addFuel(ILiquidStack liquid, int power, int duration) {
|
||||
if (liquid == null) {
|
||||
LogHelper.logError(String.format("Required parameters missing for %s Recipe.", nameFuel));
|
||||
return;
|
||||
}
|
||||
|
||||
Map<Fluid, Integer[]> recipes = new HashMap<Fluid, Integer[]>();
|
||||
|
||||
recipes.put(toFluid(liquid).getFluid(), new Integer[] { power, duration });
|
||||
|
||||
MineTweakerAPI.apply(new AddFuel(recipes));
|
||||
}
|
||||
|
||||
public static class AddFuel extends BaseMapAddition<Fluid, Integer[]> {
|
||||
|
||||
public AddFuel(Map<Fluid, Integer[]> recipes) {
|
||||
super(Smeltery.nameFuel, TConstructHelper.fuelList, recipes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeInfo(Entry<Fluid, Integer[]> recipe) {
|
||||
return LogHelper.getStackDescription(new FluidStack(recipe.getKey(), 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,10 +10,11 @@ import minetweaker.MineTweakerAPI;
|
||||
import minetweaker.api.item.IIngredient;
|
||||
import minetweaker.api.item.IItemStack;
|
||||
import modtweaker2.helpers.LogHelper;
|
||||
import modtweaker2.mods.tconstruct.TConstructHelper;
|
||||
import modtweaker2.utils.BaseListAddition;
|
||||
import modtweaker2.utils.BaseListRemoval;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import stanhebben.zenscript.annotations.Optional;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
@@ -23,72 +24,59 @@ import tconstruct.library.crafting.PatternBuilder.ItemKey;
|
||||
@ZenClass("mods.tconstruct.Tweaks")
|
||||
public class TiCTweaks {
|
||||
|
||||
// //////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// //////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/** Disabling for 0.5, will do this properly for 0.6 **/
|
||||
// Tweaks for enabling / disabling Patterns
|
||||
/*
|
||||
* @ZenMethod public static void removePattern(IItemStack stack) {
|
||||
* MineTweakerAPI.apply(new DisablePattern(toStack(stack))); }
|
||||
*
|
||||
* private static class DisablePattern implements IUndoableAction { private
|
||||
* String key; private MaterialSet set; private List list; private ItemStack
|
||||
* stack; private final ItemStack disable;
|
||||
*
|
||||
* public DisablePattern(ItemStack disable) { this.disable = disable; }
|
||||
*
|
||||
* //Loops through the pattern mappings to find an entry with the same
|
||||
* material name
|
||||
*
|
||||
* @Override public void apply() { for (Entry<List, ItemStack> entry :
|
||||
* TConstructRegistry.patternPartMapping.entrySet()) { ItemStack check =
|
||||
* entry.getValue(); if (check.isItemEqual(disable)) { list =
|
||||
* entry.getKey(); stack = entry.getValue(); break; } }
|
||||
*
|
||||
* TConstructRegistry.patternPartMapping.remove(list); }
|
||||
*
|
||||
* @Override public boolean canUndo() { return true; }
|
||||
*
|
||||
* @Override public void undo() {
|
||||
* TConstructRegistry.patternPartMapping.put(list, stack); }
|
||||
*
|
||||
* @Override public String describe() { return
|
||||
* "Disabling creation of the pattern for: " + disable.getDisplayName(); }
|
||||
*
|
||||
* @Override public String describeUndo() { return
|
||||
* "Enabling creation of the pattern for: " + disable.getDisplayName(); }
|
||||
*
|
||||
* @Override public Object getOverrideKey() { return null; } }
|
||||
*/
|
||||
/** Disabling for 0.5, will do this properly for 0.6 **/
|
||||
// Tweaks for enabling / disabling Patterns
|
||||
/*
|
||||
* @ZenMethod public static void removePattern(IItemStack stack) { MineTweakerAPI.apply(new
|
||||
* DisablePattern(toStack(stack))); } private static class DisablePattern implements IUndoableAction { private
|
||||
* String key; private MaterialSet set; private List list; private ItemStack stack; private final ItemStack disable;
|
||||
* public DisablePattern(ItemStack disable) { this.disable = disable; } //Loops through the pattern mappings to find
|
||||
* an entry with the same material name
|
||||
* @Override public void apply() { for (Entry<List, ItemStack> entry :
|
||||
* TConstructRegistry.patternPartMapping.entrySet()) { ItemStack check = entry.getValue(); if
|
||||
* (check.isItemEqual(disable)) { list = entry.getKey(); stack = entry.getValue(); break; } }
|
||||
* TConstructRegistry.patternPartMapping.remove(list); }
|
||||
* @Override public boolean canUndo() { return true; }
|
||||
* @Override public void undo() { TConstructRegistry.patternPartMapping.put(list, stack); }
|
||||
* @Override public String describe() { return "Disabling creation of the pattern for: " + disable.getDisplayName();
|
||||
* }
|
||||
* @Override public String describeUndo() { return "Enabling creation of the pattern for: " +
|
||||
* disable.getDisplayName(); }
|
||||
* @Override public Object getOverrideKey() { return null; } }
|
||||
*/
|
||||
|
||||
// //////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// //////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@ZenMethod
|
||||
public static void addRepairMaterial(IItemStack stack, String material, int value) {
|
||||
ItemStack input = toStack(stack);
|
||||
MineTweakerAPI.apply(new Add(PatternBuilder.instance.new ItemKey(input.getItem(), input.getItemDamage(), value, material)));
|
||||
}
|
||||
@ZenMethod
|
||||
public static void addRepairMaterial(IItemStack stack, String material, int value) {
|
||||
ItemStack input = toStack(stack);
|
||||
MineTweakerAPI.apply(
|
||||
new Add(PatternBuilder.instance.new ItemKey(input.getItem(), input.getItemDamage(), value, material)));
|
||||
}
|
||||
|
||||
// Tweaks for setting repair materials
|
||||
private static class Add extends BaseListAddition<ItemKey> {
|
||||
public Add(ItemKey recipe) {
|
||||
super("Repair Material", PatternBuilder.instance.materials);
|
||||
recipes.add(recipe);
|
||||
}
|
||||
// Tweaks for setting repair materials
|
||||
private static class Add extends BaseListAddition<ItemKey> {
|
||||
|
||||
@Override
|
||||
protected String getRecipeInfo(ItemKey recipe) {
|
||||
return LogHelper.getStackDescription(new ItemStack(recipe.item, 1, recipe.damage));
|
||||
}
|
||||
}
|
||||
public Add(ItemKey recipe) {
|
||||
super("Repair Material", PatternBuilder.instance.materials);
|
||||
recipes.add(recipe);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getRecipeInfo(ItemKey recipe) {
|
||||
return LogHelper.getStackDescription(new ItemStack(recipe.item, 1, recipe.damage));
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@ZenMethod
|
||||
public static void removeRepairMaterial(IIngredient output, @Optional String material) {
|
||||
|
||||
List<ItemKey> recipes = new LinkedList<ItemKey>();
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@ZenMethod
|
||||
public static void removeRepairMaterial(IIngredient output, @Optional String material) {
|
||||
|
||||
List<ItemKey> recipes = new LinkedList<ItemKey>();
|
||||
|
||||
for (ItemKey recipe : PatternBuilder.instance.materials) {
|
||||
IItemStack clone = toIItemStack(new ItemStack(recipe.item, 1, recipe.damage));
|
||||
if ((material != null && material.equalsIgnoreCase(recipe.key)) || (material == null)) {
|
||||
@@ -97,22 +85,23 @@ public class TiCTweaks {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!recipes.isEmpty()) {
|
||||
|
||||
if (!recipes.isEmpty()) {
|
||||
MineTweakerAPI.apply(new Remove(recipes));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Removes a recipe, apply is never the same for anything, so will always
|
||||
// need to override it
|
||||
private static class Remove extends BaseListRemoval<ItemKey> {
|
||||
public Remove(List<ItemKey> recipes) {
|
||||
super("Repair Material", PatternBuilder.instance.materials, recipes);
|
||||
}
|
||||
// Removes a recipe, apply is never the same for anything, so will always
|
||||
// need to override it
|
||||
private static class Remove extends BaseListRemoval<ItemKey> {
|
||||
|
||||
@Override
|
||||
protected String getRecipeInfo(ItemKey recipe) {
|
||||
return LogHelper.getStackDescription(new ItemStack(recipe.item, 1, recipe.damage));
|
||||
}
|
||||
}
|
||||
public Remove(List<ItemKey> recipes) {
|
||||
super("Repair Material", PatternBuilder.instance.materials, recipes);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getRecipeInfo(ItemKey recipe) {
|
||||
return LogHelper.getStackDescription(new ItemStack(recipe.item, 1, recipe.damage));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -14,14 +14,31 @@ import tconstruct.library.tools.ToolMaterial;
|
||||
|
||||
@ZenClass("mods.tconstruct.ToolStats")
|
||||
public class ToolStats {
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
@java.lang.Deprecated
|
||||
@ZenMethod
|
||||
public static void set(String material, @Optional String name, int level, int durability, int speed, int damage, double handle, int reinforced, double stonebound, String style, String ability) {
|
||||
public static void set(String material, @Optional String name, int level, int durability, int speed, int damage,
|
||||
double handle, int reinforced, double stonebound, String style, String ability) {
|
||||
if (name == null) name = material + " ";
|
||||
MineTweakerAPI.apply(new SetToolStats(material, "", new ToolMaterial(material, name, level, durability, speed, damage, (float) handle, reinforced, (float) stonebound, style, 0xFFFFFF)));
|
||||
MineTweakerAPI.apply(
|
||||
new SetToolStats(
|
||||
material,
|
||||
"",
|
||||
new ToolMaterial(
|
||||
material,
|
||||
name,
|
||||
level,
|
||||
durability,
|
||||
speed,
|
||||
damage,
|
||||
(float) handle,
|
||||
reinforced,
|
||||
(float) stonebound,
|
||||
style,
|
||||
0xFFFFFF)));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -29,15 +46,47 @@ public class ToolStats {
|
||||
*/
|
||||
@java.lang.Deprecated
|
||||
@ZenMethod
|
||||
public static void set(String material, @Optional String name, int level, int durability, int speed, int damage, double handle, int reinforced, double stonebound, String style, int primaryColor) {
|
||||
public static void set(String material, @Optional String name, int level, int durability, int speed, int damage,
|
||||
double handle, int reinforced, double stonebound, String style, int primaryColor) {
|
||||
if (name == null) name = material + " ";
|
||||
MineTweakerAPI.apply(new SetToolStats(material, "", new ToolMaterial(material, name, level, durability, speed, damage, (float) handle, reinforced, (float) stonebound, style, primaryColor)));
|
||||
MineTweakerAPI.apply(
|
||||
new SetToolStats(
|
||||
material,
|
||||
"",
|
||||
new ToolMaterial(
|
||||
material,
|
||||
name,
|
||||
level,
|
||||
durability,
|
||||
speed,
|
||||
damage,
|
||||
(float) handle,
|
||||
reinforced,
|
||||
(float) stonebound,
|
||||
style,
|
||||
primaryColor)));
|
||||
}
|
||||
|
||||
|
||||
@ZenMethod
|
||||
public static void setStats(String material, @Optional String name, int level, int durability, int speed, int damage, double handle, int reinforced, double stonebound, String style, int primaryColor) {
|
||||
public static void setStats(String material, @Optional String name, int level, int durability, int speed,
|
||||
int damage, double handle, int reinforced, double stonebound, String style, int primaryColor) {
|
||||
if (name == null) name = material + " ";
|
||||
MineTweakerAPI.apply(new SetToolStats(material, "", new ToolMaterial(material, name, level, durability, speed, damage, (float) handle, reinforced, (float) stonebound, style, primaryColor)));
|
||||
MineTweakerAPI.apply(
|
||||
new SetToolStats(
|
||||
material,
|
||||
"",
|
||||
new ToolMaterial(
|
||||
material,
|
||||
name,
|
||||
level,
|
||||
durability,
|
||||
speed,
|
||||
damage,
|
||||
(float) handle,
|
||||
reinforced,
|
||||
(float) stonebound,
|
||||
style,
|
||||
primaryColor)));
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
@@ -90,8 +139,9 @@ public class ToolStats {
|
||||
MineTweakerAPI.apply(new SetToolStats(material, "ability", name));
|
||||
}
|
||||
|
||||
//Sets various variables with reflection, making my life partially easier :D
|
||||
// Sets various variables with reflection, making my life partially easier :D
|
||||
private static class SetToolStats implements IUndoableAction {
|
||||
|
||||
protected int id;
|
||||
protected Object old;
|
||||
protected Object fresh;
|
||||
@@ -114,7 +164,18 @@ public class ToolStats {
|
||||
fresh = (ToolMaterial) value;
|
||||
} else {
|
||||
ToolMaterial t = (ToolMaterial) old;
|
||||
fresh = new ToolMaterial(t.materialName, t.localizationString, t.harvestLevel, t.durability, t.miningspeed, t.attack, t.handleModifier, t.reinforced, t.stonebound, t.tipStyle, t.primaryColor);
|
||||
fresh = new ToolMaterial(
|
||||
t.materialName,
|
||||
t.localizationString,
|
||||
t.harvestLevel,
|
||||
t.durability,
|
||||
t.miningspeed,
|
||||
t.attack,
|
||||
t.handleModifier,
|
||||
t.reinforced,
|
||||
t.stonebound,
|
||||
t.tipStyle,
|
||||
t.primaryColor);
|
||||
ReflectionHelper.setPrivateValue(ToolMaterial.class, fresh, field, value);
|
||||
}
|
||||
|
||||
@@ -152,10 +213,11 @@ public class ToolStats {
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//Bow Stats
|
||||
// Bow Stats
|
||||
@ZenMethod
|
||||
public static void setBowStats(String material, int durability, int drawspeed, double flightspeed) {
|
||||
MineTweakerAPI.apply(new SetBowStats(material, "", new BowMaterial(durability, drawspeed, (float) flightspeed)));
|
||||
MineTweakerAPI
|
||||
.apply(new SetBowStats(material, "", new BowMaterial(durability, drawspeed, (float) flightspeed)));
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
@@ -175,6 +237,7 @@ public class ToolStats {
|
||||
|
||||
// Bow Stats
|
||||
private static class SetBowStats extends SetToolStats {
|
||||
|
||||
public SetBowStats(String material, String field, Object value) {
|
||||
super(material, field, value);
|
||||
}
|
||||
@@ -209,10 +272,14 @@ public class ToolStats {
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//Arrow Stats
|
||||
// Arrow Stats
|
||||
@ZenMethod
|
||||
public static void setArrowStats(String material, double mass, double breakChance, double accuracy) {
|
||||
MineTweakerAPI.apply(new SetArrowStats(material, "", new ArrowMaterial((float) mass, (float) breakChance, (float) accuracy)));
|
||||
MineTweakerAPI.apply(
|
||||
new SetArrowStats(
|
||||
material,
|
||||
"",
|
||||
new ArrowMaterial((float) mass, (float) breakChance, (float) accuracy)));
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
@@ -232,6 +299,7 @@ public class ToolStats {
|
||||
|
||||
// Bow Stats
|
||||
private static class SetArrowStats extends SetToolStats {
|
||||
|
||||
public SetArrowStats(String material, String field, Object value) {
|
||||
super(material, field, value);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user