Update to REI 6 (#2404)

Signed-off-by: shedaniel <daniel@shedaniel.me>
This commit is contained in:
shedaniel 2021-06-03 23:58:56 +08:00 committed by GitHub
parent dc216b974d
commit 8243c936be
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
22 changed files with 301 additions and 315 deletions

View file

@ -143,7 +143,7 @@ dependencies {
api project(":RebornCore")
include project(":RebornCore")
disabledOptionalDependency "me.shedaniel:RoughlyEnoughItems:5.8.9"
optionalDependency "me.shedaniel:RoughlyEnoughItems-fabric:6.0.245-alpha"
disabledOptionalDependency ('com.github.emilyploszaj:trinkets:2.6.7')
disabledOptionalDependency "com.github.dexman545:autoswitch-api:-SNAPSHOT"
}

View file

@ -24,9 +24,11 @@
package techreborn.compat.rei;
import me.shedaniel.rei.api.EntryStack;
import me.shedaniel.rei.api.RecipeDisplay;
import me.shedaniel.rei.utils.CollectionUtils;
import me.shedaniel.rei.api.common.category.CategoryIdentifier;
import me.shedaniel.rei.api.common.display.Display;
import me.shedaniel.rei.api.common.entry.EntryIngredient;
import me.shedaniel.rei.api.common.util.CollectionUtils;
import me.shedaniel.rei.api.common.util.EntryIngredients;
import net.minecraft.util.Identifier;
import reborncore.common.crafting.RebornFluidRecipe;
import reborncore.common.crafting.RebornRecipe;
@ -37,11 +39,11 @@ import java.util.Collections;
import java.util.List;
import java.util.Optional;
public class MachineRecipeDisplay<R extends RebornRecipe> implements RecipeDisplay {
public class MachineRecipeDisplay<R extends RebornRecipe> implements Display {
private final R recipe;
private final List<List<EntryStack>> inputs;
private final List<EntryStack> outputs;
private final List<EntryIngredient> inputs;
private final List<EntryIngredient> outputs;
private final int energy;
private int heat = 0;
private final int time;
@ -49,8 +51,8 @@ public class MachineRecipeDisplay<R extends RebornRecipe> implements RecipeDispl
public MachineRecipeDisplay(R recipe) {
this.recipe = recipe;
this.inputs = CollectionUtils.map(recipe.getRebornIngredients(), ing -> EntryStack.ofItemStacks(ing.getPreviewStacks()));
this.outputs = EntryStack.ofItemStacks(recipe.getOutputs());
this.inputs = CollectionUtils.map(recipe.getRebornIngredients(), ing -> EntryIngredients.ofItemStacks(ing.getPreviewStacks()));
this.outputs = Collections.singletonList(EntryIngredients.ofItemStacks(recipe.getOutputs()));
this.time = recipe.getTime();
this.energy = recipe.getPower();
if (recipe instanceof BlastFurnaceRecipe) {
@ -58,13 +60,8 @@ public class MachineRecipeDisplay<R extends RebornRecipe> implements RecipeDispl
}
if (recipe instanceof RebornFluidRecipe) {
this.fluidInstance = ((RebornFluidRecipe) recipe).getFluidInstance();
inputs.add(Collections.singletonList(EntryStack.create(fluidInstance.getFluid(), fluidInstance.getAmount().getRawValue())));
inputs.add(EntryIngredients.of(fluidInstance.getFluid(), fluidInstance.getAmount().getRawValue()));
}
for (List<EntryStack> entries : inputs)
for (EntryStack stack : entries)
ReiPlugin.applyCellEntry(stack);
for (EntryStack stack : outputs)
ReiPlugin.applyCellEntry(stack);
}
public int getEnergy() {
@ -84,27 +81,22 @@ public class MachineRecipeDisplay<R extends RebornRecipe> implements RecipeDispl
}
@Override
public Optional<Identifier> getRecipeLocation() {
public Optional<Identifier> getDisplayLocation() {
return Optional.ofNullable(recipe).map(RebornRecipe::getId);
}
@Override
public List<List<EntryStack>> getInputEntries() {
public List<EntryIngredient> getInputEntries() {
return inputs;
}
@Override
public List<List<EntryStack>> getRequiredEntries() {
return inputs;
}
@Override
public List<EntryStack> getOutputEntries() {
public List<EntryIngredient> getOutputEntries() {
return outputs;
}
@Override
public Identifier getRecipeCategory() {
return recipe.getRebornRecipeType().name();
public CategoryIdentifier<?> getCategoryIdentifier() {
return CategoryIdentifier.of(recipe.getRebornRecipeType().name());
}
}

View file

@ -25,31 +25,42 @@
package techreborn.compat.rei;
import com.mojang.blaze3d.systems.RenderSystem;
import dev.architectury.event.CompoundEventResult;
import dev.architectury.fluid.FluidStack;
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 me.shedaniel.rei.api.client.entry.renderer.AbstractEntryRenderer;
import me.shedaniel.rei.api.client.entry.renderer.EntryRenderer;
import me.shedaniel.rei.api.client.gui.AbstractRenderer;
import me.shedaniel.rei.api.client.gui.widgets.Tooltip;
import me.shedaniel.rei.api.client.gui.widgets.Widget;
import me.shedaniel.rei.api.client.gui.widgets.Widgets;
import me.shedaniel.rei.api.client.plugins.REIClientPlugin;
import me.shedaniel.rei.api.client.registry.category.CategoryRegistry;
import me.shedaniel.rei.api.client.registry.display.DisplayRegistry;
import me.shedaniel.rei.api.client.registry.screen.ExclusionZones;
import me.shedaniel.rei.api.client.registry.screen.ScreenRegistry;
import me.shedaniel.rei.api.client.util.ClientEntryStacks;
import me.shedaniel.rei.api.common.category.CategoryIdentifier;
import me.shedaniel.rei.api.common.display.Display;
import me.shedaniel.rei.api.common.entry.EntryStack;
import me.shedaniel.rei.api.common.entry.comparison.ItemComparatorRegistry;
import me.shedaniel.rei.api.common.fluid.FluidSupportProvider;
import me.shedaniel.rei.api.common.util.EntryStacks;
import me.shedaniel.rei.impl.client.gui.widget.EntryWidget;
import net.fabricmc.fabric.api.client.render.fluid.v1.FluidRenderHandler;
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.item.ItemStack;
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;
@ -78,14 +89,12 @@ import techreborn.init.TRContent.Machine;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.function.Predicate;
public class ReiPlugin implements REIPluginV0 {
public static final Identifier PLUGIN = new Identifier(TechReborn.MOD_ID, "techreborn_plugin");
import java.util.stream.Stream;
public class ReiPlugin implements REIClientPlugin {
public static final Map<RebornRecipeType<?>, ItemConvertible> iconMap = new HashMap<>();
public ReiPlugin() {
@ -112,119 +121,105 @@ public class ReiPlugin implements REIPluginV0 {
}
@Override
public Identifier getPluginIdentifier() {
return PLUGIN;
public void registerCategories(CategoryRegistry registry) {
registry.add(new TwoInputsCenterOutputCategory<>(ModRecipes.ALLOY_SMELTER));
registry.add(new AssemblingMachineCategory<>(ModRecipes.ASSEMBLING_MACHINE));
registry.add(new BlastFurnaceCategory<>(ModRecipes.BLAST_FURNACE));
registry.add(new IndustrialCentrifugeCategory<>(ModRecipes.CENTRIFUGE));
registry.add(new TwoInputsCenterOutputCategory<>(ModRecipes.CHEMICAL_REACTOR));
registry.add(new OneInputOneOutputCategory<>(ModRecipes.COMPRESSOR));
registry.add(new DistillationTowerCategory<>(ModRecipes.DISTILLATION_TOWER));
registry.add(new OneInputOneOutputCategory<>(ModRecipes.EXTRACTOR));
registry.add(new FluidReplicatorRecipeCategory(ModRecipes.FLUID_REPLICATOR));
registry.add(new TwoInputsCenterOutputCategory<>(ModRecipes.FUSION_REACTOR));
registry.add(new OneInputOneOutputCategory<>(ModRecipes.GRINDER));
registry.add(new ImplosionCompressorCategory<>(ModRecipes.IMPLOSION_COMPRESSOR));
registry.add(new ElectrolyzerCategory<>(ModRecipes.INDUSTRIAL_ELECTROLYZER));
registry.add(new GrinderCategory<>(ModRecipes.INDUSTRIAL_GRINDER));
registry.add(new SawmillCategory<>(ModRecipes.INDUSTRIAL_SAWMILL));
registry.add(new RollingMachineCategory(ModRecipes.ROLLING_MACHINE));
registry.add(new OneInputOneOutputCategory<>(ModRecipes.SCRAPBOX));
registry.add(new TwoInputsCenterOutputCategory<>(ModRecipes.SOLID_CANNING_MACHINE));
registry.add(new OneInputOneOutputCategory<>(ModRecipes.VACUUM_FREEZER));
registry.add(new OneInputOneOutputCategory<>(ModRecipes.WIRE_MILL));
registry.add(new FluidGeneratorRecipeCategory(Machine.THERMAL_GENERATOR));
registry.add(new FluidGeneratorRecipeCategory(Machine.GAS_TURBINE));
registry.add(new FluidGeneratorRecipeCategory(Machine.DIESEL_GENERATOR));
registry.add(new FluidGeneratorRecipeCategory(Machine.SEMI_FLUID_GENERATOR));
registry.add(new FluidGeneratorRecipeCategory(Machine.PLASMA_GENERATOR));
addWorkstations(ModRecipes.ALLOY_SMELTER.name(), EntryStacks.of(Machine.ALLOY_SMELTER), EntryStacks.of(Machine.IRON_ALLOY_FURNACE));
addWorkstations(ModRecipes.ASSEMBLING_MACHINE.name(), EntryStacks.of(Machine.ASSEMBLY_MACHINE));
addWorkstations(ModRecipes.BLAST_FURNACE.name(), EntryStacks.of(Machine.INDUSTRIAL_BLAST_FURNACE));
addWorkstations(ModRecipes.CENTRIFUGE.name(), EntryStacks.of(Machine.INDUSTRIAL_CENTRIFUGE));
addWorkstations(ModRecipes.CHEMICAL_REACTOR.name(), EntryStacks.of(Machine.CHEMICAL_REACTOR));
addWorkstations(ModRecipes.COMPRESSOR.name(), EntryStacks.of(Machine.COMPRESSOR));
addWorkstations(ModRecipes.DISTILLATION_TOWER.name(), EntryStacks.of(Machine.DISTILLATION_TOWER));
addWorkstations(ModRecipes.EXTRACTOR.name(), EntryStacks.of(Machine.EXTRACTOR));
addWorkstations(ModRecipes.FLUID_REPLICATOR.name(), EntryStacks.of(Machine.FLUID_REPLICATOR));
addWorkstations(ModRecipes.FUSION_REACTOR.name(), EntryStacks.of(Machine.FUSION_CONTROL_COMPUTER));
addWorkstations(ModRecipes.GRINDER.name(), EntryStacks.of(Machine.GRINDER));
addWorkstations(ModRecipes.IMPLOSION_COMPRESSOR.name(), EntryStacks.of(Machine.IMPLOSION_COMPRESSOR));
addWorkstations(ModRecipes.INDUSTRIAL_ELECTROLYZER.name(), EntryStacks.of(Machine.INDUSTRIAL_ELECTROLYZER));
addWorkstations(ModRecipes.INDUSTRIAL_GRINDER.name(), EntryStacks.of(Machine.INDUSTRIAL_GRINDER));
addWorkstations(ModRecipes.INDUSTRIAL_SAWMILL.name(), EntryStacks.of(Machine.INDUSTRIAL_SAWMILL));
addWorkstations(ModRecipes.ROLLING_MACHINE.name(), EntryStacks.of(Machine.ROLLING_MACHINE));
addWorkstations(ModRecipes.SOLID_CANNING_MACHINE.name(), EntryStacks.of(Machine.SOLID_CANNING_MACHINE));
addWorkstations(ModRecipes.VACUUM_FREEZER.name(), EntryStacks.of(Machine.VACUUM_FREEZER));
addWorkstations(ModRecipes.WIRE_MILL.name(), EntryStacks.of(Machine.WIRE_MILL));
registry.addWorkstations(CategoryIdentifier.of(TechReborn.MOD_ID, Machine.THERMAL_GENERATOR.name), EntryStacks.of(Machine.THERMAL_GENERATOR));
registry.addWorkstations(CategoryIdentifier.of(TechReborn.MOD_ID, Machine.GAS_TURBINE.name), EntryStacks.of(Machine.GAS_TURBINE));
registry.addWorkstations(CategoryIdentifier.of(TechReborn.MOD_ID, Machine.DIESEL_GENERATOR.name), EntryStacks.of(Machine.DIESEL_GENERATOR));
registry.addWorkstations(CategoryIdentifier.of(TechReborn.MOD_ID, Machine.SEMI_FLUID_GENERATOR.name), EntryStacks.of(Machine.SEMI_FLUID_GENERATOR));
registry.addWorkstations(CategoryIdentifier.of(TechReborn.MOD_ID, Machine.PLASMA_GENERATOR.name), EntryStacks.of(Machine.PLASMA_GENERATOR));
}
private void addWorkstations(Identifier identifier, EntryStack<?>... stacks) {
CategoryRegistry.getInstance().addWorkstations(CategoryIdentifier.of(identifier), stacks);
}
@Override
public void registerPluginCategories(RecipeHelper recipeHelper) {
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 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 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));
public void registerDisplays(DisplayRegistry registry) {
RecipeManager.getRecipeTypes("techreborn").forEach(rebornRecipeType -> registerMachineRecipe(registry, rebornRecipeType));
recipeHelper.registerCategory(new FluidGeneratorRecipeCategory(Machine.THERMAL_GENERATOR));
recipeHelper.registerCategory(new FluidGeneratorRecipeCategory(Machine.GAS_TURBINE));
recipeHelper.registerCategory(new FluidGeneratorRecipeCategory(Machine.DIESEL_GENERATOR));
recipeHelper.registerCategory(new FluidGeneratorRecipeCategory(Machine.SEMI_FLUID_GENERATOR));
recipeHelper.registerCategory(new FluidGeneratorRecipeCategory(Machine.PLASMA_GENERATOR));
registerFluidGeneratorDisplays(registry, EFluidGenerator.THERMAL, Machine.THERMAL_GENERATOR);
registerFluidGeneratorDisplays(registry, EFluidGenerator.GAS, Machine.GAS_TURBINE);
registerFluidGeneratorDisplays(registry, EFluidGenerator.DIESEL, Machine.DIESEL_GENERATOR);
registerFluidGeneratorDisplays(registry, EFluidGenerator.SEMIFLUID, Machine.SEMI_FLUID_GENERATOR);
registerFluidGeneratorDisplays(registry, EFluidGenerator.PLASMA, Machine.PLASMA_GENERATOR);
}
@Override
public void registerRecipeDisplays(RecipeHelper recipeHelper) {
RecipeManager.getRecipeTypes("techreborn").forEach(rebornRecipeType -> registerMachineRecipe(recipeHelper, rebornRecipeType));
registerFluidGeneratorDisplays(recipeHelper, EFluidGenerator.THERMAL, Machine.THERMAL_GENERATOR);
registerFluidGeneratorDisplays(recipeHelper, EFluidGenerator.GAS, Machine.GAS_TURBINE);
registerFluidGeneratorDisplays(recipeHelper, EFluidGenerator.DIESEL, Machine.DIESEL_GENERATOR);
registerFluidGeneratorDisplays(recipeHelper, EFluidGenerator.SEMIFLUID, Machine.SEMI_FLUID_GENERATOR);
registerFluidGeneratorDisplays(recipeHelper, EFluidGenerator.PLASMA, Machine.PLASMA_GENERATOR);
}
@Override
public void registerOthers(RecipeHelper recipeHelper) {
recipeHelper.registerWorkingStations(ModRecipes.ALLOY_SMELTER.name(), EntryStack.create(Machine.ALLOY_SMELTER), EntryStack.create(Machine.IRON_ALLOY_FURNACE));
recipeHelper.registerWorkingStations(ModRecipes.ASSEMBLING_MACHINE.name(), EntryStack.create(Machine.ASSEMBLY_MACHINE));
recipeHelper.registerWorkingStations(ModRecipes.BLAST_FURNACE.name(), EntryStack.create(Machine.INDUSTRIAL_BLAST_FURNACE));
recipeHelper.registerWorkingStations(ModRecipes.CENTRIFUGE.name(), EntryStack.create(Machine.INDUSTRIAL_CENTRIFUGE));
recipeHelper.registerWorkingStations(ModRecipes.CHEMICAL_REACTOR.name(), EntryStack.create(Machine.CHEMICAL_REACTOR));
recipeHelper.registerWorkingStations(ModRecipes.COMPRESSOR.name(), EntryStack.create(Machine.COMPRESSOR));
recipeHelper.registerWorkingStations(ModRecipes.DISTILLATION_TOWER.name(), EntryStack.create(Machine.DISTILLATION_TOWER));
recipeHelper.registerWorkingStations(ModRecipes.EXTRACTOR.name(), EntryStack.create(Machine.EXTRACTOR));
recipeHelper.registerWorkingStations(ModRecipes.FLUID_REPLICATOR.name(), EntryStack.create(Machine.FLUID_REPLICATOR));
recipeHelper.registerWorkingStations(ModRecipes.FUSION_REACTOR.name(), EntryStack.create(Machine.FUSION_CONTROL_COMPUTER));
recipeHelper.registerWorkingStations(ModRecipes.GRINDER.name(), EntryStack.create(Machine.GRINDER));
recipeHelper.registerWorkingStations(ModRecipes.IMPLOSION_COMPRESSOR.name(), EntryStack.create(Machine.IMPLOSION_COMPRESSOR));
recipeHelper.registerWorkingStations(ModRecipes.INDUSTRIAL_ELECTROLYZER.name(), EntryStack.create(Machine.INDUSTRIAL_ELECTROLYZER));
recipeHelper.registerWorkingStations(ModRecipes.INDUSTRIAL_GRINDER.name(), EntryStack.create(Machine.INDUSTRIAL_GRINDER));
recipeHelper.registerWorkingStations(ModRecipes.INDUSTRIAL_SAWMILL.name(), EntryStack.create(Machine.INDUSTRIAL_SAWMILL));
recipeHelper.registerWorkingStations(ModRecipes.ROLLING_MACHINE.name(), EntryStack.create(Machine.ROLLING_MACHINE));
recipeHelper.registerWorkingStations(ModRecipes.SOLID_CANNING_MACHINE.name(), EntryStack.create(Machine.SOLID_CANNING_MACHINE));
recipeHelper.registerWorkingStations(ModRecipes.VACUUM_FREEZER.name(), EntryStack.create(Machine.VACUUM_FREEZER));
recipeHelper.registerWorkingStations(ModRecipes.WIRE_MILL.name(), EntryStack.create(Machine.WIRE_MILL));
recipeHelper.registerWorkingStations(new Identifier(TechReborn.MOD_ID, Machine.THERMAL_GENERATOR.name), EntryStack.create(Machine.THERMAL_GENERATOR));
recipeHelper.registerWorkingStations(new Identifier(TechReborn.MOD_ID, Machine.GAS_TURBINE.name), EntryStack.create(Machine.GAS_TURBINE));
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() {
public void registerFluidSupport(FluidSupportProvider support) {
support.register(new FluidSupportProvider.Provider() {
@Override
@NotNull
public EntryStack itemToFluid(@NotNull EntryStack itemStack) {
public CompoundEventResult<Stream<EntryStack<FluidStack>>> itemToFluid(EntryStack<? extends ItemStack> stack) {
ItemStack itemStack = stack.getValue();
if (itemStack.getItem() instanceof ItemFluidInfo) {
Fluid fluid = ((ItemFluidInfo) itemStack.getItem()).getFluid(itemStack.getItemStack());
Fluid fluid = ((ItemFluidInfo) itemStack.getItem()).getFluid(itemStack);
if (fluid != null)
return EntryStack.create(fluid);
return CompoundEventResult.interruptTrue(Stream.of(EntryStacks.of(fluid)));
}
return EntryStack.empty();
return CompoundEventResult.pass();
}
});
}
@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.
EntryRegistry.getInstance().getEntryStacks().forEach(ReiPlugin::applyCellEntry);
public void registerItemComparators(ItemComparatorRegistry registry) {
registry.registerNbt(TRContent.CELL);
}
public static void applyCellEntry(EntryStack stack) {
// getItem can be null but this works
if (stack.getItem() == TRContent.CELL)
stack.setting(EntryStack.Settings.CHECK_TAGS, EntryStack.Settings.TRUE);
}
private void registerFluidGeneratorDisplays(RecipeHelper recipeHelper, EFluidGenerator generator, Machine machine) {
private void registerFluidGeneratorDisplays(DisplayRegistry registry, EFluidGenerator generator, Machine machine) {
Identifier identifier = new Identifier(TechReborn.MOD_ID, machine.name);
GeneratorRecipeHelper.getFluidRecipesForGenerator(generator).getRecipes().forEach(recipe ->
recipeHelper.registerDisplay(new FluidGeneratorRecipeDisplay(recipe, identifier))
registry.add(new FluidGeneratorRecipeDisplay(recipe, identifier))
);
}
private <R extends RebornRecipe> void registerMachineRecipe(RecipeHelper recipeHelper, RebornRecipeType<R> recipeType) {
Function<R, RecipeDisplay> recipeDisplay = r -> new MachineRecipeDisplay<>((RebornRecipe) r);
private <R extends RebornRecipe> void registerMachineRecipe(DisplayRegistry registry, RebornRecipeType<R> recipeType) {
Function<R, Display> recipeDisplay = r -> new MachineRecipeDisplay<>((RebornRecipe) r);
if (recipeType == ModRecipes.ROLLING_MACHINE) {
recipeDisplay = r -> {
@ -240,36 +235,33 @@ public class ReiPlugin implements REIPluginV0 {
};
}
recipeHelper.registerRecipes(recipeType.name(), (Predicate<Recipe>) recipe -> {
registry.registerFiller(RebornRecipe.class, recipe -> {
if (recipe instanceof RebornRecipe) {
return ((RebornRecipe) recipe).getRebornRecipeType() == recipeType;
return recipe.getRebornRecipeType() == recipeType;
}
return false;
}, recipeDisplay);
}
@Override
public void registerBounds(DisplayHelper displayHelper) {
BaseBoundsHandler baseBoundsHandler = BaseBoundsHandler.getInstance();
baseBoundsHandler.registerExclusionZones(GuiBase.class, () -> {
Screen currentScreen = MinecraftClient.getInstance().currentScreen;
if (currentScreen instanceof GuiBase<?> guiBase) {
int height = 0;
if (guiBase.tryAddUpgrades() && guiBase.be instanceof IUpgradeable upgradeable) {
if (upgradeable.canBeUpgraded()) {
height = 80;
}
public void registerScreens(ScreenRegistry registry) {
ExclusionZones exclusionZones = registry.exclusionZones();
exclusionZones.register(GuiBase.class, guiBase -> {
int height = 0;
if (guiBase.tryAddUpgrades() && guiBase.be instanceof IUpgradeable upgradeable) {
if (upgradeable.canBeUpgraded()) {
height = 80;
}
for (GuiTab slot : guiBase.getTabs()) {
if (slot.enabled()) {
height += 24;
}
}
if (height > 0) {
int width = 20;
return Collections.singletonList(new Rectangle(guiBase.getGuiLeft() - width, guiBase.getGuiTop() + 8, width, height));
}
for (GuiTab slot : (List<GuiTab>) guiBase.getTabs()) {
if (slot.enabled()) {
height += 24;
}
}
if (height > 0) {
int width = 20;
return Collections.singletonList(new Rectangle(guiBase.getGuiLeft() - width, guiBase.getGuiTop() + 8, width, height));
}
return Collections.emptyList();
});
}
@ -294,27 +286,30 @@ public class ReiPlugin implements REIPluginV0 {
public static Widget createEnergyDisplay(Rectangle bounds, double energy, EntryAnimation animation, Function<Point, Tooltip> tooltipBuilder) {
return new EnergyEntryWidget(bounds, animation).entry(
new RenderingEntry() {
ClientEntryStacks.of(new AbstractRenderer() {
@Override
public void render(MatrixStack matrices, Rectangle bounds, int mouseX, int mouseY, float delta) {}
@Override
public @Nullable Tooltip getTooltip(Point mouse) {
@Nullable
public 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);
public static Widget createFluidDisplay(Rectangle bounds, EntryStack<FluidStack> fluid, EntryAnimation animation) {
EntryStack<FluidStack> copy = fluid.copy();
ClientEntryStacks.setRenderer(copy, new FluidStackRenderer(animation, copy.getRenderer()));
return Widgets.createSlot(bounds).entry(copy);
}
private static class EnergyEntryWidget extends EntryWidget {
private EntryAnimation animation;
protected EnergyEntryWidget(Rectangle rectangle, EntryAnimation animation) {
super(rectangle.x, rectangle.y);
super(new Point(rectangle.x, rectangle.y));
this.getBounds().setBounds(rectangle);
this.animation = animation;
}
@ -343,38 +338,33 @@ public class ReiPlugin implements REIPluginV0 {
@Override
protected void drawCurrentEntry(MatrixStack matrices, int mouseX, int mouseY, float delta) {}
}
private static class FluidStackRenderer extends AbstractEntryRenderer<FluidStack> {
private final EntryAnimation animation;
private final EntryRenderer<FluidStack> parent;
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;
public FluidStackRenderer(EntryAnimation animation, EntryRenderer<FluidStack> parent) {
this.animation = animation;
this.parent = parent;
}
@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;
public void render(EntryStack<FluidStack> entry, MatrixStack matrices, Rectangle bounds, int mouseX, int mouseY, float delta) {
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));
if (animation.animationType == EntryAnimationType.DOWNWARDS)
innerDisplayHeight = innerHeight - innerDisplayHeight;
} else innerDisplayHeight = innerHeight;
drawFluid(matrices, fluid, innerDisplayHeight, bounds.x + 1, bounds.y + 1, width - 2, innerHeight);
}
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));
if (animation.animationType == EntryAnimationType.DOWNWARDS)
innerDisplayHeight = innerHeight - innerDisplayHeight;
} else innerDisplayHeight = innerHeight;
drawFluid(matrices, entry.getValue().getFluid(), 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) {
@ -384,10 +374,10 @@ public class ReiPlugin implements REIPluginV0 {
FluidRenderHandler handler = FluidRenderHandlerRegistry.INSTANCE.get(fluid);
// If registry can't find it, don't render.
if(handler == null){
if (handler == null) {
return;
}
final Sprite sprite = handler.getFluidSprites(MinecraftClient.getInstance().world, BlockPos.ORIGIN, fluid.getDefaultState())[0];
int color = FluidRenderHandlerRegistry.INSTANCE.get(fluid).getFluidColor(MinecraftClient.getInstance().world, BlockPos.ORIGIN, fluid.getDefaultState());
@ -410,7 +400,10 @@ public class ReiPlugin implements REIPluginV0 {
}
@Override
protected void drawCurrentEntry(MatrixStack matrices, int mouseX, int mouseY, float delta) {}
@Nullable
public Tooltip getTooltip(EntryStack<FluidStack> entry, Point mouse) {
return parent.getTooltip(entry, mouse);
}
}
public record EntryAnimation(EntryAnimationType animationType, long duration) {

View file

@ -26,13 +26,14 @@ package techreborn.compat.rei.fluidgenerator;
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.Tooltip;
import me.shedaniel.rei.api.widgets.Widgets;
import me.shedaniel.rei.gui.widget.Widget;
import net.minecraft.client.resource.language.I18n;
import me.shedaniel.rei.api.client.ClientHelper;
import me.shedaniel.rei.api.client.gui.Renderer;
import me.shedaniel.rei.api.client.gui.widgets.Tooltip;
import me.shedaniel.rei.api.client.gui.widgets.Widget;
import me.shedaniel.rei.api.client.gui.widgets.Widgets;
import me.shedaniel.rei.api.client.registry.display.DisplayCategory;
import me.shedaniel.rei.api.common.category.CategoryIdentifier;
import me.shedaniel.rei.api.common.util.EntryStacks;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
import net.minecraft.util.Formatting;
@ -44,29 +45,29 @@ import techreborn.init.TRContent;
import java.util.List;
public class FluidGeneratorRecipeCategory implements RecipeCategory<FluidGeneratorRecipeDisplay> {
public class FluidGeneratorRecipeCategory implements DisplayCategory<FluidGeneratorRecipeDisplay> {
private final TRContent.Machine generator;
private final Identifier identifier;
private final CategoryIdentifier<? extends FluidGeneratorRecipeDisplay> identifier;
public FluidGeneratorRecipeCategory(TRContent.Machine generator) {
this.generator = generator;
this.identifier = new Identifier(TechReborn.MOD_ID, generator.name);
this.identifier = CategoryIdentifier.of(TechReborn.MOD_ID, generator.name);
}
@Override
public Identifier getIdentifier() {
public CategoryIdentifier<? extends FluidGeneratorRecipeDisplay> getCategoryIdentifier() {
return identifier;
}
@Override
public String getCategoryName() {
return I18n.translate(identifier.toString());
public Text getTitle() {
return new TranslatableText(identifier.toString());
}
@Override
public EntryStack getLogo() {
return EntryStack.create(generator);
public Renderer getIcon() {
return EntryStacks.of(generator);
}
@Override
@ -81,7 +82,7 @@ public class FluidGeneratorRecipeCategory implements RecipeCategory<FluidGenerat
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.createFluidDisplay(new Rectangle(bounds.x + 16, bounds.y + 8, 16, 50), recipeDisplay.getInputEntries().get(0).get(0).cast(), ReiPlugin.EntryAnimation.downwards(5000)));
widgets.add(ReiPlugin.createProgressBar(bounds.x + 76 - 16, bounds.y + 48 - 19, 5000, GuiBuilder.ProgressDirection.RIGHT));
return widgets;
}

View file

@ -25,44 +25,40 @@
package techreborn.compat.rei.fluidgenerator;
import com.google.common.collect.Lists;
import me.shedaniel.rei.api.EntryStack;
import me.shedaniel.rei.api.RecipeDisplay;
import me.shedaniel.rei.api.common.category.CategoryIdentifier;
import me.shedaniel.rei.api.common.display.Display;
import me.shedaniel.rei.api.common.entry.EntryIngredient;
import me.shedaniel.rei.api.common.util.EntryIngredients;
import net.minecraft.util.Identifier;
import techreborn.api.generator.FluidGeneratorRecipe;
import java.util.Collections;
import java.util.List;
public class FluidGeneratorRecipeDisplay implements RecipeDisplay {
public class FluidGeneratorRecipeDisplay implements Display {
private final List<List<EntryStack>> inputs;
private final Identifier category;
private final List<EntryIngredient> inputs;
private final CategoryIdentifier<?> category;
private final int totalEnergy;
public FluidGeneratorRecipeDisplay(FluidGeneratorRecipe recipe, Identifier category) {
this.category = category;
this.category = CategoryIdentifier.of(category);
this.inputs = Lists.newArrayList();
this.totalEnergy = recipe.getEnergyPerBucket();
inputs.add(Collections.singletonList(EntryStack.create(recipe.fluid(), 1000)));
inputs.add(EntryIngredients.of(recipe.fluid(), 1000));
}
@Override
public List<List<EntryStack>> getInputEntries() {
public List<EntryIngredient> getInputEntries() {
return inputs;
}
@Override
public List<List<EntryStack>> getRequiredEntries() {
return inputs;
}
@Override
public List<EntryStack> getOutputEntries() {
public List<EntryIngredient> getOutputEntries() {
return Lists.newArrayList();
}
@Override
public Identifier getRecipeCategory() {
public CategoryIdentifier<?> getCategoryIdentifier() {
return category;
}

View file

@ -27,13 +27,14 @@ 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.Tooltip;
import me.shedaniel.rei.api.widgets.Widgets;
import me.shedaniel.rei.gui.widget.Widget;
import net.minecraft.client.resource.language.I18n;
import me.shedaniel.rei.api.client.ClientHelper;
import me.shedaniel.rei.api.client.gui.Renderer;
import me.shedaniel.rei.api.client.gui.widgets.Tooltip;
import me.shedaniel.rei.api.client.gui.widgets.Widget;
import me.shedaniel.rei.api.client.gui.widgets.Widgets;
import me.shedaniel.rei.api.client.registry.display.DisplayCategory;
import me.shedaniel.rei.api.common.category.CategoryIdentifier;
import me.shedaniel.rei.api.common.util.EntryStacks;
import net.minecraft.item.Items;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
@ -47,7 +48,7 @@ import techreborn.compat.rei.ReiPlugin;
import java.text.DecimalFormat;
import java.util.List;
public class FluidReplicatorRecipeCategory implements RecipeCategory<FluidReplicatorRecipeDisplay> {
public class FluidReplicatorRecipeCategory implements DisplayCategory<FluidReplicatorRecipeDisplay> {
private final RebornRecipeType<FluidReplicatorRecipe> rebornRecipeType;
@ -56,18 +57,18 @@ public class FluidReplicatorRecipeCategory implements RecipeCategory<FluidReplic
}
@Override
public Identifier getIdentifier() {
return rebornRecipeType.name();
public CategoryIdentifier<? extends FluidReplicatorRecipeDisplay> getCategoryIdentifier() {
return CategoryIdentifier.of(rebornRecipeType.name());
}
@Override
public String getCategoryName() {
return I18n.translate(rebornRecipeType.name().toString());
public Text getTitle() {
return new TranslatableText(rebornRecipeType.name().toString());
}
@Override
public EntryStack getLogo() {
return EntryStack.create(ReiPlugin.iconMap.getOrDefault(rebornRecipeType, () -> Items.DIAMOND_SHOVEL));
public Renderer getIcon() {
return EntryStacks.of(ReiPlugin.iconMap.getOrDefault(rebornRecipeType, () -> Items.DIAMOND_SHOVEL));
}
@Override
@ -87,7 +88,7 @@ public class FluidReplicatorRecipeCategory implements RecipeCategory<FluidReplic
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)));
widgets.add(ReiPlugin.createFluidDisplay(new Rectangle(bounds.x + 46 + 46, bounds.y + 8, 16, 50), recipeDisplay.getOutputEntries().get(0).get(0).cast(), ReiPlugin.EntryAnimation.upwards(5000)));
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)

View file

@ -24,9 +24,11 @@
package techreborn.compat.rei.fluidreplicator;
import me.shedaniel.rei.api.EntryStack;
import me.shedaniel.rei.api.RecipeDisplay;
import me.shedaniel.rei.utils.CollectionUtils;
import me.shedaniel.rei.api.common.category.CategoryIdentifier;
import me.shedaniel.rei.api.common.display.Display;
import me.shedaniel.rei.api.common.entry.EntryIngredient;
import me.shedaniel.rei.api.common.util.CollectionUtils;
import me.shedaniel.rei.api.common.util.EntryIngredients;
import net.minecraft.util.Identifier;
import reborncore.common.crafting.RebornRecipe;
import reborncore.common.fluid.container.FluidInstance;
@ -39,20 +41,20 @@ import java.util.Optional;
/**
* @author drcrazy
*/
public class FluidReplicatorRecipeDisplay implements RecipeDisplay {
public class FluidReplicatorRecipeDisplay implements Display {
private final FluidReplicatorRecipe recipe;
private final List<List<EntryStack>> inputs;
private final List<EntryStack> output;
private final List<EntryIngredient> inputs;
private final List<EntryIngredient> output;
private final FluidInstance fluidInstance;
private final int energy;
private final int time;
public FluidReplicatorRecipeDisplay(FluidReplicatorRecipe recipe) {
this.recipe = recipe;
this.inputs = CollectionUtils.map(recipe.getRebornIngredients(), ing -> EntryStack.ofItemStacks(ing.getPreviewStacks()));
this.inputs = CollectionUtils.map(recipe.getRebornIngredients(), ing -> EntryIngredients.ofItemStacks(ing.getPreviewStacks()));
this.fluidInstance = recipe.getFluidInstance();
this.output = fluidInstance == null ? Collections.emptyList() : Collections.singletonList(EntryStack.create(fluidInstance.getFluid(), fluidInstance.getAmount().getRawValue()));
this.output = fluidInstance == null ? Collections.emptyList() : Collections.singletonList(EntryIngredients.of(fluidInstance.getFluid(), fluidInstance.getAmount().getRawValue()));
this.energy = recipe.getPower();
this.time = recipe.getTime();
}
@ -70,27 +72,22 @@ public class FluidReplicatorRecipeDisplay implements RecipeDisplay {
}
@Override
public List<List<EntryStack>> getInputEntries() {
public List<EntryIngredient> getInputEntries() {
return inputs;
}
@Override
public List<EntryStack> getOutputEntries() {
public List<EntryIngredient> getOutputEntries() {
return output;
}
@Override
public List<List<EntryStack>> getRequiredEntries() {
return inputs;
public CategoryIdentifier<?> getCategoryIdentifier() {
return CategoryIdentifier.of(recipe.getRebornRecipeType().name());
}
@Override
public Identifier getRecipeCategory() {
return recipe.getRebornRecipeType().name();
}
@Override
public Optional<Identifier> getRecipeLocation() {
public Optional<Identifier> getDisplayLocation() {
return Optional.ofNullable(recipe).map(RebornRecipe::getId);
}
}

View file

@ -26,10 +26,10 @@ 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 me.shedaniel.rei.api.client.ClientHelper;
import me.shedaniel.rei.api.client.gui.widgets.Tooltip;
import me.shedaniel.rei.api.client.gui.widgets.Widget;
import me.shedaniel.rei.api.client.gui.widgets.Widgets;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
import net.minecraft.util.Formatting;

View file

@ -24,13 +24,16 @@
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 me.shedaniel.rei.api.client.gui.DisplayRenderer;
import me.shedaniel.rei.api.client.gui.Renderer;
import me.shedaniel.rei.api.client.gui.SimpleDisplayRenderer;
import me.shedaniel.rei.api.client.registry.display.DisplayCategory;
import me.shedaniel.rei.api.common.category.CategoryIdentifier;
import me.shedaniel.rei.api.common.entry.EntryIngredient;
import me.shedaniel.rei.api.common.util.EntryStacks;
import net.minecraft.item.Items;
import net.minecraft.util.Identifier;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
import reborncore.common.crafting.RebornRecipe;
import reborncore.common.crafting.RebornRecipeType;
import techreborn.compat.rei.MachineRecipeDisplay;
@ -39,7 +42,7 @@ import techreborn.compat.rei.ReiPlugin;
import java.util.Collections;
import java.util.List;
public abstract class AbstractMachineCategory<R extends RebornRecipe> implements RecipeCategory<MachineRecipeDisplay<R>> {
public abstract class AbstractMachineCategory<R extends RebornRecipe> implements DisplayCategory<MachineRecipeDisplay<R>> {
private final RebornRecipeType<R> rebornRecipeType;
public AbstractMachineCategory(RebornRecipeType<R> rebornRecipeType) {
@ -47,32 +50,32 @@ public abstract class AbstractMachineCategory<R extends RebornRecipe> implements
}
@Override
public Identifier getIdentifier() {
return rebornRecipeType.name();
public CategoryIdentifier<? extends MachineRecipeDisplay<R>> getCategoryIdentifier() {
return CategoryIdentifier.of(rebornRecipeType.name());
}
@Override
public String getCategoryName() {
return I18n.translate(rebornRecipeType.name().toString());
public Text getTitle() {
return new TranslatableText(rebornRecipeType.name().toString());
}
@Override
public EntryStack getLogo() {
return EntryStack.create(ReiPlugin.iconMap.getOrDefault(rebornRecipeType, () -> Items.DIAMOND_SHOVEL));
public Renderer getIcon() {
return EntryStacks.of(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 DisplayRenderer getDisplayRenderer(MachineRecipeDisplay<R> recipe) {
return SimpleDisplayRenderer.from(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 EntryIngredient getInput(MachineRecipeDisplay<R> recipeDisplay, int index) {
List<EntryIngredient> inputs = recipeDisplay.getInputEntries();
return inputs.size() > index ? inputs.get(index) : EntryIngredient.empty();
}
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();
public EntryIngredient getOutput(MachineRecipeDisplay<R> recipeDisplay, int index) {
List<EntryIngredient> outputs = recipeDisplay.getOutputEntries();
return outputs.size() > index ? outputs.get(index) : EntryIngredient.empty();
}
}

View file

@ -26,8 +26,8 @@ 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 me.shedaniel.rei.api.client.gui.widgets.Widget;
import me.shedaniel.rei.api.client.gui.widgets.Widgets;
import net.minecraft.text.TranslatableText;
import reborncore.client.gui.guibuilder.GuiBuilder;
import reborncore.common.crafting.RebornRecipe;

View file

@ -26,8 +26,8 @@ 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 me.shedaniel.rei.api.client.gui.widgets.Widget;
import me.shedaniel.rei.api.client.gui.widgets.Widgets;
import net.minecraft.text.LiteralText;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;

View file

@ -26,8 +26,8 @@ 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 me.shedaniel.rei.api.client.gui.widgets.Widget;
import me.shedaniel.rei.api.client.gui.widgets.Widgets;
import net.minecraft.text.TranslatableText;
import reborncore.client.gui.guibuilder.GuiBuilder;
import reborncore.common.crafting.RebornRecipe;

View file

@ -26,8 +26,8 @@ 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 me.shedaniel.rei.api.client.gui.widgets.Widget;
import me.shedaniel.rei.api.client.gui.widgets.Widgets;
import net.minecraft.text.TranslatableText;
import reborncore.client.gui.guibuilder.GuiBuilder;
import reborncore.common.crafting.RebornRecipe;

View file

@ -27,10 +27,10 @@ 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 me.shedaniel.rei.api.client.ClientHelper;
import me.shedaniel.rei.api.client.gui.widgets.Tooltip;
import me.shedaniel.rei.api.client.gui.widgets.Widget;
import me.shedaniel.rei.api.client.gui.widgets.Widgets;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
import net.minecraft.util.Formatting;
@ -67,7 +67,7 @@ public class GrinderCategory<R extends RebornRecipe> extends AbstractMachineCate
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(ReiPlugin.createFluidDisplay(new Rectangle(bounds.x + 55 - 26, bounds.y + 18, 16, 50), getInput(recipeDisplay, 1).get(0).cast(), 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)

View file

@ -26,8 +26,8 @@ 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 me.shedaniel.rei.api.client.gui.widgets.Widget;
import me.shedaniel.rei.api.client.gui.widgets.Widgets;
import net.minecraft.text.TranslatableText;
import reborncore.client.gui.guibuilder.GuiBuilder;
import reborncore.common.crafting.RebornRecipe;

View file

@ -26,8 +26,8 @@ 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 me.shedaniel.rei.api.client.gui.widgets.Widget;
import me.shedaniel.rei.api.client.gui.widgets.Widgets;
import net.minecraft.text.TranslatableText;
import reborncore.client.gui.guibuilder.GuiBuilder;
import reborncore.common.crafting.RebornRecipe;

View file

@ -26,8 +26,8 @@ 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 me.shedaniel.rei.api.client.gui.widgets.Widget;
import me.shedaniel.rei.api.client.gui.widgets.Widgets;
import net.minecraft.text.TranslatableText;
import reborncore.client.gui.guibuilder.GuiBuilder;
import reborncore.common.crafting.RebornRecipe;

View file

@ -26,8 +26,8 @@ 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 me.shedaniel.rei.api.client.gui.widgets.Widget;
import me.shedaniel.rei.api.client.gui.widgets.Widgets;
import net.minecraft.text.TranslatableText;
import reborncore.client.gui.guibuilder.GuiBuilder;
import reborncore.common.crafting.RebornRecipe;
@ -51,7 +51,7 @@ public class SawmillCategory<R extends RebornRecipe> extends AbstractEnergyConsu
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(ReiPlugin.createFluidDisplay(new Rectangle(bounds.x + 55 - 26, bounds.y + 8, 16, 50), getInput(recipeDisplay, 1).get(0).cast(), 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)

View file

@ -26,8 +26,8 @@ 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 me.shedaniel.rei.api.client.gui.widgets.Widget;
import me.shedaniel.rei.api.client.gui.widgets.Widgets;
import net.minecraft.text.TranslatableText;
import reborncore.client.gui.guibuilder.GuiBuilder;
import reborncore.common.crafting.RebornRecipe;

View file

@ -24,11 +24,14 @@
package techreborn.compat.rei.rollingmachine;
import me.shedaniel.rei.api.EntryStack;
import me.shedaniel.rei.plugin.crafting.DefaultCraftingCategory;
import net.minecraft.client.resource.language.I18n;
import me.shedaniel.rei.api.client.gui.Renderer;
import me.shedaniel.rei.api.common.category.CategoryIdentifier;
import me.shedaniel.rei.api.common.util.EntryStacks;
import me.shedaniel.rei.plugin.client.categories.crafting.DefaultCraftingCategory;
import me.shedaniel.rei.plugin.common.displays.crafting.DefaultCraftingDisplay;
import net.minecraft.item.Items;
import net.minecraft.util.Identifier;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
import reborncore.common.crafting.RebornRecipeType;
import techreborn.api.recipe.recipes.RollingMachineRecipe;
import techreborn.compat.rei.ReiPlugin;
@ -42,18 +45,18 @@ public class RollingMachineCategory extends DefaultCraftingCategory {
}
@Override
public Identifier getIdentifier() {
return rebornRecipeType.name();
public CategoryIdentifier<? extends DefaultCraftingDisplay<?>> getCategoryIdentifier() {
return CategoryIdentifier.of(rebornRecipeType.name());
}
@Override
public String getCategoryName() {
return I18n.translate(rebornRecipeType.name().toString());
public Text getTitle() {
return new TranslatableText(rebornRecipeType.name().toString());
}
@Override
public EntryStack getLogo() {
return EntryStack.create(ReiPlugin.iconMap.getOrDefault(rebornRecipeType, () -> Items.DIAMOND_SHOVEL));
public Renderer getIcon() {
return EntryStacks.of(ReiPlugin.iconMap.getOrDefault(rebornRecipeType, () -> Items.DIAMOND_SHOVEL));
}
}

View file

@ -24,9 +24,9 @@
package techreborn.compat.rei.rollingmachine;
import me.shedaniel.rei.plugin.crafting.DefaultShapedDisplay;
import me.shedaniel.rei.api.common.category.CategoryIdentifier;
import me.shedaniel.rei.plugin.common.displays.crafting.DefaultShapedDisplay;
import net.minecraft.recipe.ShapedRecipe;
import net.minecraft.util.Identifier;
import techreborn.init.ModRecipes;
public class RollingMachineDisplay extends DefaultShapedDisplay {
@ -36,7 +36,7 @@ public class RollingMachineDisplay extends DefaultShapedDisplay {
}
@Override
public Identifier getRecipeCategory() {
return ModRecipes.ROLLING_MACHINE.name();
public CategoryIdentifier<?> getCategoryIdentifier() {
return CategoryIdentifier.of(ModRecipes.ROLLING_MACHINE.name());
}
}

View file

@ -19,7 +19,7 @@
"client": [
"techreborn.TechRebornClient"
],
"rei_plugins_v0": [
"rei": [
"techreborn.compat.rei.ReiPlugin"
],
"autoswitch": [