Add JEI integration for fluid generators recipes
This commit is contained in:
parent
1d27182cc2
commit
baebc948d9
9 changed files with 241 additions and 28 deletions
|
@ -1,5 +1,20 @@
|
|||
package techreborn.api.generator;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public enum EFluidGenerator {
|
||||
THERMAL, GAS, DIESEL, SEMIFLUID
|
||||
THERMAL("TechReborn.ThermalGenerator"), GAS("TechReborn.GasGenerator"), DIESEL(
|
||||
"TechReborn.DieselGenerator"), SEMIFLUID("TechReborn.SemifluidGenerator");
|
||||
|
||||
@Nonnull
|
||||
private final String recipeID;
|
||||
|
||||
private EFluidGenerator(@Nonnull String recipeID) {
|
||||
this.recipeID = recipeID;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public String getRecipeID() {
|
||||
return recipeID;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,34 +3,32 @@ package techreborn.api.generator;
|
|||
import net.minecraftforge.fluids.Fluid;
|
||||
|
||||
public class FluidGeneratorRecipe {
|
||||
private Fluid fluid;
|
||||
private int energyPerMb;
|
||||
private final EFluidGenerator generatorType;
|
||||
private final Fluid fluid;
|
||||
private final int energyPerMb;
|
||||
|
||||
public FluidGeneratorRecipe(Fluid fluid, int energyPerMb)
|
||||
public FluidGeneratorRecipe(Fluid fluid, int energyPerMb, EFluidGenerator generatorType)
|
||||
{
|
||||
this.fluid = fluid;
|
||||
this.energyPerMb = energyPerMb;
|
||||
this.generatorType = generatorType;
|
||||
}
|
||||
|
||||
public Fluid getFluid() {
|
||||
return fluid;
|
||||
}
|
||||
|
||||
public void setFluid(Fluid fluid) {
|
||||
this.fluid = fluid;
|
||||
}
|
||||
|
||||
public int getEnergyPerMb() {
|
||||
return energyPerMb;
|
||||
}
|
||||
|
||||
public void setEnergyPerMb(int energyPerMb) {
|
||||
this.energyPerMb = energyPerMb;
|
||||
public EFluidGenerator getGeneratorType() {
|
||||
return generatorType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "FluidGeneratorRecipe [fluid=" + fluid + ", energyPerMb=" + energyPerMb + "]";
|
||||
return "FluidGeneratorRecipe [generatorType=" + generatorType + ", fluid=" + fluid + ", energyPerMb="
|
||||
+ energyPerMb + "]";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -39,6 +37,7 @@ public class FluidGeneratorRecipe {
|
|||
int result = 1;
|
||||
result = prime * result + energyPerMb;
|
||||
result = prime * result + ((fluid == null) ? 0 : fluid.hashCode());
|
||||
result = prime * result + ((generatorType == null) ? 0 : generatorType.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -58,6 +57,8 @@ public class FluidGeneratorRecipe {
|
|||
return false;
|
||||
} else if (!fluid.equals(other.fluid))
|
||||
return false;
|
||||
if (generatorType != other.generatorType)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ public class GeneratorRecipeHelper {
|
|||
*/
|
||||
public static void registerFluidRecipe(EFluidGenerator generatorType, Fluid fluidType, int energyPerMb) {
|
||||
fluidRecipes.putIfAbsent(generatorType, new FluidGeneratorRecipeList());
|
||||
fluidRecipes.get(generatorType).addRecipe(new FluidGeneratorRecipe(fluidType, energyPerMb));
|
||||
fluidRecipes.get(generatorType).addRecipe(new FluidGeneratorRecipe(fluidType, energyPerMb, generatorType));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -11,6 +11,8 @@ import net.minecraft.item.ItemStack;
|
|||
import net.minecraft.util.text.translation.I18n;
|
||||
import reborncore.api.recipe.RecipeHandler;
|
||||
import techreborn.Core;
|
||||
import techreborn.api.generator.EFluidGenerator;
|
||||
import techreborn.api.generator.GeneratorRecipeHelper;
|
||||
import techreborn.api.reactor.FusionReactorRecipeHelper;
|
||||
import techreborn.api.recipe.machines.AssemblingMachineRecipe;
|
||||
import techreborn.api.recipe.machines.ImplosionCompressorRecipe;
|
||||
|
@ -33,6 +35,8 @@ import techreborn.compat.jei.extractor.ExtractorRecipeCategory;
|
|||
import techreborn.compat.jei.extractor.ExtractorRecipeHandler;
|
||||
import techreborn.compat.jei.fusionReactor.FusionReactorRecipeCategory;
|
||||
import techreborn.compat.jei.fusionReactor.FusionReactorRecipeHandler;
|
||||
import techreborn.compat.jei.generators.fluid.FluidGeneratorRecipeCategory;
|
||||
import techreborn.compat.jei.generators.fluid.FluidGeneratorRecipeHandler;
|
||||
import techreborn.compat.jei.grinder.GrinderRecipeCategory;
|
||||
import techreborn.compat.jei.grinder.GrinderRecipeHandler;
|
||||
import techreborn.compat.jei.implosionCompressor.ImplosionCompressorRecipeCategory;
|
||||
|
@ -125,23 +129,28 @@ public class TechRebornJeiPlugin extends BlankModPlugin {
|
|||
new CentrifugeRecipeCategory(guiHelper), new ChemicalReactorRecipeCategory(guiHelper),
|
||||
new FusionReactorRecipeCategory(guiHelper), new IndustrialGrinderRecipeCategory(guiHelper),
|
||||
new ImplosionCompressorRecipeCategory(guiHelper), new IndustrialElectrolyzerRecipeCategory(guiHelper),
|
||||
new RollingMachineRecipeCategory(guiHelper),
|
||||
new VacuumFreezerRecipeCategory(guiHelper), new GrinderRecipeCategory(guiHelper),
|
||||
new ExtractorRecipeCategory(guiHelper), new CompressorRecipeCategory(guiHelper), new ScrapboxRecipeCategory(guiHelper));
|
||||
new RollingMachineRecipeCategory(guiHelper), new VacuumFreezerRecipeCategory(guiHelper),
|
||||
new GrinderRecipeCategory(guiHelper), new ExtractorRecipeCategory(guiHelper),
|
||||
new CompressorRecipeCategory(guiHelper), new ScrapboxRecipeCategory(guiHelper));
|
||||
|
||||
for(EFluidGenerator type : EFluidGenerator.values())
|
||||
registry.addRecipeCategories(new FluidGeneratorRecipeCategory(type, guiHelper));
|
||||
|
||||
registry.addRecipeHandlers(new AlloySmelterRecipeHandler(jeiHelpers),
|
||||
new AssemblingMachineRecipeHandler(jeiHelpers), new BlastFurnaceRecipeHandler(jeiHelpers),
|
||||
new CentrifugeRecipeHandler(jeiHelpers), new ChemicalReactorRecipeHandler(jeiHelpers),
|
||||
new FusionReactorRecipeHandler(), new IndustrialGrinderRecipeHandler(jeiHelpers),
|
||||
new ImplosionCompressorRecipeHandler(jeiHelpers), new IndustrialElectrolyzerRecipeHandler(jeiHelpers),
|
||||
new RollingMachineRecipeHandler(),
|
||||
new VacuumFreezerRecipeHandler(jeiHelpers), new GrinderRecipeHandler(jeiHelpers),
|
||||
new ExtractorRecipeHandler(jeiHelpers), new CompressorRecipeHandler(jeiHelpers),
|
||||
new ScrapboxRecipeHandler(jeiHelpers));
|
||||
new RollingMachineRecipeHandler(), new VacuumFreezerRecipeHandler(jeiHelpers),
|
||||
new GrinderRecipeHandler(jeiHelpers), new ExtractorRecipeHandler(jeiHelpers),
|
||||
new CompressorRecipeHandler(jeiHelpers), new ScrapboxRecipeHandler(jeiHelpers),
|
||||
new FluidGeneratorRecipeHandler(jeiHelpers));
|
||||
|
||||
registry.addRecipes(RecipeHandler.recipeList);
|
||||
registry.addRecipes(FusionReactorRecipeHelper.reactorRecipes);
|
||||
|
||||
GeneratorRecipeHelper.fluidRecipes.forEach((type, list) -> registry.addRecipes(list.getRecipes()));
|
||||
|
||||
try {
|
||||
registry.addRecipes(RollingMachineRecipeMaker.getRecipes(jeiHelpers));
|
||||
} catch (RuntimeException e) {
|
||||
|
@ -189,6 +198,15 @@ public class TechRebornJeiPlugin extends BlankModPlugin {
|
|||
VanillaRecipeCategoryUid.FUEL);
|
||||
registry.addRecipeClickArea(GuiElectricFurnace.class, 78, 36, 24, 16, VanillaRecipeCategoryUid.SMELTING);
|
||||
|
||||
registry.addRecipeClickArea(GuiSemifluidGenerator.class, 79, 34, 18, 18,
|
||||
EFluidGenerator.SEMIFLUID.getRecipeID());
|
||||
registry.addRecipeClickArea(GuiDieselGenerator.class, 79, 34, 18, 18,
|
||||
EFluidGenerator.DIESEL.getRecipeID());
|
||||
registry.addRecipeClickArea(GuiGasTurbine.class, 79, 34, 18, 18,
|
||||
EFluidGenerator.GAS.getRecipeID());
|
||||
registry.addRecipeClickArea(GuiThermalGenerator.class, 79, 34, 18, 18,
|
||||
EFluidGenerator.THERMAL.getRecipeID());
|
||||
|
||||
registry.addRecipeCategoryCraftingItem(new ItemStack(ModBlocks.compressor), RecipeCategoryUids.COMPRESSOR);
|
||||
registry.addRecipeCategoryCraftingItem(new ItemStack(ModBlocks.alloyFurnace), RecipeCategoryUids.ALLOY_SMELTER);
|
||||
registry.addRecipeCategoryCraftingItem(new ItemStack(ModBlocks.alloySmelter), RecipeCategoryUids.ALLOY_SMELTER);
|
||||
|
@ -212,6 +230,15 @@ public class TechRebornJeiPlugin extends BlankModPlugin {
|
|||
RecipeCategoryUids.ROLLING_MACHINE);
|
||||
registry.addRecipeCategoryCraftingItem(new ItemStack(ModItems.scrapBox), RecipeCategoryUids.SCRAPBOX);
|
||||
|
||||
registry.addRecipeCategoryCraftingItem(new ItemStack(ModBlocks.semiFluidGenerator),
|
||||
EFluidGenerator.SEMIFLUID.getRecipeID());
|
||||
registry.addRecipeCategoryCraftingItem(new ItemStack(ModBlocks.gasTurbine),
|
||||
EFluidGenerator.GAS.getRecipeID());
|
||||
registry.addRecipeCategoryCraftingItem(new ItemStack(ModBlocks.dieselGenerator),
|
||||
EFluidGenerator.DIESEL.getRecipeID());
|
||||
registry.addRecipeCategoryCraftingItem(new ItemStack(ModBlocks.thermalGenerator),
|
||||
EFluidGenerator.THERMAL.getRecipeID());
|
||||
|
||||
IRecipeTransferRegistry recipeTransferRegistry = registry.getRecipeTransferRegistry();
|
||||
recipeTransferRegistry
|
||||
.addRecipeTransferHandler(ContainerAlloyFurnace.class, RecipeCategoryUids.ALLOY_SMELTER, 0, 2, 4, 36);
|
||||
|
|
|
@ -0,0 +1,66 @@
|
|||
package techreborn.compat.jei.generators.fluid;
|
||||
|
||||
import mezz.jei.api.IGuiHelper;
|
||||
import mezz.jei.api.gui.IDrawable;
|
||||
import mezz.jei.api.gui.IGuiFluidStackGroup;
|
||||
import mezz.jei.api.gui.IRecipeLayout;
|
||||
import mezz.jei.api.ingredients.IIngredients;
|
||||
import mezz.jei.api.recipe.BlankRecipeCategory;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.text.translation.I18n;
|
||||
import techreborn.api.generator.EFluidGenerator;
|
||||
import techreborn.compat.jei.RecipeUtil;
|
||||
|
||||
public class FluidGeneratorRecipeCategory extends BlankRecipeCategory<FluidGeneratorRecipeWrapper> {
|
||||
public static ResourceLocation texture = new ResourceLocation("techreborn", "textures/gui/jei_fluid_generator.png");
|
||||
|
||||
private static final int[] INPUT_TANKS = { 0 };
|
||||
|
||||
private static final int[] INPUT_SLOTS = { 0 };
|
||||
private static final int[] OUTPUT_SLOTS = { 1 };
|
||||
|
||||
private final IDrawable background;
|
||||
private final String title;
|
||||
|
||||
private final IDrawable tankOverlay;
|
||||
|
||||
private final EFluidGenerator generatorType;
|
||||
|
||||
public FluidGeneratorRecipeCategory(EFluidGenerator generatorType, IGuiHelper guiHelper) {
|
||||
background = guiHelper.createDrawable(texture, 42, 16, 102, 60);
|
||||
tankOverlay = guiHelper.createDrawable(texture, 176, 72, 12, 47);
|
||||
title = I18n.translateToLocal("techreborn.jei.category.generator." + generatorType.name().toLowerCase());
|
||||
|
||||
this.generatorType = generatorType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUid() {
|
||||
return this.generatorType.getRecipeID();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IDrawable getBackground() {
|
||||
return background;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawExtras(Minecraft minecraft) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRecipe(IRecipeLayout recipeLayout, FluidGeneratorRecipeWrapper recipeWrapper,
|
||||
IIngredients ingredients) {
|
||||
|
||||
IGuiFluidStackGroup guiFluidStacks = recipeLayout.getFluidStacks();
|
||||
guiFluidStacks.init(INPUT_TANKS[0], true, 4, 8, 12, 47, 10000, true, tankOverlay);
|
||||
|
||||
RecipeUtil.setRecipeItems(recipeLayout, ingredients, INPUT_SLOTS, OUTPUT_SLOTS, INPUT_TANKS, null);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
package techreborn.compat.jei.generators.fluid;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import mezz.jei.api.IJeiHelpers;
|
||||
import mezz.jei.api.recipe.IRecipeHandler;
|
||||
import mezz.jei.api.recipe.IRecipeWrapper;
|
||||
import techreborn.api.generator.FluidGeneratorRecipe;
|
||||
|
||||
public class FluidGeneratorRecipeHandler implements IRecipeHandler<FluidGeneratorRecipe> {
|
||||
@Nonnull
|
||||
private final IJeiHelpers jeiHelpers;
|
||||
|
||||
public FluidGeneratorRecipeHandler(@Nonnull IJeiHelpers jeiHelpers) {
|
||||
this.jeiHelpers = jeiHelpers;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Class<FluidGeneratorRecipe> getRecipeClass() {
|
||||
return FluidGeneratorRecipe.class;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getRecipeCategoryUid(FluidGeneratorRecipe recipe) {
|
||||
return recipe.getGeneratorType().getRecipeID();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IRecipeWrapper getRecipeWrapper(FluidGeneratorRecipe recipe) {
|
||||
return new FluidGeneratorRecipeWrapper(jeiHelpers, recipe);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRecipeValid(FluidGeneratorRecipe recipe) {
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
package techreborn.compat.jei.generators.fluid;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.DecimalFormatSymbols;
|
||||
import java.text.NumberFormat;
|
||||
import java.util.Locale;
|
||||
|
||||
import mezz.jei.api.IGuiHelper;
|
||||
import mezz.jei.api.IJeiHelpers;
|
||||
import mezz.jei.api.gui.IDrawable;
|
||||
import mezz.jei.api.ingredients.IIngredients;
|
||||
import mezz.jei.api.recipe.BlankRecipeWrapper;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import techreborn.api.generator.FluidGeneratorRecipe;
|
||||
|
||||
public class FluidGeneratorRecipeWrapper extends BlankRecipeWrapper {
|
||||
|
||||
private static final DecimalFormat formatter;
|
||||
|
||||
static {
|
||||
formatter = (DecimalFormat) NumberFormat.getInstance(Locale.US);
|
||||
DecimalFormatSymbols symbols = formatter.getDecimalFormatSymbols();
|
||||
|
||||
symbols.setGroupingSeparator(' ');
|
||||
formatter.setDecimalFormatSymbols(symbols);
|
||||
}
|
||||
|
||||
private static final int FLUID_GENERATOR_STORAGE = 100_000;
|
||||
|
||||
private final FluidGeneratorRecipe baseRecipe;
|
||||
private final IDrawable energyProduced;
|
||||
|
||||
public FluidGeneratorRecipeWrapper(@Nonnull IJeiHelpers jeiHelpers, @Nonnull FluidGeneratorRecipe recipe) {
|
||||
|
||||
this.baseRecipe = recipe;
|
||||
|
||||
IGuiHelper guiHelper = jeiHelpers.getGuiHelper();
|
||||
energyProduced = guiHelper.createDrawable(FluidGeneratorRecipeCategory.texture, 176, 3,
|
||||
(int) (25 * ((recipe.getEnergyPerMb() * 1000.0) / FLUID_GENERATOR_STORAGE)), 14);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawInfo(Minecraft minecraft, int recipeWidth, int recipeHeight, int mouseX, int mouseY) {
|
||||
super.drawInfo(minecraft, recipeWidth, recipeHeight, mouseX, mouseY);
|
||||
|
||||
energyProduced.draw(minecraft, 73, 26);
|
||||
|
||||
minecraft.fontRendererObj.drawString(formatter.format(baseRecipe.getEnergyPerMb() * 1000) + " FE", 70, 13,
|
||||
0x444444);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getIngredients(final IIngredients ingredients) {
|
||||
ingredients.setInput(FluidStack.class, new FluidStack(this.baseRecipe.getFluid(), Fluid.BUCKET_VOLUME));
|
||||
}
|
||||
}
|
|
@ -952,6 +952,10 @@ techreborn.desc.scrapBox=Scrapboxes can be opened by either a simple use in hand
|
|||
techreborn.desc.scrapBoxNoDispenser=Scrapboxes can be opened by a simple use in hand!
|
||||
|
||||
techreborn.jei.category.alloy.furnace=Alloy Furnace
|
||||
techreborn.jei.category.generator.gas=Gas Generator
|
||||
techreborn.jei.category.generator.semifluid=Semifluid Generator
|
||||
techreborn.jei.category.generator.diesel=Diesel Generator
|
||||
techreborn.jei.category.generator.thermal=Thermal Generator
|
||||
|
||||
#Death Messages
|
||||
death.attack.shock=%s was electrocuted
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 2.3 KiB |
Loading…
Add table
Reference in a new issue