Skip to content

Commit

Permalink
Refactored GrowthcraftMilk Data Generator
Browse files Browse the repository at this point in the history
  • Loading branch information
Alatyami committed Nov 5, 2023
1 parent e1015c6 commit 3ba2e58
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -1,31 +1,39 @@
package growthcraft.milk.datagen;

import growthcraft.milk.datagen.loot.GrowthcraftMilkLootTables;
import growthcraft.milk.datagen.providers.GrowthcraftMilkBlockStateProvider;
import growthcraft.milk.datagen.providers.GrowthcraftMilkLootTableProvider;
import growthcraft.milk.init.GrowthcraftMilkItems;
import growthcraft.milk.shared.Reference;
import net.minecraft.data.DataGenerator;
import net.minecraft.data.PackOutput;
import net.minecraftforge.client.event.ModelEvent;
import net.minecraftforge.common.data.ExistingFileHelper;
import net.minecraftforge.data.event.GatherDataEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;

public class DataGeneration {
public static void generate(GatherDataEvent event) {
@Mod.EventBusSubscriber(modid = Reference.MODID, bus = Mod.EventBusSubscriber.Bus.MOD)
public class GrowthcraftMilkDataGenerators {

@SubscribeEvent
public static void gatherData(GatherDataEvent event) {
DataGenerator generator = event.getGenerator();
PackOutput output = generator.getPackOutput();
ExistingFileHelper helper = event.getExistingFileHelper();

generator.addProvider(
event.includeServer(),
new GrowthcraftMilkLootTables(output)
new GrowthcraftMilkLootTableProvider(output)
);


generator.addProvider(event.includeClient(), new GrowthcraftMilkBlockStates(output, helper));
generator.addProvider(event.includeClient(), new GrowthcraftMilkBlockStateProvider(output, helper));

}

//@SubscribeEvent
public static void modelBake(ModelEvent.ModifyBakingResult event) {
GrowthcraftMilkItems.addItemModelProperties();
}


}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package growthcraft.milk.datagen;
package growthcraft.milk.datagen.providers;

import growthcraft.milk.init.GrowthcraftMilkBlocks;
import growthcraft.milk.shared.Reference;
Expand All @@ -18,11 +18,11 @@
import static growthcraft.milk.block.BaseCheeseWheel.SLICE_COUNT_BOTTOM;
import static growthcraft.milk.block.BaseCheeseWheel.SLICE_COUNT_TOP;

public class GrowthcraftMilkBlockStates extends BlockStateProvider {
public class GrowthcraftMilkBlockStateProvider extends BlockStateProvider {

private final ModelFile empty_model = models().getExistingFile(new ResourceLocation("growthcraft", "block/empty"));

public GrowthcraftMilkBlockStates(PackOutput output, ExistingFileHelper exFileHelper) {
public GrowthcraftMilkBlockStateProvider(PackOutput output, ExistingFileHelper exFileHelper) {
super(output, Reference.MODID, exFileHelper);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
package growthcraft.milk.datagen.loot;
package growthcraft.milk.datagen.providers;

import growthcraft.milk.datagen.providers.loot.CheeseWheelLootTable;
import net.minecraft.data.PackOutput;
import net.minecraft.data.loot.LootTableProvider;
import net.minecraft.world.level.storage.loot.parameters.LootContextParamSets;

import java.util.Collections;
import java.util.List;

public class GrowthcraftMilkLootTables extends LootTableProvider {
public GrowthcraftMilkLootTables(PackOutput output) {
public class GrowthcraftMilkLootTableProvider extends LootTableProvider {
public GrowthcraftMilkLootTableProvider(PackOutput output) {
super(output, Collections.emptySet(), List.of(
new LootTableProvider.SubProviderEntry(CheeseWheelLoot::new, LootContextParamSets.BLOCK)
new LootTableProvider.SubProviderEntry(CheeseWheelLootTable::new, LootContextParamSets.BLOCK)
));
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package growthcraft.milk.datagen.loot;
package growthcraft.milk.datagen.providers.loot;

import growthcraft.milk.block.BaseCheeseWheel;
import net.minecraft.advancements.critereon.StatePropertiesPredicate;
Expand All @@ -16,9 +16,9 @@

import java.util.Collections;

public class CheeseWheelLoot extends BlockLootSubProvider {
public class CheeseWheelLootTable extends BlockLootSubProvider {

protected CheeseWheelLoot() {
public CheeseWheelLootTable() {
super(Collections.emptySet(), FeatureFlags.REGISTRY.allFlags());
}

Expand Down

0 comments on commit 3ba2e58

Please sign in to comment.