Migrate more stuff over to datagen
This commit is contained in:
parent
8b87c86cc4
commit
1555b3a209
67 changed files with 211 additions and 1148 deletions
|
@ -2,6 +2,7 @@ package dev.zontreck.otemod.data;
|
|||
|
||||
|
||||
import dev.zontreck.otemod.OTEMod;
|
||||
import dev.zontreck.otemod.data.loot.ModBlockLootTablesProvider;
|
||||
import net.minecraft.data.DataGenerator;
|
||||
import net.minecraft.data.PackOutput;
|
||||
import net.minecraftforge.common.data.ExistingFileHelper;
|
||||
|
@ -21,7 +22,8 @@ public class ModDatagen
|
|||
|
||||
ExistingFileHelper helper = event.getExistingFileHelper();
|
||||
|
||||
gen.addProvider(event.includeClient(), new ModBlockStatesProvider(output, helper));
|
||||
gen.addProvider(event.includeClient(), new ModItemModelsProvider(output,helper));
|
||||
gen.addProvider(true, new ModBlockStatesProvider(output, helper));
|
||||
gen.addProvider(true, new ModItemModelsProvider(output,helper));
|
||||
gen.addProvider(true, ModLootTablesProvider.create(output));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
package dev.zontreck.otemod.data;
|
||||
|
||||
import dev.zontreck.otemod.data.loot.ModBlockLootTablesProvider;
|
||||
import dev.zontreck.otemod.data.loot.ModDeprecatedBlockLootTablesProvider;
|
||||
import net.minecraft.data.PackOutput;
|
||||
import net.minecraft.data.loot.LootTableProvider;
|
||||
import net.minecraft.world.level.storage.loot.parameters.LootContextParamSets;
|
||||
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class ModLootTablesProvider
|
||||
{
|
||||
public static LootTableProvider create(PackOutput output)
|
||||
{
|
||||
return new LootTableProvider(output, Set.of(), List.of(
|
||||
new LootTableProvider.SubProviderEntry(ModBlockLootTablesProvider::new, LootContextParamSets.BLOCK),
|
||||
new LootTableProvider.SubProviderEntry(ModDeprecatedBlockLootTablesProvider::new, LootContextParamSets.BLOCK)
|
||||
));
|
||||
}
|
||||
}
|
|
@ -1,4 +1,116 @@
|
|||
package dev.zontreck.otemod.data.loot;
|
||||
|
||||
public class ModBlockLootTablesProvider {
|
||||
import dev.zontreck.otemod.blocks.*;
|
||||
import dev.zontreck.otemod.items.ModItems;
|
||||
import net.minecraft.data.PackOutput;
|
||||
import net.minecraft.data.loot.BlockLootSubProvider;
|
||||
import net.minecraft.data.loot.LootTableProvider;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.flag.FeatureFlags;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.item.enchantment.Enchantments;
|
||||
import net.minecraft.world.level.block.*;
|
||||
import net.minecraft.world.level.block.state.BlockBehaviour;
|
||||
import net.minecraft.world.level.storage.loot.LootTable;
|
||||
import net.minecraft.world.level.storage.loot.entries.LootItem;
|
||||
import net.minecraft.world.level.storage.loot.entries.LootPoolEntryContainer;
|
||||
import net.minecraft.world.level.storage.loot.functions.ApplyBonusCount;
|
||||
import net.minecraft.world.level.storage.loot.functions.SetItemCountFunction;
|
||||
import net.minecraft.world.level.storage.loot.providers.number.UniformGenerator;
|
||||
import net.minecraftforge.common.data.ExistingFileHelper;
|
||||
import net.minecraftforge.registries.RegistryObject;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import static dev.zontreck.otemod.blocks.ModBlocks.BLOCKS;
|
||||
|
||||
public class ModBlockLootTablesProvider extends BlockLootSubProvider
|
||||
{
|
||||
public ModBlockLootTablesProvider()
|
||||
{
|
||||
super(Set.of(), FeatureFlags.REGISTRY.allFlags());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void generate() {
|
||||
|
||||
add(ModBlocks.ETERNIUM_ORE_BLOCK.get(), (block)-> createOreDrop(ModBlocks.ETERNIUM_ORE_BLOCK.get(), ModItems.ETERNIUM_RAW_ORE.get()));
|
||||
add(ModBlocks.VAULT_STEEL_ORE_BLOCK.get(), (block)-> createOreDrop(ModBlocks.VAULT_STEEL_ORE_BLOCK.get(), ModItems.VAULT_RAW_ORE.get()));
|
||||
add(ModBlocks.NETHER_VAULT_STEEL_ORE_BLOCK.get(), (block)-> createOreDrop(ModBlocks.NETHER_VAULT_STEEL_ORE_BLOCK.get(), ModItems.VAULT_RAW_ORE.get()));
|
||||
add(ModBlocks.DEEPSLATE_ETERNIUM_ORE_BLOCK.get(), (block)-> createOreDrop(ModBlocks.DEEPSLATE_ETERNIUM_ORE_BLOCK.get(), ModItems.ETERNIUM_RAW_ORE.get()));
|
||||
|
||||
|
||||
dropSelf(ModBlocks.ETERNIUM_BLOCK.get());
|
||||
dropSelf(ModBlocks.ITEM_SCRUBBER.get());
|
||||
dropSelf(ModBlocks.MAGICAL_SCRUBBER.get());
|
||||
dropSelf(ModBlocks.STABLE_SINGULARITY.get());
|
||||
dropSelf(ModBlocks.COMPRESSION_CHAMBER.get());
|
||||
dropSelf(ModBlocks.COMPRESSED_OBSIDIAN_BLOCK.get());
|
||||
dropSelf(ModBlocks.LAYERED_COMPRESSED_OBSIDIAN_BLOCK.get());
|
||||
dropSelf(ModBlocks.VOID.get());
|
||||
dropSelf(ModBlocks.WHITEOUT.get());
|
||||
dropSelf(ModBlocks.BLOOD_RED.get());
|
||||
dropSelf(ModBlocks.RED_TILE.get());
|
||||
dropSelf(ModBlocks.RED_STAIRS.get());
|
||||
dropSelf(ModBlocks.RED_TILE_BR.get());
|
||||
dropSelf(ModBlocks.RED_TILE_TO_WALL.get());
|
||||
dropSelf(ModBlocks.RED_WALL_V1.get());
|
||||
dropSelf(ModBlocks.RED_WALL_V2.get());
|
||||
dropSelf(ModBlocks.CYAN.get());
|
||||
dropSelf(ModBlocks.CYAN_TILE.get());
|
||||
dropSelf(ModBlocks.CYAN_STAIRS.get());
|
||||
dropSelf(ModBlocks.CYAN_TILE_BR.get());
|
||||
dropSelf(ModBlocks.CYAN_TILE_TO_WALL.get());
|
||||
dropSelf(ModBlocks.CYAN_WALL_V1.get());
|
||||
dropSelf(ModBlocks.CYAN_WALL_V2.get());
|
||||
dropSelf(ModBlocks.POOL_TILE.get());
|
||||
dropSelf(ModBlocks.POOL_TILE_STAIRS.get());
|
||||
dropSelf(ModBlocks.POOL_TILE_SLAB.get());
|
||||
dropSelf(ModBlocks.POOL_LIGHT.get());
|
||||
dropSelf(ModBlocks.DIRTY_POOL_TILE.get());
|
||||
dropSelf(ModBlocks.DIRTY_POOL_TILE_STAIRS.get());
|
||||
dropSelf(ModBlocks.DIRTY_POOL_TILE_SLAB.get());
|
||||
dropSelf(ModBlocks.DIRTY_POOL_LIGHT.get());
|
||||
dropSelf(ModBlocks.FILTHY_POOL_LIGHT.get());
|
||||
dropSelf(ModBlocks.DARK_POOL_TILE.get());
|
||||
dropSelf(ModBlocks.DARK_POOL_LIGHT.get());
|
||||
dropSelf(ModBlocks.DARK_POOL_TILE_STAIRS.get());
|
||||
dropSelf(ModBlocks.DARK_POOL_TILE_SLAB.get());
|
||||
dropSelf(ModBlocks.BLUE_POOL_TILE.get());
|
||||
dropSelf(ModBlocks.BLUE_POOL_TILE_STAIRS.get());
|
||||
dropSelf(ModBlocks.BLUE_POOL_TILE_SLAB.get());
|
||||
dropSelf(ModBlocks.BLUE_POOL_LIGHT.get());
|
||||
dropSelf(ModBlocks.DIRTY_BLUE_POOL_TILE.get());
|
||||
dropSelf(ModBlocks.DIRTY_BLUE_POOL_TILE_STAIRS.get());
|
||||
dropSelf(ModBlocks.DIRTY_BLUE_POOL_TILE_SLAB.get());
|
||||
dropSelf(ModBlocks.DIRTY_BLUE_POOL_LIGHT.get());
|
||||
dropSelf(ModBlocks.FILTHY_BLUE_POOL_LIGHT.get());
|
||||
dropSelf(ModBlocks.RED_POOL_TILE.get());
|
||||
dropSelf(ModBlocks.RED_POOL_TILE_STAIRS.get());
|
||||
dropSelf(ModBlocks.RED_POOL_TILE_SLAB.get());
|
||||
dropSelf(ModBlocks.RED_POOL_LIGHT.get());
|
||||
dropSelf(ModBlocks.DIRTY_RED_POOL_TILE.get());
|
||||
dropSelf(ModBlocks.DIRTY_RED_POOL_LIGHT.get());
|
||||
dropSelf(ModBlocks.FILTHY_RED_POOL_LIGHT.get());
|
||||
dropSelf(ModBlocks.DIRTY_RED_POOL_TILE_STAIRS.get());
|
||||
dropSelf(ModBlocks.DIRTY_RED_POOL_TILE_SLAB.get());
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Iterable<Block> getKnownBlocks() {
|
||||
return ModBlocks.BLOCKS.getEntries().stream().map(RegistryObject::get)::iterator;
|
||||
}
|
||||
|
||||
|
||||
protected LootTable.Builder createCopperOreDrops(Block block, Item rawOre) {
|
||||
return createSilkTouchDispatchTable(block, (LootPoolEntryContainer.Builder) this.applyExplosionDecay(block, LootItem.lootTableItem(rawOre).apply(SetItemCountFunction.setCount(UniformGenerator.between(2.0F, 5.0F))).apply(ApplyBonusCount.addOreBonusCount(Enchantments.BLOCK_FORTUNE))));
|
||||
}
|
||||
|
||||
protected LootTable.Builder createOreDrop(Block block, Item rawOre) {
|
||||
return createSilkTouchDispatchTable(block, (LootPoolEntryContainer.Builder)this.applyExplosionDecay(block, LootItem.lootTableItem(rawOre).apply(ApplyBonusCount.addOreBonusCount(Enchantments.BLOCK_FORTUNE))));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,66 @@
|
|||
package dev.zontreck.otemod.data.loot;
|
||||
|
||||
import dev.zontreck.otemod.blocks.DeprecatedModBlocks;
|
||||
import dev.zontreck.otemod.blocks.ModBlocks;
|
||||
import dev.zontreck.otemod.items.ModItems;
|
||||
import net.minecraft.data.loot.BlockLootSubProvider;
|
||||
import net.minecraft.world.flag.FeatureFlags;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.enchantment.Enchantments;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.storage.loot.LootTable;
|
||||
import net.minecraft.world.level.storage.loot.entries.LootItem;
|
||||
import net.minecraft.world.level.storage.loot.entries.LootPoolEntryContainer;
|
||||
import net.minecraft.world.level.storage.loot.functions.ApplyBonusCount;
|
||||
import net.minecraft.world.level.storage.loot.functions.SetItemCountFunction;
|
||||
import net.minecraft.world.level.storage.loot.providers.number.UniformGenerator;
|
||||
import net.minecraftforge.registries.RegistryObject;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
public class ModDeprecatedBlockLootTablesProvider extends BlockLootSubProvider
|
||||
{
|
||||
public ModDeprecatedBlockLootTablesProvider()
|
||||
{
|
||||
super(Set.of(), FeatureFlags.REGISTRY.allFlags());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void generate() {
|
||||
|
||||
/*
|
||||
DEPRECATED BLOCKS
|
||||
*/
|
||||
|
||||
dropSelf(DeprecatedModBlocks.ILUSIUM_ORE_BLOCK.get());
|
||||
dropSelf(DeprecatedModBlocks.DEEPSLATE_ILUSIUM_ORE_BLOCK.get());
|
||||
dropSelf(DeprecatedModBlocks.ILUSIUM_BLOCK.get());
|
||||
dropSelf(DeprecatedModBlocks.CLEAR_GLASS_BLOCK.get());
|
||||
dropSelf(DeprecatedModBlocks.LIMINAL_TILES.get());
|
||||
dropSelf(DeprecatedModBlocks.BLACK.get());
|
||||
dropSelf(DeprecatedModBlocks.LIMINAL_TILE_STAIRS.get());
|
||||
dropSelf(DeprecatedModBlocks.LIMINAL_TILE_SLAB.get());
|
||||
dropSelf(DeprecatedModBlocks.LIMINAL_WINDOW.get());
|
||||
dropSelf(DeprecatedModBlocks.LIME.get());
|
||||
dropSelf(DeprecatedModBlocks.LIME_TILE.get());
|
||||
dropSelf(DeprecatedModBlocks.LIME_STAIRS.get());
|
||||
dropSelf(DeprecatedModBlocks.LIME_TILE_BR.get());
|
||||
dropSelf(DeprecatedModBlocks.LIME_TILE_TO_WALL.get());
|
||||
dropSelf(DeprecatedModBlocks.LIME_WALL_V1.get());
|
||||
dropSelf(DeprecatedModBlocks.LIME_WALL_V2.get());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Iterable<Block> getKnownBlocks() {
|
||||
return DeprecatedModBlocks.BLOCKS.getEntries().stream().map(RegistryObject::get)::iterator;
|
||||
}
|
||||
|
||||
|
||||
protected LootTable.Builder createCopperOreDrops(Block block, Item rawOre) {
|
||||
return createSilkTouchDispatchTable(block, (LootPoolEntryContainer.Builder) this.applyExplosionDecay(block, LootItem.lootTableItem(rawOre).apply(SetItemCountFunction.setCount(UniformGenerator.between(2.0F, 5.0F))).apply(ApplyBonusCount.addOreBonusCount(Enchantments.BLOCK_FORTUNE))));
|
||||
}
|
||||
|
||||
protected LootTable.Builder createOreDrop(Block block, Item rawOre) {
|
||||
return createSilkTouchDispatchTable(block, (LootPoolEntryContainer.Builder)this.applyExplosionDecay(block, LootItem.lootTableItem(rawOre).apply(ApplyBonusCount.addOreBonusCount(Enchantments.BLOCK_FORTUNE))));
|
||||
}
|
||||
}
|
Reference in a new issue