mirror of
https://github.com/GTNewHorizons/ModTweaker.git
synced 2026-11-27 23:46:04 +00:00
ModTweaker2 Rework
- Revised base classes for IUndoableAction - Reordered lots of code, so stuck actions should be less frequent - Added wildcard support to many "remove" methods - Started working on exist & duplicate checks
This commit is contained in:
1 parent
f5034b04d8
commit
da33cc6fab
112 files changed
+4596
-3522
No files matched your search
@@ -5,9 +5,9 @@ import modtweaker2.mods.thaumcraft.handlers.Arcane;
|
||||
import modtweaker2.mods.thaumcraft.handlers.Aspects;
|
||||
import modtweaker2.mods.thaumcraft.handlers.Crucible;
|
||||
import modtweaker2.mods.thaumcraft.handlers.Infusion;
|
||||
import modtweaker2.mods.thaumcraft.handlers.Loot;
|
||||
import modtweaker2.mods.thaumcraft.handlers.Research;
|
||||
import modtweaker2.mods.thaumcraft.handlers.Warp;
|
||||
import modtweaker2.mods.thaumcraft.handlers.Loot;
|
||||
|
||||
public class Thaumcraft {
|
||||
public Thaumcraft() {
|
||||
|
||||
@@ -1,18 +1,22 @@
|
||||
package modtweaker2.mods.thaumcraft.handlers;
|
||||
|
||||
import static modtweaker2.helpers.InputHelper.toIItemStack;
|
||||
import static modtweaker2.helpers.InputHelper.toObjects;
|
||||
import static modtweaker2.helpers.InputHelper.toShapedObjects;
|
||||
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;
|
||||
import modtweaker2.helpers.InputHelper;
|
||||
import modtweaker2.helpers.LogHelper;
|
||||
import modtweaker2.mods.thaumcraft.ThaumcraftHelper;
|
||||
import modtweaker2.utils.BaseListAddition;
|
||||
import modtweaker2.utils.BaseListRemoval;
|
||||
import modtweaker2.utils.TweakerPlugin;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
@@ -23,61 +27,74 @@ import thaumcraft.api.crafting.ShapelessArcaneRecipe;
|
||||
|
||||
@ZenClass("mods.thaumcraft.Arcane")
|
||||
public class Arcane {
|
||||
|
||||
public static final String name = "Thaumcraft Arcane Worktable";
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@ZenMethod
|
||||
public static void addShaped(String key, IItemStack output, String aspects, IIngredient[][] ingredients) {
|
||||
|
||||
MineTweakerAPI.apply(new Add(new ShapedArcaneRecipe(key, toStack(output), ThaumcraftHelper.parseAspects(aspects), toShapedObjects(ingredients))));
|
||||
MineTweakerAPI.apply(new Add(new ShapedArcaneRecipe(key, toStack(output), ThaumcraftHelper.parseAspects(aspects), toShapedObjects(ingredients))));
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void addShapeless(String key, IItemStack output, String aspects, IIngredient[] ingredients) {
|
||||
|
||||
MineTweakerAPI.apply(new Add(new ShapelessArcaneRecipe(key, toStack(output), ThaumcraftHelper.parseAspects(aspects), toObjects(ingredients))));
|
||||
MineTweakerAPI.apply(new Add(new ShapelessArcaneRecipe(key, toStack(output), ThaumcraftHelper.parseAspects(aspects), toObjects(ingredients))));
|
||||
}
|
||||
|
||||
private static class Add extends BaseListAddition {
|
||||
private static class Add extends BaseListAddition<IArcaneRecipe> {
|
||||
public Add(IArcaneRecipe recipe) {
|
||||
super("Thaumcraft Arcane Worktable", ThaumcraftApi.getCraftingRecipes(), recipe);
|
||||
super(Arcane.name, ThaumcraftApi.getCraftingRecipes());
|
||||
recipes.add(recipe);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeInfo() {
|
||||
Object out = ((IArcaneRecipe) recipe).getRecipeOutput();
|
||||
if (out instanceof ItemStack) {
|
||||
return ((ItemStack) out).getDisplayName();
|
||||
} else
|
||||
return super.getRecipeInfo();
|
||||
protected String getRecipeInfo(IArcaneRecipe recipe) {
|
||||
ItemStack stack = recipe.getRecipeOutput();
|
||||
|
||||
if(stack instanceof ItemStack)
|
||||
return InputHelper.getStackDescription(stack);
|
||||
else
|
||||
return "Unknown output";
|
||||
}
|
||||
}
|
||||
|
||||
// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@ZenMethod
|
||||
public static void removeRecipe(IItemStack output) {
|
||||
MineTweakerAPI.apply(new Remove(toStack(output)));
|
||||
public static void removeRecipe(IIngredient output) {
|
||||
List<IArcaneRecipe> recipes = new LinkedList<IArcaneRecipe>();
|
||||
|
||||
for(Object o : ThaumcraftApi.getCraftingRecipes()) {
|
||||
if(o != null && o instanceof IArcaneRecipe) {
|
||||
IArcaneRecipe recipe = (IArcaneRecipe)o;
|
||||
|
||||
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", Arcane.name, output.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
private static class Remove extends BaseListRemoval {
|
||||
public Remove(ItemStack stack) {
|
||||
super("Thaumcraft Arcane Worktable", ThaumcraftApi.getCraftingRecipes(), stack);
|
||||
private static class Remove extends BaseListRemoval<IArcaneRecipe> {
|
||||
public Remove(List<IArcaneRecipe> recipes) {
|
||||
super(Arcane.name, ThaumcraftApi.getCraftingRecipes(), recipes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
for (Object o : ThaumcraftApi.getCraftingRecipes()) {
|
||||
if (o != null && o instanceof IArcaneRecipe) {
|
||||
IArcaneRecipe r = (IArcaneRecipe) o;
|
||||
if (r.getRecipeOutput() != null && r.getRecipeOutput().isItemEqual(stack)) {
|
||||
recipes.add(r);
|
||||
}
|
||||
}
|
||||
}
|
||||
super.apply();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeInfo() {
|
||||
return stack.getDisplayName();
|
||||
}
|
||||
@Override
|
||||
protected String getRecipeInfo(IArcaneRecipe recipe) {
|
||||
ItemStack stack = recipe.getRecipeOutput();
|
||||
|
||||
if(stack instanceof ItemStack)
|
||||
return InputHelper.getStackDescription(stack);
|
||||
else
|
||||
return "Unknown output";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,9 +7,7 @@ import java.util.Arrays;
|
||||
import minetweaker.MineTweakerAPI;
|
||||
import minetweaker.api.item.IItemStack;
|
||||
import modtweaker2.mods.thaumcraft.ThaumcraftHelper;
|
||||
import modtweaker2.utils.BaseDescriptionAddition;
|
||||
import modtweaker2.utils.BaseDescriptionRemoval;
|
||||
import modtweaker2.utils.TweakerPlugin;
|
||||
import modtweaker2.utils.BaseUndoable;
|
||||
import net.minecraft.entity.EntityList;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
@@ -34,7 +32,7 @@ public class Aspects {
|
||||
}
|
||||
|
||||
// Adds or sets Aspects
|
||||
private static class Add extends BaseDescriptionAddition {
|
||||
private static class Add extends BaseUndoable {
|
||||
private final ItemStack stack;
|
||||
private final String aspects;
|
||||
private final boolean replace;
|
||||
@@ -55,7 +53,10 @@ public class Aspects {
|
||||
newList = ThaumcraftHelper.parseAspects(oldList, aspects);
|
||||
else
|
||||
newList = ThaumcraftHelper.parseAspects(aspects);
|
||||
|
||||
ThaumcraftApi.objectTags.put(Arrays.asList(stack.getItem(), stack.getItemDamage()), newList);
|
||||
|
||||
success = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -80,7 +81,7 @@ public class Aspects {
|
||||
MineTweakerAPI.apply(new Remove(toStack(stack), aspects));
|
||||
}
|
||||
|
||||
private static class Remove extends BaseDescriptionRemoval {
|
||||
private static class Remove extends BaseUndoable {
|
||||
private final ItemStack stack;
|
||||
private final String aspects;
|
||||
private AspectList oldList;
|
||||
@@ -99,6 +100,8 @@ public class Aspects {
|
||||
newList = ThaumcraftHelper.removeAspects(oldList, aspects);
|
||||
ThaumcraftApi.objectTags.put(Arrays.asList(stack.getItem(), stack.getItemDamage()), newList);
|
||||
}
|
||||
|
||||
success = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -139,7 +142,7 @@ public class Aspects {
|
||||
}
|
||||
|
||||
// Adds or sets Aspects
|
||||
private static class AddEntity extends BaseDescriptionAddition {
|
||||
private static class AddEntity extends BaseUndoable {
|
||||
private final String entityName;
|
||||
private final String aspects;
|
||||
private final boolean replace;
|
||||
@@ -162,6 +165,8 @@ public class Aspects {
|
||||
newList = ThaumcraftHelper.parseAspects(aspects);
|
||||
ThaumcraftHelper.removeEntityAspects(entityName);
|
||||
ThaumcraftApi.registerEntityTag(entityName, newList);
|
||||
|
||||
success = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -189,7 +194,7 @@ public class Aspects {
|
||||
MineTweakerAPI.apply(new RemoveEntity(entityName, aspects));
|
||||
}
|
||||
|
||||
private static class RemoveEntity extends BaseDescriptionRemoval {
|
||||
private static class RemoveEntity extends BaseUndoable {
|
||||
private final String entityName;
|
||||
private final String aspects;
|
||||
private AspectList oldList;
|
||||
@@ -209,6 +214,8 @@ public class Aspects {
|
||||
ThaumcraftHelper.removeEntityAspects(entityName);
|
||||
ThaumcraftApi.registerEntityTag(entityName, newList);
|
||||
}
|
||||
|
||||
success = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,16 +1,21 @@
|
||||
package modtweaker2.mods.thaumcraft.handlers;
|
||||
|
||||
import static modtweaker2.helpers.InputHelper.toIItemStack;
|
||||
import static modtweaker2.helpers.InputHelper.toObject;
|
||||
import static modtweaker2.helpers.InputHelper.toStack;
|
||||
import static modtweaker2.helpers.StackHelper.areEqual;
|
||||
import static modtweaker2.helpers.StackHelper.matches;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import minetweaker.MineTweakerAPI;
|
||||
import minetweaker.api.item.IIngredient;
|
||||
import minetweaker.api.item.IItemStack;
|
||||
import modtweaker2.helpers.InputHelper;
|
||||
import modtweaker2.helpers.LogHelper;
|
||||
import modtweaker2.mods.thaumcraft.ThaumcraftHelper;
|
||||
import modtweaker2.utils.BaseListAddition;
|
||||
import modtweaker2.utils.BaseListRemoval;
|
||||
import modtweaker2.utils.TweakerPlugin;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
import thaumcraft.api.ThaumcraftApi;
|
||||
@@ -18,52 +23,56 @@ import thaumcraft.api.crafting.CrucibleRecipe;
|
||||
|
||||
@ZenClass("mods.thaumcraft.Crucible")
|
||||
public class Crucible {
|
||||
|
||||
public static final String name = "Thaumcraft Crucible";
|
||||
|
||||
@ZenMethod
|
||||
public static void addRecipe(String key, IItemStack result, IIngredient catalyst, String aspects) {
|
||||
|
||||
MineTweakerAPI.apply(new Add(new CrucibleRecipe(key, toStack(result), toObject(catalyst), ThaumcraftHelper.parseAspects(aspects))));
|
||||
MineTweakerAPI.apply(new Add(new CrucibleRecipe(key, toStack(result), toObject(catalyst), ThaumcraftHelper.parseAspects(aspects))));
|
||||
}
|
||||
|
||||
private static class Add extends BaseListAddition {
|
||||
|
||||
private static class Add extends BaseListAddition<CrucibleRecipe> {
|
||||
public Add(CrucibleRecipe recipe) {
|
||||
super("Thaumcraft Crucible", ThaumcraftApi.getCraftingRecipes(), recipe);
|
||||
super(Crucible.name, ThaumcraftApi.getCraftingRecipes());
|
||||
recipes.add(recipe);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getRecipeInfo() {
|
||||
return ((CrucibleRecipe) recipe).getRecipeOutput().getDisplayName();
|
||||
protected String getRecipeInfo(CrucibleRecipe recipe) {
|
||||
return InputHelper.getStackDescription(recipe.getRecipeOutput());
|
||||
}
|
||||
}
|
||||
|
||||
// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@ZenMethod
|
||||
public static void removeRecipe(IItemStack output) {
|
||||
|
||||
MineTweakerAPI.apply(new Remove(toStack(output)));
|
||||
public static void removeRecipe(IIngredient output) {
|
||||
List<CrucibleRecipe> recipes = new LinkedList<CrucibleRecipe>();
|
||||
|
||||
for (Object o : ThaumcraftApi.getCraftingRecipes()) {
|
||||
if (o instanceof CrucibleRecipe) {
|
||||
CrucibleRecipe r = (CrucibleRecipe) o;
|
||||
if (r.getRecipeOutput() != null && matches(output, toIItemStack(r.getRecipeOutput()))) {
|
||||
recipes.add(r);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!recipes.isEmpty()) {
|
||||
MineTweakerAPI.apply(new Remove(recipes));
|
||||
} else {
|
||||
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", Crucible.name, output.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
private static class Remove extends BaseListRemoval {
|
||||
public Remove(ItemStack stack) {
|
||||
super("Thaumcraft Crucible", ThaumcraftApi.getCraftingRecipes(), stack);
|
||||
private static class Remove extends BaseListRemoval<CrucibleRecipe> {
|
||||
public Remove(List<CrucibleRecipe> recipes) {
|
||||
super(Crucible.name, ThaumcraftApi.getCraftingRecipes(), recipes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
for (Object o : ThaumcraftApi.getCraftingRecipes()) {
|
||||
if (o instanceof CrucibleRecipe) {
|
||||
CrucibleRecipe r = (CrucibleRecipe) o;
|
||||
if (r.getRecipeOutput() != null && areEqual(r.getRecipeOutput(), stack)) {
|
||||
recipes.add(r);
|
||||
}
|
||||
}
|
||||
}
|
||||
super.apply();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeInfo() {
|
||||
return stack.getDisplayName();
|
||||
}
|
||||
@Override
|
||||
protected String getRecipeInfo(CrucibleRecipe recipe) {
|
||||
return InputHelper.getStackDescription(recipe.getRecipeOutput());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,16 +1,22 @@
|
||||
package modtweaker2.mods.thaumcraft.handlers;
|
||||
|
||||
import static modtweaker2.helpers.InputHelper.toIItemStack;
|
||||
import static modtweaker2.helpers.InputHelper.toStack;
|
||||
import static modtweaker2.helpers.InputHelper.toStacks;
|
||||
import static modtweaker2.helpers.StackHelper.areEqual;
|
||||
import minetweaker.IUndoableAction;
|
||||
import static modtweaker2.helpers.StackHelper.matches;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import minetweaker.MineTweakerAPI;
|
||||
import minetweaker.api.item.IIngredient;
|
||||
import minetweaker.api.item.IItemStack;
|
||||
import modtweaker2.helpers.InputHelper;
|
||||
import modtweaker2.helpers.LogHelper;
|
||||
import modtweaker2.mods.thaumcraft.ThaumcraftHelper;
|
||||
import modtweaker2.mods.thaumcraft.recipe.MTInfusionRecipe;
|
||||
import modtweaker2.utils.BaseListAddition;
|
||||
import modtweaker2.utils.BaseListRemoval;
|
||||
import modtweaker2.utils.TweakerPlugin;
|
||||
import net.minecraft.enchantment.Enchantment;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
@@ -21,6 +27,10 @@ import thaumcraft.api.crafting.InfusionRecipe;
|
||||
|
||||
@ZenClass("mods.thaumcraft.Infusion")
|
||||
public class Infusion {
|
||||
|
||||
public static final String name = "Thaumcraft Infusion";
|
||||
public static final String enchName = name + " Enchantment";
|
||||
|
||||
@ZenMethod
|
||||
public static void addRecipe(String key, IItemStack input, IItemStack[] recipe, String aspects, IItemStack result, int instability) {
|
||||
|
||||
@@ -31,131 +41,112 @@ public class Infusion {
|
||||
// fuzzy or not
|
||||
@ZenMethod
|
||||
public static void addRecipe(String key, IItemStack input, IItemStack[] recipe, String aspects, IItemStack result, int instability, boolean fuzzyCentre, boolean[] fuzzyRecipe) {
|
||||
|
||||
MineTweakerAPI.apply(new Add(new MTInfusionRecipe(key, toStack(result), instability, ThaumcraftHelper.parseAspects(aspects), toStack(input), toStacks(recipe), fuzzyCentre, fuzzyRecipe)));
|
||||
MineTweakerAPI.apply(new Add(new MTInfusionRecipe(key, toStack(result), instability, ThaumcraftHelper.parseAspects(aspects), toStack(input), toStacks(recipe), fuzzyCentre, fuzzyRecipe)));
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void addEnchantment(String key, int enchantID, int instability, String aspects, IItemStack[] recipe) {
|
||||
|
||||
MineTweakerAPI.apply(new AddEnchant(new InfusionEnchantmentRecipe(key, Enchantment.enchantmentsList[enchantID], instability, ThaumcraftHelper.parseAspects(aspects), toStacks(recipe))));
|
||||
MineTweakerAPI.apply(new AddEnchant(new InfusionEnchantmentRecipe(key, Enchantment.enchantmentsList[enchantID], instability, ThaumcraftHelper.parseAspects(aspects), toStacks(recipe))));
|
||||
}
|
||||
|
||||
private static class Add extends BaseListAddition {
|
||||
private static class Add extends BaseListAddition<InfusionRecipe> {
|
||||
public Add(InfusionRecipe recipe) {
|
||||
super("Thaumcraft Infusion", ThaumcraftApi.getCraftingRecipes(), recipe);
|
||||
super(Infusion.name, ThaumcraftApi.getCraftingRecipes());
|
||||
recipes.add(recipe);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeInfo() {
|
||||
Object out = ((InfusionRecipe) recipe).getRecipeOutput();
|
||||
if (out instanceof ItemStack) {
|
||||
return ((ItemStack) out).getDisplayName();
|
||||
} else
|
||||
return super.getRecipeInfo();
|
||||
protected String getRecipeInfo(InfusionRecipe recipe) {
|
||||
Object out = ((InfusionRecipe) recipe).getRecipeOutput();
|
||||
if (out instanceof ItemStack) {
|
||||
return ((ItemStack) out).getDisplayName();
|
||||
} else
|
||||
return "Unknown item";
|
||||
}
|
||||
}
|
||||
|
||||
private static class AddEnchant implements IUndoableAction {
|
||||
InfusionEnchantmentRecipe recipe;
|
||||
|
||||
private static class AddEnchant extends BaseListAddition<InfusionEnchantmentRecipe> {
|
||||
public AddEnchant(InfusionEnchantmentRecipe inp) {
|
||||
recipe = inp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
ThaumcraftApi.getCraftingRecipes().add(recipe);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describe() {
|
||||
return "Adding Infusion Enchantment Recipe: " + recipe.enchantment.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUndo() {
|
||||
return recipe != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void undo() {
|
||||
ThaumcraftApi.getCraftingRecipes().remove(recipe);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describeUndo() {
|
||||
return "Removing Infusion Enchantment Recipe: " + recipe.enchantment.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOverrideKey() {
|
||||
return null;
|
||||
super(Infusion.enchName, ThaumcraftApi.getCraftingRecipes());
|
||||
recipes.add(inp);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getRecipeInfo(InfusionEnchantmentRecipe recipe) {
|
||||
return recipe.getEnchantment().getName();
|
||||
}
|
||||
}
|
||||
|
||||
// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@ZenMethod
|
||||
public static void removeRecipe(IItemStack output) {
|
||||
|
||||
MineTweakerAPI.apply(new Remove(toStack(output)));
|
||||
public static void removeRecipe(IIngredient output) {
|
||||
List<InfusionRecipe> recipes = new LinkedList<InfusionRecipe>();
|
||||
|
||||
for (Object o : ThaumcraftApi.getCraftingRecipes()) {
|
||||
if (o instanceof InfusionRecipe) {
|
||||
InfusionRecipe r = (InfusionRecipe) o;
|
||||
if (r.getRecipeOutput() != null && r.getRecipeOutput() instanceof ItemStack && matches(output, toIItemStack((ItemStack)r.getRecipeOutput()))) {
|
||||
recipes.add(r);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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()));
|
||||
}
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void removeEnchant(int id) {
|
||||
|
||||
MineTweakerAPI.apply(new RemoveEnchant(Enchantment.enchantmentsList[id]));
|
||||
}
|
||||
|
||||
private static class Remove extends BaseListRemoval {
|
||||
public Remove(ItemStack stack) {
|
||||
super("Thaumcraft Infusion", ThaumcraftApi.getCraftingRecipes(), stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
for (Object o : ThaumcraftApi.getCraftingRecipes()) {
|
||||
if (o instanceof InfusionRecipe) {
|
||||
InfusionRecipe r = (InfusionRecipe) o;
|
||||
if (r.getRecipeOutput() != null && r.getRecipeOutput() instanceof ItemStack && areEqual((ItemStack) r.getRecipeOutput(), stack)) {
|
||||
recipes.add(r);
|
||||
}
|
||||
}
|
||||
}
|
||||
super.apply();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeInfo() {
|
||||
return stack.getDisplayName();
|
||||
}
|
||||
}
|
||||
|
||||
private static class RemoveEnchant extends BaseListRemoval {
|
||||
Enchantment enchant;
|
||||
|
||||
public RemoveEnchant(Enchantment ench) {
|
||||
super("Thaumcraft Infusion Enchantment", ThaumcraftApi.getCraftingRecipes());
|
||||
enchant = ench;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
for (Object recipe : list) {
|
||||
if (recipe instanceof InfusionEnchantmentRecipe) {
|
||||
InfusionEnchantmentRecipe enchRecipe = (InfusionEnchantmentRecipe) recipe;
|
||||
if (enchRecipe.getEnchantment() == enchant) {
|
||||
recipes.add(enchRecipe);
|
||||
}
|
||||
}
|
||||
}
|
||||
super.apply();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeInfo() {
|
||||
return enchant.getName();
|
||||
List<InfusionEnchantmentRecipe> recipes = new LinkedList<InfusionEnchantmentRecipe>();
|
||||
Enchantment ench = Enchantment.enchantmentsList[id];
|
||||
|
||||
for (Object recipe : ThaumcraftApi.getCraftingRecipes()) {
|
||||
if (recipe instanceof InfusionEnchantmentRecipe) {
|
||||
InfusionEnchantmentRecipe enchRecipe = (InfusionEnchantmentRecipe) recipe;
|
||||
if (enchRecipe.getEnchantment() == ench) {
|
||||
recipes.add(enchRecipe);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!recipes.isEmpty()) {
|
||||
MineTweakerAPI.apply(new RemoveEnchant(recipes));
|
||||
} else {
|
||||
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", Infusion.enchName + " Enchantment", ench.getName()));
|
||||
}
|
||||
}
|
||||
|
||||
private static class Remove extends BaseListRemoval<InfusionRecipe> {
|
||||
public Remove(List<InfusionRecipe> recipes) {
|
||||
super(Infusion.name, ThaumcraftApi.getCraftingRecipes(), recipes);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getRecipeInfo(InfusionRecipe recipe) {
|
||||
|
||||
Object o = recipe.getRecipeOutput();
|
||||
|
||||
if(o instanceof ItemStack) {
|
||||
return InputHelper.getStackDescription((ItemStack)o);
|
||||
} else {
|
||||
return "Unknown Item";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static class RemoveEnchant extends BaseListRemoval<InfusionEnchantmentRecipe> {
|
||||
public RemoveEnchant(List<InfusionEnchantmentRecipe> recipes) {
|
||||
super(Infusion.enchName, ThaumcraftApi.getCraftingRecipes(), recipes);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getRecipeInfo(InfusionEnchantmentRecipe recipe) {
|
||||
return recipe.getEnchantment().getName();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,20 +1,28 @@
|
||||
package modtweaker2.mods.thaumcraft.handlers;
|
||||
|
||||
import static modtweaker2.helpers.InputHelper.toIItemStack;
|
||||
import static modtweaker2.helpers.StackHelper.matches;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import minetweaker.MineTweakerAPI;
|
||||
import minetweaker.api.item.IIngredient;
|
||||
import minetweaker.api.item.IItemStack;
|
||||
import modtweaker2.helpers.InputHelper;
|
||||
import modtweaker2.helpers.LogHelper;
|
||||
import modtweaker2.utils.BaseListAddition;
|
||||
import modtweaker2.utils.BaseListRemoval;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
import thaumcraft.api.ThaumcraftApi;
|
||||
import thaumcraft.api.internal.WeightedRandomLoot;
|
||||
|
||||
@ZenClass("mods.thaumcraft.Loot")
|
||||
public class Loot {
|
||||
|
||||
public static final String name = "Thaumcraft LootBag";
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@ZenMethod
|
||||
public static void addCommonLoot(IItemStack stack, int weight) {
|
||||
@@ -31,40 +39,59 @@ public class Loot {
|
||||
MineTweakerAPI.apply(new Add(WeightedRandomLoot.lootBagRare, new WeightedRandomLoot(InputHelper.toStack(stack), weight)));
|
||||
}
|
||||
|
||||
public static class Add extends BaseListAddition {
|
||||
public Add(List list, WeightedRandomLoot recipe) {
|
||||
super(list, recipe);
|
||||
public static class Add extends BaseListAddition<WeightedRandomLoot> {
|
||||
public Add(List<WeightedRandomLoot> list, WeightedRandomLoot recipe) {
|
||||
super(Loot.name, list);
|
||||
recipes.add(recipe);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getRecipeInfo(WeightedRandomLoot recipe) {
|
||||
return InputHelper.getStackDescription(recipe.item);
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@ZenMethod
|
||||
public static void removeCommonLoot(IIngredient stack) {
|
||||
removeLoot(WeightedRandomLoot.lootBagCommon, stack);
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void removeCommonLoot(IItemStack stack) {
|
||||
MineTweakerAPI.apply(new Remove(WeightedRandomLoot.lootBagCommon, InputHelper.toStack(stack)));
|
||||
public static void removeUncommonLoot(IIngredient stack) {
|
||||
removeLoot(WeightedRandomLoot.lootBagUncommon, stack);
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void removeUncommonLoot(IItemStack stack) {
|
||||
MineTweakerAPI.apply(new Remove(WeightedRandomLoot.lootBagUncommon, InputHelper.toStack(stack)));
|
||||
public static void removeRareLoot(IIngredient stack) {
|
||||
removeLoot(WeightedRandomLoot.lootBagRare, stack);
|
||||
}
|
||||
|
||||
public static void removeLoot(List<WeightedRandomLoot> list, IIngredient ingredient) {
|
||||
List<WeightedRandomLoot> recipes = new LinkedList<WeightedRandomLoot>();
|
||||
|
||||
for (WeightedRandomLoot loot : list) {
|
||||
if (matches(ingredient, toIItemStack(loot.item))) {
|
||||
recipes.add(loot);
|
||||
}
|
||||
}
|
||||
|
||||
if(!recipes.isEmpty()) {
|
||||
MineTweakerAPI.apply(new Remove(list, recipes));
|
||||
} else {
|
||||
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored.", Loot.name, ingredient.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void removeRareLoot(IItemStack stack) {
|
||||
MineTweakerAPI.apply(new Remove(WeightedRandomLoot.lootBagRare, InputHelper.toStack(stack)));
|
||||
}
|
||||
|
||||
public static class Remove extends BaseListRemoval {
|
||||
public Remove(List list, ItemStack stack) {
|
||||
super(list, stack);
|
||||
public static class Remove extends BaseListRemoval<WeightedRandomLoot> {
|
||||
public Remove(List<WeightedRandomLoot> list, List<WeightedRandomLoot> recipes) {
|
||||
super(Loot.name, list, recipes);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
for (WeightedRandomLoot stack : (List<WeightedRandomLoot>) list) {
|
||||
if (stack.item.isItemEqual(this.stack)) {
|
||||
recipes.add(stack);
|
||||
}
|
||||
}
|
||||
super.apply();
|
||||
protected String getRecipeInfo(WeightedRandomLoot recipe) {
|
||||
return InputHelper.getStackDescription(recipe.item);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -21,7 +21,6 @@ import modtweaker2.mods.thaumcraft.research.RemoveResearch;
|
||||
import modtweaker2.mods.thaumcraft.research.RemoveTab;
|
||||
import modtweaker2.mods.thaumcraft.research.SetAspects;
|
||||
import modtweaker2.mods.thaumcraft.research.SetResearch;
|
||||
import modtweaker2.utils.TweakerPlugin;
|
||||
import net.minecraft.enchantment.Enchantment;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import stanhebben.zenscript.annotations.Optional;
|
||||
|
||||
@@ -10,7 +10,6 @@ import minetweaker.IUndoableAction;
|
||||
import minetweaker.MineTweakerAPI;
|
||||
import minetweaker.api.item.IItemStack;
|
||||
import modtweaker2.mods.thaumcraft.ThaumcraftHelper;
|
||||
import modtweaker2.utils.TweakerPlugin;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package modtweaker2.mods.thaumcraft.research;
|
||||
|
||||
import static modtweaker2.helpers.StackHelper.areEqual;
|
||||
import minetweaker.IUndoableAction;
|
||||
import modtweaker2.mods.thaumcraft.ThaumcraftHelper;
|
||||
import net.minecraft.enchantment.Enchantment;
|
||||
@@ -14,8 +15,6 @@ import thaumcraft.api.crafting.InfusionRecipe;
|
||||
import thaumcraft.api.research.ResearchCategories;
|
||||
import thaumcraft.api.research.ResearchPage;
|
||||
import thaumcraft.api.research.ResearchPage.PageType;
|
||||
import static modtweaker2.helpers.InputHelper.*;
|
||||
import static modtweaker2.helpers.StackHelper.*;
|
||||
|
||||
public class AddPage implements IUndoableAction {
|
||||
String key;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package modtweaker2.mods.thaumcraft.research;
|
||||
|
||||
import static modtweaker2.helpers.StackHelper.areEqual;
|
||||
import minetweaker.IUndoableAction;
|
||||
import modtweaker2.mods.thaumcraft.ThaumcraftHelper;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -12,8 +13,6 @@ import thaumcraft.api.crafting.InfusionRecipe;
|
||||
import thaumcraft.api.research.ResearchCategories;
|
||||
import thaumcraft.api.research.ResearchItem;
|
||||
import thaumcraft.api.research.ResearchPage;
|
||||
import static modtweaker2.helpers.InputHelper.*;
|
||||
import static modtweaker2.helpers.StackHelper.*;
|
||||
|
||||
public class RefreshResearch implements IUndoableAction {
|
||||
String research;
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package modtweaker2.mods.thaumcraft.research.commands;
|
||||
|
||||
import static modtweaker2.helpers.LogHelper.log;
|
||||
import static modtweaker2.helpers.LogHelper.logPrinted;
|
||||
import minetweaker.MineTweakerAPI;
|
||||
import minetweaker.api.player.IPlayer;
|
||||
import minetweaker.api.server.ICommandFunction;
|
||||
import thaumcraft.api.research.ResearchCategories;
|
||||
import static modtweaker2.helpers.InputHelper.*;
|
||||
import static modtweaker2.helpers.LogHelper.*;
|
||||
|
||||
public class ResearchLogger implements ICommandFunction {
|
||||
@Override
|
||||
|
||||
Reference in new issue
Block a user