Added some recipe texts to REI. Looks ugly

This commit is contained in:
drcrazy 2019-08-16 14:18:48 +03:00
parent 3e5965ad57
commit 3eec5bcb5b
3 changed files with 26 additions and 10 deletions

View file

@ -27,6 +27,7 @@ package techreborn.compat.rei;
import com.mojang.blaze3d.platform.GlStateManager;
import me.shedaniel.rei.api.*;
import me.shedaniel.rei.gui.renderables.RecipeRenderer;
import me.shedaniel.rei.gui.widget.LabelWidget;
import me.shedaniel.rei.gui.widget.RecipeBaseWidget;
import me.shedaniel.rei.gui.widget.SlotWidget;
import me.shedaniel.rei.gui.widget.Widget;
@ -35,13 +36,14 @@ import net.minecraft.client.MinecraftClient;
import net.minecraft.client.render.GuiLighting;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.MathHelper;
import reborncore.common.crafting.RebornRecipe;
import reborncore.common.crafting.RebornRecipeType;
import reborncore.common.util.StringUtils;
import java.awt.*;
import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
@ -102,12 +104,15 @@ public class MachineRecipeCategory<R extends RebornRecipe> implements RecipeCate
this.blit(startPoint.x + 24, startPoint.y + 1, 82, 91, width, 17);
}
}
List<Widget> widgets = new LinkedList(Arrays.asList(new RecipeBackgroundWidget(bounds)));
List<Widget> widgets = new LinkedList<>();
widgets.add(new RecipeBackgroundWidget(bounds));
int i = 0;
for (List<ItemStack> inputs : machineRecipe.getInput()){
widgets.add(new SlotWidget(startPoint.x + 1, startPoint.y + 1 + (i++ * 20), inputs, true, true, true));
}
Text energyPerTick = new TranslatableText("techreborn.jei.recipe.running.cost", "E", machineRecipe.getEnergy());
widgets.add(new LabelWidget(startPoint.x + 1, startPoint.y + 1 + (i++ * 20), energyPerTick.asFormattedString()));
i = 0;
for (ItemStack outputs : machineRecipe.getOutput()){
@ -118,8 +123,9 @@ public class MachineRecipeCategory<R extends RebornRecipe> implements RecipeCate
}
@Override
public DisplaySettings getDisplaySettings() {
return new DisplaySettings<MachineRecipeDisplay>() {
public DisplaySettings<MachineRecipeDisplay<R>> getDisplaySettings() {
return new DisplaySettings<MachineRecipeDisplay<R>>() {
public int getDisplayHeight(RecipeCategory category) {
if (recipeLines == 1) {
@ -134,13 +140,14 @@ public class MachineRecipeCategory<R extends RebornRecipe> implements RecipeCate
return 66;
}
public int getDisplayWidth(RecipeCategory category, MachineRecipeDisplay display) {
public int getDisplayWidth(RecipeCategory category, MachineRecipeDisplay<R> display) {
return 150;
}
public int getMaximumRecipePerPage(RecipeCategory category) {
return 99;
}
};
}
}

View file

@ -39,11 +39,17 @@ public class MachineRecipeDisplay<R extends RebornRecipe> implements RecipeDispl
private final R recipe;
private List<List<ItemStack>> inputs;
private List<ItemStack> outputs;
private int energy = 0;
public MachineRecipeDisplay(R recipe) {
this.recipe = recipe;
this.inputs = recipe.getRebornIngredients().stream().map(RebornIngredient::getPreviewStacks).collect(Collectors.toList());
this.outputs = recipe.getOutputs();
this.energy = recipe.getPower();
}
public int getEnergy() {
return energy;
}
@Override

View file

@ -63,14 +63,16 @@ public class ReiPlugin implements REIPluginEntry {
iconMap.put(ModRecipes.DISTILLATION_TOWER, Machine.DISTILLATION_TOWER);
iconMap.put(ModRecipes.EXTRACTOR, Machine.EXTRACTOR);
iconMap.put(ModRecipes.FLUID_REPLICATOR, Machine.FLUID_REPLICATOR);
iconMap.put(ModRecipes.FUSION_REACTOR, Machine.FUSION_CONTROL_COMPUTER);
iconMap.put(ModRecipes.GRINDER, Machine.GRINDER);
iconMap.put(ModRecipes.IMPLOSION_COMPRESSOR, Machine.IMPLOSION_COMPRESSOR);
iconMap.put(ModRecipes.INDUSTRIAL_ELECTROLYZER, Machine.INDUSTRIAL_ELECTROLYZER);
iconMap.put(ModRecipes.INDUSTRIAL_GRINDER, Machine.INDUSTRIAL_GRINDER);
iconMap.put(ModRecipes.INDUSTRIAL_SAWMILL, Machine.INDUSTRIAL_SAWMILL);
iconMap.put(ModRecipes.ROLLING_MACHINE, Machine.ROLLING_MACHINE);
iconMap.put(ModRecipes.SCRAPBOX, TRContent.SCRAP_BOX);
iconMap.put(ModRecipes.VACUUM_FREEZER, Machine.VACUUM_FREEZER);
iconMap.put(ModRecipes.ROLLING_MACHINE, Machine.ROLLING_MACHINE);
}
@Override
@ -89,15 +91,15 @@ public class ReiPlugin implements REIPluginEntry {
recipeHelper.registerCategory(new MachineRecipeCategory<>(ModRecipes.DISTILLATION_TOWER, 3));
recipeHelper.registerCategory(new MachineRecipeCategory<>(ModRecipes.EXTRACTOR, 1));
recipeHelper.registerCategory(new MachineRecipeCategory<>(ModRecipes.FLUID_REPLICATOR, 1));
recipeHelper.registerCategory(new MachineRecipeCategory<>(ModRecipes.FUSION_REACTOR, 2));
recipeHelper.registerCategory(new MachineRecipeCategory<>(ModRecipes.GRINDER, 1));
recipeHelper.registerCategory(new MachineRecipeCategory<>(ModRecipes.IMPLOSION_COMPRESSOR));
recipeHelper.registerCategory(new MachineRecipeCategory<>(ModRecipes.INDUSTRIAL_ELECTROLYZER, 4));
recipeHelper.registerCategory(new MachineRecipeCategory<>(ModRecipes.INDUSTRIAL_GRINDER, 3));
recipeHelper.registerCategory(new MachineRecipeCategory<>(ModRecipes.INDUSTRIAL_SAWMILL, 3));
recipeHelper.registerCategory(new RollingMachineCategory(ModRecipes.ROLLING_MACHINE));
recipeHelper.registerCategory(new MachineRecipeCategory<>(ModRecipes.SCRAPBOX));
recipeHelper.registerCategory(new MachineRecipeCategory<>(ModRecipes.VACUUM_FREEZER, 1));
recipeHelper.registerCategory(new MachineRecipeCategory<>(ModRecipes.FUSION_REACTOR, 2));
recipeHelper.registerCategory(new RollingMachineCategory(ModRecipes.ROLLING_MACHINE));
}
@Override
@ -115,13 +117,14 @@ public class ReiPlugin implements REIPluginEntry {
recipeHelper.registerWorkingStations(ModRecipes.DISTILLATION_TOWER.getName(), new ItemStack(Machine.DISTILLATION_TOWER.asItem()));
recipeHelper.registerWorkingStations(ModRecipes.EXTRACTOR.getName(), new ItemStack(Machine.EXTRACTOR.asItem()));
recipeHelper.registerWorkingStations(ModRecipes.FLUID_REPLICATOR.getName(), new ItemStack(Machine.FLUID_REPLICATOR.asItem()));
recipeHelper.registerWorkingStations(ModRecipes.FUSION_REACTOR.getName(), new ItemStack(Machine.FUSION_CONTROL_COMPUTER.asItem()));
recipeHelper.registerWorkingStations(ModRecipes.GRINDER.getName(), new ItemStack(Machine.GRINDER.asItem()));
recipeHelper.registerWorkingStations(ModRecipes.IMPLOSION_COMPRESSOR.getName(), new ItemStack(Machine.IMPLOSION_COMPRESSOR.asItem()));
recipeHelper.registerWorkingStations(ModRecipes.INDUSTRIAL_ELECTROLYZER.getName(), new ItemStack(Machine.INDUSTRIAL_ELECTROLYZER.asItem()));
recipeHelper.registerWorkingStations(ModRecipes.INDUSTRIAL_GRINDER.getName(), new ItemStack(Machine.INDUSTRIAL_GRINDER.asItem()));
recipeHelper.registerWorkingStations(ModRecipes.INDUSTRIAL_SAWMILL.getName(), new ItemStack(Machine.INDUSTRIAL_SAWMILL.asItem()));
recipeHelper.registerWorkingStations(ModRecipes.VACUUM_FREEZER.getName(), new ItemStack(Machine.VACUUM_FREEZER.asItem()));
recipeHelper.registerWorkingStations(ModRecipes.ROLLING_MACHINE.getName(), new ItemStack(Machine.ROLLING_MACHINE.asItem()));
recipeHelper.registerWorkingStations(ModRecipes.FUSION_REACTOR.getName(), new ItemStack(Machine.FUSION_CONTROL_COMPUTER.asItem()));
recipeHelper.registerWorkingStations(ModRecipes.VACUUM_FREEZER.getName(), new ItemStack(Machine.VACUUM_FREEZER.asItem()));
}
private <R extends RebornRecipe> void registerMachineRecipe(RecipeHelper recipeHelper, RebornRecipeType<R> recipeType){