proper datagen
This commit is contained in:
parent
891893b0f5
commit
dffd0fe3c8
14 changed files with 100 additions and 1 deletions
|
@ -0,0 +1,30 @@
|
|||
package observer.nelle.roses_mod.datagen;
|
||||
|
||||
import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput;
|
||||
import net.fabricmc.fabric.api.datagen.v1.provider.FabricTagProvider;
|
||||
import net.minecraft.registry.RegistryWrapper;
|
||||
import net.minecraft.registry.tag.BlockTags;
|
||||
import observer.nelle.roses_mod.RosesBlocks;
|
||||
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
public class RosesBlockTagProvider extends FabricTagProvider.BlockTagProvider {
|
||||
public RosesBlockTagProvider(FabricDataOutput output, CompletableFuture<RegistryWrapper.WrapperLookup> registriesFuture) {
|
||||
super(output, registriesFuture);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configure(RegistryWrapper.WrapperLookup wrapperLookup) {
|
||||
getOrCreateTagBuilder(BlockTags.TALL_FLOWERS)
|
||||
.add(RosesBlocks.INSTANCE.getCyanRoseBush())
|
||||
;
|
||||
getOrCreateTagBuilder(BlockTags.SMALL_FLOWERS)
|
||||
.add(RosesBlocks.INSTANCE.getRoseFlower())
|
||||
.add(RosesBlocks.INSTANCE.getCyanRoseFlower())
|
||||
;
|
||||
getOrCreateTagBuilder(BlockTags.FLOWER_POTS)
|
||||
.add(RosesBlocks.INSTANCE.getPottedRose())
|
||||
.add(RosesBlocks.INSTANCE.getPottedCyan())
|
||||
;
|
||||
}
|
||||
}
|
|
@ -11,6 +11,8 @@ public class RosesDataGenerator implements DataGeneratorEntrypoint {
|
|||
|
||||
// Adding a provider example:
|
||||
//
|
||||
// pack.addProvider(AdvancementsProvider::new);
|
||||
pack.addProvider(RosesRecipeProvider::new);
|
||||
pack.addProvider(RosesBlockTagProvider::new);
|
||||
pack.addProvider(RosesLootTableProvider::new);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
package observer.nelle.roses_mod.datagen;
|
||||
|
||||
import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput;
|
||||
import net.fabricmc.fabric.api.datagen.v1.provider.FabricBlockLootTableProvider;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.enchantment.Enchantments;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.loot.LootTable;
|
||||
import net.minecraft.loot.entry.ItemEntry;
|
||||
import net.minecraft.loot.function.ApplyBonusLootFunction;
|
||||
import net.minecraft.loot.function.SetCountLootFunction;
|
||||
import net.minecraft.loot.provider.number.UniformLootNumberProvider;
|
||||
import net.minecraft.registry.RegistryWrapper;
|
||||
import observer.nelle.roses_mod.RosesBlocks;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
public class RosesLootTableProvider extends FabricBlockLootTableProvider {
|
||||
protected RosesLootTableProvider(FabricDataOutput dataOutput, CompletableFuture<RegistryWrapper.WrapperLookup> registryLookup) {
|
||||
super(dataOutput, registryLookup);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generate() {
|
||||
addDrop(RosesBlocks.INSTANCE.getRoseFlower());
|
||||
addDrop(RosesBlocks.INSTANCE.getCyanRoseFlower());
|
||||
addDrop(RosesBlocks.INSTANCE.getCyanRoseBush());
|
||||
|
||||
addDrop(Blocks.ROSE_BUSH, roseBushDrops(Blocks.ROSE_BUSH, Objects.requireNonNull(RosesBlocks.INSTANCE.getRoseFlower()).asItem(), 2.0F, 5.0F));
|
||||
}
|
||||
|
||||
public LootTable.Builder roseBushDrops(Block tallPlant, Item item, Float min, Float max) {
|
||||
return dropsWithShears(tallPlant, this
|
||||
.applyExplosionDecay(tallPlant, ItemEntry.builder(item)
|
||||
.apply(SetCountLootFunction.builder(UniformLootNumberProvider.create(min, max)))
|
||||
.apply(ApplyBonusLootFunction.oreDrops(Enchantments.FORTUNE))));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
package observer.nelle.roses_mod.datagen;
|
||||
|
||||
import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput;
|
||||
import net.fabricmc.fabric.api.datagen.v1.provider.FabricRecipeProvider;
|
||||
import net.minecraft.data.server.recipe.RecipeExporter;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.recipe.book.RecipeCategory;
|
||||
import net.minecraft.registry.RegistryWrapper;
|
||||
import observer.nelle.roses_mod.RosesBlocks;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
public class RosesRecipeProvider extends FabricRecipeProvider {
|
||||
public RosesRecipeProvider(FabricDataOutput output, CompletableFuture<RegistryWrapper.WrapperLookup> registriesFuture) {
|
||||
super(output, registriesFuture);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generate(RecipeExporter recipeExporter) {
|
||||
offerShapelessRecipe(recipeExporter, Items.RED_DYE, Objects.requireNonNull(RosesBlocks.INSTANCE.getRoseFlower()), "dye", 2);
|
||||
offerShapelessRecipe(recipeExporter, Items.CYAN_DYE, Objects.requireNonNull(RosesBlocks.INSTANCE.getCyanRoseFlower()), "dye", 2);
|
||||
|
||||
offer2x2CompactingRecipe(recipeExporter, RecipeCategory.DECORATIONS, Items.ROSE_BUSH, RosesBlocks.INSTANCE.getRoseFlower());
|
||||
offer2x2CompactingRecipe(recipeExporter, RecipeCategory.DECORATIONS, Objects.requireNonNull(RosesBlocks.INSTANCE.getCyanRoseBush()).asItem(), RosesBlocks.INSTANCE.getCyanRoseFlower());
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue