-
-
Notifications
You must be signed in to change notification settings - Fork 11
Let the Attuned Crafting Interface enable and disable individual recipes #221
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
rubensworks
merged 10 commits into
master-1.21-lts
from
claude/attuned-crafting-recipe-list-x0ogkw
Sep 4, 2026
Merged
Changes from 9 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
7c08573
Let the Attuned Crafting Interface enable and disable individual recipes
claude 54f8b62
Cover the attuned recipe gui container with game tests
claude 70cb091
Show the attuned interface recipes as a grid of output icons
claude 7ad36ec
Put the recipe state border behind the output, and unpack the bulk bu…
claude ef4c36f
Inset the recipe state border by a pixel
claude 851ce9f
Return to the attuned interface gui when its sub-guis are closed
claude 42183c0
Enable and disable attuned interface recipes by dragging over them
claude 6b04fb7
Bump CyclopsCore and drop the scrolling grid workaround
claude a0c57b4
Document the attuned interface recipe gui in the infobook
claude 19998ea
Apply suggestion from @rubensworks
rubensworks File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
129 changes: 129 additions & 0 deletions
129
src/main/java/org/cyclops/integratedcrafting/api/recipe/RecipeKey.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,129 @@ | ||
| package org.cyclops.integratedcrafting.api.recipe; | ||
|
|
||
| import net.minecraft.core.HolderLookup; | ||
| import net.minecraft.nbt.CompoundTag; | ||
| import net.minecraft.nbt.Tag; | ||
| import net.minecraft.resources.ResourceLocation; | ||
| import org.cyclops.commoncapabilities.api.capability.recipehandler.IRecipeDefinition; | ||
|
|
||
| import javax.annotation.Nullable; | ||
| import java.util.Objects; | ||
|
|
||
| /** | ||
| * An opaque and persistable identifier of a recipe. | ||
| * | ||
| * Recipes that originate from a built-in recipe are identified by their recipe id, | ||
| * which keeps this key small, even for machines that expose thousands of recipes. | ||
| * All other recipes are identified by their full structural serialization. | ||
| * | ||
| * Keys are deliberately never resolved back into recipes, | ||
| * as {@link org.cyclops.commoncapabilities.api.capability.recipehandler.RecipeDefinition#fromRecipeId(HolderLookup.Provider, ResourceLocation)} | ||
| * throws once the recipe no longer exists. | ||
| * Keeping unknown keys opaque makes sure that a pack update can not silently | ||
| * change the meaning of a key that was stored before. | ||
| * | ||
| * @author rubensworks | ||
| */ | ||
| public final class RecipeKey { | ||
|
|
||
| /** | ||
| * The NBT key under which {@link IRecipeDefinition#serialize(HolderLookup.Provider, IRecipeDefinition)} | ||
| * stores the id of built-in recipes. | ||
| */ | ||
| private static final String NBT_RECIPE_ID = "recipeId"; | ||
|
|
||
| @Nullable | ||
| private final String recipeId; | ||
| @Nullable | ||
| private final CompoundTag structure; | ||
|
|
||
| private RecipeKey(@Nullable String recipeId, @Nullable CompoundTag structure) { | ||
| this.recipeId = recipeId; | ||
| this.structure = structure; | ||
| } | ||
|
|
||
| /** | ||
| * Create a key for the given built-in recipe id. | ||
| * @param recipeId A recipe id. | ||
| * @return A key. | ||
| */ | ||
| public static RecipeKey ofRecipeId(String recipeId) { | ||
| return new RecipeKey(Objects.requireNonNull(recipeId), null); | ||
| } | ||
|
|
||
| /** | ||
| * Create a key for the given recipe. | ||
| * @param lookupProvider A lookup provider, | ||
| * only used for recipes that are not backed by a built-in recipe. | ||
| * @param recipe A recipe. | ||
| * @return A key. | ||
| */ | ||
| public static RecipeKey of(HolderLookup.Provider lookupProvider, IRecipeDefinition recipe) { | ||
| ResourceLocation recipeId = recipe.getRecipeId(); | ||
| if (recipeId != null) { | ||
| return new RecipeKey(recipeId.toString(), null); | ||
| } | ||
| return new RecipeKey(null, IRecipeDefinition.serialize(lookupProvider, recipe)); | ||
| } | ||
|
|
||
| /** | ||
| * Read a key from NBT. | ||
| * @param tag An NBT tag, as produced by {@link #serialize()}. | ||
| * @return A key. | ||
| */ | ||
| public static RecipeKey deserialize(CompoundTag tag) { | ||
| if (tag.contains(NBT_RECIPE_ID, Tag.TAG_STRING)) { | ||
| return new RecipeKey(tag.getString(NBT_RECIPE_ID), null); | ||
| } | ||
| return new RecipeKey(null, tag.copy()); | ||
| } | ||
|
|
||
| /** | ||
| * @return An NBT representation of this key. | ||
| */ | ||
| public CompoundTag serialize() { | ||
| if (this.recipeId != null) { | ||
| CompoundTag tag = new CompoundTag(); | ||
| tag.putString(NBT_RECIPE_ID, this.recipeId); | ||
| return tag; | ||
| } | ||
| return this.structure.copy(); | ||
| } | ||
|
|
||
| /** | ||
| * @return The id of the built-in recipe this key refers to, or null if this key is structural. | ||
| */ | ||
| @Nullable | ||
| public String getRecipeId() { | ||
| return this.recipeId; | ||
| } | ||
|
|
||
| /** | ||
| * @return If this key identifies a recipe by its full structure instead of by a recipe id. | ||
| */ | ||
| public boolean isStructural() { | ||
| return this.recipeId == null; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean equals(Object obj) { | ||
| if (this == obj) { | ||
| return true; | ||
| } | ||
| if (!(obj instanceof RecipeKey that)) { | ||
| return false; | ||
| } | ||
| return Objects.equals(this.recipeId, that.recipeId) && Objects.equals(this.structure, that.structure); | ||
| } | ||
|
|
||
| @Override | ||
| public int hashCode() { | ||
| return this.recipeId != null ? this.recipeId.hashCode() : this.structure.hashCode(); | ||
| } | ||
|
|
||
| @Override | ||
| public String toString() { | ||
| return "[RecipeKey " + (this.recipeId != null ? this.recipeId : this.structure) + "]"; | ||
| } | ||
|
|
||
| } |
42 changes: 42 additions & 0 deletions
42
...ops/integratedcrafting/client/gui/ContainerScreenPartInterfaceCraftingAttunedOffsets.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| package org.cyclops.integratedcrafting.client.gui; | ||
|
|
||
| import net.minecraft.network.chat.Component; | ||
| import net.minecraft.world.entity.player.Inventory; | ||
| import org.cyclops.integratedcrafting.inventory.container.ContainerPartInterfaceCraftingAttunedOffsets; | ||
| import org.cyclops.integrateddynamics.core.client.gui.container.ContainerScreenPartOffset; | ||
| import org.cyclops.integrateddynamics.core.inventory.container.ContainerPartOffset; | ||
| import org.lwjgl.glfw.GLFW; | ||
|
|
||
| /** | ||
| * Offsets gui for the attuned crafting interface. | ||
| * | ||
| * Unlike the regular offsets gui, closing this one brings the player | ||
| * back to the gui of the attuned crafting interface it was opened from. | ||
| * | ||
| * @author rubensworks | ||
| */ | ||
| public class ContainerScreenPartInterfaceCraftingAttunedOffsets extends ContainerScreenPartOffset<ContainerPartInterfaceCraftingAttunedOffsets> { | ||
|
|
||
| public ContainerScreenPartInterfaceCraftingAttunedOffsets(ContainerPartInterfaceCraftingAttunedOffsets container, | ||
| Inventory inventory, Component title) { | ||
| super(container, inventory, title); | ||
| } | ||
|
|
||
| @Override | ||
| public boolean keyPressed(int typedChar, int keyCode, int modifiers) { | ||
| if (typedChar == GLFW.GLFW_KEY_ESCAPE) { | ||
| // Don't close all guis, but go back to the gui of the part. | ||
| exitToPartGui(); | ||
| return true; | ||
| } | ||
| return super.keyPressed(typedChar, keyCode, modifiers); | ||
| } | ||
|
|
||
| /** | ||
| * Save the current offsets and go back to the gui of the part. | ||
| */ | ||
| protected void exitToPartGui() { | ||
| createServerPressable(ContainerPartOffset.BUTTON_SAVE, button -> onSave()).onPress(null); | ||
| } | ||
|
|
||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.