|
| 1 | +/* |
| 2 | + * Copyright (c) 2019-2026 TagnumElite |
| 3 | + * |
| 4 | + * Permission is hereby granted, free of charge, to any person obtaining a copy |
| 5 | + * of this software and associated documentation files (the "Software"), to deal |
| 6 | + * in the Software without restriction, including without limitation the rights |
| 7 | + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 8 | + * copies of the Software, and to permit persons to whom the Software is |
| 9 | + * furnished to do so, subject to the following conditions: |
| 10 | + * |
| 11 | + * The above copyright notice and this permission notice shall be included in all |
| 12 | + * copies or substantial portions of the Software. |
| 13 | + * |
| 14 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 15 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 16 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 17 | + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 18 | + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 19 | + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 20 | + * SOFTWARE. |
| 21 | + */ |
| 22 | + |
| 23 | +package com.tagnumelite.projecteintegration.addons; |
| 24 | + |
| 25 | +import com.enderio.core.common.recipes.OutputStack; |
| 26 | +import com.enderio.enderio.content.machines.alloy.AlloySmeltingRecipe; |
| 27 | +import com.enderio.enderio.content.machines.painting.PaintingRecipe; |
| 28 | +import com.enderio.enderio.content.machines.sag_mill.SagMillingRecipe; |
| 29 | +import com.enderio.enderio.content.machines.slicer.SlicingRecipe; |
| 30 | +import com.enderio.enderio.content.machines.soul_binder.SoulBindingRecipe; |
| 31 | +import com.enderio.enderio.content.machines.vat.FermentingRecipe; |
| 32 | +import com.enderio.enderio.foundation.MachineRecipe; |
| 33 | +import com.enderio.enderio.init.EIOBlocks; |
| 34 | +import com.enderio.enderio.init.EIOItems; |
| 35 | +import com.enderio.enderio.init.EIORecipes; |
| 36 | +import com.tagnumelite.projecteintegration.api.conversion.AConversionProvider; |
| 37 | +import com.tagnumelite.projecteintegration.api.conversion.ConversionProvider; |
| 38 | +import com.tagnumelite.projecteintegration.api.recipe.ARecipeTypeMapper; |
| 39 | +import com.tagnumelite.projecteintegration.api.recipe.nss.NSSInput; |
| 40 | +import com.tagnumelite.projecteintegration.api.recipe.nss.NSSOutput; |
| 41 | +import moze_intel.projecte.api.data.CustomConversionBuilder; |
| 42 | +import moze_intel.projecte.api.mapper.recipe.RecipeTypeMapper; |
| 43 | +import net.minecraft.world.item.Items; |
| 44 | +import net.minecraft.world.item.crafting.Ingredient; |
| 45 | +import net.minecraft.world.item.crafting.RecipeType; |
| 46 | + |
| 47 | +import java.util.List; |
| 48 | + |
| 49 | +public class EnderIOAddon { |
| 50 | + protected static final String MODID = "enderio"; |
| 51 | + |
| 52 | + protected static String NAME(String name) { |
| 53 | + return "EnderIO" + name + "Mapper"; |
| 54 | + } |
| 55 | + |
| 56 | + protected abstract static class EIOMachineMapper<R extends MachineRecipe<?>> extends ARecipeTypeMapper<R> { |
| 57 | + @Override |
| 58 | + public NSSOutput getOutput(R recipe) { |
| 59 | + List<OutputStack> results = recipe.getResultStacks(registryAccess); |
| 60 | + if (results.isEmpty()) return null; |
| 61 | + if (results.size() == 1) { |
| 62 | + OutputStack result = results.getFirst(); |
| 63 | + if (result.isFluid()) return new NSSOutput(result.getFluid()); |
| 64 | + return new NSSOutput(result.getItem()); |
| 65 | + } |
| 66 | + return mapOutputs(results.stream().map(o->o.isFluid() ? o.getFluid() : o.getItem()).toArray()); |
| 67 | + } |
| 68 | + } |
| 69 | + |
| 70 | + @RecipeTypeMapper(requiredMods = MODID, priority = 1) |
| 71 | + public static class EIOAlloySmeltingMapper extends EIOMachineMapper<AlloySmeltingRecipe> { |
| 72 | + @Override |
| 73 | + public String getName( ) { |
| 74 | + return NAME("AlloySmelting"); |
| 75 | + } |
| 76 | + |
| 77 | + @Override |
| 78 | + public boolean canHandle(RecipeType<?> recipeType) { |
| 79 | + return recipeType == EIORecipes.ALLOY_SMELTING.type().get(); |
| 80 | + } |
| 81 | + |
| 82 | + @Override |
| 83 | + public NSSInput getInput(AlloySmeltingRecipe recipe) { |
| 84 | + return convertSizedIngredients(recipe.inputs()); |
| 85 | + } |
| 86 | + } |
| 87 | + |
| 88 | + // We ignore Fire Crafting because we must |
| 89 | + |
| 90 | + @RecipeTypeMapper(requiredMods = MODID, priority = 1) |
| 91 | + public static class EIOSagMillingMapper extends EIOMachineMapper<SagMillingRecipe> { |
| 92 | + @Override |
| 93 | + public String getName( ) { |
| 94 | + return NAME("SagMilling"); |
| 95 | + } |
| 96 | + |
| 97 | + @Override |
| 98 | + public boolean canHandle(RecipeType<?> recipeType) { |
| 99 | + return recipeType == EIORecipes.SAG_MILLING.type().get(); |
| 100 | + } |
| 101 | + } |
| 102 | + |
| 103 | + @RecipeTypeMapper(requiredMods = MODID, priority = 1) |
| 104 | + public static class EIOSlicingMapper extends EIOMachineMapper<SlicingRecipe> { |
| 105 | + @Override |
| 106 | + public String getName( ) { |
| 107 | + return NAME("Slicing"); |
| 108 | + } |
| 109 | + |
| 110 | + @Override |
| 111 | + public boolean canHandle(RecipeType<?> recipeType) { |
| 112 | + return recipeType == EIORecipes.SLICING.type().get(); |
| 113 | + } |
| 114 | + } |
| 115 | + |
| 116 | + @RecipeTypeMapper(requiredMods = MODID, priority = 1) |
| 117 | + public static class EIOSoulBindingMapper extends EIOMachineMapper<SoulBindingRecipe> { |
| 118 | + @Override |
| 119 | + public String getName( ) { |
| 120 | + return NAME("SoulBinding"); |
| 121 | + } |
| 122 | + |
| 123 | + @Override |
| 124 | + public boolean canHandle(RecipeType<?> recipeType) { |
| 125 | + return recipeType == EIORecipes.SOUL_BINDING.type().get(); |
| 126 | + } |
| 127 | + |
| 128 | + // We skip the soul vials because those are returned & TODO: Look at making souls have emc |
| 129 | + @Override |
| 130 | + protected List<Ingredient> getIngredients(SoulBindingRecipe recipe) { |
| 131 | + return List.of(recipe.getInput()); |
| 132 | + } |
| 133 | + |
| 134 | + @Override |
| 135 | + public NSSOutput getOutput(SoulBindingRecipe recipe) { |
| 136 | + return new NSSOutput(recipe.output()); |
| 137 | + } |
| 138 | + } |
| 139 | + |
| 140 | + @RecipeTypeMapper(requiredMods = MODID, priority = 1) |
| 141 | + public static class EIOPaintingMapper extends EIOMachineMapper<PaintingRecipe> { |
| 142 | + @Override |
| 143 | + public String getName( ) { |
| 144 | + return NAME("Painting"); |
| 145 | + } |
| 146 | + |
| 147 | + @Override |
| 148 | + public boolean canHandle(RecipeType<?> recipeType) { |
| 149 | + return recipeType == EIORecipes.PAINTING.type().get(); |
| 150 | + } |
| 151 | + } |
| 152 | + |
| 153 | + @RecipeTypeMapper(requiredMods = MODID, priority = 1) |
| 154 | + public static class EIOFermentingMapper extends EIOMachineMapper<FermentingRecipe> { |
| 155 | + @Override |
| 156 | + public String getName( ) { |
| 157 | + return NAME("Fermenting"); |
| 158 | + } |
| 159 | + |
| 160 | + @Override |
| 161 | + public boolean canHandle(RecipeType<?> recipeType) { |
| 162 | + return recipeType == EIORecipes.VAT_FERMENTING.type().get(); |
| 163 | + } |
| 164 | + |
| 165 | + @Override |
| 166 | + public NSSInput getInput(FermentingRecipe recipe) { |
| 167 | + return getInputBuilder().addFluid(recipe.input()).addItemKey(recipe.firstReagent()) |
| 168 | + .addItemKey(recipe.secondReagent()).build(); |
| 169 | + } |
| 170 | + } |
| 171 | + |
| 172 | + @ConversionProvider(MODID) |
| 173 | + public static class EnderIOConversionProvider extends AConversionProvider { |
| 174 | + @Override |
| 175 | + public void convert(CustomConversionBuilder builder) { |
| 176 | + builder.comment("Default EMC for EnderIO").before(EIOItems.GRAINS_OF_INFINITY, 4) |
| 177 | + .before(EIOItems.SUSPICIOUS_SEED, 8) |
| 178 | + .before(EIOBlocks.ENDERMAN_HEAD, 2048) |
| 179 | + .conversion(EIOItems.SILICON).ingredient(Items.SAND).end(); // TODO: I don't like this conversion |
| 180 | + } |
| 181 | + } |
| 182 | +} |
0 commit comments