Skip to content

Commit

Permalink
generated compostables data map
Browse files Browse the repository at this point in the history
  • Loading branch information
TheMCLoveMan committed Feb 29, 2024
1 parent 70b5050 commit 04f84b6
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 17 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// 1.20.4 2024-02-29T22:48:41.221262 Data Maps
82bdfaf84557680cbc3e67eec4ada083e2b21591 data/neoforge/data_maps/item/compostables.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"values": {
"uselessmod:blue_rose": {
"chance": 0.65
},
"uselessmod:coffee_beans": {
"chance": 0.65
},
"uselessmod:coffee_seeds": {
"chance": 0.3
},
"uselessmod:red_rose": {
"chance": 0.65
},
"uselessmod:useless_oak_sapling": {
"chance": 0.3
},
"uselessmod:useless_rose": {
"chance": 0.65
},
"uselessmod:useless_wheat": {
"chance": 0.65
},
"uselessmod:useless_wheat_seeds": {
"chance": 0.3
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
import net.minecraft.world.InteractionResult;
import net.minecraft.world.item.AxeItem;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.ItemLike;
import net.minecraft.world.level.block.*;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.FireBlock;
import net.minecraft.world.level.block.LayeredCauldronBlock;
import net.themcbrothers.uselessmod.init.ModBlocks;
import net.themcbrothers.uselessmod.init.ModItems;

Expand All @@ -30,17 +32,6 @@ public static void register() {
registerStrippable(ModBlocks.USELESS_OAK_LOG.get(), ModBlocks.STRIPPED_USELESS_OAK_LOG.get());
registerStrippable(ModBlocks.USELESS_OAK_WOOD.get(), ModBlocks.STRIPPED_USELESS_OAK_WOOD.get());

// Compostable blocks
registerCompostable(0.3F, ModBlocks.USELESS_OAK_SAPLING.get());
registerCompostable(0.3F, ModBlocks.USELESS_OAK_LEAVES.get());
registerCompostable(0.3F, ModItems.USELESS_WHEAT_SEEDS.get());
registerCompostable(0.3F, ModItems.COFFEE_SEEDS.get());
registerCompostable(0.65F, ModBlocks.RED_ROSE.get());
registerCompostable(0.65F, ModBlocks.BLUE_ROSE.get());
registerCompostable(0.65F, ModBlocks.USELESS_ROSE.get());
registerCompostable(0.65F, ModItems.USELESS_WHEAT.get());
registerCompostable(0.65F, ModItems.COFFEE_BEANS.get());

// Cauldron
CauldronInteraction.WATER.map().put(ModBlocks.PAINTED_WOOL.asItem(), (state, level, pos, player, hand, stack) -> {
if (!level.isClientSide) {
Expand Down Expand Up @@ -83,10 +74,6 @@ private static void registerStrippable(Block log, Block stripped_log) {
AxeItem.STRIPPABLES.put(log, stripped_log);
}

private static void registerCompostable(float chance, ItemLike itemIn) {
ComposterBlock.COMPOSTABLES.put(itemIn.asItem(), chance);
}

private static void registerFlammable(Block blockIn, int encouragement, int flammability) {
FireBlock fireblock = (FireBlock) Blocks.FIRE;
fireblock.setFlammable(blockIn, encouragement, flammability);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public static void dataGen(final GatherDataEvent event) {
generator.addProvider(event.includeServer(), new UselessTagsProvider.Fluids(packOutput, lookupProvider, existingFileHelper));
generator.addProvider(event.includeServer(), new UselessTagsProvider.Entities(packOutput, lookupProvider, existingFileHelper));
generator.addProvider(event.includeServer(), new UselessTagsProvider.Paintings(packOutput, lookupProvider, existingFileHelper));
generator.addProvider(event.includeServer(), new UselessDataMapsProvider(packOutput, lookupProvider));

// Resources
generator.addProvider(event.includeClient(), new UselessSpriteSourceProvider(packOutput, lookupProvider, existingFileHelper));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package net.themcbrothers.uselessmod.data;

import net.minecraft.core.HolderLookup;
import net.minecraft.data.PackOutput;
import net.neoforged.neoforge.common.data.DataMapProvider;
import net.neoforged.neoforge.registries.datamaps.builtin.Compostable;
import net.neoforged.neoforge.registries.datamaps.builtin.NeoForgeDataMaps;
import net.themcbrothers.uselessmod.init.ModBlocks;
import net.themcbrothers.uselessmod.init.ModItems;

import java.util.concurrent.CompletableFuture;

public class UselessDataMapsProvider extends DataMapProvider {
public UselessDataMapsProvider(PackOutput packOutput, CompletableFuture<HolderLookup.Provider> lookupProvider) {
super(packOutput, lookupProvider);
}

@Override
protected void gather() {
//noinspection deprecation
this.builder(NeoForgeDataMaps.COMPOSTABLES)
.add(ModBlocks.USELESS_OAK_SAPLING.asItem().builtInRegistryHolder(), new Compostable(0.3F), false)
.add(ModItems.USELESS_WHEAT_SEEDS.asItem().builtInRegistryHolder(), new Compostable(0.3F), false)
.add(ModItems.COFFEE_SEEDS.asItem().builtInRegistryHolder(), new Compostable(0.3F), false)
.add(ModBlocks.RED_ROSE.asItem().builtInRegistryHolder(), new Compostable(0.65F), false)
.add(ModBlocks.BLUE_ROSE.asItem().builtInRegistryHolder(), new Compostable(0.65F), false)
.add(ModBlocks.USELESS_ROSE.asItem().builtInRegistryHolder(), new Compostable(0.65F), false)
.add(ModItems.USELESS_WHEAT.asItem().builtInRegistryHolder(), new Compostable(0.65F), false)
.add(ModItems.COFFEE_BEANS.asItem().builtInRegistryHolder(), new Compostable(0.65F), false)
;
}
}

0 comments on commit 04f84b6

Please sign in to comment.