Skip to content

Commit

Permalink
Merge pull request #8 from skyinr/new
Browse files Browse the repository at this point in the history
dg修复
  • Loading branch information
Glyceryl6 authored Nov 5, 2022
2 parents 6b2e090 + 10c9185 commit 1ae8fb9
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 15 deletions.
22 changes: 12 additions & 10 deletions .github/workflows/gradle-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ 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: build/**/*
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Run DataGen
run: gradle runData -q
Expand All @@ -56,10 +56,12 @@ jobs:
if: always()
run: gradle build -q

- name: Upload To Github Release
- name: Upload files to a GitHub release
if: always()
uses: xresloader/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
uses: svenstaro/[email protected]
with:
file: "./build/libs/*.jar"
repo_token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ github.ref }}-Alpha
file: build/libs/*.jar
overwrite: true
file_glob: true
Original file line number Diff line number Diff line change
Expand Up @@ -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<Block> 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<Block> getKnownBlocks() {
return skipBlocks;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -34,4 +36,9 @@ protected List<Pair<Supplier<Consumer<BiConsumer<ResourceLocation, LootTable.Bui
builder.add(Pair.of(ModBlockLootProvider::new, LootContextParamSets.BLOCK));
return builder.build();
}

@Override
protected void validate(@NotNull Map<ResourceLocation, LootTable> map, @NotNull ValidationContext validationtracker) {

}
}

0 comments on commit 1ae8fb9

Please sign in to comment.