diff --git a/src/main/java/slimeknights/tconstruct/plugin/rei/REIPlugin.java b/src/main/java/slimeknights/tconstruct/plugin/rei/REIPlugin.java index e0b3a322756..85458d91d94 100644 --- a/src/main/java/slimeknights/tconstruct/plugin/rei/REIPlugin.java +++ b/src/main/java/slimeknights/tconstruct/plugin/rei/REIPlugin.java @@ -48,6 +48,7 @@ import slimeknights.tconstruct.library.recipe.modifiers.severing.SeveringRecipe; import slimeknights.tconstruct.library.recipe.molding.MoldingRecipe; import slimeknights.tconstruct.library.recipe.partbuilder.IDisplayPartBuilderRecipe; +import slimeknights.tconstruct.library.recipe.worktable.IModifierWorktableRecipe; import slimeknights.tconstruct.library.tools.SlotType; import slimeknights.tconstruct.library.tools.item.IModifiableDisplay; import slimeknights.tconstruct.plugin.jei.entity.DefaultEntityMeltingRecipe; @@ -67,6 +68,8 @@ import slimeknights.tconstruct.plugin.rei.modifiers.ModifierEntryDefinition; import slimeknights.tconstruct.plugin.rei.modifiers.ModifierRecipeCategory; import slimeknights.tconstruct.plugin.rei.modifiers.ModifierRecipeDisplay; +import slimeknights.tconstruct.plugin.rei.modifiers.ModifierWorktableCategory; +import slimeknights.tconstruct.plugin.rei.modifiers.ModifierWorktableDisplay; import slimeknights.tconstruct.plugin.rei.partbuilder.PartBuilderCategory; import slimeknights.tconstruct.plugin.rei.partbuilder.PartBuilderDisplay; import slimeknights.tconstruct.plugin.rei.partbuilder.PatternEntryDefinition; @@ -99,12 +102,15 @@ public void registerCategories(CategoryRegistry registry) { registry.add(new SeveringCategory()); // part builder registry.add(new PartBuilderCategory()); + // modifier worktable + registry.add(new ModifierWorktableCategory()); // tables registry.addWorkstations(TConstructREIConstants.PART_BUILDER, EntryStacks.of(TinkerTables.partBuilder)); registry.addWorkstations(TConstructREIConstants.MODIFIERS, EntryStacks.of(TinkerTables.tinkerStation)); registry.addWorkstations(TConstructREIConstants.MODIFIERS, EntryStacks.of(TinkerTables.tinkersAnvil)); registry.addWorkstations(TConstructREIConstants.MODIFIERS, EntryStacks.of(TinkerTables.scorchedAnvil)); + registry.addWorkstations(TConstructREIConstants.MODIFIER_WORKTABLE, EntryStacks.of(TinkerTables.modifierWorktable)); // smeltery registry.addWorkstations(TConstructREIConstants.MELTING, EntryStacks.of(TinkerSmeltery.searedMelter)); @@ -221,6 +227,10 @@ public void registerDisplays(DisplayRegistry registry) { MaterialItemList.setRecipes(materialRecipes); List partRecipes = RecipeHelper.getJEIRecipes(manager, TinkerRecipeTypes.PART_BUILDER.get(), IDisplayPartBuilderRecipe.class); partRecipes.forEach(partRecipe -> registry.add(new PartBuilderDisplay(partRecipe))); + + // modifier worktable + List modifierWorktableRecipes = RecipeHelper.getJEIRecipes(manager, TinkerRecipeTypes.MODIFIER_WORKTABLE.get(), IModifierWorktableRecipe.class); + modifierWorktableRecipes.forEach(iModifierWorktableRecipe -> registry.add(new ModifierWorktableDisplay(iModifierWorktableRecipe))); } @Override diff --git a/src/main/java/slimeknights/tconstruct/plugin/rei/TConstructREIConstants.java b/src/main/java/slimeknights/tconstruct/plugin/rei/TConstructREIConstants.java index 49cbb9a4734..86ba2c94282 100644 --- a/src/main/java/slimeknights/tconstruct/plugin/rei/TConstructREIConstants.java +++ b/src/main/java/slimeknights/tconstruct/plugin/rei/TConstructREIConstants.java @@ -3,15 +3,18 @@ import me.shedaniel.rei.api.common.category.CategoryIdentifier; import me.shedaniel.rei.api.common.display.Display; import me.shedaniel.rei.api.common.entry.type.EntryType; +import mezz.jei.api.recipe.RecipeType; import net.minecraft.world.entity.EntityType; import slimeknights.tconstruct.TConstruct; import slimeknights.tconstruct.library.modifiers.ModifierEntry; import slimeknights.tconstruct.library.recipe.partbuilder.Pattern; +import slimeknights.tconstruct.library.recipe.worktable.IModifierWorktableRecipe; import slimeknights.tconstruct.plugin.rei.casting.CastingDisplay; import slimeknights.tconstruct.plugin.rei.entity.EntityMeltingRecipeDisplay; import slimeknights.tconstruct.plugin.rei.entity.SeveringDisplay; import slimeknights.tconstruct.plugin.rei.melting.MeltingDisplay; import slimeknights.tconstruct.plugin.rei.modifiers.ModifierRecipeDisplay; +import slimeknights.tconstruct.plugin.rei.modifiers.ModifierWorktableDisplay; import slimeknights.tconstruct.plugin.rei.partbuilder.PartBuilderDisplay; public class TConstructREIConstants { @@ -39,6 +42,9 @@ public class TConstructREIConstants { // part builder public static final CategoryIdentifier PART_BUILDER = type("part_builder"); + // modifier workstation + public static final CategoryIdentifier MODIFIER_WORKTABLE = type("worktable"); + private static CategoryIdentifier type(String name) { return CategoryIdentifier.of(TConstruct.MOD_ID, name); } diff --git a/src/main/java/slimeknights/tconstruct/plugin/rei/modifiers/ModifierWorktableCategory.java b/src/main/java/slimeknights/tconstruct/plugin/rei/modifiers/ModifierWorktableCategory.java new file mode 100644 index 00000000000..8a8f65a5c4b --- /dev/null +++ b/src/main/java/slimeknights/tconstruct/plugin/rei/modifiers/ModifierWorktableCategory.java @@ -0,0 +1,107 @@ +package slimeknights.tconstruct.plugin.rei.modifiers; + +import com.mojang.blaze3d.vertex.PoseStack; +import lombok.Getter; +import me.shedaniel.math.Point; +import me.shedaniel.math.Rectangle; +import me.shedaniel.rei.api.client.gui.Renderer; +import me.shedaniel.rei.api.client.gui.widgets.Slot; +import me.shedaniel.rei.api.client.gui.widgets.Widget; +import me.shedaniel.rei.api.common.category.CategoryIdentifier; +import me.shedaniel.rei.api.common.util.EntryIngredients; +import me.shedaniel.rei.api.common.util.EntryStacks; +import net.minecraft.client.Minecraft; +import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.item.ItemStack; +import slimeknights.tconstruct.TConstruct; +import slimeknights.tconstruct.library.recipe.worktable.IModifierWorktableRecipe; +import slimeknights.tconstruct.plugin.rei.TConstructREIConstants; +import slimeknights.tconstruct.plugin.rei.TinkersCategory; +import slimeknights.tconstruct.plugin.rei.widgets.WidgetHolder; +import slimeknights.tconstruct.tables.TinkerTables; + +import java.util.Collections; +import java.util.List; + +public class ModifierWorktableCategory implements TinkersCategory { + private static final ResourceLocation BACKGROUND_LOC = TConstruct.getResource("textures/gui/jei/tinker_station.png"); + private static final Component TITLE = TConstruct.makeTranslation("jei", "modifier_worktable.title"); + + @Getter + private final WidgetHolder background; + @Getter + private final Renderer icon; + private final WidgetHolder toolIcon; + private final WidgetHolder[] slotIcons; + public ModifierWorktableCategory() { + this.background = new WidgetHolder(BACKGROUND_LOC, 0, 166, 121, 35); + this.icon = EntryStacks.of(TinkerTables.modifierWorktable); + this.toolIcon = new WidgetHolder(BACKGROUND_LOC, 128, 0, 16, 16); + this.slotIcons = new WidgetHolder[] { + new WidgetHolder(BACKGROUND_LOC, 176, 0, 16, 16), + new WidgetHolder(BACKGROUND_LOC, 208, 0, 16, 16) + }; + } + + @Override + public WidgetHolder getBackground() { + return this.background; + } + + @Override + public CategoryIdentifier getCategoryIdentifier() { + return TConstructREIConstants.MODIFIER_WORKTABLE; + } + + @Override + public Component getTitle() { + return TITLE; + } + + @Override + public Renderer getIcon() { + return this.icon; + } + + @Override + public void draw(ModifierWorktableDisplay display, PoseStack matrixStack, double mouseX, double mouseY) { + Minecraft.getInstance().font.draw(matrixStack, display.getRecipe().getTitle(), 3, 2, 0x404040); + } + + @Override + public List getTooltipStrings(ModifierWorktableDisplay recipe, List widgets, double mouseX, double mouseY) { + if (mouseY >= 2 && mouseY <= 12) { + return List.of(recipe.getRecipe().getDescription(null)); + } + return Collections.emptyList(); + } + + @Override + public void addWidgets(ModifierWorktableDisplay display, List ingredients, Point origin, Rectangle bounds) { + IModifierWorktableRecipe recipe = display.getRecipe(); + // items + ingredients.add(slot(23, 16, origin).markInput().entries(EntryIngredients.ofItemStacks(recipe.getInputTools()))); + int max = Math.min(2, recipe.getInputCount()); + for (int i = 0; i < max; i++) { + ingredients.add(slot(43 + i*18, 16, origin).markInput().entries(EntryIngredients.ofItemStacks(recipe.getDisplayItems(i)))); + } + // modifier input + Slot slot = slot(82, 16, origin).entries(EntryIngredients.of(TConstructREIConstants.MODIFIER_TYPE, recipe.getModifierOptions(null))); + if (recipe.isModifierOutput()) + slot.markOutput(); + else + slot.markInput(); + ingredients.add(slot); + + if (recipe.getInputTools().isEmpty()) { + ingredients.add(toolIcon.build(23, 16, origin)); + } + for (int i = 0; i < 2; i++) { + List stacks = recipe.getDisplayItems(i); + if (stacks.isEmpty()) { + ingredients.add(slotIcons[i].build(43 + i * 18, 16, origin)); + } + } + } +} diff --git a/src/main/java/slimeknights/tconstruct/plugin/rei/modifiers/ModifierWorktableDisplay.java b/src/main/java/slimeknights/tconstruct/plugin/rei/modifiers/ModifierWorktableDisplay.java new file mode 100644 index 00000000000..c003f4b986a --- /dev/null +++ b/src/main/java/slimeknights/tconstruct/plugin/rei/modifiers/ModifierWorktableDisplay.java @@ -0,0 +1,45 @@ +package slimeknights.tconstruct.plugin.rei.modifiers; + +import com.google.common.collect.ImmutableList; +import lombok.Getter; +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 slimeknights.tconstruct.library.recipe.worktable.IModifierWorktableRecipe; +import slimeknights.tconstruct.plugin.rei.TConstructREIConstants; + +import java.util.List; + +public class ModifierWorktableDisplay implements Display { + @Getter + private final List inputEntries; + @Getter + private final List outputEntries; + @Getter + private final IModifierWorktableRecipe recipe; + + public ModifierWorktableDisplay(IModifierWorktableRecipe recipe) { + ImmutableList.Builder inputs = ImmutableList.builder(); + ImmutableList.Builder outputs = ImmutableList.builder(); + inputs.add(EntryIngredients.ofItemStacks(recipe.getInputTools())); + int max = Math.min(2, recipe.getInputCount()); + for (int i = 0; i < max; i++) { + inputs.add(EntryIngredients.ofItemStacks(recipe.getDisplayItems(i))); + } + // modifier input + if (recipe.isModifierOutput()) + outputs.add(EntryIngredients.of(TConstructREIConstants.MODIFIER_TYPE, recipe.getModifierOptions(null))); + else + outputs.add(EntryIngredients.of(TConstructREIConstants.MODIFIER_TYPE, recipe.getModifierOptions(null))); + + this.inputEntries = inputs.build(); + this.outputEntries = outputs.build(); + this.recipe = recipe; + } + + @Override + public CategoryIdentifier getCategoryIdentifier() { + return TConstructREIConstants.MODIFIER_WORKTABLE; + } +}