From 1c4bb8aa977def022f7196087030aa4e92772330 Mon Sep 17 00:00:00 2001 From: skyinr <2587135207@qq.com> Date: Sat, 5 Nov 2022 15:05:59 +0800 Subject: [PATCH 1/2] =?UTF-8?q?dg=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/gradle-publish.yml | 26 ++++++++------ .../loottable/ModBlockLootProvider.java | 36 ++++++++++++++++--- .../loottable/ModLootTableProvider.java | 7 ++++ 3 files changed, 53 insertions(+), 16 deletions(-) diff --git a/.github/workflows/gradle-publish.yml b/.github/workflows/gradle-publish.yml index 7ea60be4..0885db2d 100644 --- a/.github/workflows/gradle-publish.yml +++ b/.github/workflows/gradle-publish.yml @@ -32,15 +32,17 @@ jobs: - name: Cache if: always() - uses: actions/cache@v3.0.11 + uses: actions/cache@v3 with: - # A list of files, directories, and wildcard patterns to cache and restore - path: ~/.cache - # An explicit key for restoring and saving the cache - key: Gradle-Cache + path: | + .gradle/caches + .gradle/wrapper + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} + restore-keys: | + ${{ runner.os }}-gradle- - name: Run DataGen - run: gradle runData -q + run: gradle runData -q --no-daemon - name: Push if: always() @@ -56,10 +58,12 @@ jobs: if: always() run: gradle build -q - - name: Upload To Github Release + - name: Upload files to a GitHub release if: always() - uses: xresloader/upload-to-github-release@v1.3.7 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + uses: svenstaro/upload-release-action@2.3.0 with: - file: "./build/libs/*.jar" + repo_token: ${{ secrets.GITHUB_TOKEN }} + tag: ${{ github.ref }}-Alpha + file: build/libs/*.jar + overwrite: true + file_glob: true \ No newline at end of file diff --git a/src/main/java/io/github/tt432/kitchenkarrot/datagen/loottable/ModBlockLootProvider.java b/src/main/java/io/github/tt432/kitchenkarrot/datagen/loottable/ModBlockLootProvider.java index d6179b55..8aac2752 100644 --- a/src/main/java/io/github/tt432/kitchenkarrot/datagen/loottable/ModBlockLootProvider.java +++ b/src/main/java/io/github/tt432/kitchenkarrot/datagen/loottable/ModBlockLootProvider.java @@ -4,18 +4,44 @@ import io.github.tt432.kitchenkarrot.item.ModBlockItems; import net.minecraft.advancements.critereon.StatePropertiesPredicate; import net.minecraft.data.loot.BlockLoot; +import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.CropBlock; +import net.minecraft.world.level.storage.loot.LootTable; import net.minecraft.world.level.storage.loot.predicates.LootItemBlockStatePropertyCondition; +import org.jetbrains.annotations.NotNull; + +import java.util.Collection; +import java.util.Collections; +import java.util.HashSet; +import java.util.Set; public class ModBlockLootProvider extends BlockLoot { + private final Set skipBlocks = new HashSet<>(); + + @Override + protected void add(@NotNull Block pBlock, @NotNull LootTable.Builder pLootTableBuilder) { + super.add(pBlock, pLootTableBuilder); + skipBlocks.add(pBlock); + } + @Override protected void addTables() { - createCropDrops(ModBlocks.GEM_CARROT.get(), ModBlockItems.GEM_CARROT.get(), ModBlockItems.GEM_CARROT.get(), - LootItemBlockStatePropertyCondition - .hasBlockStateProperties(Blocks.WHEAT) - .setProperties(StatePropertiesPredicate.Builder.properties() - .hasProperty(CropBlock.AGE, 7))); + add(ModBlocks.GEM_CARROT.get(), + createCropDrops(ModBlocks.GEM_CARROT.get(), + ModBlockItems.GEM_CARROT.get(), + ModBlockItems.GEM_CARROT.get(), + LootItemBlockStatePropertyCondition + .hasBlockStateProperties(ModBlocks.GEM_CARROT.get()) + .setProperties(StatePropertiesPredicate.Builder.properties() + .hasProperty(CropBlock.AGE, 7)))); } + + @Override + @NotNull + protected Iterable getKnownBlocks() { + return skipBlocks; + } + } diff --git a/src/main/java/io/github/tt432/kitchenkarrot/datagen/loottable/ModLootTableProvider.java b/src/main/java/io/github/tt432/kitchenkarrot/datagen/loottable/ModLootTableProvider.java index 7bb957fd..b8e63df2 100644 --- a/src/main/java/io/github/tt432/kitchenkarrot/datagen/loottable/ModLootTableProvider.java +++ b/src/main/java/io/github/tt432/kitchenkarrot/datagen/loottable/ModLootTableProvider.java @@ -7,11 +7,13 @@ import net.minecraft.data.loot.LootTableProvider; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.level.storage.loot.LootTable; +import net.minecraft.world.level.storage.loot.ValidationContext; import net.minecraft.world.level.storage.loot.parameters.LootContextParamSet; import net.minecraft.world.level.storage.loot.parameters.LootContextParamSets; import org.jetbrains.annotations.NotNull; import java.util.List; +import java.util.Map; import java.util.function.BiConsumer; import java.util.function.Consumer; import java.util.function.Supplier; @@ -34,4 +36,9 @@ protected List map, @NotNull ValidationContext validationtracker) { + + } } From 10c918559657f6cbc0ed47332c297dce9e647fce Mon Sep 17 00:00:00 2001 From: skyinr <2587135207@qq.com> Date: Sat, 5 Nov 2022 15:43:30 +0800 Subject: [PATCH 2/2] =?UTF-8?q?dg=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/gradle-publish.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/gradle-publish.yml b/.github/workflows/gradle-publish.yml index 0885db2d..dd6f6057 100644 --- a/.github/workflows/gradle-publish.yml +++ b/.github/workflows/gradle-publish.yml @@ -34,15 +34,13 @@ jobs: if: always() uses: actions/cache@v3 with: - path: | - .gradle/caches - .gradle/wrapper + path: build/**/* key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} restore-keys: | ${{ runner.os }}-gradle- - name: Run DataGen - run: gradle runData -q --no-daemon + run: gradle runData -q - name: Push if: always()