Skip to content

Commit

Permalink
closes and fixes #7
Browse files Browse the repository at this point in the history
  • Loading branch information
manmaed committed Oct 1, 2024
1 parent 145acda commit c97bdc9
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// 1.21 2024-10-01T22:03:29.4033395 Data Maps
cd167d458df01c70b8fdf741124c5cb6ad903930 data/neoforge/data_maps/item/compostables.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"values": {
"cottonly:cotton_ball": {
"chance": 0.65
},
"cottonly:cotton_seeds": {
"can_villager_compost": true,
"chance": 0.3
}
}
}
12 changes: 0 additions & 12 deletions src/main/java/net/manmaed/cottonly/Cottonly.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,8 @@
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.level.block.ComposterBlock;
import net.neoforged.bus.api.IEventBus;
import net.neoforged.fml.common.Mod;
import net.neoforged.fml.event.lifecycle.FMLCommonSetupEvent;
import net.neoforged.neoforge.registries.DeferredHolder;
import net.neoforged.neoforge.registries.DeferredRegister;

Expand Down Expand Up @@ -49,19 +47,9 @@ public class Cottonly {
public Cottonly(IEventBus eventBus) {
CItems.ITEMS.register(eventBus);
CBlocks.BLOCKS.register(eventBus);
eventBus.addListener(this::init);
CLoots.LOOT_MODIFIERS.register(eventBus);
CREATIVE_MODE_TABS.register(eventBus);
eventBus.addListener(CottonlyClient::doClientStuff);

}

private void init(FMLCommonSetupEvent event) {
registerCompostable(0.65F, CItems.COTTON_SEED.get());
}

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

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package net.manmaed.cottonly.datagenerators;

import net.manmaed.cottonly.items.CItems;
import net.minecraft.core.HolderLookup;
import net.minecraft.core.registries.BuiltInRegistries;
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 java.util.concurrent.CompletableFuture;

public class CottonDataMaps extends DataMapProvider {

public CottonDataMaps(PackOutput packOutput, CompletableFuture<HolderLookup.Provider> lookupProvider) {
super(packOutput, lookupProvider);
}

@Override
protected void gather() {
builder(NeoForgeDataMaps.COMPOSTABLES)
.add(BuiltInRegistries.ITEM.wrapAsHolder(CItems.COTTON_SEED.get()), new Compostable(0.3F, true), false)
.add(BuiltInRegistries.ITEM.wrapAsHolder(CItems.COTTON_BALL.get()), new Compostable(0.65F), false);
;
}

/* how it should look like
"minecraft:wheat_seeds": {
"can_villager_compost": true,
"chance": 0.3
}
*/
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,6 @@ public static void gatherData(GatherDataEvent event) {
generator.addProvider(true, new CottonLootTables(packOutput, lookupProvider));
generator.addProvider(true, new CottonBlockStateProvider(packOutput, fileHelper));
CottonLanguageProvider.addTranslations(generator);
generator.addProvider(true, new CottonDataMaps(packOutput, lookupProvider));
}
}

0 comments on commit c97bdc9

Please sign in to comment.