2016-01-05 04:47:35 +01:00
|
|
|
package de.ellpeck.actuallyadditions.mod.items.lens;
|
|
|
|
|
2017-12-12 07:54:12 +01:00
|
|
|
import java.util.ArrayList;
|
2018-06-24 02:44:47 +02:00
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
import javax.annotation.Nullable;
|
2017-12-12 07:54:12 +01:00
|
|
|
|
2016-01-05 04:47:35 +01:00
|
|
|
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
|
2018-06-24 02:44:47 +02:00
|
|
|
import de.ellpeck.actuallyadditions.api.lens.Lens;
|
2016-05-05 19:50:59 +02:00
|
|
|
import de.ellpeck.actuallyadditions.api.recipe.ColorLensChangerByDyeMeta;
|
|
|
|
import de.ellpeck.actuallyadditions.api.recipe.IColorLensChanger;
|
2016-05-14 13:51:18 +02:00
|
|
|
import de.ellpeck.actuallyadditions.api.recipe.LensConversionRecipe;
|
2016-01-05 04:47:35 +01:00
|
|
|
import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks;
|
2018-07-28 03:40:36 +02:00
|
|
|
import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues;
|
2016-01-05 04:47:35 +01:00
|
|
|
import de.ellpeck.actuallyadditions.mod.items.InitItems;
|
|
|
|
import de.ellpeck.actuallyadditions.mod.items.metalists.TheCrystals;
|
|
|
|
import de.ellpeck.actuallyadditions.mod.items.metalists.TheMiscItems;
|
2018-07-28 03:40:36 +02:00
|
|
|
import de.ellpeck.actuallyadditions.mod.recipe.ColorLensRotator;
|
2017-12-12 07:54:12 +01:00
|
|
|
import de.ellpeck.actuallyadditions.mod.recipe.EnchBookConversion;
|
2016-03-18 18:41:37 +01:00
|
|
|
import de.ellpeck.actuallyadditions.mod.util.RecipeUtil;
|
2018-06-24 02:44:47 +02:00
|
|
|
import net.minecraft.block.Block;
|
2016-01-05 04:47:35 +01:00
|
|
|
import net.minecraft.init.Blocks;
|
|
|
|
import net.minecraft.init.Items;
|
2016-05-05 19:50:59 +02:00
|
|
|
import net.minecraft.item.Item;
|
2016-01-05 04:47:35 +01:00
|
|
|
import net.minecraft.item.ItemStack;
|
2018-06-24 02:44:47 +02:00
|
|
|
import net.minecraft.item.crafting.Ingredient;
|
2018-07-28 03:40:36 +02:00
|
|
|
import net.minecraft.util.NonNullList;
|
|
|
|
import net.minecraftforge.oredict.OreDictionary;
|
2016-01-05 04:47:35 +01:00
|
|
|
|
2018-07-28 03:40:36 +02:00
|
|
|
public final class LensRecipeHandler {
|
2016-01-05 04:47:35 +01:00
|
|
|
|
2019-02-27 19:53:05 +01:00
|
|
|
public static final ArrayList<LensConversionRecipe> MAIN_PAGE_RECIPES = new ArrayList<>();
|
2016-05-14 13:51:18 +02:00
|
|
|
public static LensConversionRecipe recipeColorLens;
|
|
|
|
public static LensConversionRecipe recipeSoulSand;
|
|
|
|
public static LensConversionRecipe recipeGreenWall;
|
|
|
|
public static LensConversionRecipe recipeWhiteWall;
|
|
|
|
public static LensConversionRecipe recipeExplosionLens;
|
|
|
|
public static LensConversionRecipe recipeDamageLens;
|
|
|
|
public static LensConversionRecipe recipeLeather;
|
|
|
|
public static LensConversionRecipe recipeNetherWart;
|
2016-08-31 20:47:12 +02:00
|
|
|
public static LensConversionRecipe recipePrismarine;
|
2016-09-11 14:51:52 +02:00
|
|
|
public static LensConversionRecipe recipeCrystallizedCanolaSeed;
|
2016-12-18 12:08:32 +01:00
|
|
|
public static LensConversionRecipe recipeItemLaser;
|
|
|
|
public static LensConversionRecipe recipeFluidLaser;
|
2017-12-12 07:54:12 +01:00
|
|
|
public static EnchBookConversion recipeEnchBook;
|
2016-01-05 04:47:35 +01:00
|
|
|
|
2018-07-28 03:40:36 +02:00
|
|
|
public static void init() {
|
2016-01-05 04:47:35 +01:00
|
|
|
//Crystal Blocks
|
2018-06-24 02:44:47 +02:00
|
|
|
ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(fromBlock(Blocks.REDSTONE_BLOCK), new ItemStack(InitBlocks.blockCrystal, 1, TheCrystals.REDSTONE.ordinal()), 400);
|
2016-06-17 23:50:38 +02:00
|
|
|
MAIN_PAGE_RECIPES.add(RecipeUtil.lastReconstructorRecipe());
|
2018-06-24 02:44:47 +02:00
|
|
|
ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(fromBlock(Blocks.LAPIS_BLOCK), new ItemStack(InitBlocks.blockCrystal, 1, TheCrystals.LAPIS.ordinal()), 400);
|
2016-06-17 23:50:38 +02:00
|
|
|
MAIN_PAGE_RECIPES.add(RecipeUtil.lastReconstructorRecipe());
|
2018-06-24 02:44:47 +02:00
|
|
|
ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(fromBlock(Blocks.DIAMOND_BLOCK), new ItemStack(InitBlocks.blockCrystal, 1, TheCrystals.DIAMOND.ordinal()), 600);
|
2016-06-17 23:50:38 +02:00
|
|
|
MAIN_PAGE_RECIPES.add(RecipeUtil.lastReconstructorRecipe());
|
2018-06-24 02:44:47 +02:00
|
|
|
ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(fromBlock(Blocks.EMERALD_BLOCK), new ItemStack(InitBlocks.blockCrystal, 1, TheCrystals.EMERALD.ordinal()), 1000);
|
2016-06-17 23:50:38 +02:00
|
|
|
MAIN_PAGE_RECIPES.add(RecipeUtil.lastReconstructorRecipe());
|
2018-06-24 02:44:47 +02:00
|
|
|
ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(fromBlock(Blocks.COAL_BLOCK), new ItemStack(InitBlocks.blockCrystal, 1, TheCrystals.COAL.ordinal()), 600);
|
2016-06-17 23:50:38 +02:00
|
|
|
MAIN_PAGE_RECIPES.add(RecipeUtil.lastReconstructorRecipe());
|
2018-06-24 02:44:47 +02:00
|
|
|
ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(fromBlock(Blocks.IRON_BLOCK), new ItemStack(InitBlocks.blockCrystal, 1, TheCrystals.IRON.ordinal()), 800);
|
2016-06-17 23:50:38 +02:00
|
|
|
MAIN_PAGE_RECIPES.add(RecipeUtil.lastReconstructorRecipe());
|
2016-01-05 04:47:35 +01:00
|
|
|
|
|
|
|
//Crystal Items
|
2018-06-26 22:25:51 +02:00
|
|
|
ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(Ingredient.fromItems(Items.REDSTONE), new ItemStack(InitItems.itemCrystal, 1, TheCrystals.REDSTONE.ordinal()), 40);
|
2016-06-17 23:50:38 +02:00
|
|
|
MAIN_PAGE_RECIPES.add(RecipeUtil.lastReconstructorRecipe());
|
2018-06-24 02:44:47 +02:00
|
|
|
ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(Ingredient.fromStacks(new ItemStack(Items.DYE, 1, 4)), new ItemStack(InitItems.itemCrystal, 1, TheCrystals.LAPIS.ordinal()), 40);
|
2016-06-17 23:50:38 +02:00
|
|
|
MAIN_PAGE_RECIPES.add(RecipeUtil.lastReconstructorRecipe());
|
2018-06-26 22:25:51 +02:00
|
|
|
ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(Ingredient.fromItems(Items.DIAMOND), new ItemStack(InitItems.itemCrystal, 1, TheCrystals.DIAMOND.ordinal()), 60);
|
2016-06-17 23:50:38 +02:00
|
|
|
MAIN_PAGE_RECIPES.add(RecipeUtil.lastReconstructorRecipe());
|
2018-06-26 22:25:51 +02:00
|
|
|
ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(Ingredient.fromItems(Items.EMERALD), new ItemStack(InitItems.itemCrystal, 1, TheCrystals.EMERALD.ordinal()), 100);
|
2016-06-17 23:50:38 +02:00
|
|
|
MAIN_PAGE_RECIPES.add(RecipeUtil.lastReconstructorRecipe());
|
2018-06-26 22:25:51 +02:00
|
|
|
ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(Ingredient.fromItems(Items.COAL), new ItemStack(InitItems.itemCrystal, 1, TheCrystals.COAL.ordinal()), 60);
|
2016-06-17 23:50:38 +02:00
|
|
|
MAIN_PAGE_RECIPES.add(RecipeUtil.lastReconstructorRecipe());
|
2018-06-26 22:25:51 +02:00
|
|
|
ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(Ingredient.fromItems(Items.IRON_INGOT), new ItemStack(InitItems.itemCrystal, 1, TheCrystals.IRON.ordinal()), 80);
|
2016-08-03 18:08:07 +02:00
|
|
|
MAIN_PAGE_RECIPES.add(RecipeUtil.lastReconstructorRecipe());
|
2016-01-05 04:47:35 +01:00
|
|
|
|
|
|
|
//Lenses
|
2018-06-24 02:44:47 +02:00
|
|
|
ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(Ingredient.fromStacks(new ItemStack(InitItems.itemMisc, 1, TheMiscItems.LENS.ordinal())), new ItemStack(InitItems.itemColorLens), 5000);
|
2016-03-18 18:41:37 +01:00
|
|
|
recipeColorLens = RecipeUtil.lastReconstructorRecipe();
|
2018-06-26 22:25:51 +02:00
|
|
|
ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(Ingredient.fromItems(InitItems.itemColorLens), new ItemStack(InitItems.itemExplosionLens), 5000);
|
2016-11-30 17:05:49 +01:00
|
|
|
recipeExplosionLens = RecipeUtil.lastReconstructorRecipe();
|
2018-06-26 22:25:51 +02:00
|
|
|
ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(Ingredient.fromItems(InitItems.itemExplosionLens), new ItemStack(InitItems.itemDamageLens), 5000);
|
2016-11-30 17:05:49 +01:00
|
|
|
recipeDamageLens = RecipeUtil.lastReconstructorRecipe();
|
2018-06-26 22:25:51 +02:00
|
|
|
ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(Ingredient.fromItems(InitItems.itemDamageLens), new ItemStack(InitItems.itemMisc, 1, TheMiscItems.LENS.ordinal()), 5000);
|
2016-01-05 04:47:35 +01:00
|
|
|
|
2018-06-24 02:44:47 +02:00
|
|
|
ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(fromBlock(InitBlocks.blockLaserRelay), new ItemStack(InitBlocks.blockLaserRelayFluids), 2000);
|
2016-12-18 12:08:32 +01:00
|
|
|
recipeFluidLaser = RecipeUtil.lastReconstructorRecipe();
|
2018-06-24 02:44:47 +02:00
|
|
|
ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(fromBlock(InitBlocks.blockLaserRelayFluids), new ItemStack(InitBlocks.blockLaserRelayItem), 2000);
|
2016-12-18 12:08:32 +01:00
|
|
|
recipeItemLaser = RecipeUtil.lastReconstructorRecipe();
|
2018-06-24 02:44:47 +02:00
|
|
|
ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(fromBlock(InitBlocks.blockLaserRelayItem), new ItemStack(InitBlocks.blockLaserRelay), 2000);
|
2016-12-18 12:08:32 +01:00
|
|
|
|
2016-01-05 04:47:35 +01:00
|
|
|
//Misc
|
2018-06-24 02:44:47 +02:00
|
|
|
ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(fromBlock(Blocks.SAND), new ItemStack(Blocks.SOUL_SAND), 20000);
|
2016-11-30 17:05:49 +01:00
|
|
|
recipeSoulSand = RecipeUtil.lastReconstructorRecipe();
|
2018-06-26 22:25:51 +02:00
|
|
|
ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(Ingredient.fromItems(Items.ROTTEN_FLESH), new ItemStack(Items.LEATHER), 8000);
|
2016-11-30 17:05:49 +01:00
|
|
|
recipeLeather = RecipeUtil.lastReconstructorRecipe();
|
2016-01-17 20:12:20 +01:00
|
|
|
|
2018-06-24 02:44:47 +02:00
|
|
|
ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(fromBlock(Blocks.RED_MUSHROOM), new ItemStack(Items.NETHER_WART), 150000);
|
2016-11-30 17:05:49 +01:00
|
|
|
recipeNetherWart = RecipeUtil.lastReconstructorRecipe();
|
2018-06-26 22:25:51 +02:00
|
|
|
ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(Ingredient.fromItems(Items.QUARTZ), new ItemStack(Items.PRISMARINE_SHARD), 30000);
|
2016-11-30 17:05:49 +01:00
|
|
|
recipePrismarine = RecipeUtil.lastReconstructorRecipe();
|
2016-01-05 04:47:35 +01:00
|
|
|
|
2018-06-26 22:25:51 +02:00
|
|
|
ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(Ingredient.fromItems(InitItems.itemCanolaSeed), new ItemStack(InitItems.itemMisc, 1, TheMiscItems.CRYSTALLIZED_CANOLA_SEED.ordinal()), 2000);
|
2016-09-11 14:51:52 +02:00
|
|
|
recipeCrystallizedCanolaSeed = RecipeUtil.lastReconstructorRecipe();
|
|
|
|
|
2018-06-24 02:44:47 +02:00
|
|
|
ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(fromBlock(Blocks.QUARTZ_BLOCK), new ItemStack(InitBlocks.blockTestifiBucksWhiteWall), 10);
|
2016-03-18 18:41:37 +01:00
|
|
|
recipeWhiteWall = RecipeUtil.lastReconstructorRecipe();
|
2018-06-24 02:44:47 +02:00
|
|
|
ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(Ingredient.fromStacks(new ItemStack(Blocks.QUARTZ_BLOCK, 1, 1)), new ItemStack(InitBlocks.blockTestifiBucksGreenWall), 10);
|
2016-03-18 18:41:37 +01:00
|
|
|
recipeGreenWall = RecipeUtil.lastReconstructorRecipe();
|
2018-07-28 03:40:36 +02:00
|
|
|
|
2017-12-12 07:54:12 +01:00
|
|
|
ActuallyAdditionsAPI.RECONSTRUCTOR_LENS_CONVERSION_RECIPES.add(recipeEnchBook = new EnchBookConversion());
|
2016-05-05 19:50:59 +02:00
|
|
|
|
|
|
|
IColorLensChanger changer = new ColorLensChangerByDyeMeta();
|
2018-07-28 03:40:36 +02:00
|
|
|
if (ConfigBoolValues.COLOR_LENS_USES_OREDICT.isEnabled()) {
|
|
|
|
initOredictDyeRotator();
|
|
|
|
} else {
|
|
|
|
ActuallyAdditionsAPI.addReconstructorLensColorChangeItem(Items.DYE, changer);
|
|
|
|
}
|
2016-05-05 19:50:59 +02:00
|
|
|
ActuallyAdditionsAPI.addReconstructorLensColorChangeItem(Item.getItemFromBlock(Blocks.WOOL), changer);
|
|
|
|
ActuallyAdditionsAPI.addReconstructorLensColorChangeItem(Item.getItemFromBlock(Blocks.STAINED_GLASS), changer);
|
|
|
|
ActuallyAdditionsAPI.addReconstructorLensColorChangeItem(Item.getItemFromBlock(Blocks.STAINED_GLASS_PANE), changer);
|
|
|
|
ActuallyAdditionsAPI.addReconstructorLensColorChangeItem(Item.getItemFromBlock(Blocks.STAINED_HARDENED_CLAY), changer);
|
|
|
|
ActuallyAdditionsAPI.addReconstructorLensColorChangeItem(Item.getItemFromBlock(Blocks.CARPET), changer);
|
|
|
|
ActuallyAdditionsAPI.addReconstructorLensColorChangeItem(Item.getItemFromBlock(InitBlocks.blockColoredLamp), changer);
|
|
|
|
ActuallyAdditionsAPI.addReconstructorLensColorChangeItem(Item.getItemFromBlock(InitBlocks.blockColoredLampOn), changer);
|
2016-01-05 04:47:35 +01:00
|
|
|
}
|
|
|
|
|
2018-06-24 02:44:47 +02:00
|
|
|
@Deprecated //Use lens-checking method below.
|
2018-07-28 03:40:36 +02:00
|
|
|
public static List<LensConversionRecipe> getRecipesFor(ItemStack input) {
|
2018-06-24 02:44:47 +02:00
|
|
|
List<LensConversionRecipe> possibleRecipes = new ArrayList<>();
|
2018-07-28 03:40:36 +02:00
|
|
|
for (LensConversionRecipe recipe : ActuallyAdditionsAPI.RECONSTRUCTOR_LENS_CONVERSION_RECIPES)
|
|
|
|
if (recipe.getInput().apply(input)) possibleRecipes.add(recipe);
|
2016-01-05 04:47:35 +01:00
|
|
|
return possibleRecipes;
|
|
|
|
}
|
2018-06-24 02:44:47 +02:00
|
|
|
|
|
|
|
@Nullable
|
2018-07-28 03:40:36 +02:00
|
|
|
public static LensConversionRecipe findMatchingRecipe(ItemStack input, Lens lens) {
|
|
|
|
for (LensConversionRecipe recipe : ActuallyAdditionsAPI.RECONSTRUCTOR_LENS_CONVERSION_RECIPES)
|
|
|
|
if (recipe.matches(input, lens)) return recipe;
|
2018-06-24 02:44:47 +02:00
|
|
|
return null;
|
|
|
|
}
|
2018-07-28 03:40:36 +02:00
|
|
|
|
2018-06-24 02:44:47 +02:00
|
|
|
private static Ingredient fromBlock(Block b) {
|
2018-06-26 22:25:51 +02:00
|
|
|
return Ingredient.fromItems(Item.getItemFromBlock(b));
|
2018-06-24 02:44:47 +02:00
|
|
|
}
|
2018-07-28 03:40:36 +02:00
|
|
|
|
|
|
|
private static void initOredictDyeRotator() {
|
|
|
|
List<ItemStack> stacks = NonNullList.withSize(16, ItemStack.EMPTY);
|
|
|
|
List<ItemStack> dyeItems = new ArrayList<>();
|
|
|
|
String[] dyes = { "White", "Orange", "Magenta", "LightBlue", "Yellow", "Lime", "Pink", "Gray", "LightGray", "Cyan", "Purple", "Blue", "Brown", "Green", "Red", "Black" };
|
|
|
|
for (int i = 0; i < dyes.length; i++) {
|
|
|
|
List<ItemStack> ores = OreDictionary.getOres("dye" + dyes[i]);
|
|
|
|
dyeItems.addAll(ores);
|
|
|
|
stacks.set(i, ores.get(ores.size() - 1));
|
|
|
|
}
|
|
|
|
ColorLensRotator rotator = new ColorLensRotator(stacks);
|
|
|
|
for (ItemStack s : dyeItems)
|
|
|
|
ActuallyAdditionsAPI.addReconstructorLensColorChangeItem(s.getItem(), rotator);
|
|
|
|
}
|
2016-01-05 04:47:35 +01:00
|
|
|
}
|