diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index e886cab9..2fc9449a 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -1,41 +1,33 @@ -# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time -# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle - -name: Java CI with Gradle - on: + workflow_dispatch: push: - paths-ignore: - - '.github/**' - - '**.md' - - '.gitignore' - - 'LICENSE' - pull_request: - paths-ignore: - - '.github/**' - - '**.md' - - '.gitignore' - - 'LICENSE' - -jobs: - build: - - runs-on: ubuntu-latest + branches: [ "main" ] +jobs: + gradle: + strategy: + matrix: + os: [ ubuntu-latest ] + runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v4 - - name: Set up JDK 17 - uses: actions/setup-java@v4 - with: - java-version: '17' - distribution: 'adopt' - cache: gradle - - name: Grant execute permission for gradlew - run: chmod +x gradlew - - name: Build with Gradle - run: ./gradlew build - - name: Publish artifacts - uses: actions/upload-artifact@v4 - with: - name: Package - path: build/libs + - uses: actions/checkout@v4 + - uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: 17 + - name: Setup Gradle + uses: gradle/gradle-build-action@v2 + - name: Make gradlew executable + run: chmod +x ./gradlew + - name: Execute Gradle build + run: ./gradlew build + - name: 'MC Publish' + uses: Kir-Antipov/mc-publish@v3.3 + with: + modrinth-id: McLbj2dz + modrinth-token: ${{ secrets.MODRINTH_TOKEN }} + modrinth-featured: true + curseforge-id: 960132 + curseforge-token: ${{ secrets.CURSEFORGE_TOKEN }} + github-generate-changelog: true + github-token: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/build.gradle b/build.gradle index f298f72b..65621951 100644 --- a/build.gradle +++ b/build.gradle @@ -39,8 +39,8 @@ dependencies { } modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" - modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}+1.20.1" // Fabric API. This is technically optional, but you probably want it anyway. + modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}+1.20.1" modApi ("me.shedaniel.cloth:cloth-config-fabric:${project.cloth_version}") { exclude(group: 'net.fabricmc.fabric.fabric-api') } diff --git a/src/main/java/com/theomenden/prefabricated/ModRegistry.java b/src/main/java/com/theomenden/prefabricated/ModRegistry.java index b86f0eaa..b8aa890c 100644 --- a/src/main/java/com/theomenden/prefabricated/ModRegistry.java +++ b/src/main/java/com/theomenden/prefabricated/ModRegistry.java @@ -15,20 +15,13 @@ import com.theomenden.prefabricated.structures.items.*; import com.theomenden.prefabricated.structures.messages.StructureTagMessage; import lombok.Getter; -import net.fabricmc.fabric.api.itemgroup.v1.FabricItemGroup; import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking; import net.fabricmc.fabric.api.object.builder.v1.block.entity.FabricBlockEntityTypeBuilder; -import net.minecraft.Util; import net.minecraft.core.BlockPos; -import net.minecraft.core.Holder; import net.minecraft.core.Registry; import net.minecraft.core.registries.BuiltInRegistries; -import net.minecraft.core.registries.Registries; import net.minecraft.nbt.CompoundTag; -import net.minecraft.network.chat.Component; -import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceLocation; -import net.minecraft.server.packs.resources.Resource; import net.minecraft.sounds.SoundEvent; import net.minecraft.util.LazyLoadedValue; import net.minecraft.world.item.*; @@ -43,8 +36,6 @@ import org.jetbrains.annotations.NotNull; import java.util.ArrayList; -import java.util.Comparator; -import java.util.Objects; import java.util.function.Consumer; import java.util.function.Supplier; diff --git a/src/main/java/com/theomenden/prefabricated/recipe/ConditionedCuttingRecipe.java b/src/main/java/com/theomenden/prefabricated/recipe/ConditionedCuttingRecipe.java deleted file mode 100644 index f6e00d88..00000000 --- a/src/main/java/com/theomenden/prefabricated/recipe/ConditionedCuttingRecipe.java +++ /dev/null @@ -1,87 +0,0 @@ -package com.theomenden.prefabricated.recipe; - -import com.google.common.base.Strings; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.theomenden.prefabricated.ModRegistry; -import com.theomenden.prefabricated.Prefab; -import net.minecraft.core.registries.BuiltInRegistries; -import net.minecraft.network.FriendlyByteBuf; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.util.GsonHelper; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.crafting.Ingredient; -import net.minecraft.world.item.crafting.RecipeSerializer; -import net.minecraft.world.item.crafting.StonecutterRecipe; -import net.minecraft.world.level.block.Blocks; -import org.jetbrains.annotations.NotNull; - -public final class ConditionedCuttingRecipe extends StonecutterRecipe { - private final String configName; - public ConditionedCuttingRecipe(ResourceLocation id, String group, Ingredient ingredient, ItemStack result, String configName) { - super(id, group, ingredient, result); - - this.configName = configName; - } - - public @NotNull ItemStack getToastSymbol() { - return new ItemStack(Blocks.FURNACE); - } - - public @NotNull RecipeSerializer getSerializer() { - return ModRegistry.CONDITIONED_SMELTING_RECIPE_RECIPE_SERIALIZER; - } - - public static class Serializer implements RecipeSerializer { - public @NotNull ConditionedCuttingRecipe fromJson(ResourceLocation identifier, JsonObject jsonObject) { - String string = GsonHelper.getAsString(jsonObject, "group", ""); - String configName = GsonHelper.getAsString(jsonObject, "configName", ""); - JsonElement jsonElement = GsonHelper.isArrayNode(jsonObject, "ingredient") ? GsonHelper.getAsJsonArray(jsonObject, "ingredient") : GsonHelper.getAsJsonObject(jsonObject, "ingredient"); - Ingredient ingredient = Ingredient.fromJson((JsonElement)jsonElement); - String string2 = GsonHelper.getAsString(jsonObject, "result"); - ResourceLocation identifier2 = new ResourceLocation(string2); - ItemStack itemStack = new ItemStack(BuiltInRegistries.ITEM.getOptional(identifier2).orElseThrow(() -> { - return new IllegalStateException("Item: " + string2 + " does not exist"); - })); - - itemStack = this.validateRecipeOutput(itemStack, configName); - - float experience = GsonHelper.getAsFloat(jsonObject, "experience", 0.0F); - int cookingtime = GsonHelper.getAsInt(jsonObject, "cookingtime", 200); - return new ConditionedCuttingRecipe(identifier, string, ingredient, itemStack, configName); - } - - public @NotNull ConditionedCuttingRecipe fromNetwork(ResourceLocation identifier, FriendlyByteBuf packetByteBuf) { - String group = packetByteBuf.readUtf(); - String configName = packetByteBuf.readUtf() ; - Ingredient ingredient = Ingredient.fromNetwork(packetByteBuf); - ItemStack itemStack = this.validateRecipeOutput(packetByteBuf.readItem(), configName); - float experience = packetByteBuf.readFloat(); - int cookTime = packetByteBuf.readVarInt(); - return new ConditionedCuttingRecipe(identifier, group, ingredient, itemStack, configName); - } - - public void toNetwork(FriendlyByteBuf packetByteBuf, ConditionedCuttingRecipe abstractCuttingRecipe) { - packetByteBuf.writeUtf(abstractCuttingRecipe.group); - packetByteBuf.writeUtf(abstractCuttingRecipe.configName); - abstractCuttingRecipe.ingredient.toNetwork(packetByteBuf); - packetByteBuf.writeItem(abstractCuttingRecipe.result); - } - - public ItemStack validateRecipeOutput(ItemStack originalOutput, String configName) { - if (originalOutput == ItemStack.EMPTY) { - return ItemStack.EMPTY; - } - - if (!Strings.isNullOrEmpty(configName) - && Prefab.serverConfiguration.recipes.containsKey(configName) - && !Prefab.serverConfiguration.recipes.get(configName)) { - // The configuration option for this recipe was turned off. - // Specify that the recipe has no output which basically makes it disabled. - return ItemStack.EMPTY; - } - - return originalOutput; - } - } -} diff --git a/src/main/java/com/theomenden/prefabricated/recipe/ConditionedSmeltingRecipe.java b/src/main/java/com/theomenden/prefabricated/recipe/ConditionedSmeltingRecipe.java index 3d655a3b..f0b32475 100644 --- a/src/main/java/com/theomenden/prefabricated/recipe/ConditionedSmeltingRecipe.java +++ b/src/main/java/com/theomenden/prefabricated/recipe/ConditionedSmeltingRecipe.java @@ -42,9 +42,7 @@ public static class Serializer implements RecipeSerializer { - return new IllegalStateException("Item: " + string2 + " does not exist"); - })); + ItemStack itemStack = new ItemStack(BuiltInRegistries.ITEM.getOptional(identifier2).orElseThrow(() -> new IllegalStateException("Item: " + string2 + " does not exist"))); itemStack = this.validateRecipeOutput(itemStack, configName); diff --git a/src/main/resources/data/prefabricated/recipes/glass_slab_reverse.json b/src/main/resources/data/prefabricated/recipes/glass_slab_reverse.json new file mode 100644 index 00000000..625b2a91 --- /dev/null +++ b/src/main/resources/data/prefabricated/recipes/glass_slab_reverse.json @@ -0,0 +1,19 @@ +{ + "type": "prefabricated:condition_crafting_shaped", + "config": "Glass Recipes", + "group": "Glass Recipes", + "pattern": [ + "#", + "#" + ], + "key": { + "#": { + "item": "prefabricated:block_glass_slab" + } + }, + "result": { + "item": "minecraft:glass", + "count": 1 + } + } + \ No newline at end of file diff --git a/src/main/resources/data/prefabricated/recipes/glass_slabs_stonecutting.json b/src/main/resources/data/prefabricated/recipes/glass_slabs_stonecutting.json new file mode 100644 index 00000000..367065bc --- /dev/null +++ b/src/main/resources/data/prefabricated/recipes/glass_slabs_stonecutting.json @@ -0,0 +1,8 @@ +{ + "type": "minecraft:stonecutting", + "ingredient": { + "item": "minecraft:glass" + }, + "result": "prefabricated:block_glass_slab", + "count": 2 + } \ No newline at end of file diff --git a/src/main/resources/data/prefabricated/recipes/glass_stairs_stonecutting.json b/src/main/resources/data/prefabricated/recipes/glass_stairs_stonecutting.json new file mode 100644 index 00000000..8c6a1b19 --- /dev/null +++ b/src/main/resources/data/prefabricated/recipes/glass_stairs_stonecutting.json @@ -0,0 +1,8 @@ +{ + "type": "minecraft:stonecutting", + "ingredient": { + "item": "minecraft:glass" + }, + "result": "prefabricated:block_glass_stairs", + "count": 1 + } \ No newline at end of file diff --git a/src/main/resources/data/prefabricated/recipes/glasspane_to_slab.json b/src/main/resources/data/prefabricated/recipes/glasspane_to_slab.json new file mode 100644 index 00000000..3e36b05f --- /dev/null +++ b/src/main/resources/data/prefabricated/recipes/glasspane_to_slab.json @@ -0,0 +1,19 @@ +{ + "type": "prefabricated:condition_crafting_shaped", + "config": "Glass Recipes", + "group": "Glass Recipes", + "pattern": [ + "##", + "##" + ], + "key": { + "#": { + "item": "minecraft:glass_pane" + } + }, + "result": { + "item": "prefabricated:block_glass_slab", + "count": 1 + } + } + \ No newline at end of file diff --git a/src/main/resources/data/prefabricated/recipes/quartz_crete_bricks_stonecutting.json b/src/main/resources/data/prefabricated/recipes/quartz_crete_bricks_stonecutting.json new file mode 100644 index 00000000..c07386f2 --- /dev/null +++ b/src/main/resources/data/prefabricated/recipes/quartz_crete_bricks_stonecutting.json @@ -0,0 +1,8 @@ +{ + "type": "minecraft:stonecutting", + "ingredient": { + "item": "prefabricated:block_quartz_crete" + }, + "result": "prefabricated:block_quartz_crete_bricks", + "count": 1 + } \ No newline at end of file diff --git a/src/main/resources/data/prefabricated/recipes/quartz_crete_pillar_stonecutting.json b/src/main/resources/data/prefabricated/recipes/quartz_crete_pillar_stonecutting.json new file mode 100644 index 00000000..c602e349 --- /dev/null +++ b/src/main/resources/data/prefabricated/recipes/quartz_crete_pillar_stonecutting.json @@ -0,0 +1,8 @@ +{ + "type": "minecraft:stonecutting", + "ingredient": { + "item": "prefabricated:block_quartz_crete" + }, + "result": "prefabricated:block_quartz_crete_pillar", + "count": 1 + } \ No newline at end of file diff --git a/src/main/resources/data/prefabricated/recipes/quartz_crete_slabs_stonecutting.json b/src/main/resources/data/prefabricated/recipes/quartz_crete_slabs_stonecutting.json new file mode 100644 index 00000000..e74efc5e --- /dev/null +++ b/src/main/resources/data/prefabricated/recipes/quartz_crete_slabs_stonecutting.json @@ -0,0 +1,8 @@ +{ + "type": "minecraft:stonecutting", + "ingredient": { + "item": "prefabricated:block_quartz_crete" + }, + "result": "prefabricated:block_quartz_crete_slab", + "count": 2 + } \ No newline at end of file diff --git a/src/main/resources/data/prefabricated/recipes/quartz_crete_smooth_slabs_stonecutting.json b/src/main/resources/data/prefabricated/recipes/quartz_crete_smooth_slabs_stonecutting.json new file mode 100644 index 00000000..1ad5da5e --- /dev/null +++ b/src/main/resources/data/prefabricated/recipes/quartz_crete_smooth_slabs_stonecutting.json @@ -0,0 +1,8 @@ +{ + "type": "minecraft:stonecutting", + "ingredient": { + "item": "prefabricated:block_quartz_crete" + }, + "result": "prefabricated:block_quartz_crete_smooth_slab", + "count": 2 + } \ No newline at end of file diff --git a/src/main/resources/data/prefabricated/recipes/quartz_crete_smooth_stairs_stonecutting.json b/src/main/resources/data/prefabricated/recipes/quartz_crete_smooth_stairs_stonecutting.json new file mode 100644 index 00000000..a3d8a101 --- /dev/null +++ b/src/main/resources/data/prefabricated/recipes/quartz_crete_smooth_stairs_stonecutting.json @@ -0,0 +1,8 @@ +{ + "type": "minecraft:stonecutting", + "ingredient": { + "item": "prefabricated:block_quartz_crete" + }, + "result": "prefabricated:block_quartz_crete_smooth_stairs", + "count": 1 + } \ No newline at end of file diff --git a/src/main/resources/data/prefabricated/recipes/quartz_crete_smooth_stonecutting.json b/src/main/resources/data/prefabricated/recipes/quartz_crete_smooth_stonecutting.json new file mode 100644 index 00000000..e9c57d25 --- /dev/null +++ b/src/main/resources/data/prefabricated/recipes/quartz_crete_smooth_stonecutting.json @@ -0,0 +1,8 @@ +{ + "type": "minecraft:stonecutting", + "ingredient": { + "item": "prefabricated:block_quartz_crete" + }, + "result": "prefabricated:block_quartz_crete_smooth", + "count": 1 + } \ No newline at end of file diff --git a/src/main/resources/data/prefabricated/recipes/quartz_crete_smooth_wall_stonecutting.json b/src/main/resources/data/prefabricated/recipes/quartz_crete_smooth_wall_stonecutting.json new file mode 100644 index 00000000..13883cc2 --- /dev/null +++ b/src/main/resources/data/prefabricated/recipes/quartz_crete_smooth_wall_stonecutting.json @@ -0,0 +1,8 @@ +{ + "type": "minecraft:stonecutting", + "ingredient": { + "item": "prefabricated:block_quartz_crete" + }, + "result": "prefabricated:block_quartz_crete_smooth_wall", + "count": 1 + } \ No newline at end of file diff --git a/src/main/resources/data/prefabricated/recipes/quartz_crete_stairs_stonecutting.json b/src/main/resources/data/prefabricated/recipes/quartz_crete_stairs_stonecutting.json new file mode 100644 index 00000000..86c945ce --- /dev/null +++ b/src/main/resources/data/prefabricated/recipes/quartz_crete_stairs_stonecutting.json @@ -0,0 +1,8 @@ +{ + "type": "minecraft:stonecutting", + "ingredient": { + "item": "prefabricated:block_quartz_crete" + }, + "result": "prefabricated:block_quartz_crete_stairs", + "count": 1 + } \ No newline at end of file diff --git a/src/main/resources/data/prefabricated/recipes/quartz_crete_wall_stonecutting.json b/src/main/resources/data/prefabricated/recipes/quartz_crete_wall_stonecutting.json new file mode 100644 index 00000000..79b33c76 --- /dev/null +++ b/src/main/resources/data/prefabricated/recipes/quartz_crete_wall_stonecutting.json @@ -0,0 +1,8 @@ +{ + "type": "minecraft:stonecutting", + "ingredient": { + "item": "prefabricated:block_quartz_crete" + }, + "result": "prefabricated:block_quartz_crete_wall", + "count": 1 + } \ No newline at end of file diff --git a/src/main/resources/data/prefabricated/recipes/smooth_quartz_crete_quartz_crete_smooth_slabs_stonecutting.json b/src/main/resources/data/prefabricated/recipes/smooth_quartz_crete_quartz_crete_smooth_slabs_stonecutting.json new file mode 100644 index 00000000..b0652c66 --- /dev/null +++ b/src/main/resources/data/prefabricated/recipes/smooth_quartz_crete_quartz_crete_smooth_slabs_stonecutting.json @@ -0,0 +1,8 @@ +{ + "type": "minecraft:stonecutting", + "ingredient": { + "item": "prefabricated:block_quartz_crete_smooth" + }, + "result": "prefabricated:block_quartz_crete_smooth_slab", + "count": 2 + } \ No newline at end of file diff --git a/src/main/resources/data/prefabricated/recipes/smooth_quartz_crete_quartz_crete_smooth_stairs_stonecutting.json b/src/main/resources/data/prefabricated/recipes/smooth_quartz_crete_quartz_crete_smooth_stairs_stonecutting.json new file mode 100644 index 00000000..a61e0849 --- /dev/null +++ b/src/main/resources/data/prefabricated/recipes/smooth_quartz_crete_quartz_crete_smooth_stairs_stonecutting.json @@ -0,0 +1,8 @@ +{ + "type": "minecraft:stonecutting", + "ingredient": { + "item": "prefabricated:block_quartz_crete_smooth" + }, + "result": "prefabricated:block_quartz_crete_smooth_stairs", + "count": 1 + } \ No newline at end of file diff --git a/src/main/resources/data/prefabricated/recipes/smooth_quartz_crete_smooth_wall_stonecutting.json b/src/main/resources/data/prefabricated/recipes/smooth_quartz_crete_smooth_wall_stonecutting.json new file mode 100644 index 00000000..2fdbbe82 --- /dev/null +++ b/src/main/resources/data/prefabricated/recipes/smooth_quartz_crete_smooth_wall_stonecutting.json @@ -0,0 +1,8 @@ +{ + "type": "minecraft:stonecutting", + "ingredient": { + "item": "prefabricated:block_quartz_crete_smooth" + }, + "result": "prefabricated:block_quartz_crete_smooth_wall", + "count": 1 + } \ No newline at end of file