Added forestry
This commit is contained in:
parent
9017b2e6f8
commit
915e949491
10 changed files with 983 additions and 0 deletions
BIN
libs/forestry_1.11.2-5.3.4.101.jar
Normal file
BIN
libs/forestry_1.11.2-5.3.4.101.jar
Normal file
Binary file not shown.
89
src/main/java/com/blamejared/compat/forestry/Carpenter.java
Normal file
89
src/main/java/com/blamejared/compat/forestry/Carpenter.java
Normal file
|
@ -0,0 +1,89 @@
|
|||
package com.blamejared.compat.forestry;
|
||||
|
||||
import com.blamejared.api.annotations.Handler;
|
||||
import com.blamejared.compat.forestry.util.*;
|
||||
import com.blamejared.mtlib.helpers.LogHelper;
|
||||
import forestry.api.recipes.*;
|
||||
import forestry.core.recipes.ShapedRecipeCustom;
|
||||
import forestry.factory.recipes.CarpenterRecipe;
|
||||
import minetweaker.MineTweakerAPI;
|
||||
import minetweaker.api.item.*;
|
||||
import minetweaker.api.liquid.ILiquidStack;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import stanhebben.zenscript.annotations.Optional;
|
||||
import stanhebben.zenscript.annotations.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import static com.blamejared.mtlib.helpers.InputHelper.*;
|
||||
import static com.blamejared.mtlib.helpers.StackHelper.matches;
|
||||
|
||||
@ZenClass("mods.forestry.Carpenter")
|
||||
@Handler("forestry")
|
||||
public class Carpenter {
|
||||
|
||||
@ZenMethod
|
||||
public static void addRecipe(IItemStack output, IIngredient[][] ingredients, int packagingTime, @Optional ILiquidStack fluidInput, @Optional IItemStack box) {
|
||||
MineTweakerAPI.apply(new Add(new CarpenterRecipe(packagingTime, toFluid(fluidInput), toStack(box), new ShapedRecipeCustom(toStack(output), toShapedObjects(ingredients)))));
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void removeRecipe(IIngredient output, @Optional IIngredient fluidInput) {
|
||||
List<ICarpenterRecipe> recipes = new LinkedList<>();
|
||||
|
||||
for(ICarpenterRecipe recipe : RecipeManagers.carpenterManager.recipes()) {
|
||||
if(recipe != null) {
|
||||
ItemStack recipeResult = recipe.getCraftingGridRecipe().getOutput();
|
||||
if(recipeResult != null && matches(output, toIItemStack(recipeResult))) {
|
||||
if(fluidInput != null) {
|
||||
if(matches(fluidInput, toILiquidStack(recipe.getFluidResource())))
|
||||
recipes.add(recipe);
|
||||
} else {
|
||||
recipes.add(recipe);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!recipes.isEmpty()) {
|
||||
MineTweakerAPI.apply(new Remove(recipes));
|
||||
} else {
|
||||
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", "Carpenter", output.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
private static class Add extends ForestryListAddition<ICarpenterRecipe> {
|
||||
|
||||
protected Add(ICarpenterRecipe recipe) {
|
||||
super("Carpenter", RecipeManagers.carpenterManager);
|
||||
recipes.add(recipe);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getRecipeInfo(ICarpenterRecipe recipe) {
|
||||
return LogHelper.getStackDescription(recipe.getCraftingGridRecipe().getOutput());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getJEICategory(ICarpenterRecipe recipe) {
|
||||
return "forestry.carpenter";
|
||||
}
|
||||
}
|
||||
|
||||
private static class Remove extends ForestryListRemoval<ICarpenterRecipe, ICarpenterManager> {
|
||||
|
||||
public Remove(List<ICarpenterRecipe> recipes) {
|
||||
super("Carpenter", RecipeManagers.carpenterManager, recipes);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getRecipeInfo(ICarpenterRecipe recipe) {
|
||||
return LogHelper.getStackDescription(recipe.getCraftingGridRecipe().getOutput());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getJEICategory(ICarpenterRecipe recipe) {
|
||||
return "forestry.carpenter";
|
||||
}
|
||||
}
|
||||
}
|
101
src/main/java/com/blamejared/compat/forestry/Centrifuge.java
Normal file
101
src/main/java/com/blamejared/compat/forestry/Centrifuge.java
Normal file
|
@ -0,0 +1,101 @@
|
|||
package com.blamejared.compat.forestry;
|
||||
|
||||
import com.blamejared.api.annotations.Handler;
|
||||
import com.blamejared.compat.forestry.util.*;
|
||||
import com.blamejared.mtlib.helpers.LogHelper;
|
||||
import forestry.api.recipes.*;
|
||||
import forestry.factory.recipes.CentrifugeRecipe;
|
||||
import minetweaker.MineTweakerAPI;
|
||||
import minetweaker.api.item.*;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import stanhebben.zenscript.annotations.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import static com.blamejared.mtlib.helpers.InputHelper.*;
|
||||
import static com.blamejared.mtlib.helpers.StackHelper.matches;
|
||||
|
||||
|
||||
@ZenClass("mods.forestry.Centrifuge")
|
||||
@Handler("forestry")
|
||||
public class Centrifuge {
|
||||
|
||||
public static final String name = "Forestry Centrifuge";
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Adds recipe to Centrifuge
|
||||
*
|
||||
* @param output recipe product
|
||||
* @param ingredients required ingredients
|
||||
* @param packagingTime amount of ticks per crafting operation
|
||||
*/
|
||||
@ZenMethod
|
||||
public static void addRecipe(WeightedItemStack[] output, IItemStack ingredients, int packagingTime) {
|
||||
Map<ItemStack, Float> products = new HashMap<ItemStack, Float>();
|
||||
for(WeightedItemStack product : output) {
|
||||
products.put(toStack(product.getStack()), product.getChance());
|
||||
}
|
||||
MineTweakerAPI.apply(new Add(new CentrifugeRecipe(packagingTime, toStack(ingredients), products)));
|
||||
}
|
||||
|
||||
private static class Add extends ForestryListAddition<ICentrifugeRecipe> {
|
||||
|
||||
public Add(ICentrifugeRecipe recipe) {
|
||||
super(Centrifuge.name, RecipeManagers.centrifugeManager);
|
||||
recipes.add(recipe);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getRecipeInfo(ICentrifugeRecipe recipe) {
|
||||
return LogHelper.getStackDescription(recipe.getInput());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getJEICategory(ICentrifugeRecipe recipe) {
|
||||
return "forestry.centrifuge";
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Removes a recipe for the Centrifuge
|
||||
*
|
||||
* @param input type of item in input
|
||||
*/
|
||||
@ZenMethod
|
||||
public static void removeRecipe(IIngredient input) {
|
||||
List<ICentrifugeRecipe> recipes = new LinkedList<ICentrifugeRecipe>();
|
||||
|
||||
for(ICentrifugeRecipe recipe : RecipeManagers.centrifugeManager.recipes()) {
|
||||
if(recipe != null && matches(input, toIItemStack(recipe.getInput()))) {
|
||||
recipes.add(recipe);
|
||||
}
|
||||
}
|
||||
|
||||
if(!recipes.isEmpty()) {
|
||||
MineTweakerAPI.apply(new Remove(recipes));
|
||||
} else {
|
||||
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", Centrifuge.name, input.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
private static class Remove extends ForestryListRemoval<ICentrifugeRecipe, ICentrifugeManager> {
|
||||
|
||||
public Remove(List<ICentrifugeRecipe> recipes) {
|
||||
super(Centrifuge.name, RecipeManagers.centrifugeManager, recipes);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getRecipeInfo(ICentrifugeRecipe recipe) {
|
||||
return LogHelper.getStackDescription(recipe.getInput());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getJEICategory(ICentrifugeRecipe recipe) {
|
||||
return "forestry.centrifuge";
|
||||
}
|
||||
}
|
||||
}
|
177
src/main/java/com/blamejared/compat/forestry/Fermenter.java
Normal file
177
src/main/java/com/blamejared/compat/forestry/Fermenter.java
Normal file
|
@ -0,0 +1,177 @@
|
|||
package com.blamejared.compat.forestry;
|
||||
|
||||
import com.blamejared.api.annotations.Handler;
|
||||
import com.blamejared.compat.forestry.util.*;
|
||||
import com.blamejared.mtlib.helpers.LogHelper;
|
||||
import com.blamejared.mtlib.utils.*;
|
||||
import forestry.api.fuels.*;
|
||||
import forestry.api.recipes.*;
|
||||
import forestry.factory.recipes.FermenterRecipe;
|
||||
import forestry.factory.recipes.jei.fermenter.FermenterRecipeWrapper;
|
||||
import mezz.jei.api.recipe.IRecipeWrapper;
|
||||
import minetweaker.MineTweakerAPI;
|
||||
import minetweaker.api.item.*;
|
||||
import minetweaker.api.liquid.ILiquidStack;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import stanhebben.zenscript.annotations.*;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import static com.blamejared.mtlib.helpers.InputHelper.*;
|
||||
import static com.blamejared.mtlib.helpers.StackHelper.matches;
|
||||
|
||||
@ZenClass("mods.forestry.Fermenter")
|
||||
@Handler("forestry")
|
||||
public class Fermenter {
|
||||
|
||||
public static final String name = "Forestry Fermenter";
|
||||
public static final String nameFuel = name + " (Fuel)";
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Adds recipe to fermenter
|
||||
* Amount of fluid output: fermentationValue * fluidOutputModifier
|
||||
* Note: the actual consumption of fluid input depends on the fermentation fuel
|
||||
*
|
||||
* @param fluidOutput type of fluid produced
|
||||
* @param resource organic item
|
||||
* @param fluidInput type of fluid required in input
|
||||
* @param fermentationValue amount of inputFluid on organic item requires
|
||||
* @param fluidOutputModifier Output multiplier (this is usually a from the input fluid)
|
||||
*/
|
||||
@ZenMethod
|
||||
public static void addRecipe(ILiquidStack fluidOutput, IItemStack resource, ILiquidStack fluidInput, int fermentationValue, float fluidOutputModifier) {
|
||||
MineTweakerAPI.apply(new Add(new FermenterRecipe(toStack(resource), fermentationValue, fluidOutputModifier, getFluid(fluidOutput), toFluid(fluidInput))));
|
||||
}
|
||||
|
||||
private static class Add extends ForestryListAddition<IFermenterRecipe> {
|
||||
|
||||
public Add(IFermenterRecipe recipe) {
|
||||
super(Fermenter.name, RecipeManagers.fermenterManager);
|
||||
recipes.add(recipe);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeInfo(IFermenterRecipe recipe) {
|
||||
return LogHelper.getStackDescription(recipe.getOutput());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getJEICategory(IFermenterRecipe recipe) {
|
||||
return "forestry.fermenter";
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Removes recipe from Fermenter
|
||||
*
|
||||
* @param input type of item in input
|
||||
*/
|
||||
@ZenMethod
|
||||
public static void removeRecipe(IIngredient input) {
|
||||
List<IFermenterRecipe> recipes = new LinkedList<IFermenterRecipe>();
|
||||
|
||||
for(IFermenterRecipe recipe : RecipeManagers.fermenterManager.recipes()) {
|
||||
// check for input items
|
||||
if(recipe != null && recipe.getResource() != null && matches(input, toIItemStack(recipe.getResource()))) {
|
||||
recipes.add(recipe);
|
||||
}
|
||||
|
||||
// check for input liquids
|
||||
if(recipe != null && recipe.getResource() != null && matches(input, toILiquidStack(recipe.getFluidResource()))) {
|
||||
recipes.add(recipe);
|
||||
}
|
||||
}
|
||||
|
||||
if(!recipes.isEmpty()) {
|
||||
MineTweakerAPI.apply(new Remove(recipes));
|
||||
} else {
|
||||
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", Fermenter.name, input.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
private static class Remove extends ForestryListRemoval<IFermenterRecipe, IFermenterManager> {
|
||||
|
||||
public Remove(List<IFermenterRecipe> recipes) {
|
||||
super(Fermenter.name, RecipeManagers.fermenterManager, recipes);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getRecipeInfo(IFermenterRecipe recipe) {
|
||||
return LogHelper.getStackDescription(recipe.getOutput());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getJEICategory(IFermenterRecipe recipe) {
|
||||
return "forestry.fermenter";
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Adds fermenter fuel
|
||||
* Note: the actual consumption of fluid input depends on the fermentation fuel
|
||||
*
|
||||
* @param item Item that is a valid fuel for the fermenter
|
||||
* @param fermentPerCycle How much is fermented per work cycle, i.e. how much fluid of the input is consumed.
|
||||
* @param burnDuration Amount of work cycles a single item of this fuel lasts before expiring.
|
||||
*/
|
||||
@ZenMethod
|
||||
public static void addFuel(IItemStack item, int fermentPerCycle, int burnDuration) {
|
||||
MineTweakerAPI.apply(new AddFuel(new FermenterFuel(toStack(item), fermentPerCycle, burnDuration)));
|
||||
}
|
||||
|
||||
private static class AddFuel extends BaseMapAddition<ItemStack, FermenterFuel> {
|
||||
|
||||
public AddFuel(FermenterFuel fuelEntry) {
|
||||
super(Fermenter.nameFuel, FuelManager.fermenterFuel);
|
||||
recipes.put(fuelEntry.getItem(), fuelEntry);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeInfo(Entry<ItemStack, FermenterFuel> fuelEntry) {
|
||||
return LogHelper.getStackDescription(fuelEntry.getKey());
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Removes fermenter fuel
|
||||
*
|
||||
* @param fermenterItem Item that is a valid fuel for the fermenter
|
||||
*/
|
||||
@ZenMethod
|
||||
public static void removeFuel(IIngredient fermenterItem) {
|
||||
Map<ItemStack, FermenterFuel> fuelItems = new HashMap<ItemStack, FermenterFuel>();
|
||||
|
||||
for(Entry<ItemStack, FermenterFuel> fuelItem : FuelManager.fermenterFuel.entrySet()) {
|
||||
if(fuelItem != null && matches(fermenterItem, toIItemStack(fuelItem.getValue().getItem()))) {
|
||||
fuelItems.put(fuelItem.getKey(), fuelItem.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
if(!fuelItems.isEmpty()) {
|
||||
MineTweakerAPI.apply(new RemoveFuel(fuelItems));
|
||||
} else {
|
||||
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", Fermenter.name, fermenterItem.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
private static class RemoveFuel extends BaseMapRemoval<ItemStack, FermenterFuel> {
|
||||
|
||||
public RemoveFuel(Map<ItemStack, FermenterFuel> recipes) {
|
||||
super(Fermenter.nameFuel, FuelManager.fermenterFuel, recipes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeInfo(Entry<ItemStack, FermenterFuel> fuelEntry) {
|
||||
return LogHelper.getStackDescription(fuelEntry.getKey());
|
||||
}
|
||||
}
|
||||
}
|
168
src/main/java/com/blamejared/compat/forestry/Moistener.java
Normal file
168
src/main/java/com/blamejared/compat/forestry/Moistener.java
Normal file
|
@ -0,0 +1,168 @@
|
|||
package com.blamejared.compat.forestry;
|
||||
|
||||
import com.blamejared.api.annotations.Handler;
|
||||
import com.blamejared.compat.forestry.util.*;
|
||||
import com.blamejared.mtlib.helpers.LogHelper;
|
||||
import com.blamejared.mtlib.utils.*;
|
||||
import forestry.api.fuels.*;
|
||||
import forestry.api.recipes.*;
|
||||
import forestry.factory.recipes.MoistenerRecipe;
|
||||
import mezz.jei.api.recipe.IRecipeWrapper;
|
||||
import minetweaker.MineTweakerAPI;
|
||||
import minetweaker.api.item.*;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import stanhebben.zenscript.annotations.*;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import static com.blamejared.mtlib.helpers.InputHelper.*;
|
||||
import static com.blamejared.mtlib.helpers.StackHelper.matches;
|
||||
|
||||
@ZenClass("mods.forestry.Moistener")
|
||||
@Handler("forestry")
|
||||
public class Moistener {
|
||||
|
||||
public static final String name = "Forestry Moistener";
|
||||
public static final String nameFuel = name + " (Fuel)";
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Adds recipe to Moistener
|
||||
*
|
||||
* @param output recipe product
|
||||
* @param input required item
|
||||
* @param packagingTime amount of ticks per crafting operation
|
||||
*/
|
||||
@ZenMethod
|
||||
public static void addRecipe(IItemStack output, IItemStack input, int packagingTime) {
|
||||
MineTweakerAPI.apply(new Add(new MoistenerRecipe(toStack(input), toStack(output), packagingTime)));
|
||||
}
|
||||
|
||||
private static class Add extends ForestryListAddition<IMoistenerRecipe> {
|
||||
|
||||
public Add(IMoistenerRecipe recipe) {
|
||||
super(Moistener.name, RecipeManagers.moistenerManager);
|
||||
recipes.add(recipe);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeInfo(IMoistenerRecipe recipe) {
|
||||
return LogHelper.getStackDescription(recipe.getProduct());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getJEICategory(IMoistenerRecipe recipe) {
|
||||
return "forestry.moistener";
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Removes recipe from Fermenter
|
||||
*
|
||||
* @param output recipe product
|
||||
*/
|
||||
@ZenMethod
|
||||
public static void removeRecipe(IIngredient output) {
|
||||
List<IMoistenerRecipe> recipes = new LinkedList<IMoistenerRecipe>();
|
||||
for(IMoistenerRecipe recipe : RecipeManagers.moistenerManager.recipes()) {
|
||||
if(recipe != null && recipe.getProduct() != null && matches(output, toIItemStack(recipe.getProduct()))) {
|
||||
recipes.add(recipe);
|
||||
}
|
||||
}
|
||||
|
||||
if(!recipes.isEmpty()) {
|
||||
MineTweakerAPI.apply(new Remove(recipes));
|
||||
} else {
|
||||
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", Moistener.name, output.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
private static class Remove extends ForestryListRemoval<IMoistenerRecipe, IMoistenerManager> {
|
||||
|
||||
public Remove(List<IMoistenerRecipe> recipes) {
|
||||
super(Moistener.name, RecipeManagers.moistenerManager, recipes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeInfo(IMoistenerRecipe recipe) {
|
||||
return LogHelper.getStackDescription(recipe.getProduct());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getJEICategory(IMoistenerRecipe recipe) {
|
||||
return "forestry.moistener";
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Adds Moistener fuel
|
||||
*
|
||||
* @param item The item to use
|
||||
* @param product The item that leaves the moistener's working slot (i.e. mouldy wheat, decayed wheat, mulch)
|
||||
* @param moistenerValue How much this item contributes to the final product of the moistener (i.e. mycelium)
|
||||
* @param stage What stage this product represents. Resources with lower stage value will be consumed first. (First Stage is 0)
|
||||
*/
|
||||
@ZenMethod
|
||||
public static void addFuel(IItemStack item, IItemStack product, int moistenerValue, int stage) {
|
||||
if(stage >= 0) {
|
||||
MineTweakerAPI.apply(new AddFuel(new MoistenerFuel(toStack(item), toStack(product), moistenerValue, stage)));
|
||||
} else {
|
||||
LogHelper.logWarning(String.format("No %s Recipe add for %s. Stage parameter must positive!", Moistener.name, item.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
private static class AddFuel extends BaseMapAddition<ItemStack, MoistenerFuel> {
|
||||
|
||||
public AddFuel(MoistenerFuel fuelEntry) {
|
||||
super(Moistener.nameFuel, FuelManager.moistenerResource);
|
||||
recipes.put(fuelEntry.getItem(), fuelEntry);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeInfo(Entry<ItemStack, MoistenerFuel> fuelEntry) {
|
||||
return LogHelper.getStackDescription(fuelEntry.getKey());
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Removes Moistener fuel.
|
||||
*
|
||||
* @param moistenerItem Item that is a valid fuel for the moistener
|
||||
*/
|
||||
@ZenMethod
|
||||
public static void removeFuel(IIngredient moistenerItem) {
|
||||
Map<ItemStack, MoistenerFuel> fuelItems = new HashMap<ItemStack, MoistenerFuel>();
|
||||
|
||||
for(Entry<ItemStack, MoistenerFuel> fuelItem : FuelManager.moistenerResource.entrySet()) {
|
||||
if(fuelItem != null && matches(moistenerItem, toIItemStack(fuelItem.getValue().getItem()))) {
|
||||
fuelItems.put(fuelItem.getKey(), fuelItem.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
if(!fuelItems.isEmpty()) {
|
||||
MineTweakerAPI.apply(new RemoveFuel(fuelItems));
|
||||
} else {
|
||||
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", Moistener.name, moistenerItem.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
private static class RemoveFuel extends BaseMapRemoval<ItemStack, MoistenerFuel> {
|
||||
|
||||
public RemoveFuel(Map<ItemStack, MoistenerFuel> recipes) {
|
||||
super(Moistener.nameFuel, FuelManager.moistenerResource, recipes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeInfo(Entry<ItemStack, MoistenerFuel> fuelEntry) {
|
||||
return LogHelper.getStackDescription(fuelEntry.getKey());
|
||||
}
|
||||
}
|
||||
}
|
129
src/main/java/com/blamejared/compat/forestry/Squeezer.java
Normal file
129
src/main/java/com/blamejared/compat/forestry/Squeezer.java
Normal file
|
@ -0,0 +1,129 @@
|
|||
package com.blamejared.compat.forestry;
|
||||
|
||||
import com.blamejared.api.annotations.Handler;
|
||||
import com.blamejared.compat.forestry.util.*;
|
||||
import com.blamejared.mtlib.helpers.LogHelper;
|
||||
import forestry.api.recipes.*;
|
||||
import forestry.factory.recipes.SqueezerRecipe;
|
||||
import forestry.factory.recipes.jei.squeezer.SqueezerRecipeWrapper;
|
||||
import minetweaker.MineTweakerAPI;
|
||||
import minetweaker.api.item.*;
|
||||
import minetweaker.api.liquid.ILiquidStack;
|
||||
import minetweaker.mc1112.item.MCItemStack;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import stanhebben.zenscript.annotations.Optional;
|
||||
import stanhebben.zenscript.annotations.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import static com.blamejared.mtlib.helpers.InputHelper.*;
|
||||
import static com.blamejared.mtlib.helpers.StackHelper.matches;
|
||||
|
||||
@ZenClass("mods.forestry.Squeezer")
|
||||
@Handler("forestry")
|
||||
public class Squeezer {
|
||||
|
||||
public static final String name = "Forestry Squeezer";
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Adds recipe to Squeezer
|
||||
*
|
||||
* @param fluidOutput recipe fluid amount
|
||||
* @param ingredients recipe ingredients
|
||||
* @param timePerItem time per crafting operation
|
||||
* * @param itemOutput recipe output (optional)
|
||||
*/
|
||||
@ZenMethod
|
||||
public static void addRecipe(ILiquidStack fluidOutput, IItemStack[] ingredients, int timePerItem, @Optional WeightedItemStack itemOutput) {
|
||||
if(itemOutput == null) {
|
||||
itemOutput = new WeightedItemStack(new MCItemStack(new ItemStack(Blocks.AIR)), 0);
|
||||
}
|
||||
NonNullList<ItemStack> list = NonNullList.withSize(ingredients.length, ItemStack.EMPTY);
|
||||
for(int i = 0; i < toStacks(ingredients).length; i++) {
|
||||
list.set(i, toStack(ingredients[i]));
|
||||
}
|
||||
MineTweakerAPI.apply(new Add(new SqueezerRecipe(timePerItem, list, toFluid(fluidOutput), toStack(itemOutput.getStack()), itemOutput.getChance())));
|
||||
}
|
||||
|
||||
private static class Add extends ForestryListAddition<ISqueezerRecipe> {
|
||||
|
||||
public Add(ISqueezerRecipe recipe) {
|
||||
super(Squeezer.name, RecipeManagers.squeezerManager);
|
||||
recipes.add(recipe);
|
||||
MineTweakerAPI.getIjeiRecipeRegistry().addRecipe(new SqueezerRecipeWrapper(recipe));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeInfo(ISqueezerRecipe recipe) {
|
||||
return LogHelper.getStackDescription(recipe.getFluidOutput());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getJEICategory(ISqueezerRecipe recipe) {
|
||||
return "forestry.squeezer";
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Removes a recipe for the Centrifuge
|
||||
*
|
||||
* @param liquid liquid output
|
||||
* * @param ingredients list of ingredients (optional)
|
||||
*/
|
||||
@ZenMethod
|
||||
public static void removeRecipe(IIngredient liquid, @Optional IIngredient[] ingredients) {
|
||||
List<ISqueezerRecipe> recipes = new LinkedList<ISqueezerRecipe>();
|
||||
|
||||
for(ISqueezerRecipe r : RecipeManagers.squeezerManager.recipes()) {
|
||||
if(r != null && r.getFluidOutput() != null && matches(liquid, toILiquidStack(r.getFluidOutput()))) {
|
||||
// optional check for ingredients
|
||||
if(ingredients != null) {
|
||||
boolean matched = false;
|
||||
for(int i = 0; i < ingredients.length; i++) {
|
||||
if(matches(ingredients[i], toIItemStack(r.getResources().get(i))))
|
||||
matched = true;
|
||||
else {
|
||||
matched = false;
|
||||
// if one ingredients doesn't match abort all further checks
|
||||
break;
|
||||
}
|
||||
}
|
||||
// if some ingredient doesn't match, the last one is false
|
||||
if(matched)
|
||||
recipes.add(r);
|
||||
} else {
|
||||
recipes.add(r);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!recipes.isEmpty()) {
|
||||
MineTweakerAPI.apply(new Remove(recipes));
|
||||
} else {
|
||||
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", Squeezer.name, LogHelper.getStackDescription(liquid)));
|
||||
}
|
||||
}
|
||||
|
||||
private static class Remove extends ForestryListRemoval<ISqueezerRecipe, ISqueezerManager> {
|
||||
|
||||
public Remove(List<ISqueezerRecipe> recipes) {
|
||||
super(Squeezer.name, RecipeManagers.squeezerManager, recipes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeInfo(ISqueezerRecipe recipe) {
|
||||
return LogHelper.getStackDescription(recipe.getFluidOutput());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getJEICategory(ISqueezerRecipe recipe) {
|
||||
return "forestry.squeezer";
|
||||
}
|
||||
}
|
||||
}
|
106
src/main/java/com/blamejared/compat/forestry/Still.java
Normal file
106
src/main/java/com/blamejared/compat/forestry/Still.java
Normal file
|
@ -0,0 +1,106 @@
|
|||
package com.blamejared.compat.forestry;
|
||||
|
||||
import com.blamejared.api.annotations.Handler;
|
||||
import com.blamejared.compat.forestry.util.*;
|
||||
import com.blamejared.mtlib.helpers.LogHelper;
|
||||
import forestry.api.recipes.*;
|
||||
import forestry.factory.recipes.StillRecipe;
|
||||
import minetweaker.MineTweakerAPI;
|
||||
import minetweaker.api.item.IIngredient;
|
||||
import minetweaker.api.liquid.ILiquidStack;
|
||||
import stanhebben.zenscript.annotations.Optional;
|
||||
import stanhebben.zenscript.annotations.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import static com.blamejared.mtlib.helpers.InputHelper.*;
|
||||
import static com.blamejared.mtlib.helpers.StackHelper.matches;
|
||||
|
||||
@ZenClass("mods.forestry.Still")
|
||||
@Handler("forestry")
|
||||
public class Still {
|
||||
|
||||
public static final String name = "Forestry Still";
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Adds recipe to Still
|
||||
*
|
||||
* @param fluidOutput recipe fluid amount
|
||||
* @param fluidInput recipe fluid input
|
||||
* @param timePerUnit time per crafting operation
|
||||
*/
|
||||
@ZenMethod
|
||||
public static void addRecipe(ILiquidStack fluidOutput, ILiquidStack fluidInput, int timePerUnit) {
|
||||
fluidOutput.amount(fluidOutput.getAmount() / 100);
|
||||
fluidInput.amount(fluidInput.getAmount() / 100);
|
||||
|
||||
MineTweakerAPI.apply(new Add(new StillRecipe(timePerUnit, toFluid(fluidInput), toFluid(fluidOutput))));
|
||||
}
|
||||
|
||||
private static class Add extends ForestryListAddition<IStillRecipe> {
|
||||
|
||||
public Add(IStillRecipe recipe) {
|
||||
super("Forestry Still", RecipeManagers.stillManager);
|
||||
recipes.add(recipe);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeInfo(IStillRecipe recipe) {
|
||||
return LogHelper.getStackDescription(recipe.getOutput());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getJEICategory(IStillRecipe recipe) {
|
||||
return "forestry.still";
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Removes recipe from Still
|
||||
*
|
||||
* @param output = liquid output
|
||||
* * @param fluidInput = liquid input (optional)
|
||||
*/
|
||||
@ZenMethod
|
||||
public static void removeRecipe(IIngredient output, @Optional ILiquidStack fluidInput) {
|
||||
List<IStillRecipe> recipes = new LinkedList<IStillRecipe>();
|
||||
|
||||
for(IStillRecipe r : RecipeManagers.stillManager.recipes()) {
|
||||
if(r != null && r.getOutput() != null && matches(output, toILiquidStack(r.getOutput()))) {
|
||||
if(fluidInput != null) {
|
||||
if(matches(fluidInput, toILiquidStack(r.getInput()))) {
|
||||
recipes.add(r);
|
||||
}
|
||||
} else
|
||||
recipes.add(r);
|
||||
}
|
||||
}
|
||||
|
||||
if(!recipes.isEmpty()) {
|
||||
MineTweakerAPI.apply(new Remove(recipes));
|
||||
} else {
|
||||
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", Still.name, LogHelper.getStackDescription(output)));
|
||||
}
|
||||
}
|
||||
|
||||
private static class Remove extends ForestryListRemoval<IStillRecipe, IStillManager> {
|
||||
|
||||
public Remove(List<IStillRecipe> recipes) {
|
||||
super(Still.name, RecipeManagers.stillManager, recipes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeInfo(IStillRecipe recipe) {
|
||||
return LogHelper.getStackDescription(recipe.getOutput());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getJEICategory(IStillRecipe recipe) {
|
||||
return "forestry.still";
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,106 @@
|
|||
package com.blamejared.compat.forestry;
|
||||
|
||||
import com.blamejared.api.annotations.Handler;
|
||||
import com.blamejared.compat.forestry.util.*;
|
||||
import com.blamejared.mtlib.helpers.LogHelper;
|
||||
import forestry.api.recipes.*;
|
||||
import forestry.factory.recipes.FabricatorSmeltingRecipe;
|
||||
import minetweaker.MineTweakerAPI;
|
||||
import minetweaker.api.item.*;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import stanhebben.zenscript.annotations.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import static com.blamejared.mtlib.helpers.InputHelper.*;
|
||||
import static com.blamejared.mtlib.helpers.StackHelper.matches;
|
||||
|
||||
@ZenClass("mods.forestry.ThermionicFabricator")
|
||||
@Handler("forestry")
|
||||
public class ThermionicFabricator {
|
||||
|
||||
public static final String nameSmelting = "Forestry Thermionic Fabricator (Smelting)";
|
||||
public static final String nameCasting = "Forestry Thermionic Fabricator (Casting)";
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Adds smelting recipe to Thermionic Fabricator
|
||||
*
|
||||
* @param fluidOutput recipe fluid amount
|
||||
* @param itemInput recipe input input
|
||||
* @param meltingPoint point at where itemInput melts down
|
||||
*/
|
||||
@ZenMethod
|
||||
public static void addSmelting(int fluidOutput, IItemStack itemInput, int meltingPoint) {
|
||||
//The machines internal tank accept only liquid glass, therefor this function only accept the amount and hardcode the fluid to glass
|
||||
MineTweakerAPI.apply(new AddSmelting(new FabricatorSmeltingRecipe(toStack(itemInput), FluidRegistry.getFluidStack("glass", fluidOutput), meltingPoint)));
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
/*
|
||||
Implements the actions to add a recipe
|
||||
Since the machine has two crafting Steps, this is a constructors for both
|
||||
*/
|
||||
private static class AddSmelting extends ForestryListAddition<IFabricatorSmeltingRecipe> {
|
||||
|
||||
public AddSmelting(IFabricatorSmeltingRecipe recipe) {
|
||||
super(ThermionicFabricator.nameSmelting, RecipeManagers.fabricatorSmeltingManager);
|
||||
recipes.add(recipe);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeInfo(IFabricatorSmeltingRecipe recipe) {
|
||||
return LogHelper.getStackDescription(recipe.getResource());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getJEICategory(IFabricatorSmeltingRecipe recipe) {
|
||||
return "forestry.fabricator";
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Removes smelting recipe from Thermionic Fabricator
|
||||
*
|
||||
* @param itemInput = item input
|
||||
*/
|
||||
@ZenMethod
|
||||
public static void removeSmelting(IIngredient itemInput) {
|
||||
List<IFabricatorSmeltingRecipe> recipes = new LinkedList<IFabricatorSmeltingRecipe>();
|
||||
|
||||
for(IFabricatorSmeltingRecipe r : RecipeManagers.fabricatorSmeltingManager.recipes()) {
|
||||
if(r != null && r.getResource() != null && matches(itemInput, toIItemStack(r.getResource()))) {
|
||||
recipes.add(r);
|
||||
}
|
||||
}
|
||||
|
||||
if(!recipes.isEmpty()) {
|
||||
MineTweakerAPI.apply(new RemoveSmelting(recipes));
|
||||
} else {
|
||||
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", ThermionicFabricator.nameSmelting, itemInput.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
private static class RemoveSmelting extends ForestryListRemoval<IFabricatorSmeltingRecipe, IFabricatorSmeltingManager> {
|
||||
|
||||
public RemoveSmelting(List<IFabricatorSmeltingRecipe> recipes) {
|
||||
super(ThermionicFabricator.nameSmelting, RecipeManagers.fabricatorSmeltingManager, recipes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeInfo(IFabricatorSmeltingRecipe recipe) {
|
||||
return LogHelper.getStackDescription(recipe.getResource());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getJEICategory(IFabricatorSmeltingRecipe recipe) {
|
||||
return "forestry.fabricator";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
package com.blamejared.compat.forestry.util;
|
||||
|
||||
import com.blamejared.mtlib.utils.BaseListAddition;
|
||||
import forestry.api.recipes.IForestryRecipe;
|
||||
import com.blamejared.mtlib.helpers.LogHelper;
|
||||
import forestry.api.recipes.ICraftingProvider;
|
||||
import mezz.jei.api.recipe.*;
|
||||
import minetweaker.MineTweakerAPI;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public abstract class ForestryListAddition<T extends IForestryRecipe> extends BaseListAddition<T> {
|
||||
private final ICraftingProvider manager;
|
||||
|
||||
protected ForestryListAddition(String name, ICraftingProvider manager) {
|
||||
super(name, new ArrayList(manager.recipes()));
|
||||
this.manager = manager;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected abstract String getRecipeInfo(T recipe);
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
for (T recipe : recipes) {
|
||||
if (recipe != null) {
|
||||
if (manager.addRecipe(recipe)){
|
||||
successful.add(recipe);
|
||||
MineTweakerAPI.getIjeiRecipeRegistry().addRecipe(recipe, getJEICategory(recipe));
|
||||
} else {
|
||||
LogHelper.logError(String.format("Error adding %s Recipe for %s", name, getRecipeInfo(recipe)));
|
||||
}
|
||||
} else {
|
||||
LogHelper.logError(String.format("Error adding %s Recipe: null object", name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void undo() {
|
||||
for (T recipe : successful) {
|
||||
if (recipe != null) {
|
||||
if (!manager.removeRecipe(recipe)) {
|
||||
LogHelper.logError(String.format("Error removing %s Recipe for %s", name, this.getRecipeInfo(recipe)));
|
||||
}else{
|
||||
MineTweakerAPI.getIjeiRecipeRegistry().removeRecipe(recipe, getJEICategory(recipe));
|
||||
}
|
||||
} else {
|
||||
LogHelper.logError(String.format("Error removing %s Recipe: null object", name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
package com.blamejared.compat.forestry.util;
|
||||
|
||||
import com.blamejared.mtlib.helpers.LogHelper;
|
||||
import com.blamejared.mtlib.utils.BaseListRemoval;
|
||||
import forestry.api.recipes.*;
|
||||
import minetweaker.MineTweakerAPI;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public abstract class ForestryListRemoval<T extends IForestryRecipe, C extends ICraftingProvider<T>> extends BaseListRemoval<T> {
|
||||
|
||||
private final C craftingProvider;
|
||||
|
||||
public ForestryListRemoval(String name, C craftingProvider, List<T> recipes) {
|
||||
super(name, new ArrayList<T>(craftingProvider.recipes()), recipes);
|
||||
this.craftingProvider = craftingProvider;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected abstract String getRecipeInfo(T recipe);
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
for(T recipe : recipes) {
|
||||
if(recipe != null) {
|
||||
if(craftingProvider.removeRecipe(recipe)) {
|
||||
successful.add(recipe);
|
||||
MineTweakerAPI.getIjeiRecipeRegistry().removeRecipe(recipe, getJEICategory(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
|
||||
public final void undo() {
|
||||
for(T recipe : successful) {
|
||||
if(recipe != null) {
|
||||
if(!craftingProvider.addRecipe(recipe)) {
|
||||
LogHelper.logError(String.format("Error restoring %s Recipe for %s", name, getRecipeInfo(recipe)));
|
||||
} else {
|
||||
MineTweakerAPI.getIjeiRecipeRegistry().addRecipe(recipe, getJEICategory(recipe));
|
||||
}
|
||||
} else {
|
||||
LogHelper.logError(String.format("Error restoring %s Recipe: null object", name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue