diff --git a/build.gradle b/build.gradle index 6382c5083..446435e32 100644 --- a/build.gradle +++ b/build.gradle @@ -80,7 +80,7 @@ dependencies { //Fabric api 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 ('com.github.emilyploszaj:trinkets:2.6.0') diff --git a/src/main/java/techreborn/compat/rei/MachineRecipeCategory.java b/src/main/java/techreborn/compat/rei/MachineRecipeCategory.java deleted file mode 100644 index d017cf0b9..000000000 --- a/src/main/java/techreborn/compat/rei/MachineRecipeCategory.java +++ /dev/null @@ -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 implements RecipeCategory> { - - private final RebornRecipeType rebornRecipeType; - private final int recipeLines; - - MachineRecipeCategory(RebornRecipeType rebornRecipeType) { - this(rebornRecipeType, 2); - } - - MachineRecipeCategory(RebornRecipeType 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 recipe) { - return SimpleRecipeEntry.create(Collections.singletonList(recipe.getInputEntries().get(0)), recipe.getOutputEntries()); - } - - @Override - public List setupDisplay(MachineRecipeDisplay machineRecipe, Rectangle bounds) { - Point startPoint = new Point(bounds.getCenterX() - 41, bounds.getCenterY() - recipeLines * 12 - 1); - - List 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 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; - } - -} diff --git a/src/main/java/techreborn/compat/rei/MachineRecipeDisplay.java b/src/main/java/techreborn/compat/rei/MachineRecipeDisplay.java index 3520c3e12..311d06983 100644 --- a/src/main/java/techreborn/compat/rei/MachineRecipeDisplay.java +++ b/src/main/java/techreborn/compat/rei/MachineRecipeDisplay.java @@ -49,8 +49,8 @@ public class MachineRecipeDisplay implements RecipeDispl public MachineRecipeDisplay(R recipe) { this.recipe = recipe; - this.inputs = CollectionUtils.map(recipe.getRebornIngredients(), ing -> CollectionUtils.map(ing.getPreviewStacks(), RebornEntryStack::create)); - this.outputs = CollectionUtils.map(recipe.getOutputs(), RebornEntryStack::create); + this.inputs = CollectionUtils.map(recipe.getRebornIngredients(), ing -> EntryStack.ofItemStacks(ing.getPreviewStacks())); + this.outputs = EntryStack.ofItemStacks(recipe.getOutputs()); this.time = recipe.getTime(); this.energy = recipe.getPower(); if (recipe instanceof BlastFurnaceRecipe) { @@ -58,7 +58,7 @@ public class MachineRecipeDisplay implements RecipeDispl } if (recipe instanceof RebornFluidRecipe) { 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 entries : inputs) for (EntryStack stack : entries) diff --git a/src/main/java/techreborn/compat/rei/RebornEntryStack.java b/src/main/java/techreborn/compat/rei/RebornEntryStack.java deleted file mode 100644 index 021c1ae1a..000000000 --- a/src/main/java/techreborn/compat/rei/RebornEntryStack.java +++ /dev/null @@ -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; - } - -} diff --git a/src/main/java/techreborn/compat/rei/RebornFluidEntryStack.java b/src/main/java/techreborn/compat/rei/RebornFluidEntryStack.java deleted file mode 100644 index 4f1548039..000000000 --- a/src/main/java/techreborn/compat/rei/RebornFluidEntryStack.java +++ /dev/null @@ -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); - } - -} diff --git a/src/main/java/techreborn/compat/rei/RebornItemEntryStack.java b/src/main/java/techreborn/compat/rei/RebornItemEntryStack.java deleted file mode 100644 index 73b58e168..000000000 --- a/src/main/java/techreborn/compat/rei/RebornItemEntryStack.java +++ /dev/null @@ -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); - } - -} diff --git a/src/main/java/techreborn/compat/rei/ReiPlugin.java b/src/main/java/techreborn/compat/rei/ReiPlugin.java index e18ac897d..7e15b6a7e 100644 --- a/src/main/java/techreborn/compat/rei/ReiPlugin.java +++ b/src/main/java/techreborn/compat/rei/ReiPlugin.java @@ -24,20 +24,41 @@ package techreborn.compat.rei; +import com.mojang.blaze3d.systems.RenderSystem; +import me.shedaniel.math.Point; import me.shedaniel.math.Rectangle; import me.shedaniel.rei.api.*; +import me.shedaniel.rei.api.fluid.FluidSupportProvider; 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.gui.DrawableHelper; 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.recipe.Recipe; 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.client.gui.builder.GuiBase; import reborncore.client.gui.builder.slot.GuiTab; +import reborncore.client.gui.guibuilder.GuiBuilder; import reborncore.common.crafting.RebornRecipe; import reborncore.common.crafting.RebornRecipeType; import reborncore.common.crafting.RecipeManager; +import reborncore.common.fluid.container.ItemFluidInfo; +import reborncore.common.powerSystem.PowerSystem; import techreborn.TechReborn; import techreborn.api.generator.EFluidGenerator; 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.fluidreplicator.FluidReplicatorRecipeCategory; import techreborn.compat.rei.fluidreplicator.FluidReplicatorRecipeDisplay; +import techreborn.compat.rei.machine.*; import techreborn.compat.rei.rollingmachine.RollingMachineCategory; import techreborn.compat.rei.rollingmachine.RollingMachineDisplay; import techreborn.init.ModRecipes; @@ -95,26 +117,26 @@ public class ReiPlugin implements REIPluginV0 { @Override public void registerPluginCategories(RecipeHelper recipeHelper) { - recipeHelper.registerCategory(new MachineRecipeCategory<>(ModRecipes.ALLOY_SMELTER)); - recipeHelper.registerCategory(new MachineRecipeCategory<>(ModRecipes.ASSEMBLING_MACHINE)); - recipeHelper.registerCategory(new MachineRecipeCategory<>(ModRecipes.BLAST_FURNACE)); - recipeHelper.registerCategory(new MachineRecipeCategory<>(ModRecipes.CENTRIFUGE, 4)); - recipeHelper.registerCategory(new MachineRecipeCategory<>(ModRecipes.CHEMICAL_REACTOR)); - recipeHelper.registerCategory(new MachineRecipeCategory<>(ModRecipes.COMPRESSOR, 1)); - recipeHelper.registerCategory(new MachineRecipeCategory<>(ModRecipes.DISTILLATION_TOWER, 3)); - recipeHelper.registerCategory(new MachineRecipeCategory<>(ModRecipes.EXTRACTOR, 1)); + recipeHelper.registerCategory(new TwoInputsCenterOutputCategory<>(ModRecipes.ALLOY_SMELTER)); + recipeHelper.registerCategory(new AssemblingMachineCategory<>(ModRecipes.ASSEMBLING_MACHINE)); + recipeHelper.registerCategory(new BlastFurnaceCategory<>(ModRecipes.BLAST_FURNACE)); + recipeHelper.registerCategory(new IndustrialCentrifugeCategory<>(ModRecipes.CENTRIFUGE)); + recipeHelper.registerCategory(new TwoInputsCenterOutputCategory<>(ModRecipes.CHEMICAL_REACTOR)); + recipeHelper.registerCategory(new OneInputOneOutputCategory<>(ModRecipes.COMPRESSOR)); + recipeHelper.registerCategory(new DistillationTowerCategory<>(ModRecipes.DISTILLATION_TOWER)); + recipeHelper.registerCategory(new OneInputOneOutputCategory<>(ModRecipes.EXTRACTOR)); recipeHelper.registerCategory(new FluidReplicatorRecipeCategory(ModRecipes.FLUID_REPLICATOR)); - 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 TwoInputsCenterOutputCategory<>(ModRecipes.FUSION_REACTOR)); + recipeHelper.registerCategory(new OneInputOneOutputCategory<>(ModRecipes.GRINDER)); + recipeHelper.registerCategory(new ImplosionCompressorCategory<>(ModRecipes.IMPLOSION_COMPRESSOR)); + recipeHelper.registerCategory(new ElectrolyzerCategory<>(ModRecipes.INDUSTRIAL_ELECTROLYZER)); + recipeHelper.registerCategory(new GrinderCategory<>(ModRecipes.INDUSTRIAL_GRINDER)); + recipeHelper.registerCategory(new SawmillCategory<>(ModRecipes.INDUSTRIAL_SAWMILL)); recipeHelper.registerCategory(new RollingMachineCategory(ModRecipes.ROLLING_MACHINE)); - recipeHelper.registerCategory(new MachineRecipeCategory<>(ModRecipes.SCRAPBOX)); - recipeHelper.registerCategory(new MachineRecipeCategory<>(ModRecipes.SOLID_CANNING_MACHINE)); - recipeHelper.registerCategory(new MachineRecipeCategory<>(ModRecipes.VACUUM_FREEZER, 1)); - recipeHelper.registerCategory(new MachineRecipeCategory<>(ModRecipes.WIRE_MILL, 1)); + recipeHelper.registerCategory(new OneInputOneOutputCategory<>(ModRecipes.SCRAPBOX)); + recipeHelper.registerCategory(new TwoInputsCenterOutputCategory<>(ModRecipes.SOLID_CANNING_MACHINE)); + recipeHelper.registerCategory(new OneInputOneOutputCategory<>(ModRecipes.VACUUM_FREEZER)); + recipeHelper.registerCategory(new OneInputOneOutputCategory<>(ModRecipes.WIRE_MILL)); recipeHelper.registerCategory(new FluidGeneratorRecipeCategory(Machine.THERMAL_GENERATOR)); 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.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)); + + 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 public void postRegister() { // 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. - for (EntryStack stack : EntryRegistry.getInstance().getStacksList()) - applyCellEntry(stack); + EntryRegistry.getInstance().getEntryStacks().forEach(ReiPlugin::applyCellEntry); } public static void applyCellEntry(EntryStack stack) { // getItem can be null but this works 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) { @@ -200,7 +239,6 @@ public class ReiPlugin implements REIPluginV0 { }; } - recipeHelper.registerRecipes(recipeType.getName(), (Predicate) recipe -> { if (recipe instanceof RebornRecipe) { return ((RebornRecipe) recipe).getRebornRecipeType() == recipeType; @@ -236,4 +274,171 @@ public class ReiPlugin implements REIPluginV0 { 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 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 + } } diff --git a/src/main/java/techreborn/compat/rei/fluidgenerator/FluidGeneratorRecipeCategory.java b/src/main/java/techreborn/compat/rei/fluidgenerator/FluidGeneratorRecipeCategory.java index 103b57165..425191420 100644 --- a/src/main/java/techreborn/compat/rei/fluidgenerator/FluidGeneratorRecipeCategory.java +++ b/src/main/java/techreborn/compat/rei/fluidgenerator/FluidGeneratorRecipeCategory.java @@ -24,21 +24,24 @@ package techreborn.compat.rei.fluidgenerator; -import me.shedaniel.math.Point; +import com.google.common.collect.Lists; import me.shedaniel.math.Rectangle; +import me.shedaniel.rei.api.ClientHelper; 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.Tooltip; import me.shedaniel.rei.api.widgets.Widgets; import me.shedaniel.rei.gui.widget.Widget; import net.minecraft.client.resource.language.I18n; 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 techreborn.TechReborn; +import techreborn.compat.rei.ReiPlugin; import techreborn.init.TRContent; -import java.util.LinkedList; import java.util.List; public class FluidGeneratorRecipeCategory implements RecipeCategory { @@ -67,29 +70,19 @@ public class FluidGeneratorRecipeCategory implements RecipeCategory setupDisplay(FluidGeneratorRecipeDisplay machineRecipe, Rectangle bounds) { - Point startPoint = new Point(bounds.getCenterX() - 41, bounds.getCenterY() - 13); - - List widgets = new LinkedList<>(); + public List setupDisplay(FluidGeneratorRecipeDisplay recipeDisplay, Rectangle bounds) { + List widgets = Lists.newArrayList(); widgets.add(Widgets.createRecipeBase(bounds)); - widgets.add(Widgets.createArrow(new Point(startPoint.x + 26, startPoint.y + 1)).animationDurationMS(1000.0)); - - for (List inputs : machineRecipe.getInputEntries()) { - widgets.add(Widgets.createSlot(new Point(startPoint.x + 1, startPoint.y + 1)).entries(inputs).markInput()); - } - - Text energyPerTick = new TranslatableText("techreborn.jei.recipe.generator.total", machineRecipe.getTotalEnergy()); - Label costLabel; - widgets.add(costLabel = Widgets.createLabel(new Point(bounds.getCenterX(), startPoint.y + 20), energyPerTick)); - costLabel.shadow(false); - costLabel.color(0xFF404040, 0xFFBBBBBB); - + widgets.add(ReiPlugin.createEnergyDisplay(new Rectangle(bounds.x + 108, bounds.y + 8, 14, 50), recipeDisplay.getTotalEnergy(), ReiPlugin.EntryAnimation.upwards(5000), point -> { + List list = Lists.newArrayList(); + list.add(Text.method_30163("Energy")); + 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", ""))); + return Tooltip.create(point, list); + })); + widgets.add(ReiPlugin.createFluidDisplay(new Rectangle(bounds.x + 16, bounds.y + 8, 16, 50), recipeDisplay.getInputEntries().get(0).get(0), ReiPlugin.EntryAnimation.downwards(5000))); + widgets.add(ReiPlugin.createProgressBar(bounds.x + 76 - 16, bounds.y + 48 - 19, 5000, GuiBuilder.ProgressDirection.RIGHT)); return widgets; } - - @Override - public int getDisplayHeight() { - return 37; - } - } diff --git a/src/main/java/techreborn/compat/rei/fluidgenerator/FluidGeneratorRecipeDisplay.java b/src/main/java/techreborn/compat/rei/fluidgenerator/FluidGeneratorRecipeDisplay.java index 7ef76648d..163f57225 100644 --- a/src/main/java/techreborn/compat/rei/fluidgenerator/FluidGeneratorRecipeDisplay.java +++ b/src/main/java/techreborn/compat/rei/fluidgenerator/FluidGeneratorRecipeDisplay.java @@ -29,7 +29,6 @@ import me.shedaniel.rei.api.EntryStack; import me.shedaniel.rei.api.RecipeDisplay; import net.minecraft.util.Identifier; import techreborn.api.generator.FluidGeneratorRecipe; -import techreborn.compat.rei.RebornEntryStack; import java.util.Collections; import java.util.List; @@ -44,7 +43,7 @@ public class FluidGeneratorRecipeDisplay implements RecipeDisplay { this.category = category; this.inputs = Lists.newArrayList(); this.totalEnergy = recipe.getEnergyPerBucket(); - inputs.add(Collections.singletonList(RebornEntryStack.create(recipe.getFluid(), 1000))); + inputs.add(Collections.singletonList(EntryStack.create(recipe.getFluid(), 1000))); } @Override @@ -52,6 +51,11 @@ public class FluidGeneratorRecipeDisplay implements RecipeDisplay { return inputs; } + @Override + public List> getRequiredEntries() { + return inputs; + } + @Override public List getOutputEntries() { return Lists.newArrayList(); @@ -65,5 +69,4 @@ public class FluidGeneratorRecipeDisplay implements RecipeDisplay { public int getTotalEnergy() { return totalEnergy; } - } diff --git a/src/main/java/techreborn/compat/rei/fluidreplicator/FluidReplicatorRecipeCategory.java b/src/main/java/techreborn/compat/rei/fluidreplicator/FluidReplicatorRecipeCategory.java index 64bf099e5..ca2ac7be3 100644 --- a/src/main/java/techreborn/compat/rei/fluidreplicator/FluidReplicatorRecipeCategory.java +++ b/src/main/java/techreborn/compat/rei/fluidreplicator/FluidReplicatorRecipeCategory.java @@ -24,23 +24,27 @@ package techreborn.compat.rei.fluidreplicator; +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.EntryStack; 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.gui.widget.Widget; import net.minecraft.client.resource.language.I18n; import net.minecraft.item.Items; 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.RebornRecipeType; import techreborn.api.recipe.recipes.FluidReplicatorRecipe; import techreborn.compat.rei.ReiPlugin; -import java.util.LinkedList; +import java.text.DecimalFormat; import java.util.List; public class FluidReplicatorRecipeCategory implements RecipeCategory { @@ -49,7 +53,6 @@ public class FluidReplicatorRecipeCategory implements RecipeCategory recipeType) { this.rebornRecipeType = recipeType; - } @Override @@ -68,26 +71,29 @@ public class FluidReplicatorRecipeCategory implements RecipeCategory setupDisplay(FluidReplicatorRecipeDisplay machineRecipe, Rectangle bounds) { + public List setupDisplay(FluidReplicatorRecipeDisplay recipeDisplay, Rectangle bounds) { Point startPoint = new Point(bounds.getCenterX() - 41, bounds.getCenterY() - 13); - List widgets = new LinkedList<>(); + List widgets = Lists.newArrayList(); 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 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; - for (List inputs : machineRecipe.getInputEntries()) { - widgets.add(Widgets.createSlot(new Point(startPoint.x + 1, startPoint.y + 1 + (i++ * 20))).entries(inputs).markInput()); - } + widgets.add(Widgets.createSlot(new Point(bounds.x + 46, bounds.y + 26)).entries(recipeDisplay.getInputEntries().get(0)).markInput()); + widgets.add(ReiPlugin.createProgressBar(bounds.x + 46 + 21, bounds.y + 30, recipeDisplay.getTime() * 50, GuiBuilder.ProgressDirection.RIGHT)); + 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()); - 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); - - if (!machineRecipe.getOutputEntries().isEmpty()) - widgets.add(Widgets.createSlot(new Point(startPoint.x + 61, startPoint.y + 1)).entries(machineRecipe.getOutputEntries()).markInput()); + 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; } diff --git a/src/main/java/techreborn/compat/rei/fluidreplicator/FluidReplicatorRecipeDisplay.java b/src/main/java/techreborn/compat/rei/fluidreplicator/FluidReplicatorRecipeDisplay.java index 476d74afa..6156a83fd 100644 --- a/src/main/java/techreborn/compat/rei/fluidreplicator/FluidReplicatorRecipeDisplay.java +++ b/src/main/java/techreborn/compat/rei/fluidreplicator/FluidReplicatorRecipeDisplay.java @@ -28,12 +28,13 @@ import me.shedaniel.rei.api.EntryStack; import me.shedaniel.rei.api.RecipeDisplay; import me.shedaniel.rei.utils.CollectionUtils; import net.minecraft.util.Identifier; +import reborncore.common.crafting.RebornRecipe; import reborncore.common.fluid.container.FluidInstance; import techreborn.api.recipe.recipes.FluidReplicatorRecipe; -import techreborn.compat.rei.RebornEntryStack; import java.util.Collections; import java.util.List; +import java.util.Optional; /** * @author drcrazy @@ -49,9 +50,9 @@ public class FluidReplicatorRecipeDisplay implements RecipeDisplay { public FluidReplicatorRecipeDisplay(FluidReplicatorRecipe 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.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.time = recipe.getTime(); } @@ -87,4 +88,9 @@ public class FluidReplicatorRecipeDisplay implements RecipeDisplay { public Identifier getRecipeCategory() { return recipe.getRebornRecipeType().getName(); } + + @Override + public Optional getRecipeLocation() { + return Optional.ofNullable(recipe).map(RebornRecipe::getId); + } } diff --git a/src/main/java/techreborn/compat/rei/machine/AbstractEnergyConsumingMachineCategory.java b/src/main/java/techreborn/compat/rei/machine/AbstractEnergyConsumingMachineCategory.java new file mode 100644 index 000000000..e3b0f4f2a --- /dev/null +++ b/src/main/java/techreborn/compat/rei/machine/AbstractEnergyConsumingMachineCategory.java @@ -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 extends AbstractMachineCategory { + public AbstractEnergyConsumingMachineCategory(RebornRecipeType rebornRecipeType) { + super(rebornRecipeType); + } + + @Override + public List setupDisplay(MachineRecipeDisplay recipeDisplay, Rectangle bounds) { + List 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 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; + } +} diff --git a/src/main/java/techreborn/compat/rei/machine/AbstractMachineCategory.java b/src/main/java/techreborn/compat/rei/machine/AbstractMachineCategory.java new file mode 100644 index 000000000..a7b0dacc4 --- /dev/null +++ b/src/main/java/techreborn/compat/rei/machine/AbstractMachineCategory.java @@ -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 implements RecipeCategory> { + private final RebornRecipeType rebornRecipeType; + + public AbstractMachineCategory(RebornRecipeType 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 recipe) { + return SimpleRecipeEntry.create(Collections.singletonList(recipe.getInputEntries().get(0)), recipe.getOutputEntries()); + } + + public List getInput(MachineRecipeDisplay recipeDisplay, int index) { + List> inputs = recipeDisplay.getInputEntries(); + return inputs.size() > index ? inputs.get(index) : Collections.emptyList(); + } + + public List getOutput(MachineRecipeDisplay recipeDisplay, int index) { + List outputs = recipeDisplay.getOutputEntries(); + return outputs.size() > index ? Collections.singletonList(outputs.get(index)) : Collections.emptyList(); + } +} diff --git a/src/main/java/techreborn/compat/rei/machine/AssemblingMachineCategory.java b/src/main/java/techreborn/compat/rei/machine/AssemblingMachineCategory.java new file mode 100644 index 000000000..4f77e8204 --- /dev/null +++ b/src/main/java/techreborn/compat/rei/machine/AssemblingMachineCategory.java @@ -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 extends AbstractEnergyConsumingMachineCategory { + public AssemblingMachineCategory(RebornRecipeType rebornRecipeType) { + super(rebornRecipeType); + } + + @Override + public List setupDisplay(MachineRecipeDisplay recipeDisplay, Rectangle bounds) { + List 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; + } +} diff --git a/src/main/java/techreborn/compat/rei/machine/BlastFurnaceCategory.java b/src/main/java/techreborn/compat/rei/machine/BlastFurnaceCategory.java new file mode 100644 index 000000000..eeae6633b --- /dev/null +++ b/src/main/java/techreborn/compat/rei/machine/BlastFurnaceCategory.java @@ -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 extends AbstractEnergyConsumingMachineCategory { + public BlastFurnaceCategory(RebornRecipeType rebornRecipeType) { + super(rebornRecipeType); + } + + @Override + public List setupDisplay(MachineRecipeDisplay recipeDisplay, Rectangle bounds) { + List 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; + } +} diff --git a/src/main/java/techreborn/compat/rei/machine/DistillationTowerCategory.java b/src/main/java/techreborn/compat/rei/machine/DistillationTowerCategory.java new file mode 100644 index 000000000..c5fca27c8 --- /dev/null +++ b/src/main/java/techreborn/compat/rei/machine/DistillationTowerCategory.java @@ -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 extends AbstractEnergyConsumingMachineCategory { + public DistillationTowerCategory(RebornRecipeType rebornRecipeType) { + super(rebornRecipeType); + } + + @Override + public List setupDisplay(MachineRecipeDisplay recipeDisplay, Rectangle bounds) { + List 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; + } +} diff --git a/src/main/java/techreborn/compat/rei/machine/ElectrolyzerCategory.java b/src/main/java/techreborn/compat/rei/machine/ElectrolyzerCategory.java new file mode 100644 index 000000000..38870af6c --- /dev/null +++ b/src/main/java/techreborn/compat/rei/machine/ElectrolyzerCategory.java @@ -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 extends AbstractEnergyConsumingMachineCategory { + public ElectrolyzerCategory(RebornRecipeType rebornRecipeType) { + super(rebornRecipeType); + } + + @Override + public List setupDisplay(MachineRecipeDisplay recipeDisplay, Rectangle bounds) { + List 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; + } +} diff --git a/src/main/java/techreborn/compat/rei/machine/GrinderCategory.java b/src/main/java/techreborn/compat/rei/machine/GrinderCategory.java new file mode 100644 index 000000000..73d5baced --- /dev/null +++ b/src/main/java/techreborn/compat/rei/machine/GrinderCategory.java @@ -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 extends AbstractMachineCategory { + public GrinderCategory(RebornRecipeType rebornRecipeType) { + super(rebornRecipeType); + } + + @Override + public List setupDisplay(MachineRecipeDisplay recipeDisplay, Rectangle bounds) { + List 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 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; + } +} diff --git a/src/main/java/techreborn/compat/rei/machine/ImplosionCompressorCategory.java b/src/main/java/techreborn/compat/rei/machine/ImplosionCompressorCategory.java new file mode 100644 index 000000000..bf7ba66dd --- /dev/null +++ b/src/main/java/techreborn/compat/rei/machine/ImplosionCompressorCategory.java @@ -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 extends AbstractEnergyConsumingMachineCategory { + public ImplosionCompressorCategory(RebornRecipeType rebornRecipeType) { + super(rebornRecipeType); + } + + @Override + public List setupDisplay(MachineRecipeDisplay recipeDisplay, Rectangle bounds) { + List 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; + } +} diff --git a/src/main/java/techreborn/compat/rei/machine/IndustrialCentrifugeCategory.java b/src/main/java/techreborn/compat/rei/machine/IndustrialCentrifugeCategory.java new file mode 100644 index 000000000..59c779bd2 --- /dev/null +++ b/src/main/java/techreborn/compat/rei/machine/IndustrialCentrifugeCategory.java @@ -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 extends AbstractEnergyConsumingMachineCategory { + public IndustrialCentrifugeCategory(RebornRecipeType rebornRecipeType) { + super(rebornRecipeType); + } + + @Override + public List setupDisplay(MachineRecipeDisplay recipeDisplay, Rectangle bounds) { + List 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; + } +} diff --git a/src/main/java/techreborn/compat/rei/machine/OneInputOneOutputCategory.java b/src/main/java/techreborn/compat/rei/machine/OneInputOneOutputCategory.java new file mode 100644 index 000000000..69be5f7d0 --- /dev/null +++ b/src/main/java/techreborn/compat/rei/machine/OneInputOneOutputCategory.java @@ -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 extends AbstractEnergyConsumingMachineCategory { + public OneInputOneOutputCategory(RebornRecipeType rebornRecipeType) { + super(rebornRecipeType); + } + + @Override + public List setupDisplay(MachineRecipeDisplay recipeDisplay, Rectangle bounds) { + List 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; + } +} diff --git a/src/main/java/techreborn/compat/rei/machine/SawmillCategory.java b/src/main/java/techreborn/compat/rei/machine/SawmillCategory.java new file mode 100644 index 000000000..e16ba6c75 --- /dev/null +++ b/src/main/java/techreborn/compat/rei/machine/SawmillCategory.java @@ -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 extends AbstractEnergyConsumingMachineCategory { + public SawmillCategory(RebornRecipeType rebornRecipeType) { + super(rebornRecipeType); + } + + @Override + public List setupDisplay(MachineRecipeDisplay recipeDisplay, Rectangle bounds) { + List 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; + } +} diff --git a/src/main/java/techreborn/compat/rei/machine/TwoInputsCenterOutputCategory.java b/src/main/java/techreborn/compat/rei/machine/TwoInputsCenterOutputCategory.java new file mode 100644 index 000000000..0c19462a4 --- /dev/null +++ b/src/main/java/techreborn/compat/rei/machine/TwoInputsCenterOutputCategory.java @@ -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 extends AbstractEnergyConsumingMachineCategory { + public TwoInputsCenterOutputCategory(RebornRecipeType rebornRecipeType) { + super(rebornRecipeType); + } + + @Override + public List setupDisplay(MachineRecipeDisplay recipeDisplay, Rectangle bounds) { + List 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; + } +} diff --git a/src/main/resources/assets/techreborn/lang/en_us.json b/src/main/resources/assets/techreborn/lang/en_us.json index 0eac67ed0..0bf2fde51 100644 --- a/src/main/resources/assets/techreborn/lang/en_us.json +++ b/src/main/resources/assets/techreborn/lang/en_us.json @@ -772,6 +772,7 @@ "techreborn.jei.recipe.running.cost": "%s/t: %s", "techreborn.jei.recipe.processing.time.1": "Time: %s ticks", "techreborn.jei.recipe.processing.time.2": "(%s sec)", + "techreborn.jei.recipe.processing.time.3": "%s sec", "techreborn.jei.recipe.heat": "Heat", "techreborn.jei.recipe.generator.total": "E total: %s",