pre setup
This commit is contained in:
@@ -39,25 +39,6 @@ public class Ornamentum {
|
|||||||
public static final String MODID = "ornamentum";
|
public static final String MODID = "ornamentum";
|
||||||
// Directly reference a slf4j logger
|
// Directly reference a slf4j logger
|
||||||
private static final Logger LOGGER = LogUtils.getLogger();
|
private static final Logger LOGGER = LogUtils.getLogger();
|
||||||
// Create a Deferred Register to hold Blocks which will all be registered under the "ornamentum" namespace
|
|
||||||
public static final DeferredRegister.Blocks BLOCKS = DeferredRegister.createBlocks(MODID);
|
|
||||||
// Create a Deferred Register to hold Items which will all be registered under the "ornamentum" namespace
|
|
||||||
public static final DeferredRegister.Items ITEMS = DeferredRegister.createItems(MODID);
|
|
||||||
// Create a Deferred Register to hold CreativeModeTabs which will all be registered under the "ornamentum" namespace
|
|
||||||
public static final DeferredRegister<CreativeModeTab> CREATIVE_MODE_TABS = DeferredRegister.create(Registries.CREATIVE_MODE_TAB, MODID);
|
|
||||||
|
|
||||||
// Creates a new Block with the id "ornamentum:example_block", combining the namespace and path
|
|
||||||
public static final DeferredBlock<Block> EXAMPLE_BLOCK = BLOCKS.registerSimpleBlock("example_block", BlockBehaviour.Properties.of().mapColor(MapColor.STONE));
|
|
||||||
// Creates a new BlockItem with the id "ornamentum:example_block", combining the namespace and path
|
|
||||||
public static final DeferredItem<BlockItem> EXAMPLE_BLOCK_ITEM = ITEMS.registerSimpleBlockItem("example_block", EXAMPLE_BLOCK);
|
|
||||||
|
|
||||||
// Creates a new food item with the id "ornamentum:example_id", nutrition 1 and saturation 2
|
|
||||||
public static final DeferredItem<Item> EXAMPLE_ITEM = ITEMS.registerSimpleItem("example_item", new Item.Properties().food(new FoodProperties.Builder().alwaysEdible().nutrition(1).saturationModifier(2f).build()));
|
|
||||||
|
|
||||||
// Creates a creative tab with the id "ornamentum:example_tab" for the example item, that is placed after the combat tab
|
|
||||||
public static final DeferredHolder<CreativeModeTab, CreativeModeTab> EXAMPLE_TAB = CREATIVE_MODE_TABS.register("example_tab", () -> CreativeModeTab.builder().title(Component.translatable("itemGroup.ornamentum")).withTabsBefore(CreativeModeTabs.COMBAT).icon(() -> EXAMPLE_ITEM.get().getDefaultInstance()).displayItems((parameters, output) -> {
|
|
||||||
output.accept(EXAMPLE_ITEM.get()); // Add the example item to the tab. For your own tabs, this method is preferred over the event
|
|
||||||
}).build());
|
|
||||||
|
|
||||||
// The constructor for the mod class is the first code that is run when your mod is loaded.
|
// The constructor for the mod class is the first code that is run when your mod is loaded.
|
||||||
// FML will recognize some parameter types like IEventBus or ModContainer and pass them in automatically.
|
// FML will recognize some parameter types like IEventBus or ModContainer and pass them in automatically.
|
||||||
@@ -65,21 +46,11 @@ public class Ornamentum {
|
|||||||
// Register the commonSetup method for modloading
|
// Register the commonSetup method for modloading
|
||||||
modEventBus.addListener(this::commonSetup);
|
modEventBus.addListener(this::commonSetup);
|
||||||
|
|
||||||
// Register the Deferred Register to the mod event bus so blocks get registered
|
|
||||||
BLOCKS.register(modEventBus);
|
|
||||||
// Register the Deferred Register to the mod event bus so items get registered
|
|
||||||
ITEMS.register(modEventBus);
|
|
||||||
// Register the Deferred Register to the mod event bus so tabs get registered
|
|
||||||
CREATIVE_MODE_TABS.register(modEventBus);
|
|
||||||
|
|
||||||
// Register ourselves for server and other game events we are interested in.
|
// Register ourselves for server and other game events we are interested in.
|
||||||
// Note that this is necessary if and only if we want *this* class (Ornamentum) to respond directly to events.
|
// Note that this is necessary if and only if we want *this* class (Ornamentum) to respond directly to events.
|
||||||
// Do not add this line if there are no @SubscribeEvent-annotated functions in this class, like onServerStarting() below.
|
// Do not add this line if there are no @SubscribeEvent-annotated functions in this class, like onServerStarting() below.
|
||||||
NeoForge.EVENT_BUS.register(this);
|
NeoForge.EVENT_BUS.register(this);
|
||||||
|
|
||||||
// Register the item to a creative tab
|
|
||||||
modEventBus.addListener(this::addCreative);
|
|
||||||
|
|
||||||
// Register our mod's ModConfigSpec so that FML can create and load the config file for us
|
// Register our mod's ModConfigSpec so that FML can create and load the config file for us
|
||||||
modContainer.registerConfig(ModConfig.Type.COMMON, Config.SPEC);
|
modContainer.registerConfig(ModConfig.Type.COMMON, Config.SPEC);
|
||||||
}
|
}
|
||||||
@@ -95,11 +66,6 @@ public class Ornamentum {
|
|||||||
Config.items.forEach((item) -> LOGGER.info("ITEM >> {}", item.toString()));
|
Config.items.forEach((item) -> LOGGER.info("ITEM >> {}", item.toString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add the example block item to the building blocks tab
|
|
||||||
private void addCreative(BuildCreativeModeTabContentsEvent event) {
|
|
||||||
if (event.getTabKey() == CreativeModeTabs.BUILDING_BLOCKS) event.accept(EXAMPLE_BLOCK_ITEM);
|
|
||||||
}
|
|
||||||
|
|
||||||
// You can use SubscribeEvent and let the Event Bus discover methods to call
|
// You can use SubscribeEvent and let the Event Bus discover methods to call
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onServerStarting(ServerStartingEvent event) {
|
public void onServerStarting(ServerStartingEvent event) {
|
||||||
@@ -114,7 +80,7 @@ public class Ornamentum {
|
|||||||
public static void onClientSetup(FMLClientSetupEvent event) {
|
public static void onClientSetup(FMLClientSetupEvent event) {
|
||||||
// Some client setup code
|
// Some client setup code
|
||||||
LOGGER.info("HELLO FROM CLIENT SETUP");
|
LOGGER.info("HELLO FROM CLIENT SETUP");
|
||||||
LOGGER.info("MINECRAFT NAME >> {}", Minecraft.getInstance().getUser().getName());
|
//LOGGER.info("MINECRAFT NAME >> {}", Minecraft.getInstance().getUser().getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,37 @@
|
|||||||
|
package ovh.glitchlabs.ornamentum.blocks;
|
||||||
|
|
||||||
|
import net.minecraft.world.item.BlockItem;
|
||||||
|
import net.minecraft.world.item.Item;
|
||||||
|
import net.minecraft.world.level.block.Block;
|
||||||
|
import net.minecraft.world.level.block.Blocks;
|
||||||
|
import net.minecraft.world.level.block.state.BlockBehaviour;
|
||||||
|
import net.neoforged.bus.api.IEventBus;
|
||||||
|
import net.neoforged.neoforge.registries.DeferredBlock;
|
||||||
|
import net.neoforged.neoforge.registries.DeferredRegister;
|
||||||
|
import ovh.glitchlabs.ornamentum.Ornamentum;
|
||||||
|
import ovh.glitchlabs.ornamentum.items.ModItems;
|
||||||
|
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
|
public class ModBlocks {
|
||||||
|
public static final DeferredRegister.Blocks BLOCKS =
|
||||||
|
DeferredRegister.createBlocks(Ornamentum.MODID);
|
||||||
|
|
||||||
|
//public static final DeferredBlock<Block> OBSIDIAN_BRICKS = registerBlock("obsidian_bricks",
|
||||||
|
// () -> new Block(BlockBehaviour.Properties.ofFullCopy(Blocks.OBSIDIAN)
|
||||||
|
// ));
|
||||||
|
//
|
||||||
|
private static <T extends Block> DeferredBlock<T> registerBlock(String name, Supplier<T> block) {
|
||||||
|
DeferredBlock<T> toReturn = BLOCKS.register(name, block);
|
||||||
|
registerBlockItem(name, toReturn);
|
||||||
|
return toReturn;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static <T extends Block> void registerBlockItem(String name, DeferredBlock<T> block) {
|
||||||
|
ModItems.ITEMS.register(name, () -> new BlockItem(block.get(), new Item.Properties()));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void register(IEventBus eventBus) {
|
||||||
|
BLOCKS.register(eventBus);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
package ovh.glitchlabs.ornamentum.datagen;
|
||||||
|
|
||||||
|
import net.minecraft.core.HolderLookup;
|
||||||
|
import net.minecraft.data.DataGenerator;
|
||||||
|
import net.minecraft.data.PackOutput;
|
||||||
|
import net.minecraft.data.loot.LootTableProvider;
|
||||||
|
import net.minecraft.world.level.storage.loot.parameters.LootContextParamSets;
|
||||||
|
import net.neoforged.bus.api.SubscribeEvent;
|
||||||
|
import net.neoforged.fml.common.EventBusSubscriber;
|
||||||
|
import net.neoforged.neoforge.common.data.BlockTagsProvider;
|
||||||
|
import net.neoforged.neoforge.common.data.ExistingFileHelper;
|
||||||
|
import net.neoforged.neoforge.data.event.GatherDataEvent;
|
||||||
|
import ovh.glitchlabs.ornamentum.Ornamentum;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
|
@EventBusSubscriber(modid = Ornamentum.MODID, bus = EventBusSubscriber.Bus.MOD)
|
||||||
|
public class DataGenerators {
|
||||||
|
@SubscribeEvent
|
||||||
|
public static void gatherData(GatherDataEvent event) {
|
||||||
|
DataGenerator generator = event.getGenerator();
|
||||||
|
PackOutput packOutput = generator.getPackOutput();
|
||||||
|
ExistingFileHelper existingFileHelper = event.getExistingFileHelper();
|
||||||
|
CompletableFuture<HolderLookup.Provider> lookupProvider = event.getLookupProvider();
|
||||||
|
|
||||||
|
generator.addProvider(event.includeServer(), new LootTableProvider(packOutput, Collections.emptySet(),
|
||||||
|
List.of(new LootTableProvider.SubProviderEntry(ModBlockLootTableProvider::new, LootContextParamSets.BLOCK)), lookupProvider));
|
||||||
|
|
||||||
|
BlockTagsProvider blockTagsProvider = new ModBlockTagProvider(packOutput, lookupProvider, existingFileHelper);
|
||||||
|
generator.addProvider(event.includeServer(), blockTagsProvider);
|
||||||
|
|
||||||
|
generator.addProvider(event.includeServer(), new ModItemTagProvider(packOutput, lookupProvider, blockTagsProvider.contentsGetter(), existingFileHelper));
|
||||||
|
|
||||||
|
generator.addProvider(event.includeClient(), new ModItemModelProvider(packOutput, existingFileHelper));
|
||||||
|
generator.addProvider(event.includeClient(), new ModBlockStateProvider(packOutput, existingFileHelper));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
package ovh.glitchlabs.ornamentum.datagen;
|
||||||
|
|
||||||
|
import net.minecraft.core.Holder;
|
||||||
|
import net.minecraft.core.HolderLookup;
|
||||||
|
import net.minecraft.data.loot.BlockLootSubProvider;
|
||||||
|
import net.minecraft.world.flag.FeatureFlags;
|
||||||
|
import net.minecraft.world.level.block.Block;
|
||||||
|
import ovh.glitchlabs.ornamentum.blocks.ModBlocks;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
public class ModBlockLootTableProvider extends BlockLootSubProvider {
|
||||||
|
protected ModBlockLootTableProvider(HolderLookup.Provider registries) {
|
||||||
|
super(Set.of(), FeatureFlags.REGISTRY.allFlags(), registries);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void generate() {
|
||||||
|
//dropSelf(ModBlocks.OBSIDIAN_BRICKS.get());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Iterable<Block> getKnownBlocks() {
|
||||||
|
return ModBlocks.BLOCKS.getEntries().stream().map(Holder::value)::iterator;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
package ovh.glitchlabs.ornamentum.datagen;
|
||||||
|
|
||||||
|
import net.minecraft.data.PackOutput;
|
||||||
|
import net.neoforged.neoforge.client.model.generators.BlockStateProvider;
|
||||||
|
import net.neoforged.neoforge.common.data.ExistingFileHelper;
|
||||||
|
import net.neoforged.neoforge.registries.DeferredBlock;
|
||||||
|
import ovh.glitchlabs.ornamentum.Ornamentum;
|
||||||
|
|
||||||
|
public class ModBlockStateProvider extends BlockStateProvider {
|
||||||
|
public ModBlockStateProvider(PackOutput output, ExistingFileHelper exFileHelper) {
|
||||||
|
super(output, Ornamentum.MODID, exFileHelper);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void registerStatesAndModels() {
|
||||||
|
// blockWithItem(ModBlocks.POLISHED_OBSIDIAN);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void blockWithItem(DeferredBlock<?> deferredBlock) {
|
||||||
|
simpleBlockWithItem(deferredBlock.get(), cubeAll(deferredBlock.get()));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
package ovh.glitchlabs.ornamentum.datagen;
|
||||||
|
|
||||||
|
import net.minecraft.core.HolderLookup;
|
||||||
|
import net.minecraft.data.PackOutput;
|
||||||
|
import net.minecraft.tags.BlockTags;
|
||||||
|
import net.neoforged.neoforge.common.data.BlockTagsProvider;
|
||||||
|
import net.neoforged.neoforge.common.data.ExistingFileHelper;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
import ovh.glitchlabs.ornamentum.Ornamentum;
|
||||||
|
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
|
public class ModBlockTagProvider extends BlockTagsProvider {
|
||||||
|
public ModBlockTagProvider(PackOutput output, CompletableFuture<HolderLookup.Provider> lookupProvider, @Nullable ExistingFileHelper existingFileHelper) {
|
||||||
|
super(output, lookupProvider, Ornamentum.MODID, existingFileHelper);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void addTags(HolderLookup.Provider provider) {
|
||||||
|
tag(BlockTags.MINEABLE_WITH_PICKAXE)
|
||||||
|
//.add(ModBlocks.POLISHED_OBSIDIAN.get())
|
||||||
|
;
|
||||||
|
|
||||||
|
tag(BlockTags.NEEDS_DIAMOND_TOOL)
|
||||||
|
//.add(ModBlocks.POLISHED_OBSIDIAN.get())
|
||||||
|
;
|
||||||
|
|
||||||
|
tag(BlockTags.ANCIENT_CITY_REPLACEABLE)
|
||||||
|
//.add(ModBlocks.OBSIDIAN_BRICKS.get())
|
||||||
|
;
|
||||||
|
|
||||||
|
tag(BlockTags.SCULK_REPLACEABLE_WORLD_GEN)
|
||||||
|
//.add(ModBlocks.POLISHED_OBSIDIAN.get())
|
||||||
|
;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package ovh.glitchlabs.ornamentum.datagen;
|
||||||
|
|
||||||
|
import net.minecraft.data.PackOutput;
|
||||||
|
import net.neoforged.neoforge.client.model.generators.ItemModelProvider;
|
||||||
|
import net.neoforged.neoforge.common.data.ExistingFileHelper;
|
||||||
|
import ovh.glitchlabs.ornamentum.Ornamentum;
|
||||||
|
|
||||||
|
public class ModItemModelProvider extends ItemModelProvider {
|
||||||
|
public ModItemModelProvider(PackOutput output, ExistingFileHelper existingFileHelper) {
|
||||||
|
super(output, Ornamentum.MODID, existingFileHelper);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void registerModels() {
|
||||||
|
// basicItem(ModItems.OBSIDIAN_DUST.get());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
package ovh.glitchlabs.ornamentum.datagen;
|
||||||
|
|
||||||
|
import net.minecraft.core.HolderLookup;
|
||||||
|
import net.minecraft.data.PackOutput;
|
||||||
|
import net.minecraft.data.tags.ItemTagsProvider;
|
||||||
|
import net.minecraft.tags.ItemTags;
|
||||||
|
import net.minecraft.world.item.Items;
|
||||||
|
import net.minecraft.world.level.block.Block;
|
||||||
|
import net.neoforged.neoforge.common.data.ExistingFileHelper;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
import ovh.glitchlabs.ornamentum.Ornamentum;
|
||||||
|
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
|
public class ModItemTagProvider extends ItemTagsProvider {
|
||||||
|
public ModItemTagProvider(PackOutput output, CompletableFuture<HolderLookup.Provider> lookupProvider,
|
||||||
|
CompletableFuture<TagLookup<Block>> blockTags, @Nullable ExistingFileHelper existingFileHelper) {
|
||||||
|
super(output, lookupProvider, blockTags, Ornamentum.MODID, existingFileHelper);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void addTags(HolderLookup.Provider provider) {
|
||||||
|
|
||||||
|
this.tag(ItemTags.TRIMMABLE_ARMOR)
|
||||||
|
//.add(ModItems.OBSIDIAN_HELMET.get())
|
||||||
|
;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
package ovh.glitchlabs.ornamentum.items;
|
||||||
|
|
||||||
|
import net.minecraft.world.item.ArmorItem;
|
||||||
|
import net.minecraft.world.item.Item;
|
||||||
|
import net.minecraft.world.item.Rarity;
|
||||||
|
import net.neoforged.bus.api.IEventBus;
|
||||||
|
import net.neoforged.neoforge.registries.DeferredItem;
|
||||||
|
import net.neoforged.neoforge.registries.DeferredRegister;
|
||||||
|
import ovh.glitchlabs.ornamentum.Ornamentum;
|
||||||
|
|
||||||
|
public class ModItems {
|
||||||
|
public static final DeferredRegister.Items ITEMS = DeferredRegister.createItems(Ornamentum.MODID);
|
||||||
|
|
||||||
|
//public static final DeferredItem<Item> OBSIDIAN_DUST = ITEMS.register("obsidian_dust",
|
||||||
|
// () -> new Item(new Item.Properties()
|
||||||
|
// .stacksTo(16)
|
||||||
|
// .rarity(Rarity.RARE)
|
||||||
|
// ));
|
||||||
|
|
||||||
|
public static void register(IEventBus eventBus) {
|
||||||
|
ITEMS.register(eventBus);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user