Skip to content

Commit

Permalink
wip: Continue port to Minecraft 1.21.3, broken thanks to Java generics
Browse files Browse the repository at this point in the history
  • Loading branch information
BlayTheNinth committed Oct 31, 2024
1 parent e403fea commit 964d82a
Show file tree
Hide file tree
Showing 12 changed files with 125 additions and 98 deletions.
4 changes: 0 additions & 4 deletions .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -171,15 +171,11 @@ jobs:
cache: 'gradle'
- name: Make gradle wrapper executable
run: chmod +x ./gradlew
- name: Check current artifact hash TODO
run: sha1sum ${{ matrix.loader }}/build/libs/*
- name: Publish
run: ./gradlew :${{ matrix.loader }}:${{ matrix.site }} '-Pversion=${{needs.create-release.outputs.version}}' '-PtwelveIterationsNexusUsername=${{ secrets.NEXUS_USER }}' '-PtwelveIterationsNexusPassword=${{ secrets.NEXUS_PASSWORD }}'
env:
CURSEFORGE_TOKEN: ${{secrets.CURSEFORGE_TOKEN}}
MODRINTH_TOKEN: ${{secrets.MODRINTH_TOKEN}}
- name: Check new artifact hash TODO
run: sha1sum ${{ matrix.loader }}/build/libs/*
needs:
- create-release
- build-common
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ public FoodStatsProvider getFoodStatsProvider() {
}

@Override
public <C extends RecipeInput, T extends Recipe<C>> void registerKitchenRecipeHandler(Class<T> recipeClass, KitchenRecipeHandler<T> kitchenRecipeHandler) {
public <C extends RecipeInput, T extends Recipe<C>> void registerKitchenRecipeHandler(Class<T> recipeClass, KitchenRecipeHandler<C, T> kitchenRecipeHandler) {
CookingForBlockheadsRegistry.registerKitchenRecipeHandler(recipeClass, kitchenRecipeHandler);
}

@Override
public <T extends Recipe<? extends RecipeInput>> KitchenRecipeHandler<T> getKitchenRecipeHandler(T recipe) {
public <C extends RecipeInput, T extends Recipe<C>> KitchenRecipeHandler<C, T> getKitchenRecipeHandler(T recipe) {
return CookingForBlockheadsRegistry.getKitchenRecipeHandler(recipe);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ public static Kitchen createKitchen(ItemStack itemStack) {
return internalMethods.createKitchen(itemStack);
}

public static <C extends RecipeInput, T extends Recipe<C>> void registerKitchenRecipeHandler(Class<T> recipeClass, KitchenRecipeHandler<T> kitchenRecipeHandler) {
public static <C extends RecipeInput, T extends Recipe<C>> void registerKitchenRecipeHandler(Class<T> recipeClass, KitchenRecipeHandler<C, T> kitchenRecipeHandler) {
internalMethods.registerKitchenRecipeHandler(recipeClass, kitchenRecipeHandler);
}

public static <C extends RecipeInput, T extends Recipe<C>> KitchenRecipeHandler<T> getKitchenRecipeHandler(T recipe) {
public static <C extends RecipeInput, T extends Recipe<C>> KitchenRecipeHandler<C, T> getKitchenRecipeHandler(T recipe) {
return internalMethods.getKitchenRecipeHandler(recipe);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public interface InternalMethods {

FoodStatsProvider getFoodStatsProvider();

<C extends RecipeInput, T extends Recipe<C>> void registerKitchenRecipeHandler(Class<T> recipeClass, KitchenRecipeHandler<T> kitchenRecipeHandler);
<C extends RecipeInput, T extends Recipe<C>> void registerKitchenRecipeHandler(Class<T> recipeClass, KitchenRecipeHandler<C, T> kitchenRecipeHandler);

<T extends Recipe<? extends RecipeInput>> KitchenRecipeHandler<T> getKitchenRecipeHandler(T recipe);
<C extends RecipeInput, T extends Recipe<C>> KitchenRecipeHandler<C, T> getKitchenRecipeHandler(T recipe);
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

import net.blay09.mods.cookingforblockheads.crafting.CraftingContext;
import net.minecraft.core.RegistryAccess;
import net.minecraft.world.inventory.CraftingContainer;
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.RecipeInput;

import java.util.List;
import java.util.Optional;

public interface KitchenRecipeHandler<T extends Recipe<?>> {
public interface KitchenRecipeHandler<C extends RecipeInput, T extends Recipe<C>> {
int mapToMatrixSlot(T recipe, int ingredientIndex);

List<Optional<Ingredient>> getIngredients(T recipe);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
import net.blay09.mods.cookingforblockheads.api.KitchenRecipeHandler;
import net.minecraft.core.RegistryAccess;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.crafting.CraftingRecipe;
import net.minecraft.world.item.crafting.CraftingInput;
import net.minecraft.world.item.crafting.Recipe;

import java.util.List;

public abstract class AbstractKitchenCraftingRecipeHandler<T extends CraftingRecipe> implements KitchenRecipeHandler<T> {
public abstract class AbstractKitchenCraftingRecipeHandler<T extends Recipe<CraftingInput>> implements KitchenRecipeHandler<CraftingInput, T> {
@Override
public ItemStack assemble(CraftingContext context, T recipe, List<IngredientToken> ingredientTokens, RegistryAccess registryAccess) {
final var craftingContainer = new TransientHeadlessCraftingContainer(3, 3);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import net.minecraft.world.item.crafting.Ingredient;
import net.minecraft.world.item.crafting.Recipe;
import net.minecraft.world.item.crafting.RecipeHolder;
import net.minecraft.world.item.crafting.RecipeInput;
import org.jetbrains.annotations.Nullable;

import java.util.HashMap;
Expand All @@ -28,8 +29,8 @@ public CraftingContext(final Kitchen kitchen, final @Nullable Player player) {
itemProcessors = kitchen.getItemProcessors();
}

public CraftingOperation createOperation(RecipeHolder<Recipe<?>> recipe) {
return new CraftingOperation(this, recipe);
public <C extends RecipeInput, T extends Recipe<C>> CraftingOperation<C, T> createOperation(RecipeHolder<T> recipe) {
return new CraftingOperation<>(this, recipe );
}

public List<KitchenItemProvider> getItemProviders() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
import net.blay09.mods.cookingforblockheads.api.Kitchen;
import net.blay09.mods.cookingforblockheads.api.KitchenItemProcessor;
import net.blay09.mods.cookingforblockheads.api.KitchenItemProvider;
import net.blay09.mods.cookingforblockheads.block.CookingTableBlock;
import net.blay09.mods.cookingforblockheads.block.ModBlocks;
import net.blay09.mods.cookingforblockheads.block.entity.CookingTableBlockEntity;
import net.blay09.mods.cookingforblockheads.item.ModItems;
import net.blay09.mods.cookingforblockheads.kitchen.ContainerKitchenItemProvider;
Expand All @@ -18,6 +16,7 @@
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.crafting.Recipe;
import net.minecraft.world.item.crafting.RecipeHolder;
import net.minecraft.world.item.crafting.RecipeInput;
import net.minecraft.world.item.crafting.RecipeType;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Blocks;
Expand Down Expand Up @@ -113,7 +112,7 @@ public boolean canProcess(RecipeType<?> recipeType) {
return itemProcessorList.stream().anyMatch(it -> it.canProcess(recipeType));
}

public boolean isRecipeAvailable(RecipeHolder<Recipe<?>> recipe, CraftingOperation operation) {
public <C extends RecipeInput, T extends Recipe<C>> boolean isRecipeAvailable(RecipeHolder<T> recipe, CraftingOperation<C, T> operation) {
final var isNoFilter = activatingItemStack.is(ModItems.noFilterBook) || (activatingBlockEntity instanceof CookingTableBlockEntity cookingTable && cookingTable.hasNoFilterBook());
if (isNoFilter) {
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@
import net.minecraft.core.RegistryAccess;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.crafting.Ingredient;
import net.minecraft.world.item.crafting.SingleRecipeInput;
import net.minecraft.world.item.crafting.SmeltingRecipe;

import java.util.List;
import java.util.Optional;

public class KitchenSmeltingRecipeHandler implements KitchenRecipeHandler<SmeltingRecipe> {
public class KitchenSmeltingRecipeHandler implements KitchenRecipeHandler<SingleRecipeInput, SmeltingRecipe> {
@Override
public int mapToMatrixSlot(SmeltingRecipe recipe, int ingredientIndex) {
return 4;
Expand Down
Loading

0 comments on commit 964d82a

Please sign in to comment.