diff --git a/CHANGELOG.md b/CHANGELOG.md index 6a99e60..e062e72 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1 +1,2 @@ -- Fixed refilling stack only refilling a single craft \ No newline at end of file +- Updated to Minecraft 1.21.2 +- The Compress key now only works if the mod is installed on the server side \ No newline at end of file diff --git a/common/src/main/java/net/blay09/mods/craftingtweaks/CraftingTweaks.java b/common/src/main/java/net/blay09/mods/craftingtweaks/CraftingTweaks.java index fde3e62..1305735 100644 --- a/common/src/main/java/net/blay09/mods/craftingtweaks/CraftingTweaks.java +++ b/common/src/main/java/net/blay09/mods/craftingtweaks/CraftingTweaks.java @@ -13,6 +13,8 @@ import net.blay09.mods.craftingtweaks.network.HelloMessage; import net.blay09.mods.craftingtweaks.network.ModNetworking; import net.minecraft.resources.ResourceLocation; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.inventory.CraftingContainer; import net.minecraft.world.item.crafting.RecipeType; import net.minecraft.world.item.crafting.ShapedRecipe; @@ -34,18 +36,20 @@ public static void initialize() { Balm.addServerReloadListener(ResourceLocation.fromNamespaceAndPath(MOD_ID, "json_registry"), new JsonCompatLoader()); CraftingTweaksAPI.registerCraftingGridProvider(new VanillaCraftingGridProvider()); - CraftingTweaksAPI.registerRecipeMatrixMapper(ShapedRecipe.class, new ShapedRecipeMatrixMapper()); - CraftingTweaksAPI.registerRecipeMatrixMapper(ShapelessRecipe.class, new ShapelessRecipeMatrixMapper()); + CraftingTweaksAPI.registerRecipeMapper(ShapedRecipe.class, new ShapedRecipeMatrixMapper()); + CraftingTweaksAPI.registerRecipeMapper(ShapelessRecipe.class, new ShapelessRecipeMatrixMapper()); Balm.getEvents().onEvent(PlayerLoginEvent.class, event -> Balm.getNetworking().sendTo(event.getPlayer(), new HelloMessage())); Balm.getEvents().onEvent(ItemCraftedEvent.class, event -> { final var player = event.getPlayer(); final var level = player.level(); - final var craftMatrix = event.getCraftMatrix(); - final var recipeManager = level.getRecipeManager(); - if (craftMatrix instanceof CraftingContainer craftingContainer) { - final var optionalRecipeHolder = recipeManager.getRecipeFor(RecipeType.CRAFTING, craftingContainer.asCraftInput(), level); - optionalRecipeHolder.ifPresent(recipeHolder -> CraftingTweaksAPI.setLastCraftedRecipe(player, recipeHolder)); + if (player instanceof ServerPlayer serverPlayer && level instanceof ServerLevel serverLevel) { + final var craftMatrix = event.getCraftMatrix(); + final var recipeManager = serverLevel.getServer().getRecipeManager(); + if (craftMatrix instanceof CraftingContainer craftingContainer) { + final var optionalRecipeHolder = recipeManager.getRecipeFor(RecipeType.CRAFTING, craftingContainer.asCraftInput(), level); + optionalRecipeHolder.ifPresent(recipeHolder -> CraftingTweaksAPI.setLastCraftedRecipe(serverPlayer, recipeHolder)); + } } }); } diff --git a/common/src/main/java/net/blay09/mods/craftingtweaks/api/CraftingTweaksAPI.java b/common/src/main/java/net/blay09/mods/craftingtweaks/api/CraftingTweaksAPI.java index ef1c3e7..ed6a4d2 100644 --- a/common/src/main/java/net/blay09/mods/craftingtweaks/api/CraftingTweaksAPI.java +++ b/common/src/main/java/net/blay09/mods/craftingtweaks/api/CraftingTweaksAPI.java @@ -1,6 +1,6 @@ package net.blay09.mods.craftingtweaks.api; -import net.minecraft.world.Container; +import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.crafting.Recipe; import net.minecraft.world.item.crafting.RecipeHolder; @@ -30,19 +30,19 @@ public static void unregisterCraftingGridProvider(CraftingGridProvider provider) internalMethods.unregisterCraftingGridProvider(provider); } - public static > void registerRecipeMatrixMapper(Class recipeClass, RecipeMatrixMapper recipeMatrixMapper) { - internalMethods.registerRecipeMatrixMapper(recipeClass, recipeMatrixMapper); + public static > void registerRecipeMapper(Class recipeClass, RecipeMapper recipeMapper) { + internalMethods.registerRecipeMapper(recipeClass, recipeMapper); } - public static > RecipeMatrixMapper getRecipeMatrixMapper(Class recipe) { - return internalMethods.getRecipeMatrixMapper(recipe); + public static > RecipeMapper getRecipeMapper(Class recipe) { + return internalMethods.getRecipeMapper(recipe); } - public static Optional> getLastCraftedRecipe(Player player) { + public static Optional> getLastCraftedRecipe(ServerPlayer player) { return internalMethods.getLastCraftedRecipe(player); } - public static > void setLastCraftedRecipe(Player player, RecipeHolder recipe) { + public static > void setLastCraftedRecipe(ServerPlayer player, RecipeHolder recipe) { internalMethods.setLastCraftedRecipe(player, recipe); } } diff --git a/common/src/main/java/net/blay09/mods/craftingtweaks/api/GridRefillHandler.java b/common/src/main/java/net/blay09/mods/craftingtweaks/api/GridRefillHandler.java index da0182d..32523e2 100644 --- a/common/src/main/java/net/blay09/mods/craftingtweaks/api/GridRefillHandler.java +++ b/common/src/main/java/net/blay09/mods/craftingtweaks/api/GridRefillHandler.java @@ -1,5 +1,6 @@ package net.blay09.mods.craftingtweaks.api; +import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.entity.player.Player; import net.minecraft.world.inventory.AbstractContainerMenu; import net.minecraft.world.item.crafting.RecipeHolder; @@ -14,7 +15,7 @@ public interface GridRefillHandler { * @param player the player this is in regard to * @param menu the menu the grid is part of */ - default Optional> getLastCrafted(CraftingGrid grid, Player player, TMenu menu) { + default Optional> getLastCrafted(CraftingGrid grid, ServerPlayer player, TMenu menu) { return CraftingTweaksAPI.getLastCraftedRecipe(player); } @@ -25,7 +26,7 @@ default Optional> getLastCrafted(CraftingGrid grid, Player playe * @param menu the menu the grid is part of * @param stack if true, the grid will be filled to produce a stack of the last crafted recipe */ - default void refillLastCrafted(CraftingGrid grid, Player player, TMenu menu, boolean stack) { + default void refillLastCrafted(CraftingGrid grid, ServerPlayer player, TMenu menu, boolean stack) { final var lastCrafted = getLastCrafted(grid, player, menu); lastCrafted.ifPresent(recipeHolder -> refillRecipe(grid, player, menu, recipeHolder, stack)); } diff --git a/common/src/main/java/net/blay09/mods/craftingtweaks/api/InternalMethods.java b/common/src/main/java/net/blay09/mods/craftingtweaks/api/InternalMethods.java index 1a1c6eb..daf89a5 100644 --- a/common/src/main/java/net/blay09/mods/craftingtweaks/api/InternalMethods.java +++ b/common/src/main/java/net/blay09/mods/craftingtweaks/api/InternalMethods.java @@ -1,6 +1,6 @@ package net.blay09.mods.craftingtweaks.api; -import net.minecraft.world.Container; +import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.entity.player.Player; import net.minecraft.world.inventory.AbstractContainerMenu; import net.minecraft.world.item.crafting.Recipe; @@ -27,11 +27,11 @@ public interface InternalMethods { GridRefillHandler defaultRefillHandler(); - Optional> getLastCraftedRecipe(Player player); + Optional> getLastCraftedRecipe(ServerPlayer player); - > void setLastCraftedRecipe(Player player, RecipeHolder recipe); + > void setLastCraftedRecipe(ServerPlayer player, RecipeHolder recipe); - > void registerRecipeMatrixMapper(Class recipeClass, RecipeMatrixMapper recipeMatrixMapper); + > void registerRecipeMapper(Class recipeClass, RecipeMapper recipeMapper); - > RecipeMatrixMapper getRecipeMatrixMapper(Class recipeClass); + > RecipeMapper getRecipeMapper(Class recipeClass); } diff --git a/common/src/main/java/net/blay09/mods/craftingtweaks/api/RecipeMapper.java b/common/src/main/java/net/blay09/mods/craftingtweaks/api/RecipeMapper.java new file mode 100644 index 0000000..bc74477 --- /dev/null +++ b/common/src/main/java/net/blay09/mods/craftingtweaks/api/RecipeMapper.java @@ -0,0 +1,12 @@ +package net.blay09.mods.craftingtweaks.api; + +import net.minecraft.world.item.crafting.Ingredient; +import net.minecraft.world.item.crafting.Recipe; + +import java.util.List; +import java.util.Optional; + +public interface RecipeMapper> { + int mapToMatrixSlot(T recipe, int ingredientIndex); + List> getIngredients(T recipe); +} diff --git a/common/src/main/java/net/blay09/mods/craftingtweaks/api/RecipeMatrixMapper.java b/common/src/main/java/net/blay09/mods/craftingtweaks/api/RecipeMatrixMapper.java deleted file mode 100644 index 8c19f7f..0000000 --- a/common/src/main/java/net/blay09/mods/craftingtweaks/api/RecipeMatrixMapper.java +++ /dev/null @@ -1,7 +0,0 @@ -package net.blay09.mods.craftingtweaks.api; - -import net.minecraft.world.item.crafting.Recipe; - -public interface RecipeMatrixMapper> { - int mapToMatrixSlot(T recipe, int ingredientIndex); -} diff --git a/common/src/main/java/net/blay09/mods/craftingtweaks/api/impl/DefaultGridRefillHandler.java b/common/src/main/java/net/blay09/mods/craftingtweaks/api/impl/DefaultGridRefillHandler.java index 88c0381..db3499f 100644 --- a/common/src/main/java/net/blay09/mods/craftingtweaks/api/impl/DefaultGridRefillHandler.java +++ b/common/src/main/java/net/blay09/mods/craftingtweaks/api/impl/DefaultGridRefillHandler.java @@ -36,7 +36,7 @@ public void refillRecipe(CraftingGrid grid, Player player, AbstractContainerMenu outer: do { final var ingredientTokens = operation.getIngredientTokens(); - final var matrixMapper = CraftingTweaksAPI.getRecipeMatrixMapper(recipe.getClass()); + final var matrixMapper = CraftingTweaksAPI.getRecipeMapper(recipe.getClass()); final var matrixDiff = new HashMap(); for (int i = 0; i < ingredientTokens.size(); i++) { diff --git a/common/src/main/java/net/blay09/mods/craftingtweaks/api/impl/InternalMethodsImpl.java b/common/src/main/java/net/blay09/mods/craftingtweaks/api/impl/InternalMethodsImpl.java index 53e0f1e..77daf95 100644 --- a/common/src/main/java/net/blay09/mods/craftingtweaks/api/impl/InternalMethodsImpl.java +++ b/common/src/main/java/net/blay09/mods/craftingtweaks/api/impl/InternalMethodsImpl.java @@ -3,8 +3,10 @@ import net.blay09.mods.balm.api.Balm; import net.blay09.mods.craftingtweaks.CraftingTweaksProviderManager; import net.blay09.mods.craftingtweaks.api.*; +import net.minecraft.core.registries.Registries; +import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.Container; +import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.entity.player.Player; import net.minecraft.world.inventory.AbstractContainerMenu; import net.minecraft.world.item.crafting.Recipe; @@ -17,7 +19,7 @@ public class InternalMethodsImpl implements InternalMethods { - private static final Map>, RecipeMatrixMapper>> recipeMatrixMappers = new HashMap<>(); + private static final Map>, RecipeMapper>> recipeMatrixMappers = new HashMap<>(); @Override public void registerCraftingGridProvider(CraftingGridProvider provider) { @@ -65,38 +67,38 @@ public GridRefillHandler defaultRefillHandler() { } @Override - public Optional> getLastCraftedRecipe(Player player) { - final var level = player.level(); - final var recipeManager = level.getRecipeManager(); + public Optional> getLastCraftedRecipe(ServerPlayer player) { + final var level = player.serverLevel(); + final var recipeManager = level.getServer().getRecipeManager(); final var persistentData = Balm.getHooks().getPersistentData(player); final var lastCraftedRecipeId = ResourceLocation.tryParse(persistentData.getString("LastCraftedRecipe")); if (lastCraftedRecipeId != null) { - return recipeManager.byKey(lastCraftedRecipeId); + return recipeManager.byKey(ResourceKey.create(Registries.RECIPE, lastCraftedRecipeId)); } return Optional.empty(); } @Override - public > void setLastCraftedRecipe(Player player, RecipeHolder recipe) { + public > void setLastCraftedRecipe(ServerPlayer player, RecipeHolder recipe) { final var persistentData = Balm.getHooks().getPersistentData(player); - persistentData.putString("LastCraftedRecipe", recipe.id().toString()); + persistentData.putString("LastCraftedRecipe", recipe.id().location().toString()); } @Override - public > void registerRecipeMatrixMapper(Class recipeClass, RecipeMatrixMapper recipeMatrixMapper) { - recipeMatrixMappers.put(recipeClass, recipeMatrixMapper); + public > void registerRecipeMapper(Class recipeClass, RecipeMapper recipeMapper) { + recipeMatrixMappers.put(recipeClass, recipeMapper); } @Override @SuppressWarnings("unchecked") - public > RecipeMatrixMapper getRecipeMatrixMapper(Class recipeClass) { + public > RecipeMapper getRecipeMapper(Class recipeClass) { for (Class> handlerClass : recipeMatrixMappers.keySet()) { if (handlerClass.isAssignableFrom(recipeClass)) { - return (RecipeMatrixMapper) recipeMatrixMappers.get(handlerClass); + return (RecipeMapper) recipeMatrixMappers.get(handlerClass); } } - return (RecipeMatrixMapper) recipeMatrixMappers.get(recipeClass); + return (RecipeMapper) recipeMatrixMappers.get(recipeClass); } } diff --git a/common/src/main/java/net/blay09/mods/craftingtweaks/client/ClientProvider.java b/common/src/main/java/net/blay09/mods/craftingtweaks/client/ClientProvider.java index 7bfcef6..d234af9 100644 --- a/common/src/main/java/net/blay09/mods/craftingtweaks/client/ClientProvider.java +++ b/common/src/main/java/net/blay09/mods/craftingtweaks/client/ClientProvider.java @@ -433,14 +433,15 @@ public void compress(LocalPlayer player, AbstractContainerMenu menu, CraftingGri @SuppressWarnings("unchecked") private static ItemStack findMatchingResult(T craftingInventory, LocalPlayer player) { - for (RecipeCollection recipeList : player.getRecipeBook().getCollections()) { - for (RecipeHolder recipe : recipeList.getRecipes()) { - if (recipe.value().getType() == RecipeType.CRAFTING) { - final var craftingRecipe = (Recipe) recipe.value(); - if (craftingRecipe.matches(craftingInventory, player.level())) { - return craftingRecipe.assemble(craftingInventory, player.level().registryAccess()); - } - } + for (final var recipeList : player.getRecipeBook().getCollections()) { + for (final var recipe : recipeList.getRecipes()) { + // TODO Recipes are no longer available on the client + // if (recipe.value().getType() == RecipeType.CRAFTING) { + // final var craftingRecipe = (Recipe) recipe.value(); + // if (craftingRecipe.matches(craftingInventory, player.level())) { + // return craftingRecipe.assemble(craftingInventory, player.level().registryAccess()); + // } + // } } } diff --git a/common/src/main/java/net/blay09/mods/craftingtweaks/client/CraftingTweaksDebugger.java b/common/src/main/java/net/blay09/mods/craftingtweaks/client/CraftingTweaksDebugger.java index 1b87f6f..e75252a 100644 --- a/common/src/main/java/net/blay09/mods/craftingtweaks/client/CraftingTweaksDebugger.java +++ b/common/src/main/java/net/blay09/mods/craftingtweaks/client/CraftingTweaksDebugger.java @@ -88,9 +88,7 @@ public static void onScreenDrawn(ContainerScreenDrawEvent.Background event) { } for (int x = startX; x <= endX; x++) { for (int y = startY; y <= endY; y++) { - graphics.setColor(1f, 1f, 1f, 0.1f); - graphics.fillGradient(x, y, x + 16, y + 16, 0x1000FF00, 0x1000FF00); - graphics.setColor(1f, 1f, 1f, 1f); + graphics.fillGradient(x, y, x + 16, y + 16, 0x1900FF00, 0x1900FF00); } } graphics.pose().popPose(); diff --git a/common/src/main/java/net/blay09/mods/craftingtweaks/client/GuiImageButton.java b/common/src/main/java/net/blay09/mods/craftingtweaks/client/GuiImageButton.java index 1a935b9..b8b766b 100644 --- a/common/src/main/java/net/blay09/mods/craftingtweaks/client/GuiImageButton.java +++ b/common/src/main/java/net/blay09/mods/craftingtweaks/client/GuiImageButton.java @@ -5,6 +5,7 @@ import net.blay09.mods.craftingtweaks.api.ButtonState; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.Button; +import net.minecraft.client.renderer.RenderType; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; @@ -23,13 +24,12 @@ public GuiImageButton(int x, int y, ButtonProperties properties) { @Override public void renderWidget(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTicks) { isHovered = active && visible && mouseX >= getX() && mouseY >= getY() && mouseX < getX() + width && mouseY < getY() + height; - guiGraphics.setColor(1f, 1f, 1f, 1f); var state = isHovered ? ButtonState.HOVER : ButtonState.NORMAL; if(!active) { state = ButtonState.DISABLED; } var stateProperties = properties.getState(state); - guiGraphics.blit(texture, getX(), getY(), stateProperties.getTextureX(), stateProperties.getTextureY(), width, height); + guiGraphics.blit(RenderType::guiTextured, texture, getX(), getY(), stateProperties.getTextureX(), stateProperties.getTextureY(), width, height, 256, 256); } } diff --git a/common/src/main/java/net/blay09/mods/craftingtweaks/crafting/CraftingContext.java b/common/src/main/java/net/blay09/mods/craftingtweaks/crafting/CraftingContext.java index 27f27ca..83979d0 100644 --- a/common/src/main/java/net/blay09/mods/craftingtweaks/crafting/CraftingContext.java +++ b/common/src/main/java/net/blay09/mods/craftingtweaks/crafting/CraftingContext.java @@ -1,6 +1,7 @@ package net.blay09.mods.craftingtweaks.crafting; -import it.unimi.dsi.fastutil.ints.IntList; +import net.minecraft.core.Holder; +import net.minecraft.world.item.Item; import net.minecraft.world.item.crafting.Ingredient; import net.minecraft.world.item.crafting.Recipe; import net.minecraft.world.item.crafting.RecipeHolder; @@ -11,7 +12,7 @@ public class CraftingContext { - private final Map cachedProviderIndexByIngredient = new HashMap<>(); + private final Map>, Integer> cachedProviderIndexByIngredient = new HashMap<>(); private final Map cacheHintsByIngredient = new HashMap<>(); private final List ingredientProviders; @@ -29,7 +30,7 @@ public List getIngredientProviders() { } public int getCachedIngredientProviderIndexFor(Ingredient ingredient) { - return cachedProviderIndexByIngredient.getOrDefault(ingredient.getStackingIds(), -1); + return cachedProviderIndexByIngredient.getOrDefault(ingredient.items(), -1); } public IngredientCacheHint getCacheHintFor(CraftingOperation.IngredientTokenKey ingredientTokenKey) { @@ -38,6 +39,6 @@ public IngredientCacheHint getCacheHintFor(CraftingOperation.IngredientTokenKey public void cache(CraftingOperation.IngredientTokenKey ingredientTokenKey, int itemProviderIndex, IngredientCacheHint cacheHint) { cacheHintsByIngredient.put(ingredientTokenKey, cacheHint); - cachedProviderIndexByIngredient.put(ingredientTokenKey.stackingIds(), itemProviderIndex); + cachedProviderIndexByIngredient.put(ingredientTokenKey.items(), itemProviderIndex); } } diff --git a/common/src/main/java/net/blay09/mods/craftingtweaks/crafting/CraftingOperation.java b/common/src/main/java/net/blay09/mods/craftingtweaks/crafting/CraftingOperation.java index efc73ff..9278d20 100644 --- a/common/src/main/java/net/blay09/mods/craftingtweaks/crafting/CraftingOperation.java +++ b/common/src/main/java/net/blay09/mods/craftingtweaks/crafting/CraftingOperation.java @@ -2,33 +2,32 @@ import com.google.common.collect.ArrayListMultimap; import com.google.common.collect.Multimap; -import it.unimi.dsi.fastutil.ints.IntList; +import net.blay09.mods.craftingtweaks.api.CraftingTweaksAPI; +import net.minecraft.core.Holder; import net.minecraft.core.NonNullList; +import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.crafting.Ingredient; import net.minecraft.world.item.crafting.Recipe; import net.minecraft.world.item.crafting.RecipeHolder; import org.jetbrains.annotations.Nullable; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.Objects; +import java.util.*; public class CraftingOperation { - public record IngredientTokenKey(int providerIndex, IntList stackingIds) { + public record IngredientTokenKey(int providerIndex, List> items) { @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; IngredientTokenKey that = (IngredientTokenKey) o; - return providerIndex == that.providerIndex && Objects.equals(stackingIds, that.stackingIds); + return providerIndex == that.providerIndex && Objects.equals(items, that.items); } @Override public int hashCode() { - return Objects.hash(providerIndex, stackingIds); + return Objects.hash(providerIndex, items); } } @@ -58,10 +57,11 @@ public CraftingOperation prepare() { missingIngredients.clear(); missingIngredientsMask = 0; - final var ingredients = recipe.getIngredients(); + final var recipeMapper = CraftingTweaksAPI.getRecipeMapper(recipe.getClass()); + final List> ingredients = recipeMapper.getIngredients(recipe); for (int i = 0; i < ingredients.size(); i++) { - final var ingredient = ingredients.get(i); - if (ingredient.isEmpty()) { + final var ingredient = ingredients.get(i).orElse(null); + if (ingredient == null || ingredient.items().isEmpty()) { ingredientTokens.add(IngredientToken.EMPTY); continue; } @@ -69,9 +69,9 @@ public CraftingOperation prepare() { final var lockedInput = lockedInputs != null ? lockedInputs.get(i) : ItemStack.EMPTY; final var ingredientToken = accountForIngredient(ingredient, lockedInput); if (ingredientToken != null) { - if (ingredient.getItems().length > 1) { + if (ingredient.items().size() > 1) { if (lockedInputs == null) { - lockedInputs = NonNullList.withSize(recipe.getIngredients().size(), ItemStack.EMPTY); + lockedInputs = NonNullList.withSize(ingredients.size(), ItemStack.EMPTY); } lockedInputs.set(i, ingredientToken.peek()); } @@ -109,7 +109,7 @@ private IngredientToken accountForIngredient(Ingredient ingredient, ItemStack lo @Nullable private IngredientToken accountForIngredient(int ingredientProviderIndex, IngredientProvider ingredientProvider, Ingredient ingredient, ItemStack lockedInput, boolean useCache) { - final var ingredientTokenKey = new IngredientTokenKey(ingredientProviderIndex, ingredient.getStackingIds()); + final var ingredientTokenKey = new IngredientTokenKey(ingredientProviderIndex, ingredient.items()); final var scopedIngredientTokens = tokensByIngredient.get(ingredientTokenKey); final var cacheHint = useCache ? context.getCacheHintFor(ingredientTokenKey) : IngredientCacheHint.NONE; final var ingredientToken = findIngredient(ingredientProvider, ingredient, lockedInput, scopedIngredientTokens, cacheHint); diff --git a/common/src/main/java/net/blay09/mods/craftingtweaks/crafting/ShapedRecipeMatrixMapper.java b/common/src/main/java/net/blay09/mods/craftingtweaks/crafting/ShapedRecipeMatrixMapper.java index a045c0a..faf31e0 100644 --- a/common/src/main/java/net/blay09/mods/craftingtweaks/crafting/ShapedRecipeMatrixMapper.java +++ b/common/src/main/java/net/blay09/mods/craftingtweaks/crafting/ShapedRecipeMatrixMapper.java @@ -1,9 +1,13 @@ package net.blay09.mods.craftingtweaks.crafting; -import net.blay09.mods.craftingtweaks.api.RecipeMatrixMapper; +import net.blay09.mods.craftingtweaks.api.RecipeMapper; +import net.minecraft.world.item.crafting.Ingredient; import net.minecraft.world.item.crafting.ShapedRecipe; -public class ShapedRecipeMatrixMapper implements RecipeMatrixMapper { +import java.util.List; +import java.util.Optional; + +public class ShapedRecipeMatrixMapper implements RecipeMapper { @Override public int mapToMatrixSlot(ShapedRecipe recipe, int ingredientIndex) { final int recipeWidth = recipe.getWidth(); @@ -15,5 +19,10 @@ public int mapToMatrixSlot(ShapedRecipe recipe, int ingredientIndex) { return origY * 3 + origX + offsetX; } + + @Override + public List> getIngredients(ShapedRecipe recipe) { + return recipe.getIngredients(); + } } diff --git a/common/src/main/java/net/blay09/mods/craftingtweaks/crafting/ShapelessRecipeMatrixMapper.java b/common/src/main/java/net/blay09/mods/craftingtweaks/crafting/ShapelessRecipeMatrixMapper.java index 2195e62..9c00825 100644 --- a/common/src/main/java/net/blay09/mods/craftingtweaks/crafting/ShapelessRecipeMatrixMapper.java +++ b/common/src/main/java/net/blay09/mods/craftingtweaks/crafting/ShapelessRecipeMatrixMapper.java @@ -1,11 +1,21 @@ package net.blay09.mods.craftingtweaks.crafting; -import net.blay09.mods.craftingtweaks.api.RecipeMatrixMapper; +import net.blay09.mods.craftingtweaks.api.RecipeMapper; +import net.blay09.mods.craftingtweaks.mixin.ShapelessRecipeAccessor; +import net.minecraft.world.item.crafting.Ingredient; import net.minecraft.world.item.crafting.ShapelessRecipe; -public class ShapelessRecipeMatrixMapper implements RecipeMatrixMapper { +import java.util.List; +import java.util.Optional; + +public class ShapelessRecipeMatrixMapper implements RecipeMapper { @Override public int mapToMatrixSlot(ShapelessRecipe recipe, int ingredientIndex) { return ingredientIndex; } + + @Override + public List> getIngredients(ShapelessRecipe recipe) { + return recipe instanceof ShapelessRecipeAccessor accessor ? accessor.getIngredients() : List.of(); + } } \ No newline at end of file diff --git a/common/src/main/java/net/blay09/mods/craftingtweaks/mixin/ShapelessRecipeAccessor.java b/common/src/main/java/net/blay09/mods/craftingtweaks/mixin/ShapelessRecipeAccessor.java new file mode 100644 index 0000000..6ca40b1 --- /dev/null +++ b/common/src/main/java/net/blay09/mods/craftingtweaks/mixin/ShapelessRecipeAccessor.java @@ -0,0 +1,15 @@ +package net.blay09.mods.craftingtweaks.mixin; + +import net.minecraft.world.item.crafting.Ingredient; +import net.minecraft.world.item.crafting.ShapelessRecipe; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; + +import java.util.List; +import java.util.Optional; + +@Mixin(ShapelessRecipe.class) +public interface ShapelessRecipeAccessor { + @Accessor + List> getIngredients(); +} diff --git a/common/src/main/java/net/blay09/mods/craftingtweaks/network/CompressMessage.java b/common/src/main/java/net/blay09/mods/craftingtweaks/network/CompressMessage.java index 2128842..045ecc7 100644 --- a/common/src/main/java/net/blay09/mods/craftingtweaks/network/CompressMessage.java +++ b/common/src/main/java/net/blay09/mods/craftingtweaks/network/CompressMessage.java @@ -170,7 +170,7 @@ private static ItemStack findMatchingResult(T recipeIn RecipeManager recipeManager = Objects.requireNonNull(player.getServer()).getRecipeManager(); Level level = player.level(); RecipeHolder recipe = recipeManager.getRecipeFor(RecipeType.CRAFTING, recipeInput, level).orElse(null); - if (recipe != null && recipeCraftingHolder.setRecipeUsed(level, player, recipe)) { + if (recipe != null && recipeCraftingHolder.setRecipeUsed(player, recipe)) { return recipe.value().assemble(recipeInput, level.registryAccess()); } diff --git a/gradle.properties b/gradle.properties index ffbd39b..d7edbf6 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,7 +3,7 @@ mod_id = craftingtweaks mod_name = Crafting Tweaks mod_main=CraftingTweaks description=Allows you to rotate, balance or clear the crafting matrix by the press of a button, in any (supported) crafting window. -version = 21.1.1 +version = 21.2.0 group = net.blay09.mods homepage=https://mods.twelveiterations.com/mc/craftingtweaks sources=https://github.com/TwelveIterationMods/CraftingTweaks @@ -18,16 +18,16 @@ modrinth_release_type = release modrinth_project_id = DMu0oBKf # Minecraft -minecraft_version = 1.21.1 +minecraft_version = 1.21.2-pre1 minimum_minecraft_version = 1.21 -minecraft_versions = 1.21,1.21.1 +minecraft_versions = 1.21,1.21.1,1.21.2-pre1 minecraft_version_range = [1.21,) pack_format_number = 18 java_version = 21 # Balm -balm_version = 21.0.14-SNAPSHOT -balm_version_range = [21.0.0,) +balm_version = 21.2.1-SNAPSHOT +balm_version_range = [21.2.0,) # Forge forge_version = 52.0.2 @@ -40,8 +40,8 @@ neoforge_version_range = [21-beta,) neoforge_loader_version_range = [1,) # Fabric -fabric_version = 0.102.1+1.21.1 -fabric_loader_version = 0.15.11 +fabric_version = 0.105.3+1.21.2 +fabric_loader_version = 0.16.5 # Dependencies mixin_version=0.8.5 @@ -53,6 +53,6 @@ org.gradle.daemon=false mod_author = BlayTheNinth credits = BlayTheNinth kuma_version = [21.0,22) -neo_form_version = 1.21.1-20240808.144430 +neo_form_version = 1.21.2-pre1-20241008.174159 parchment_minecraft = 1.21 parchment_version = 2024.06.23 \ No newline at end of file diff --git a/repositories.gradle b/repositories.gradle index 0fa21f4..d4e1b68 100644 --- a/repositories.gradle +++ b/repositories.gradle @@ -49,6 +49,7 @@ repositories { url = 'https://jitpack.io' content { includeGroup "com.github.BlueMap-Minecraft" + includeGroup "com.github.mattidragon" } } @@ -65,4 +66,22 @@ repositories { includeGroup "de.siphalor" } } + + maven { + url = "https://dl.cloudsmith.io/public/novamachina-mods/release/maven/" + content { + includeGroup "novamachina.novacore" + includeGroup "novamachina.exnihilosequentia" + } + } + + exclusiveContent { + forRepository { + maven { + name = 'Minecraft' + url = 'https://libraries.minecraft.net/' + } + } + filter { includeGroupAndSubgroups("com.mojang") } + } } \ No newline at end of file diff --git a/settings.gradle b/settings.gradle index bce959e..f5a6464 100644 --- a/settings.gradle +++ b/settings.gradle @@ -45,5 +45,5 @@ plugins { include("common") include("fabric") -include("neoforge") -include("forge") +//include("neoforge") +//include("forge")