Epic REI displays. Thanks to shedaniel! (#2167)

* Epic REI displays

Signed-off-by: shedaniel <daniel@shedaniel.me>

* use the AbstractEnergyConsumingMachineCategory for ElectrolyzerCategory

Signed-off-by: shedaniel <daniel@shedaniel.me>
This commit is contained in:
shedaniel 2020-07-18 23:58:35 +08:00 committed by GitHub
parent 140ff2f365
commit 01663648c4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
24 changed files with 807 additions and 363 deletions

View file

@ -80,7 +80,7 @@ dependencies {
//Fabric api //Fabric api
modImplementation "net.fabricmc.fabric-api:fabric-api:0.13.1+build.370-1.16" modImplementation "net.fabricmc.fabric-api:fabric-api:0.13.1+build.370-1.16"
optionalDependency ("me.shedaniel:RoughlyEnoughItems:4.5.4") optionalDependency ("me.shedaniel:RoughlyEnoughItems:4.10.2")
disabledOptionalDependency ('io.github.cottonmc:LibCD:2.4.1+1.15.2') disabledOptionalDependency ('io.github.cottonmc:LibCD:2.4.1+1.15.2')
disabledOptionalDependency ('com.github.emilyploszaj:trinkets:2.6.0') disabledOptionalDependency ('com.github.emilyploszaj:trinkets:2.6.0')

View file

@ -1,131 +0,0 @@
/*
* This file is part of TechReborn, licensed under the MIT License (MIT).
*
* Copyright (c) 2020 TechReborn
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package techreborn.compat.rei;
import me.shedaniel.math.Point;
import me.shedaniel.math.Rectangle;
import me.shedaniel.rei.api.EntryStack;
import me.shedaniel.rei.api.RecipeCategory;
import me.shedaniel.rei.api.widgets.Label;
import me.shedaniel.rei.api.widgets.Widgets;
import me.shedaniel.rei.gui.entries.RecipeEntry;
import me.shedaniel.rei.gui.entries.SimpleRecipeEntry;
import me.shedaniel.rei.gui.widget.Widget;
import net.minecraft.client.resource.language.I18n;
import net.minecraft.item.Items;
import net.minecraft.text.LiteralText;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
import net.minecraft.util.Identifier;
import reborncore.common.crafting.RebornRecipe;
import reborncore.common.crafting.RebornRecipeType;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
public class MachineRecipeCategory<R extends RebornRecipe> implements RecipeCategory<MachineRecipeDisplay<R>> {
private final RebornRecipeType<R> rebornRecipeType;
private final int recipeLines;
MachineRecipeCategory(RebornRecipeType<R> rebornRecipeType) {
this(rebornRecipeType, 2);
}
MachineRecipeCategory(RebornRecipeType<R> rebornRecipeType, int lines) {
this.rebornRecipeType = rebornRecipeType;
this.recipeLines = lines;
}
@Override
public Identifier getIdentifier() {
return rebornRecipeType.getName();
}
@Override
public String getCategoryName() {
return I18n.translate(rebornRecipeType.getName().toString());
}
@Override
public EntryStack getLogo() {
return EntryStack.create(ReiPlugin.iconMap.getOrDefault(rebornRecipeType, () -> Items.DIAMOND_SHOVEL));
}
@Override
public RecipeEntry getSimpleRenderer(MachineRecipeDisplay<R> recipe) {
return SimpleRecipeEntry.create(Collections.singletonList(recipe.getInputEntries().get(0)), recipe.getOutputEntries());
}
@Override
public List<Widget> setupDisplay(MachineRecipeDisplay<R> machineRecipe, Rectangle bounds) {
Point startPoint = new Point(bounds.getCenterX() - 41, bounds.getCenterY() - recipeLines * 12 - 1);
List<Widget> widgets = new LinkedList<>();
widgets.add(Widgets.createRecipeBase(bounds));
widgets.add(Widgets.createArrow(new Point(startPoint.x + 26, startPoint.y + 1)).animationDurationTicks(machineRecipe.getTime()));
int i = 0;
for (List<EntryStack> inputs : machineRecipe.getInputEntries()) {
widgets.add(Widgets.createSlot(new Point(startPoint.x + 1, startPoint.y + 1 + (i++ * 20))).entries(inputs).markInput());
}
Text energyPerTick = new TranslatableText("techreborn.jei.recipe.running.cost", "E", machineRecipe.getEnergy());
Label costLabel;
widgets.add(costLabel = Widgets.createLabel(new Point(startPoint.x + 1, startPoint.y + 1 + (i++ * 20)), energyPerTick));
costLabel.shadow(false);
costLabel.color(0xFF404040, 0xFFBBBBBB);
i = 0;
for (EntryStack outputs : machineRecipe.getOutputEntries()) {
widgets.add(Widgets.createSlot(new Point(startPoint.x + 61, startPoint.y + 1 + (i++ * 20))).entry(outputs).markInput());
}
int heat = machineRecipe.getHeat();
if (heat > 0) {
Text neededHeat = new LiteralText(String.valueOf(heat)).append(" ").append(new TranslatableText("techreborn.jei.recipe.heat"));
Label heatLabel;
widgets.add(heatLabel = Widgets.createLabel(new Point(startPoint.x + 61, startPoint.y + 1 + (i++ * 20)), neededHeat));
heatLabel.shadow(false);
heatLabel.color(0xFF404040, 0xFFBBBBBB);
}
return widgets;
}
@Override
public int getDisplayHeight() {
if (recipeLines == 1) {
return 37;
} else if (recipeLines == 3) {
return 80;
} else if (recipeLines == 4) {
return 105;
}
return 60;
}
}

View file

@ -49,8 +49,8 @@ public class MachineRecipeDisplay<R extends RebornRecipe> implements RecipeDispl
public MachineRecipeDisplay(R recipe) { public MachineRecipeDisplay(R recipe) {
this.recipe = recipe; this.recipe = recipe;
this.inputs = CollectionUtils.map(recipe.getRebornIngredients(), ing -> CollectionUtils.map(ing.getPreviewStacks(), RebornEntryStack::create)); this.inputs = CollectionUtils.map(recipe.getRebornIngredients(), ing -> EntryStack.ofItemStacks(ing.getPreviewStacks()));
this.outputs = CollectionUtils.map(recipe.getOutputs(), RebornEntryStack::create); this.outputs = EntryStack.ofItemStacks(recipe.getOutputs());
this.time = recipe.getTime(); this.time = recipe.getTime();
this.energy = recipe.getPower(); this.energy = recipe.getPower();
if (recipe instanceof BlastFurnaceRecipe) { if (recipe instanceof BlastFurnaceRecipe) {
@ -58,7 +58,7 @@ public class MachineRecipeDisplay<R extends RebornRecipe> implements RecipeDispl
} }
if (recipe instanceof RebornFluidRecipe) { if (recipe instanceof RebornFluidRecipe) {
this.fluidInstance = ((RebornFluidRecipe) recipe).getFluidInstance(); this.fluidInstance = ((RebornFluidRecipe) recipe).getFluidInstance();
inputs.add(Collections.singletonList(RebornEntryStack.create(fluidInstance.getFluid(), fluidInstance.getAmount().getRawValue()))); inputs.add(Collections.singletonList(EntryStack.create(fluidInstance.getFluid(), fluidInstance.getAmount().getRawValue())));
} }
for (List<EntryStack> entries : inputs) for (List<EntryStack> entries : inputs)
for (EntryStack stack : entries) for (EntryStack stack : entries)

View file

@ -1,69 +0,0 @@
/*
* This file is part of TechReborn, licensed under the MIT License (MIT).
*
* Copyright (c) 2020 TechReborn
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package techreborn.compat.rei;
import me.shedaniel.rei.api.EntryStack;
import net.minecraft.fluid.Fluid;
import net.minecraft.item.ItemStack;
import reborncore.common.fluid.container.ItemFluidInfo;
import techreborn.utils.FluidUtils;
public interface RebornEntryStack extends EntryStack {
static EntryStack create(Fluid fluid, int amount) {
return new RebornFluidEntryStack(fluid, amount);
}
static EntryStack create(ItemStack stack) {
return new RebornItemEntryStack(stack);
}
static boolean compareFluids(EntryStack a, Object obj) {
if (!(obj instanceof EntryStack)) {
return false;
}
Fluid fluid1, fluid2;
if (a.getItem() instanceof ItemFluidInfo) {
fluid1 = ((ItemFluidInfo) a.getItem()).getFluid(a.getItemStack());
} else {
fluid1 = a.getFluid();
}
EntryStack b = (EntryStack) obj;
if (b.getItem() instanceof ItemFluidInfo) {
fluid2 = ((ItemFluidInfo) b.getItem()).getFluid(b.getItemStack());
} else {
fluid2 = b.getFluid();
}
if (fluid1 != null && fluid2 != null) {
return FluidUtils.fluidEquals(fluid1, fluid2);
}
return false;
}
}

View file

@ -1,44 +0,0 @@
/*
* This file is part of TechReborn, licensed under the MIT License (MIT).
*
* Copyright (c) 2020 TechReborn
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package techreborn.compat.rei;
import me.shedaniel.rei.impl.FluidEntryStack;
import net.minecraft.fluid.Fluid;
public class RebornFluidEntryStack extends FluidEntryStack {
public RebornFluidEntryStack(Fluid fluid, int amount) {
super(fluid, amount);
}
@Override
public boolean equals(Object obj) {
if (super.equals(obj)) {
return true;
}
return RebornEntryStack.compareFluids(this, obj);
}
}

View file

@ -1,44 +0,0 @@
/*
* This file is part of TechReborn, licensed under the MIT License (MIT).
*
* Copyright (c) 2020 TechReborn
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package techreborn.compat.rei;
import me.shedaniel.rei.impl.ItemEntryStack;
import net.minecraft.item.ItemStack;
public class RebornItemEntryStack extends ItemEntryStack {
public RebornItemEntryStack(ItemStack itemStack) {
super(itemStack);
}
@Override
public boolean equals(Object obj) {
if (super.equals(obj)) {
return true;
}
return RebornEntryStack.compareFluids(this, obj);
}
}

View file

@ -24,20 +24,41 @@
package techreborn.compat.rei; package techreborn.compat.rei;
import com.mojang.blaze3d.systems.RenderSystem;
import me.shedaniel.math.Point;
import me.shedaniel.math.Rectangle; import me.shedaniel.math.Rectangle;
import me.shedaniel.rei.api.*; import me.shedaniel.rei.api.*;
import me.shedaniel.rei.api.fluid.FluidSupportProvider;
import me.shedaniel.rei.api.plugins.REIPluginV0; import me.shedaniel.rei.api.plugins.REIPluginV0;
import me.shedaniel.rei.api.widgets.Tooltip;
import me.shedaniel.rei.api.widgets.Widgets;
import me.shedaniel.rei.gui.widget.EntryWidget;
import me.shedaniel.rei.gui.widget.Widget;
import me.shedaniel.rei.impl.RenderingEntry;
import net.fabricmc.fabric.api.client.render.fluid.v1.FluidRenderHandlerRegistry;
import net.minecraft.client.MinecraftClient; import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.DrawableHelper;
import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.texture.Sprite;
import net.minecraft.client.texture.SpriteAtlasTexture;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.fluid.Fluid;
import net.minecraft.item.ItemConvertible; import net.minecraft.item.ItemConvertible;
import net.minecraft.recipe.Recipe; import net.minecraft.recipe.Recipe;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import reborncore.api.blockentity.IUpgradeable; import reborncore.api.blockentity.IUpgradeable;
import reborncore.client.gui.builder.GuiBase; import reborncore.client.gui.builder.GuiBase;
import reborncore.client.gui.builder.slot.GuiTab; import reborncore.client.gui.builder.slot.GuiTab;
import reborncore.client.gui.guibuilder.GuiBuilder;
import reborncore.common.crafting.RebornRecipe; import reborncore.common.crafting.RebornRecipe;
import reborncore.common.crafting.RebornRecipeType; import reborncore.common.crafting.RebornRecipeType;
import reborncore.common.crafting.RecipeManager; import reborncore.common.crafting.RecipeManager;
import reborncore.common.fluid.container.ItemFluidInfo;
import reborncore.common.powerSystem.PowerSystem;
import techreborn.TechReborn; import techreborn.TechReborn;
import techreborn.api.generator.EFluidGenerator; import techreborn.api.generator.EFluidGenerator;
import techreborn.api.generator.GeneratorRecipeHelper; import techreborn.api.generator.GeneratorRecipeHelper;
@ -47,6 +68,7 @@ import techreborn.compat.rei.fluidgenerator.FluidGeneratorRecipeCategory;
import techreborn.compat.rei.fluidgenerator.FluidGeneratorRecipeDisplay; import techreborn.compat.rei.fluidgenerator.FluidGeneratorRecipeDisplay;
import techreborn.compat.rei.fluidreplicator.FluidReplicatorRecipeCategory; import techreborn.compat.rei.fluidreplicator.FluidReplicatorRecipeCategory;
import techreborn.compat.rei.fluidreplicator.FluidReplicatorRecipeDisplay; import techreborn.compat.rei.fluidreplicator.FluidReplicatorRecipeDisplay;
import techreborn.compat.rei.machine.*;
import techreborn.compat.rei.rollingmachine.RollingMachineCategory; import techreborn.compat.rei.rollingmachine.RollingMachineCategory;
import techreborn.compat.rei.rollingmachine.RollingMachineDisplay; import techreborn.compat.rei.rollingmachine.RollingMachineDisplay;
import techreborn.init.ModRecipes; import techreborn.init.ModRecipes;
@ -95,26 +117,26 @@ public class ReiPlugin implements REIPluginV0 {
@Override @Override
public void registerPluginCategories(RecipeHelper recipeHelper) { public void registerPluginCategories(RecipeHelper recipeHelper) {
recipeHelper.registerCategory(new MachineRecipeCategory<>(ModRecipes.ALLOY_SMELTER)); recipeHelper.registerCategory(new TwoInputsCenterOutputCategory<>(ModRecipes.ALLOY_SMELTER));
recipeHelper.registerCategory(new MachineRecipeCategory<>(ModRecipes.ASSEMBLING_MACHINE)); recipeHelper.registerCategory(new AssemblingMachineCategory<>(ModRecipes.ASSEMBLING_MACHINE));
recipeHelper.registerCategory(new MachineRecipeCategory<>(ModRecipes.BLAST_FURNACE)); recipeHelper.registerCategory(new BlastFurnaceCategory<>(ModRecipes.BLAST_FURNACE));
recipeHelper.registerCategory(new MachineRecipeCategory<>(ModRecipes.CENTRIFUGE, 4)); recipeHelper.registerCategory(new IndustrialCentrifugeCategory<>(ModRecipes.CENTRIFUGE));
recipeHelper.registerCategory(new MachineRecipeCategory<>(ModRecipes.CHEMICAL_REACTOR)); recipeHelper.registerCategory(new TwoInputsCenterOutputCategory<>(ModRecipes.CHEMICAL_REACTOR));
recipeHelper.registerCategory(new MachineRecipeCategory<>(ModRecipes.COMPRESSOR, 1)); recipeHelper.registerCategory(new OneInputOneOutputCategory<>(ModRecipes.COMPRESSOR));
recipeHelper.registerCategory(new MachineRecipeCategory<>(ModRecipes.DISTILLATION_TOWER, 3)); recipeHelper.registerCategory(new DistillationTowerCategory<>(ModRecipes.DISTILLATION_TOWER));
recipeHelper.registerCategory(new MachineRecipeCategory<>(ModRecipes.EXTRACTOR, 1)); recipeHelper.registerCategory(new OneInputOneOutputCategory<>(ModRecipes.EXTRACTOR));
recipeHelper.registerCategory(new FluidReplicatorRecipeCategory(ModRecipes.FLUID_REPLICATOR)); recipeHelper.registerCategory(new FluidReplicatorRecipeCategory(ModRecipes.FLUID_REPLICATOR));
recipeHelper.registerCategory(new MachineRecipeCategory<>(ModRecipes.FUSION_REACTOR, 2)); recipeHelper.registerCategory(new TwoInputsCenterOutputCategory<>(ModRecipes.FUSION_REACTOR));
recipeHelper.registerCategory(new MachineRecipeCategory<>(ModRecipes.GRINDER, 1)); recipeHelper.registerCategory(new OneInputOneOutputCategory<>(ModRecipes.GRINDER));
recipeHelper.registerCategory(new MachineRecipeCategory<>(ModRecipes.IMPLOSION_COMPRESSOR)); recipeHelper.registerCategory(new ImplosionCompressorCategory<>(ModRecipes.IMPLOSION_COMPRESSOR));
recipeHelper.registerCategory(new MachineRecipeCategory<>(ModRecipes.INDUSTRIAL_ELECTROLYZER, 4)); recipeHelper.registerCategory(new ElectrolyzerCategory<>(ModRecipes.INDUSTRIAL_ELECTROLYZER));
recipeHelper.registerCategory(new MachineRecipeCategory<>(ModRecipes.INDUSTRIAL_GRINDER, 3)); recipeHelper.registerCategory(new GrinderCategory<>(ModRecipes.INDUSTRIAL_GRINDER));
recipeHelper.registerCategory(new MachineRecipeCategory<>(ModRecipes.INDUSTRIAL_SAWMILL, 3)); recipeHelper.registerCategory(new SawmillCategory<>(ModRecipes.INDUSTRIAL_SAWMILL));
recipeHelper.registerCategory(new RollingMachineCategory(ModRecipes.ROLLING_MACHINE)); recipeHelper.registerCategory(new RollingMachineCategory(ModRecipes.ROLLING_MACHINE));
recipeHelper.registerCategory(new MachineRecipeCategory<>(ModRecipes.SCRAPBOX)); recipeHelper.registerCategory(new OneInputOneOutputCategory<>(ModRecipes.SCRAPBOX));
recipeHelper.registerCategory(new MachineRecipeCategory<>(ModRecipes.SOLID_CANNING_MACHINE)); recipeHelper.registerCategory(new TwoInputsCenterOutputCategory<>(ModRecipes.SOLID_CANNING_MACHINE));
recipeHelper.registerCategory(new MachineRecipeCategory<>(ModRecipes.VACUUM_FREEZER, 1)); recipeHelper.registerCategory(new OneInputOneOutputCategory<>(ModRecipes.VACUUM_FREEZER));
recipeHelper.registerCategory(new MachineRecipeCategory<>(ModRecipes.WIRE_MILL, 1)); recipeHelper.registerCategory(new OneInputOneOutputCategory<>(ModRecipes.WIRE_MILL));
recipeHelper.registerCategory(new FluidGeneratorRecipeCategory(Machine.THERMAL_GENERATOR)); recipeHelper.registerCategory(new FluidGeneratorRecipeCategory(Machine.THERMAL_GENERATOR));
recipeHelper.registerCategory(new FluidGeneratorRecipeCategory(Machine.GAS_TURBINE)); recipeHelper.registerCategory(new FluidGeneratorRecipeCategory(Machine.GAS_TURBINE));
@ -160,20 +182,37 @@ public class ReiPlugin implements REIPluginV0 {
recipeHelper.registerWorkingStations(new Identifier(TechReborn.MOD_ID, Machine.DIESEL_GENERATOR.name), EntryStack.create(Machine.DIESEL_GENERATOR)); recipeHelper.registerWorkingStations(new Identifier(TechReborn.MOD_ID, Machine.DIESEL_GENERATOR.name), EntryStack.create(Machine.DIESEL_GENERATOR));
recipeHelper.registerWorkingStations(new Identifier(TechReborn.MOD_ID, Machine.SEMI_FLUID_GENERATOR.name), EntryStack.create(Machine.SEMI_FLUID_GENERATOR)); recipeHelper.registerWorkingStations(new Identifier(TechReborn.MOD_ID, Machine.SEMI_FLUID_GENERATOR.name), EntryStack.create(Machine.SEMI_FLUID_GENERATOR));
recipeHelper.registerWorkingStations(new Identifier(TechReborn.MOD_ID, Machine.PLASMA_GENERATOR.name), EntryStack.create(Machine.PLASMA_GENERATOR)); recipeHelper.registerWorkingStations(new Identifier(TechReborn.MOD_ID, Machine.PLASMA_GENERATOR.name), EntryStack.create(Machine.PLASMA_GENERATOR));
registerFluidSupport();
}
@SuppressWarnings("UnstableApiUsage")
private void registerFluidSupport() {
FluidSupportProvider.INSTANCE.registerFluidProvider(new FluidSupportProvider.FluidProvider() {
@Override
@NotNull
public EntryStack itemToFluid(@NotNull EntryStack itemStack) {
if (itemStack.getItem() instanceof ItemFluidInfo) {
Fluid fluid = ((ItemFluidInfo) itemStack.getItem()).getFluid(itemStack.getItemStack());
if (fluid != null)
return EntryStack.create(fluid);
}
return EntryStack.empty();
}
});
} }
@Override @Override
public void postRegister() { public void postRegister() {
// Alright we are going to apply check tags to cells, this should not take long at all. // Alright we are going to apply check tags to cells, this should not take long at all.
// Check Tags will not check the amount of the ItemStack, but will enable checking their tags. // Check Tags will not check the amount of the ItemStack, but will enable checking their tags.
for (EntryStack stack : EntryRegistry.getInstance().getStacksList()) EntryRegistry.getInstance().getEntryStacks().forEach(ReiPlugin::applyCellEntry);
applyCellEntry(stack);
} }
public static void applyCellEntry(EntryStack stack) { public static void applyCellEntry(EntryStack stack) {
// getItem can be null but this works // getItem can be null but this works
if (stack.getItem() == TRContent.CELL) if (stack.getItem() == TRContent.CELL)
stack.addSetting(EntryStack.Settings.CHECK_TAGS, EntryStack.Settings.TRUE); stack.setting(EntryStack.Settings.CHECK_TAGS, EntryStack.Settings.TRUE);
} }
private void registerFluidGeneratorDisplays(RecipeHelper recipeHelper, EFluidGenerator generator, Machine machine) { private void registerFluidGeneratorDisplays(RecipeHelper recipeHelper, EFluidGenerator generator, Machine machine) {
@ -200,7 +239,6 @@ public class ReiPlugin implements REIPluginV0 {
}; };
} }
recipeHelper.registerRecipes(recipeType.getName(), (Predicate<Recipe>) recipe -> { recipeHelper.registerRecipes(recipeType.getName(), (Predicate<Recipe>) recipe -> {
if (recipe instanceof RebornRecipe) { if (recipe instanceof RebornRecipe) {
return ((RebornRecipe) recipe).getRebornRecipeType() == recipeType; return ((RebornRecipe) recipe).getRebornRecipeType() == recipeType;
@ -236,4 +274,171 @@ public class ReiPlugin implements REIPluginV0 {
return Collections.emptyList(); return Collections.emptyList();
}); });
} }
public static Widget createProgressBar(int x, int y, double animationDuration, GuiBuilder.ProgressDirection direction) {
return Widgets.createDrawableWidget((helper, matrices, mouseX, mouseY, delta) -> {
MinecraftClient.getInstance().getTextureManager().bindTexture(GuiBuilder.defaultTextureSheet);
helper.drawTexture(matrices, x, y, direction.x, direction.y, direction.width, direction.height);
int j = (int) ((System.currentTimeMillis() / animationDuration) % 1.0 * 16.0);
if (j < 0) {
j = 0;
}
switch (direction) {
case RIGHT:
helper.drawTexture(matrices, x, y, direction.xActive, direction.yActive, j, 10);
break;
case LEFT:
helper.drawTexture(matrices, x + 16 - j, y, direction.xActive + 16 - j, direction.yActive, j, 10);
break;
case UP:
helper.drawTexture(matrices, x, y + 16 - j, direction.xActive, direction.yActive + 16 - j, 10, j);
break;
case DOWN:
helper.drawTexture(matrices, x, y, direction.xActive, direction.yActive, 10, j);
break;
}
});
}
public static Widget createEnergyDisplay(Rectangle bounds, double energy, EntryAnimation animation, Function<Point, Tooltip> tooltipBuilder) {
return new EnergyEntryWidget(bounds, animation).entry(
new RenderingEntry() {
@Override
public void render(MatrixStack matrices, Rectangle bounds, int mouseX, int mouseY, float delta) {}
@Override
public @Nullable Tooltip getTooltip(Point mouse) {
return tooltipBuilder.apply(mouse);
}
}
).notFavoritesInteractable();
}
public static Widget createFluidDisplay(Rectangle bounds, EntryStack fluid, EntryAnimation animation) {
return new FluidEntryWidget(bounds, fluid.getFluid(), animation).entry(fluid);
}
private static class EnergyEntryWidget extends EntryWidget {
private EntryAnimation animation;
protected EnergyEntryWidget(Rectangle rectangle, EntryAnimation animation) {
super(rectangle.x, rectangle.y);
this.getBounds().setBounds(rectangle);
this.animation = animation;
}
@Override
protected void drawBackground(MatrixStack matrices, int mouseX, int mouseY, float delta) {
if (background) {
Rectangle bounds = getBounds();
int width = bounds.width;
int height = bounds.height;
int innerHeight = height - 2;
PowerSystem.EnergySystem displayPower = PowerSystem.getDisplayPower();
MinecraftClient.getInstance().getTextureManager().bindTexture(GuiBuilder.defaultTextureSheet);
drawTexture(matrices, bounds.x, bounds.y, displayPower.xBar - 15, displayPower.yBar - 1, width, height);
int innerDisplayHeight;
if (animation.animationType != EntryAnimationType.NONE) {
innerDisplayHeight = MathHelper.ceil((System.currentTimeMillis() / (animation.duration / innerHeight) % innerHeight) / 1f);
if (animation.animationType == EntryAnimationType.DOWNWARDS)
innerDisplayHeight = innerHeight - innerDisplayHeight;
} else innerDisplayHeight = innerHeight;
drawTexture(matrices, bounds.x + 1, bounds.y + 1 + innerHeight - innerDisplayHeight, displayPower.xBar, innerHeight + displayPower.yBar - innerDisplayHeight, width - 2, innerDisplayHeight);
}
}
@Override
protected void drawCurrentEntry(MatrixStack matrices, int mouseX, int mouseY, float delta) {}
}
private static class FluidEntryWidget extends EntryWidget {
private Fluid fluid;
private EntryAnimation animation;
protected FluidEntryWidget(Rectangle rectangle, Fluid fluid, EntryAnimation animation) {
super(rectangle.x, rectangle.y);
this.getBounds().setBounds(rectangle);
this.fluid = fluid;
this.animation = animation;
}
@Override
protected void drawBackground(MatrixStack matrices, int mouseX, int mouseY, float delta) {
if (background) {
Rectangle bounds = getBounds();
int width = bounds.width;
int height = bounds.height;
int innerHeight = height - 2;
PowerSystem.EnergySystem displayPower = PowerSystem.getDisplayPower();
MinecraftClient.getInstance().getTextureManager().bindTexture(GuiBuilder.defaultTextureSheet);
drawTexture(matrices, bounds.x - 3, bounds.y - 3, 194, 26, width + 6, height + 6);
drawTexture(matrices, bounds.x, bounds.y, 194, 82, width, height);
int innerDisplayHeight;
if (animation.animationType != EntryAnimationType.NONE) {
innerDisplayHeight = MathHelper.ceil((System.currentTimeMillis() / (animation.duration / innerHeight) % innerHeight) / 1f);
if (animation.animationType == EntryAnimationType.DOWNWARDS)
innerDisplayHeight = innerHeight - innerDisplayHeight;
} else innerDisplayHeight = innerHeight;
drawFluid(matrices, fluid, innerDisplayHeight, bounds.x + 1, bounds.y + 1, width - 2, innerHeight);
}
}
public void drawFluid(MatrixStack matrixStack, Fluid fluid, int drawHeight, int x, int y, int width, int height) {
MinecraftClient.getInstance().getTextureManager().bindTexture(SpriteAtlasTexture.BLOCK_ATLAS_TEX);
y += height;
final Sprite sprite = FluidRenderHandlerRegistry.INSTANCE.get(fluid).getFluidSprites(MinecraftClient.getInstance().world, BlockPos.ORIGIN, fluid.getDefaultState())[0];
int color = FluidRenderHandlerRegistry.INSTANCE.get(fluid).getFluidColor(MinecraftClient.getInstance().world, BlockPos.ORIGIN, fluid.getDefaultState());
final int iconHeight = sprite.getHeight();
int offsetHeight = drawHeight;
RenderSystem.color3f((color >> 16 & 255) / 255.0F, (float) (color >> 8 & 255) / 255.0F, (float) (color & 255) / 255.0F);
int iteration = 0;
while (offsetHeight != 0) {
final int curHeight = Math.min(offsetHeight, iconHeight);
DrawableHelper.drawSprite(matrixStack, x, y - offsetHeight, 0, width, curHeight, sprite);
offsetHeight -= curHeight;
iteration++;
if (iteration > 50) {
break;
}
}
}
@Override
protected void drawCurrentEntry(MatrixStack matrices, int mouseX, int mouseY, float delta) {}
}
public static class EntryAnimation {
private final EntryAnimationType animationType;
private final long duration;
private EntryAnimation(EntryAnimationType animationType, long duration) {
this.animationType = animationType;
this.duration = duration;
}
public static EntryAnimation upwards(long duration) {
return new EntryAnimation(EntryAnimationType.UPWARDS, duration);
}
public static EntryAnimation downwards(long duration) {
return new EntryAnimation(EntryAnimationType.DOWNWARDS, duration);
}
public static EntryAnimation none() {
return new EntryAnimation(EntryAnimationType.NONE, 0);
}
}
public enum EntryAnimationType {
UPWARDS,
DOWNWARDS,
NONE
}
} }

View file

@ -24,21 +24,24 @@
package techreborn.compat.rei.fluidgenerator; package techreborn.compat.rei.fluidgenerator;
import me.shedaniel.math.Point; import com.google.common.collect.Lists;
import me.shedaniel.math.Rectangle; import me.shedaniel.math.Rectangle;
import me.shedaniel.rei.api.ClientHelper;
import me.shedaniel.rei.api.EntryStack; import me.shedaniel.rei.api.EntryStack;
import me.shedaniel.rei.api.RecipeCategory; import me.shedaniel.rei.api.RecipeCategory;
import me.shedaniel.rei.api.widgets.Label; import me.shedaniel.rei.api.widgets.Tooltip;
import me.shedaniel.rei.api.widgets.Widgets; import me.shedaniel.rei.api.widgets.Widgets;
import me.shedaniel.rei.gui.widget.Widget; import me.shedaniel.rei.gui.widget.Widget;
import net.minecraft.client.resource.language.I18n; import net.minecraft.client.resource.language.I18n;
import net.minecraft.text.Text; import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText; import net.minecraft.text.TranslatableText;
import net.minecraft.util.Formatting;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import reborncore.client.gui.guibuilder.GuiBuilder;
import techreborn.TechReborn; import techreborn.TechReborn;
import techreborn.compat.rei.ReiPlugin;
import techreborn.init.TRContent; import techreborn.init.TRContent;
import java.util.LinkedList;
import java.util.List; import java.util.List;
public class FluidGeneratorRecipeCategory implements RecipeCategory<FluidGeneratorRecipeDisplay> { public class FluidGeneratorRecipeCategory implements RecipeCategory<FluidGeneratorRecipeDisplay> {
@ -67,29 +70,19 @@ public class FluidGeneratorRecipeCategory implements RecipeCategory<FluidGenerat
} }
@Override @Override
public List<Widget> setupDisplay(FluidGeneratorRecipeDisplay machineRecipe, Rectangle bounds) { public List<Widget> setupDisplay(FluidGeneratorRecipeDisplay recipeDisplay, Rectangle bounds) {
Point startPoint = new Point(bounds.getCenterX() - 41, bounds.getCenterY() - 13); List<Widget> widgets = Lists.newArrayList();
List<Widget> widgets = new LinkedList<>();
widgets.add(Widgets.createRecipeBase(bounds)); widgets.add(Widgets.createRecipeBase(bounds));
widgets.add(Widgets.createArrow(new Point(startPoint.x + 26, startPoint.y + 1)).animationDurationMS(1000.0)); widgets.add(ReiPlugin.createEnergyDisplay(new Rectangle(bounds.x + 108, bounds.y + 8, 14, 50), recipeDisplay.getTotalEnergy(), ReiPlugin.EntryAnimation.upwards(5000), point -> {
List<Text> list = Lists.newArrayList();
for (List<EntryStack> inputs : machineRecipe.getInputEntries()) { list.add(Text.method_30163("Energy"));
widgets.add(Widgets.createSlot(new Point(startPoint.x + 1, startPoint.y + 1)).entries(inputs).markInput()); list.add(new TranslatableText("techreborn.jei.recipe.generator.total", recipeDisplay.getTotalEnergy()).formatted(Formatting.GRAY));
} list.add(Text.method_30163(""));
list.add(ClientHelper.getInstance().getFormattedModFromIdentifier(new Identifier("techreborn", "")));
Text energyPerTick = new TranslatableText("techreborn.jei.recipe.generator.total", machineRecipe.getTotalEnergy()); return Tooltip.create(point, list);
Label costLabel; }));
widgets.add(costLabel = Widgets.createLabel(new Point(bounds.getCenterX(), startPoint.y + 20), energyPerTick)); widgets.add(ReiPlugin.createFluidDisplay(new Rectangle(bounds.x + 16, bounds.y + 8, 16, 50), recipeDisplay.getInputEntries().get(0).get(0), ReiPlugin.EntryAnimation.downwards(5000)));
costLabel.shadow(false); widgets.add(ReiPlugin.createProgressBar(bounds.x + 76 - 16, bounds.y + 48 - 19, 5000, GuiBuilder.ProgressDirection.RIGHT));
costLabel.color(0xFF404040, 0xFFBBBBBB);
return widgets; return widgets;
} }
@Override
public int getDisplayHeight() {
return 37;
}
} }

View file

@ -29,7 +29,6 @@ import me.shedaniel.rei.api.EntryStack;
import me.shedaniel.rei.api.RecipeDisplay; import me.shedaniel.rei.api.RecipeDisplay;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import techreborn.api.generator.FluidGeneratorRecipe; import techreborn.api.generator.FluidGeneratorRecipe;
import techreborn.compat.rei.RebornEntryStack;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
@ -44,7 +43,7 @@ public class FluidGeneratorRecipeDisplay implements RecipeDisplay {
this.category = category; this.category = category;
this.inputs = Lists.newArrayList(); this.inputs = Lists.newArrayList();
this.totalEnergy = recipe.getEnergyPerBucket(); this.totalEnergy = recipe.getEnergyPerBucket();
inputs.add(Collections.singletonList(RebornEntryStack.create(recipe.getFluid(), 1000))); inputs.add(Collections.singletonList(EntryStack.create(recipe.getFluid(), 1000)));
} }
@Override @Override
@ -52,6 +51,11 @@ public class FluidGeneratorRecipeDisplay implements RecipeDisplay {
return inputs; return inputs;
} }
@Override
public List<List<EntryStack>> getRequiredEntries() {
return inputs;
}
@Override @Override
public List<EntryStack> getOutputEntries() { public List<EntryStack> getOutputEntries() {
return Lists.newArrayList(); return Lists.newArrayList();
@ -65,5 +69,4 @@ public class FluidGeneratorRecipeDisplay implements RecipeDisplay {
public int getTotalEnergy() { public int getTotalEnergy() {
return totalEnergy; return totalEnergy;
} }
} }

View file

@ -24,23 +24,27 @@
package techreborn.compat.rei.fluidreplicator; package techreborn.compat.rei.fluidreplicator;
import com.google.common.collect.Lists;
import me.shedaniel.math.Point; import me.shedaniel.math.Point;
import me.shedaniel.math.Rectangle; import me.shedaniel.math.Rectangle;
import me.shedaniel.rei.api.ClientHelper;
import me.shedaniel.rei.api.EntryStack; import me.shedaniel.rei.api.EntryStack;
import me.shedaniel.rei.api.RecipeCategory; import me.shedaniel.rei.api.RecipeCategory;
import me.shedaniel.rei.api.widgets.Label; import me.shedaniel.rei.api.widgets.Tooltip;
import me.shedaniel.rei.api.widgets.Widgets; import me.shedaniel.rei.api.widgets.Widgets;
import me.shedaniel.rei.gui.widget.Widget; import me.shedaniel.rei.gui.widget.Widget;
import net.minecraft.client.resource.language.I18n; import net.minecraft.client.resource.language.I18n;
import net.minecraft.item.Items; import net.minecraft.item.Items;
import net.minecraft.text.Text; import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText; import net.minecraft.text.TranslatableText;
import net.minecraft.util.Formatting;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import reborncore.client.gui.guibuilder.GuiBuilder;
import reborncore.common.crafting.RebornRecipeType; import reborncore.common.crafting.RebornRecipeType;
import techreborn.api.recipe.recipes.FluidReplicatorRecipe; import techreborn.api.recipe.recipes.FluidReplicatorRecipe;
import techreborn.compat.rei.ReiPlugin; import techreborn.compat.rei.ReiPlugin;
import java.util.LinkedList; import java.text.DecimalFormat;
import java.util.List; import java.util.List;
public class FluidReplicatorRecipeCategory implements RecipeCategory<FluidReplicatorRecipeDisplay> { public class FluidReplicatorRecipeCategory implements RecipeCategory<FluidReplicatorRecipeDisplay> {
@ -49,7 +53,6 @@ public class FluidReplicatorRecipeCategory implements RecipeCategory<FluidReplic
public FluidReplicatorRecipeCategory(RebornRecipeType<FluidReplicatorRecipe> recipeType) { public FluidReplicatorRecipeCategory(RebornRecipeType<FluidReplicatorRecipe> recipeType) {
this.rebornRecipeType = recipeType; this.rebornRecipeType = recipeType;
} }
@Override @Override
@ -68,26 +71,29 @@ public class FluidReplicatorRecipeCategory implements RecipeCategory<FluidReplic
} }
@Override @Override
public List<Widget> setupDisplay(FluidReplicatorRecipeDisplay machineRecipe, Rectangle bounds) { public List<Widget> setupDisplay(FluidReplicatorRecipeDisplay recipeDisplay, Rectangle bounds) {
Point startPoint = new Point(bounds.getCenterX() - 41, bounds.getCenterY() - 13); Point startPoint = new Point(bounds.getCenterX() - 41, bounds.getCenterY() - 13);
List<Widget> widgets = new LinkedList<>(); List<Widget> widgets = Lists.newArrayList();
widgets.add(Widgets.createRecipeBase(bounds)); widgets.add(Widgets.createRecipeBase(bounds));
widgets.add(Widgets.createArrow(new Point(startPoint.x + 26, startPoint.y + 1)).animationDurationTicks(machineRecipe.getTime())); widgets.add(ReiPlugin.createEnergyDisplay(new Rectangle(bounds.x + 8, bounds.y + 8, 14, 50), recipeDisplay.getEnergy(), ReiPlugin.EntryAnimation.downwards(5000), point -> {
List<Text> list = Lists.newArrayList();
list.add(Text.method_30163("Energy"));
list.add(new TranslatableText("techreborn.jei.recipe.running.cost", "E", recipeDisplay.getEnergy()).formatted(Formatting.GRAY));
list.add(Text.method_30163(""));
list.add(ClientHelper.getInstance().getFormattedModFromIdentifier(new Identifier("techreborn", "")));
return Tooltip.create(point, list);
}));
int i = 0; widgets.add(Widgets.createSlot(new Point(bounds.x + 46, bounds.y + 26)).entries(recipeDisplay.getInputEntries().get(0)).markInput());
for (List<EntryStack> inputs : machineRecipe.getInputEntries()) { widgets.add(ReiPlugin.createProgressBar(bounds.x + 46 + 21, bounds.y + 30, recipeDisplay.getTime() * 50, GuiBuilder.ProgressDirection.RIGHT));
widgets.add(Widgets.createSlot(new Point(startPoint.x + 1, startPoint.y + 1 + (i++ * 20))).entries(inputs).markInput()); widgets.add(ReiPlugin.createFluidDisplay(new Rectangle(bounds.x + 46 + 46, bounds.y + 8, 16, 50), recipeDisplay.getOutputEntries().get(0), ReiPlugin.EntryAnimation.upwards(5000)));
}
Text energyPerTick = new TranslatableText("techreborn.jei.recipe.running.cost", "E", machineRecipe.getEnergy()); widgets.add(Widgets.createLabel(new Point(bounds.x + 24, bounds.y + 5), new TranslatableText("techreborn.jei.recipe.processing.time.3", new DecimalFormat("###.##").format(recipeDisplay.getTime() / 20.0)))
Label costLabel; .shadow(false)
widgets.add(costLabel = Widgets.createLabel(new Point(startPoint.x + 1, startPoint.y + 1 + (i++ * 20)), energyPerTick)); .leftAligned()
costLabel.shadow(false); .color(0xFF404040, 0xFFBBBBBB)
costLabel.color(0xFF404040, 0xFFBBBBBB); );
if (!machineRecipe.getOutputEntries().isEmpty())
widgets.add(Widgets.createSlot(new Point(startPoint.x + 61, startPoint.y + 1)).entries(machineRecipe.getOutputEntries()).markInput());
return widgets; return widgets;
} }

View file

@ -28,12 +28,13 @@ import me.shedaniel.rei.api.EntryStack;
import me.shedaniel.rei.api.RecipeDisplay; import me.shedaniel.rei.api.RecipeDisplay;
import me.shedaniel.rei.utils.CollectionUtils; import me.shedaniel.rei.utils.CollectionUtils;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import reborncore.common.crafting.RebornRecipe;
import reborncore.common.fluid.container.FluidInstance; import reborncore.common.fluid.container.FluidInstance;
import techreborn.api.recipe.recipes.FluidReplicatorRecipe; import techreborn.api.recipe.recipes.FluidReplicatorRecipe;
import techreborn.compat.rei.RebornEntryStack;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Optional;
/** /**
* @author drcrazy * @author drcrazy
@ -49,9 +50,9 @@ public class FluidReplicatorRecipeDisplay implements RecipeDisplay {
public FluidReplicatorRecipeDisplay(FluidReplicatorRecipe recipe) { public FluidReplicatorRecipeDisplay(FluidReplicatorRecipe recipe) {
this.recipe = recipe; this.recipe = recipe;
this.inputs = CollectionUtils.map(recipe.getRebornIngredients(), ing -> CollectionUtils.map(ing.getPreviewStacks(), RebornEntryStack::create)); this.inputs = CollectionUtils.map(recipe.getRebornIngredients(), ing -> EntryStack.ofItemStacks(ing.getPreviewStacks()));
this.fluidInstance = recipe.getFluidInstance(); this.fluidInstance = recipe.getFluidInstance();
this.output = fluidInstance == null ? Collections.emptyList() : Collections.singletonList(RebornEntryStack.create(fluidInstance.getFluid(), fluidInstance.getAmount().getRawValue())); this.output = fluidInstance == null ? Collections.emptyList() : Collections.singletonList(EntryStack.create(fluidInstance.getFluid(), fluidInstance.getAmount().getRawValue()));
this.energy = recipe.getPower(); this.energy = recipe.getPower();
this.time = recipe.getTime(); this.time = recipe.getTime();
} }
@ -87,4 +88,9 @@ public class FluidReplicatorRecipeDisplay implements RecipeDisplay {
public Identifier getRecipeCategory() { public Identifier getRecipeCategory() {
return recipe.getRebornRecipeType().getName(); return recipe.getRebornRecipeType().getName();
} }
@Override
public Optional<Identifier> getRecipeLocation() {
return Optional.ofNullable(recipe).map(RebornRecipe::getId);
}
} }

View file

@ -0,0 +1,39 @@
package techreborn.compat.rei.machine;
import com.google.common.collect.Lists;
import me.shedaniel.math.Rectangle;
import me.shedaniel.rei.api.ClientHelper;
import me.shedaniel.rei.api.widgets.Tooltip;
import me.shedaniel.rei.api.widgets.Widgets;
import me.shedaniel.rei.gui.widget.Widget;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
import net.minecraft.util.Formatting;
import net.minecraft.util.Identifier;
import reborncore.common.crafting.RebornRecipe;
import reborncore.common.crafting.RebornRecipeType;
import techreborn.compat.rei.MachineRecipeDisplay;
import techreborn.compat.rei.ReiPlugin;
import java.util.List;
public abstract class AbstractEnergyConsumingMachineCategory<R extends RebornRecipe> extends AbstractMachineCategory<R> {
public AbstractEnergyConsumingMachineCategory(RebornRecipeType<R> rebornRecipeType) {
super(rebornRecipeType);
}
@Override
public List<Widget> setupDisplay(MachineRecipeDisplay<R> recipeDisplay, Rectangle bounds) {
List<Widget> widgets = Lists.newArrayList();
widgets.add(Widgets.createRecipeBase(bounds));
widgets.add(ReiPlugin.createEnergyDisplay(new Rectangle(bounds.x + 8, bounds.y + 8, 14, 50), recipeDisplay.getEnergy(), ReiPlugin.EntryAnimation.downwards(5000), point -> {
List<Text> list = Lists.newArrayList();
list.add(Text.method_30163("Energy"));
list.add(new TranslatableText("techreborn.jei.recipe.running.cost", "E", recipeDisplay.getEnergy()).formatted(Formatting.GRAY));
list.add(Text.method_30163(""));
list.add(ClientHelper.getInstance().getFormattedModFromIdentifier(new Identifier("techreborn", "")));
return Tooltip.create(point, list);
}));
return widgets;
}
}

View file

@ -0,0 +1,54 @@
package techreborn.compat.rei.machine;
import me.shedaniel.rei.api.EntryStack;
import me.shedaniel.rei.api.RecipeCategory;
import me.shedaniel.rei.gui.entries.RecipeEntry;
import me.shedaniel.rei.gui.entries.SimpleRecipeEntry;
import net.minecraft.client.resource.language.I18n;
import net.minecraft.item.Items;
import net.minecraft.util.Identifier;
import reborncore.common.crafting.RebornRecipe;
import reborncore.common.crafting.RebornRecipeType;
import techreborn.compat.rei.MachineRecipeDisplay;
import techreborn.compat.rei.ReiPlugin;
import java.util.Collections;
import java.util.List;
public abstract class AbstractMachineCategory<R extends RebornRecipe> implements RecipeCategory<MachineRecipeDisplay<R>> {
private final RebornRecipeType<R> rebornRecipeType;
public AbstractMachineCategory(RebornRecipeType<R> rebornRecipeType) {
this.rebornRecipeType = rebornRecipeType;
}
@Override
public Identifier getIdentifier() {
return rebornRecipeType.getName();
}
@Override
public String getCategoryName() {
return I18n.translate(rebornRecipeType.getName().toString());
}
@Override
public EntryStack getLogo() {
return EntryStack.create(ReiPlugin.iconMap.getOrDefault(rebornRecipeType, () -> Items.DIAMOND_SHOVEL));
}
@Override
public RecipeEntry getSimpleRenderer(MachineRecipeDisplay<R> recipe) {
return SimpleRecipeEntry.create(Collections.singletonList(recipe.getInputEntries().get(0)), recipe.getOutputEntries());
}
public List<EntryStack> getInput(MachineRecipeDisplay<R> recipeDisplay, int index) {
List<List<EntryStack>> inputs = recipeDisplay.getInputEntries();
return inputs.size() > index ? inputs.get(index) : Collections.emptyList();
}
public List<EntryStack> getOutput(MachineRecipeDisplay<R> recipeDisplay, int index) {
List<EntryStack> outputs = recipeDisplay.getOutputEntries();
return outputs.size() > index ? Collections.singletonList(outputs.get(index)) : Collections.emptyList();
}
}

View file

@ -0,0 +1,38 @@
package techreborn.compat.rei.machine;
import me.shedaniel.math.Point;
import me.shedaniel.math.Rectangle;
import me.shedaniel.rei.api.widgets.Widgets;
import me.shedaniel.rei.gui.widget.Widget;
import net.minecraft.text.TranslatableText;
import reborncore.client.gui.guibuilder.GuiBuilder;
import reborncore.common.crafting.RebornRecipe;
import reborncore.common.crafting.RebornRecipeType;
import techreborn.compat.rei.MachineRecipeDisplay;
import techreborn.compat.rei.ReiPlugin;
import java.text.DecimalFormat;
import java.util.List;
public class AssemblingMachineCategory<R extends RebornRecipe> extends AbstractEnergyConsumingMachineCategory<R> {
public AssemblingMachineCategory(RebornRecipeType<R> rebornRecipeType) {
super(rebornRecipeType);
}
@Override
public List<Widget> setupDisplay(MachineRecipeDisplay<R> recipeDisplay, Rectangle bounds) {
List<Widget> widgets = super.setupDisplay(recipeDisplay, bounds);
widgets.add(Widgets.createSlot(new Point(bounds.x + 55 - 9, bounds.y + 35 - 19)).entries(getInput(recipeDisplay, 0)).markInput());
widgets.add(Widgets.createSlot(new Point(bounds.x + 55 - 9, bounds.y + 55 - 19)).entries(getInput(recipeDisplay, 1)).markInput());
widgets.add(Widgets.createResultSlotBackground(new Point(bounds.x + 101 - 9, bounds.y + 45 - 19)));
widgets.add(Widgets.createSlot(new Point(bounds.x + 101 - 9, bounds.y + 45 - 19)).entries(getOutput(recipeDisplay, 0)).disableBackground().markOutput());
widgets.add(ReiPlugin.createProgressBar(bounds.x + 76 - 9, bounds.y + 48 - 19, recipeDisplay.getTime() * 50, GuiBuilder.ProgressDirection.RIGHT));
widgets.add(Widgets.createLabel(new Point(bounds.getMaxX() - 5, bounds.y + 5), new TranslatableText("techreborn.jei.recipe.processing.time.3", new DecimalFormat("###.##").format(recipeDisplay.getTime() / 20.0)))
.shadow(false)
.rightAligned()
.color(0xFF404040, 0xFFBBBBBB)
);
return widgets;
}
}

View file

@ -0,0 +1,48 @@
package techreborn.compat.rei.machine;
import me.shedaniel.math.Point;
import me.shedaniel.math.Rectangle;
import me.shedaniel.rei.api.widgets.Widgets;
import me.shedaniel.rei.gui.widget.Widget;
import net.minecraft.text.LiteralText;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
import reborncore.client.gui.guibuilder.GuiBuilder;
import reborncore.common.crafting.RebornRecipe;
import reborncore.common.crafting.RebornRecipeType;
import techreborn.compat.rei.MachineRecipeDisplay;
import techreborn.compat.rei.ReiPlugin;
import java.text.DecimalFormat;
import java.util.List;
public class BlastFurnaceCategory<R extends RebornRecipe> extends AbstractEnergyConsumingMachineCategory<R> {
public BlastFurnaceCategory(RebornRecipeType<R> rebornRecipeType) {
super(rebornRecipeType);
}
@Override
public List<Widget> setupDisplay(MachineRecipeDisplay<R> recipeDisplay, Rectangle bounds) {
List<Widget> widgets = super.setupDisplay(recipeDisplay, bounds);
widgets.add(Widgets.createSlot(new Point(bounds.x + 55 - 17, bounds.y + 35 - 19)).entries(getInput(recipeDisplay, 0)).markInput());
widgets.add(Widgets.createSlot(new Point(bounds.x + 55 - 17, bounds.y + 55 - 19)).entries(getInput(recipeDisplay, 1)).markInput());
widgets.add(Widgets.createSlotBase(new Rectangle(bounds.x + 101 - 17 - 5, bounds.y + 45 - 19 - 5, 46, 26)));
widgets.add(Widgets.createSlot(new Point(bounds.x + 101 - 17, bounds.y + 45 - 19)).entries(getOutput(recipeDisplay, 0)).disableBackground().markOutput());
widgets.add(Widgets.createSlot(new Point(bounds.x + 101 + 20 - 17, bounds.y + 45 - 19)).entries(getOutput(recipeDisplay, 1)).disableBackground().markOutput());
widgets.add(ReiPlugin.createProgressBar(bounds.x + 76 - 17, bounds.y + 48 - 19, recipeDisplay.getTime() * 50, GuiBuilder.ProgressDirection.RIGHT));
Text neededHeat = new LiteralText(String.valueOf(recipeDisplay.getHeat())).append(" ").append(new TranslatableText("techreborn.jei.recipe.heat"));
widgets.add(Widgets.createLabel(new Point(bounds.getMaxX() - 5, bounds.y + 5), neededHeat)
.shadow(false)
.rightAligned()
.color(0xFF404040, 0xFFBBBBBB)
);
widgets.add(Widgets.createLabel(new Point(bounds.x + 24, bounds.y + 5), new TranslatableText("techreborn.jei.recipe.processing.time.3", new DecimalFormat("###.##").format(recipeDisplay.getTime() / 20.0)))
.shadow(false)
.leftAligned()
.color(0xFF404040, 0xFFBBBBBB)
);
return widgets;
}
}

View file

@ -0,0 +1,40 @@
package techreborn.compat.rei.machine;
import me.shedaniel.math.Point;
import me.shedaniel.math.Rectangle;
import me.shedaniel.rei.api.widgets.Widgets;
import me.shedaniel.rei.gui.widget.Widget;
import net.minecraft.text.TranslatableText;
import reborncore.client.gui.guibuilder.GuiBuilder;
import reborncore.common.crafting.RebornRecipe;
import reborncore.common.crafting.RebornRecipeType;
import techreborn.compat.rei.MachineRecipeDisplay;
import techreborn.compat.rei.ReiPlugin;
import java.text.DecimalFormat;
import java.util.List;
public class DistillationTowerCategory<R extends RebornRecipe> extends AbstractEnergyConsumingMachineCategory<R> {
public DistillationTowerCategory(RebornRecipeType<R> rebornRecipeType) {
super(rebornRecipeType);
}
@Override
public List<Widget> setupDisplay(MachineRecipeDisplay<R> recipeDisplay, Rectangle bounds) {
List<Widget> widgets = super.setupDisplay(recipeDisplay, bounds);
widgets.add(Widgets.createSlot(new Point(bounds.x + 55 - 23, bounds.y + 35 - 19)).entries(getInput(recipeDisplay, 0)).markInput());
widgets.add(Widgets.createSlot(new Point(bounds.x + 55 - 23, bounds.y + 55 - 19)).entries(getInput(recipeDisplay, 1)).markInput());
widgets.add(Widgets.createSlotBase(new Rectangle(bounds.x + 101 - 23 - 5, bounds.y + 45 - 19 - 5, 66, 26)));
widgets.add(Widgets.createSlot(new Point(bounds.x + 101 - 23, bounds.y + 45 - 19)).entries(getOutput(recipeDisplay, 0)).disableBackground().markOutput());
widgets.add(Widgets.createSlot(new Point(bounds.x + 101 + 20 - 23, bounds.y + 45 - 19)).entries(getOutput(recipeDisplay, 1)).disableBackground().markOutput());
widgets.add(Widgets.createSlot(new Point(bounds.x + 101 + 40 - 23, bounds.y + 45 - 19)).entries(getOutput(recipeDisplay, 2)).disableBackground().markOutput());
widgets.add(ReiPlugin.createProgressBar(bounds.x + 76 - 23, bounds.y + 48 - 19, recipeDisplay.getTime() * 50, GuiBuilder.ProgressDirection.RIGHT));
widgets.add(Widgets.createLabel(new Point(bounds.getMaxX() - 5, bounds.y + 5), new TranslatableText("techreborn.jei.recipe.processing.time.3", new DecimalFormat("###.##").format(recipeDisplay.getTime() / 20.0)))
.shadow(false)
.rightAligned()
.color(0xFF404040, 0xFFBBBBBB)
);
return widgets;
}
}

View file

@ -0,0 +1,46 @@
package techreborn.compat.rei.machine;
import me.shedaniel.math.Point;
import me.shedaniel.math.Rectangle;
import me.shedaniel.rei.api.widgets.Widgets;
import me.shedaniel.rei.gui.widget.Widget;
import net.minecraft.text.TranslatableText;
import reborncore.client.gui.guibuilder.GuiBuilder;
import reborncore.common.crafting.RebornRecipe;
import reborncore.common.crafting.RebornRecipeType;
import techreborn.compat.rei.MachineRecipeDisplay;
import techreborn.compat.rei.ReiPlugin;
import java.text.DecimalFormat;
import java.util.List;
public class ElectrolyzerCategory<R extends RebornRecipe> extends AbstractEnergyConsumingMachineCategory<R> {
public ElectrolyzerCategory(RebornRecipeType<R> rebornRecipeType) {
super(rebornRecipeType);
}
@Override
public List<Widget> setupDisplay(MachineRecipeDisplay<R> recipeDisplay, Rectangle bounds) {
List<Widget> widgets = super.setupDisplay(recipeDisplay, bounds);
widgets.add(Widgets.createSlot(new Point(bounds.x + 55 - 20, bounds.y + 41)).entries(getInput(recipeDisplay, 0)).markInput());
widgets.add(Widgets.createSlot(new Point(bounds.x + 55, bounds.y + 41)).entries(getInput(recipeDisplay, 1)).markInput());
widgets.add(Widgets.createSlotBase(new Rectangle(bounds.x + 55 + 17 - 9 - 20 - 5, bounds.y + 36 - 22 - 5, 86, 26)));
widgets.add(Widgets.createSlot(new Point(bounds.x + 55 + 17 - 9 - 20, bounds.y + 36 - 22)).entries(getOutput(recipeDisplay, 0)).disableBackground().markOutput());
widgets.add(Widgets.createSlot(new Point(bounds.x + 55 + 17 - 9, bounds.y + 36 - 22)).entries(getOutput(recipeDisplay, 1)).disableBackground().markOutput());
widgets.add(Widgets.createSlot(new Point(bounds.x + 55 + 17 - 9 + 20, bounds.y + 36 - 22)).entries(getOutput(recipeDisplay, 2)).disableBackground().markOutput());
widgets.add(Widgets.createSlot(new Point(bounds.x + 55 + 17 - 9 + 40, bounds.y + 36 - 22)).entries(getOutput(recipeDisplay, 3)).disableBackground().markOutput());
widgets.add(ReiPlugin.createProgressBar(bounds.x + 55 + 21, bounds.y + 36 + 4, recipeDisplay.getTime() * 50, GuiBuilder.ProgressDirection.UP));
widgets.add(Widgets.createLabel(new Point(bounds.getMaxX() - 17, bounds.getMaxY() - 13), new TranslatableText("techreborn.jei.recipe.processing.time.3", new DecimalFormat("###.##").format(recipeDisplay.getTime() / 20.0)))
.shadow(false)
.rightAligned()
.color(0xFF404040, 0xFFBBBBBB)
);
return widgets;
}
@Override
public int getDisplayHeight() {
return 66;
}
}

View file

@ -0,0 +1,60 @@
package techreborn.compat.rei.machine;
import com.google.common.collect.Lists;
import me.shedaniel.math.Point;
import me.shedaniel.math.Rectangle;
import me.shedaniel.rei.api.ClientHelper;
import me.shedaniel.rei.api.widgets.Tooltip;
import me.shedaniel.rei.api.widgets.Widgets;
import me.shedaniel.rei.gui.widget.Widget;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
import net.minecraft.util.Formatting;
import net.minecraft.util.Identifier;
import reborncore.client.gui.guibuilder.GuiBuilder;
import reborncore.common.crafting.RebornRecipe;
import reborncore.common.crafting.RebornRecipeType;
import techreborn.compat.rei.MachineRecipeDisplay;
import techreborn.compat.rei.ReiPlugin;
import java.text.DecimalFormat;
import java.util.List;
public class GrinderCategory<R extends RebornRecipe> extends AbstractMachineCategory<R> {
public GrinderCategory(RebornRecipeType<R> rebornRecipeType) {
super(rebornRecipeType);
}
@Override
public List<Widget> setupDisplay(MachineRecipeDisplay<R> recipeDisplay, Rectangle bounds) {
List<Widget> widgets = Lists.newArrayList();
widgets.add(Widgets.createRecipeBase(bounds));
widgets.add(ReiPlugin.createEnergyDisplay(new Rectangle(bounds.x + 8, bounds.y + 18, 14, 50), recipeDisplay.getEnergy(), ReiPlugin.EntryAnimation.downwards(5000), point -> {
List<Text> list = Lists.newArrayList();
list.add(Text.method_30163("Energy"));
list.add(new TranslatableText("techreborn.jei.recipe.running.cost", "E", recipeDisplay.getEnergy()).formatted(Formatting.GRAY));
list.add(Text.method_30163(""));
list.add(ClientHelper.getInstance().getFormattedModFromIdentifier(new Identifier("techreborn", "")));
return Tooltip.create(point, list);
}));
widgets.add(Widgets.createSlot(new Point(bounds.x + 55, bounds.y + 36)).entries(getInput(recipeDisplay, 0)).markInput());
widgets.add(Widgets.createSlot(new Point(bounds.x + 55 + 46, bounds.y + 36 - 9 - 18)).entries(getOutput(recipeDisplay, 0)).markOutput());
widgets.add(Widgets.createSlot(new Point(bounds.x + 55 + 46, bounds.y + 36 - 9)).entries(getOutput(recipeDisplay, 1)).markOutput());
widgets.add(Widgets.createSlot(new Point(bounds.x + 55 + 46, bounds.y + 36 - 9 + 18)).entries(getOutput(recipeDisplay, 2)).markOutput());
widgets.add(Widgets.createSlot(new Point(bounds.x + 55 + 46, bounds.y + 36 - 9 + 36)).entries(getOutput(recipeDisplay, 3)).markOutput());
widgets.add(ReiPlugin.createProgressBar(bounds.x + 55 + 21, bounds.y + 36 + 4, recipeDisplay.getTime() * 50, GuiBuilder.ProgressDirection.RIGHT));
widgets.add(ReiPlugin.createFluidDisplay(new Rectangle(bounds.x + 55 - 26, bounds.y + 18, 16, 50), getInput(recipeDisplay, 1).get(0), ReiPlugin.EntryAnimation.downwards(5000)));
widgets.add(Widgets.createLabel(new Point(bounds.x + 51, bounds.y + 15), new TranslatableText("techreborn.jei.recipe.processing.time.3", new DecimalFormat("###.##").format(recipeDisplay.getTime() / 20.0)))
.shadow(false)
.leftAligned()
.color(0xFF404040, 0xFFBBBBBB)
);
return widgets;
}
@Override
public int getDisplayHeight() {
return 88;
}
}

View file

@ -0,0 +1,38 @@
package techreborn.compat.rei.machine;
import me.shedaniel.math.Point;
import me.shedaniel.math.Rectangle;
import me.shedaniel.rei.api.widgets.Widgets;
import me.shedaniel.rei.gui.widget.Widget;
import net.minecraft.text.TranslatableText;
import reborncore.client.gui.guibuilder.GuiBuilder;
import reborncore.common.crafting.RebornRecipe;
import reborncore.common.crafting.RebornRecipeType;
import techreborn.compat.rei.MachineRecipeDisplay;
import techreborn.compat.rei.ReiPlugin;
import java.text.DecimalFormat;
import java.util.List;
public class ImplosionCompressorCategory<R extends RebornRecipe> extends AbstractEnergyConsumingMachineCategory<R> {
public ImplosionCompressorCategory(RebornRecipeType<R> rebornRecipeType) {
super(rebornRecipeType);
}
@Override
public List<Widget> setupDisplay(MachineRecipeDisplay<R> recipeDisplay, Rectangle bounds) {
List<Widget> widgets = super.setupDisplay(recipeDisplay, bounds);
widgets.add(Widgets.createSlot(new Point(bounds.x + 55 - 15, bounds.y + 35 - 19)).entries(getInput(recipeDisplay, 0)).markInput());
widgets.add(Widgets.createSlot(new Point(bounds.x + 55 - 15, bounds.y + 55 - 19)).entries(getInput(recipeDisplay, 1)).markInput());
widgets.add(Widgets.createSlot(new Point(bounds.x + 97 - 15, bounds.y + 45 - 19)).entries(getOutput(recipeDisplay, 0)).markOutput());
widgets.add(Widgets.createSlot(new Point(bounds.x + 97 + 18 - 15, bounds.y + 45 - 19)).entries(getOutput(recipeDisplay, 1)).markOutput());
widgets.add(ReiPlugin.createProgressBar(bounds.x + 76 - 15, bounds.y + 48 - 19, recipeDisplay.getTime() * 50, GuiBuilder.ProgressDirection.RIGHT));
widgets.add(Widgets.createLabel(new Point(bounds.getMaxX() - 5, bounds.y + 5), new TranslatableText("techreborn.jei.recipe.processing.time.3", new DecimalFormat("###.##").format(recipeDisplay.getTime() / 20.0)))
.shadow(false)
.rightAligned()
.color(0xFF404040, 0xFFBBBBBB)
);
return widgets;
}
}

View file

@ -0,0 +1,40 @@
package techreborn.compat.rei.machine;
import me.shedaniel.math.Point;
import me.shedaniel.math.Rectangle;
import me.shedaniel.rei.api.widgets.Widgets;
import me.shedaniel.rei.gui.widget.Widget;
import net.minecraft.text.TranslatableText;
import reborncore.client.gui.guibuilder.GuiBuilder;
import reborncore.common.crafting.RebornRecipe;
import reborncore.common.crafting.RebornRecipeType;
import techreborn.compat.rei.MachineRecipeDisplay;
import techreborn.compat.rei.ReiPlugin;
import java.text.DecimalFormat;
import java.util.List;
public class IndustrialCentrifugeCategory<R extends RebornRecipe> extends AbstractEnergyConsumingMachineCategory<R> {
public IndustrialCentrifugeCategory(RebornRecipeType<R> rebornRecipeType) {
super(rebornRecipeType);
}
@Override
public List<Widget> setupDisplay(MachineRecipeDisplay<R> recipeDisplay, Rectangle bounds) {
List<Widget> widgets = super.setupDisplay(recipeDisplay, bounds);
widgets.add(Widgets.createSlot(new Point(bounds.x + 55 - 17, bounds.y + 35 - 19)).entries(getInput(recipeDisplay, 0)).markInput());
widgets.add(Widgets.createSlot(new Point(bounds.x + 55 - 17, bounds.y + 55 - 19)).entries(getInput(recipeDisplay, 1)).markInput());
widgets.add(Widgets.createSlot(new Point(bounds.x + 97 - 17, bounds.y + 45 - 19)).entries(getOutput(recipeDisplay, 0)).markOutput());
widgets.add(Widgets.createSlot(new Point(bounds.x + 116 - 17, bounds.y + 26 - 19)).entries(getOutput(recipeDisplay, 1)).markOutput());
widgets.add(Widgets.createSlot(new Point(bounds.x + 135 - 17, bounds.y + 45 - 19)).entries(getOutput(recipeDisplay, 2)).markOutput());
widgets.add(Widgets.createSlot(new Point(bounds.x + 116 - 17, bounds.y + 64 - 19)).entries(getOutput(recipeDisplay, 3)).markOutput());
widgets.add(ReiPlugin.createProgressBar(bounds.x + 76 - 17, bounds.y + 48 - 19, recipeDisplay.getTime() * 50, GuiBuilder.ProgressDirection.RIGHT));
widgets.add(Widgets.createLabel(new Point(bounds.x + 24, bounds.y + 5), new TranslatableText("techreborn.jei.recipe.processing.time.3", new DecimalFormat("###.##").format(recipeDisplay.getTime() / 20.0)))
.shadow(false)
.leftAligned()
.color(0xFF404040, 0xFFBBBBBB)
);
return widgets;
}
}

View file

@ -0,0 +1,37 @@
package techreborn.compat.rei.machine;
import me.shedaniel.math.Point;
import me.shedaniel.math.Rectangle;
import me.shedaniel.rei.api.widgets.Widgets;
import me.shedaniel.rei.gui.widget.Widget;
import net.minecraft.text.TranslatableText;
import reborncore.client.gui.guibuilder.GuiBuilder;
import reborncore.common.crafting.RebornRecipe;
import reborncore.common.crafting.RebornRecipeType;
import techreborn.compat.rei.MachineRecipeDisplay;
import techreborn.compat.rei.ReiPlugin;
import java.text.DecimalFormat;
import java.util.List;
public class OneInputOneOutputCategory<R extends RebornRecipe> extends AbstractEnergyConsumingMachineCategory<R> {
public OneInputOneOutputCategory(RebornRecipeType<R> rebornRecipeType) {
super(rebornRecipeType);
}
@Override
public List<Widget> setupDisplay(MachineRecipeDisplay<R> recipeDisplay, Rectangle bounds) {
List<Widget> widgets = super.setupDisplay(recipeDisplay, bounds);
widgets.add(Widgets.createSlot(new Point(bounds.x + 46, bounds.y + 26)).entries(getInput(recipeDisplay, 0)).markInput());
widgets.add(Widgets.createResultSlotBackground(new Point(bounds.x + 46 + 46, bounds.y + 26)));
widgets.add(Widgets.createSlot(new Point(bounds.x + 46 + 46, bounds.y + 26)).entries(getOutput(recipeDisplay, 0)).disableBackground().markOutput());
widgets.add(ReiPlugin.createProgressBar(bounds.x + 46 + 21, bounds.y + 30, recipeDisplay.getTime() * 50, GuiBuilder.ProgressDirection.RIGHT));
widgets.add(Widgets.createLabel(new Point(bounds.getMaxX() - 5, bounds.y + 5), new TranslatableText("techreborn.jei.recipe.processing.time.3", new DecimalFormat("###.##").format(recipeDisplay.getTime() / 20.0)))
.shadow(false)
.rightAligned()
.color(0xFF404040, 0xFFBBBBBB)
);
return widgets;
}
}

View file

@ -0,0 +1,39 @@
package techreborn.compat.rei.machine;
import me.shedaniel.math.Point;
import me.shedaniel.math.Rectangle;
import me.shedaniel.rei.api.widgets.Widgets;
import me.shedaniel.rei.gui.widget.Widget;
import net.minecraft.text.TranslatableText;
import reborncore.client.gui.guibuilder.GuiBuilder;
import reborncore.common.crafting.RebornRecipe;
import reborncore.common.crafting.RebornRecipeType;
import techreborn.compat.rei.MachineRecipeDisplay;
import techreborn.compat.rei.ReiPlugin;
import java.text.DecimalFormat;
import java.util.List;
public class SawmillCategory<R extends RebornRecipe> extends AbstractEnergyConsumingMachineCategory<R> {
public SawmillCategory(RebornRecipeType<R> rebornRecipeType) {
super(rebornRecipeType);
}
@Override
public List<Widget> setupDisplay(MachineRecipeDisplay<R> recipeDisplay, Rectangle bounds) {
List<Widget> widgets = super.setupDisplay(recipeDisplay, bounds);
widgets.add(Widgets.createSlot(new Point(bounds.x + 55, bounds.y + 26)).entries(getInput(recipeDisplay, 0)).markInput());
widgets.add(Widgets.createSlot(new Point(bounds.x + 55 + 46, bounds.y + 26 - 18)).entries(getOutput(recipeDisplay, 0)).markOutput());
widgets.add(Widgets.createSlot(new Point(bounds.x + 55 + 46, bounds.y + 26)).entries(getOutput(recipeDisplay, 1)).markOutput());
widgets.add(Widgets.createSlot(new Point(bounds.x + 55 + 46, bounds.y + 26 + 18)).entries(getOutput(recipeDisplay, 2)).markOutput());
widgets.add(ReiPlugin.createProgressBar(bounds.x + 55 + 21, bounds.y + 30, recipeDisplay.getTime() * 50, GuiBuilder.ProgressDirection.RIGHT));
widgets.add(ReiPlugin.createFluidDisplay(new Rectangle(bounds.x + 55 - 26, bounds.y + 8, 16, 50), getInput(recipeDisplay, 1).get(0), ReiPlugin.EntryAnimation.downwards(5000)));
widgets.add(Widgets.createLabel(new Point(bounds.x + 51, bounds.y + 5), new TranslatableText("techreborn.jei.recipe.processing.time.3", new DecimalFormat("###.##").format(recipeDisplay.getTime() / 20.0)))
.shadow(false)
.leftAligned()
.color(0xFF404040, 0xFFBBBBBB)
);
return widgets;
}
}

View file

@ -0,0 +1,39 @@
package techreborn.compat.rei.machine;
import me.shedaniel.math.Point;
import me.shedaniel.math.Rectangle;
import me.shedaniel.rei.api.widgets.Widgets;
import me.shedaniel.rei.gui.widget.Widget;
import net.minecraft.text.TranslatableText;
import reborncore.client.gui.guibuilder.GuiBuilder;
import reborncore.common.crafting.RebornRecipe;
import reborncore.common.crafting.RebornRecipeType;
import techreborn.compat.rei.MachineRecipeDisplay;
import techreborn.compat.rei.ReiPlugin;
import java.text.DecimalFormat;
import java.util.List;
public class TwoInputsCenterOutputCategory<R extends RebornRecipe> extends AbstractEnergyConsumingMachineCategory<R> {
public TwoInputsCenterOutputCategory(RebornRecipeType<R> rebornRecipeType) {
super(rebornRecipeType);
}
@Override
public List<Widget> setupDisplay(MachineRecipeDisplay<R> recipeDisplay, Rectangle bounds) {
List<Widget> widgets = super.setupDisplay(recipeDisplay, bounds);
widgets.add(Widgets.createSlot(new Point(bounds.x + 29, bounds.y + 26)).entries(getInput(recipeDisplay, 0)).markInput());
widgets.add(Widgets.createSlot(new Point(bounds.x + 29 + 92, bounds.y + 26)).entries(getInput(recipeDisplay, 1)).markInput());
widgets.add(Widgets.createResultSlotBackground(new Point(bounds.x + 29 + 46, bounds.y + 26)));
widgets.add(Widgets.createSlot(new Point(bounds.x + 29 + 46, bounds.y + 26)).entries(getOutput(recipeDisplay, 0)).disableBackground().markOutput());
widgets.add(ReiPlugin.createProgressBar(bounds.x + 29 + 21, bounds.y + 30, recipeDisplay.getTime() * 50, GuiBuilder.ProgressDirection.RIGHT));
widgets.add(ReiPlugin.createProgressBar(bounds.x + 29 + 71, bounds.y + 30, recipeDisplay.getTime() * 50, GuiBuilder.ProgressDirection.LEFT));
widgets.add(Widgets.createLabel(new Point(bounds.getMaxX() - 5, bounds.y + 5), new TranslatableText("techreborn.jei.recipe.processing.time.3", new DecimalFormat("###.##").format(recipeDisplay.getTime() / 20.0)))
.shadow(false)
.rightAligned()
.color(0xFF404040, 0xFFBBBBBB)
);
return widgets;
}
}

View file

@ -772,6 +772,7 @@
"techreborn.jei.recipe.running.cost": "%s/t: %s", "techreborn.jei.recipe.running.cost": "%s/t: %s",
"techreborn.jei.recipe.processing.time.1": "Time: %s ticks", "techreborn.jei.recipe.processing.time.1": "Time: %s ticks",
"techreborn.jei.recipe.processing.time.2": "(%s sec)", "techreborn.jei.recipe.processing.time.2": "(%s sec)",
"techreborn.jei.recipe.processing.time.3": "%s sec",
"techreborn.jei.recipe.heat": "Heat", "techreborn.jei.recipe.heat": "Heat",
"techreborn.jei.recipe.generator.total": "E total: %s", "techreborn.jei.recipe.generator.total": "E total: %s",