implement DataGen correctly
This commit is contained in:
parent
cfeed04a0a
commit
9b4a3e4b7a
@ -1,21 +1,13 @@
|
|||||||
package com.jenny.compressedblocks;
|
package com.jenny.compressedblocks;
|
||||||
|
|
||||||
|
|
||||||
import com.jenny.compressedblocks.Tools;
|
|
||||||
import com.mojang.logging.LogUtils;
|
import com.mojang.logging.LogUtils;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.resources.model.Material;
|
|
||||||
import net.minecraft.core.registries.Registries;
|
import net.minecraft.core.registries.Registries;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.world.flag.FeatureFlag;
|
|
||||||
import net.minecraft.world.flag.FeatureFlagSet;
|
|
||||||
import net.minecraft.world.flag.FeatureFlags;
|
|
||||||
import net.minecraft.world.item.*;
|
import net.minecraft.world.item.*;
|
||||||
import net.minecraft.world.level.block.Block;
|
import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.world.level.block.Blocks;
|
import net.minecraft.world.level.block.Blocks;
|
||||||
import net.minecraft.world.level.block.IronBarsBlock;
|
|
||||||
import net.minecraft.world.level.block.state.BlockBehaviour;
|
import net.minecraft.world.level.block.state.BlockBehaviour;
|
||||||
import net.minecraft.world.level.block.state.properties.NoteBlockInstrument;
|
|
||||||
import net.minecraft.world.level.material.MapColor;
|
import net.minecraft.world.level.material.MapColor;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
@ -140,21 +132,13 @@ public class CompressedBlocks
|
|||||||
{
|
{
|
||||||
IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();
|
IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();
|
||||||
|
|
||||||
// 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);
|
BLOCKS.register(modEventBus);
|
||||||
// Register the Deferred Register to the mod event bus so items get registered
|
|
||||||
ITEMS.register(modEventBus);
|
ITEMS.register(modEventBus);
|
||||||
Tools.register(modEventBus);
|
Tools.register(modEventBus);
|
||||||
// Register the Deferred Register to the mod event bus so tabs get registered
|
|
||||||
CREATIVE_MODE_TABS.register(modEventBus);
|
CREATIVE_MODE_TABS.register(modEventBus);
|
||||||
|
|
||||||
// Register ourselves for server and other game events we are interested in
|
|
||||||
MinecraftForge.EVENT_BUS.register(this);
|
MinecraftForge.EVENT_BUS.register(this);
|
||||||
|
|
||||||
// Register our mod's ForgeConfigSpec so that Forge can create and load the config file for us
|
|
||||||
ModLoadingContext.get().registerConfig(ModConfig.Type.COMMON, Config.SPEC);
|
ModLoadingContext.get().registerConfig(ModConfig.Type.COMMON, Config.SPEC);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
package com.jenny.compressedblocks;
|
package com.jenny.compressedblocks;
|
||||||
|
|
||||||
import com.jenny.compressedblocks.ToolTiers;
|
|
||||||
import net.minecraft.world.item.*;
|
import net.minecraft.world.item.*;
|
||||||
import net.minecraftforge.common.ForgeSpawnEggItem;
|
|
||||||
import net.minecraftforge.eventbus.api.IEventBus;
|
import net.minecraftforge.eventbus.api.IEventBus;
|
||||||
import net.minecraftforge.registries.DeferredRegister;
|
import net.minecraftforge.registries.DeferredRegister;
|
||||||
import net.minecraftforge.registries.ForgeRegistries;
|
import net.minecraftforge.registries.ForgeRegistries;
|
||||||
@ -16,5 +14,5 @@ public class Tools {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static void register(IEventBus eventBus) {TOOLS.register(eventBus);};
|
public static void register(IEventBus eventBus) {TOOLS.register(eventBus);}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,28 @@
|
|||||||
|
package com.jenny.compressedblocks.datagen;
|
||||||
|
|
||||||
|
import com.jenny.compressedblocks.CompressedBlocks;
|
||||||
|
import net.minecraft.core.HolderLookup;
|
||||||
|
import net.minecraft.data.DataGenerator;
|
||||||
|
import net.minecraft.data.PackOutput;
|
||||||
|
import net.minecraftforge.common.data.ExistingFileHelper;
|
||||||
|
import net.minecraftforge.data.event.GatherDataEvent;
|
||||||
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
|
import net.minecraftforge.fml.common.Mod;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
|
@Mod.EventBusSubscriber(modid = CompressedBlocks.MODID, bus = Mod.EventBusSubscriber.Bus.MOD)
|
||||||
|
public class DataGenerators {
|
||||||
|
@SubscribeEvent
|
||||||
|
public static void gatherData(@NotNull GatherDataEvent event) {
|
||||||
|
DataGenerator generator = event.getGenerator();
|
||||||
|
PackOutput packOutput = generator.getPackOutput();
|
||||||
|
ExistingFileHelper existingFileHelper = event.getExistingFileHelper();
|
||||||
|
CompletableFuture<HolderLookup.Provider> lookupProvider = event.getLookupProvider();
|
||||||
|
|
||||||
|
generator.addProvider(event.includeClient(), new ModItemModelProvider(packOutput, existingFileHelper));
|
||||||
|
ModBlockTagGenerator blockTagGenerator = generator.addProvider(event.includeServer(),
|
||||||
|
new ModBlockTagGenerator(packOutput, lookupProvider, existingFileHelper));
|
||||||
|
generator.addProvider(event.includeServer(), new ModItemTagGenerator(packOutput, lookupProvider, blockTagGenerator.contentsGetter(), existingFileHelper));
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,76 @@
|
|||||||
|
package com.jenny.compressedblocks.datagen;
|
||||||
|
|
||||||
|
import com.jenny.compressedblocks.CompressedBlocks;
|
||||||
|
import net.minecraft.core.HolderLookup;
|
||||||
|
import net.minecraft.data.PackOutput;
|
||||||
|
import net.minecraft.tags.BlockTags;
|
||||||
|
import net.minecraftforge.common.data.BlockTagsProvider;
|
||||||
|
import net.minecraftforge.common.data.ExistingFileHelper;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
|
public class ModBlockTagGenerator extends BlockTagsProvider {
|
||||||
|
public ModBlockTagGenerator(PackOutput output, CompletableFuture<HolderLookup.Provider> lookupProvider, @Nullable ExistingFileHelper existingFileHelper) {
|
||||||
|
super(output, lookupProvider, CompressedBlocks.MODID, existingFileHelper);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void addTags(@NotNull HolderLookup.Provider pProvider) {
|
||||||
|
this.tag(BlockTags.MINEABLE_WITH_PICKAXE)
|
||||||
|
.add(
|
||||||
|
CompressedBlocks.COBBLESTONE_1X.get(),
|
||||||
|
CompressedBlocks.COBBLESTONE_2X.get(),
|
||||||
|
CompressedBlocks.COBBLESTONE_3X.get(),
|
||||||
|
CompressedBlocks.COBBLESTONE_4X.get(),
|
||||||
|
|
||||||
|
CompressedBlocks.ANDESITE_1X.get(),
|
||||||
|
CompressedBlocks.ANDESITE_2X.get(),
|
||||||
|
CompressedBlocks.ANDESITE_3X.get(),
|
||||||
|
CompressedBlocks.ANDESITE_4X.get(),
|
||||||
|
|
||||||
|
CompressedBlocks.DIORITE_1X.get(),
|
||||||
|
CompressedBlocks.DIORITE_2X.get(),
|
||||||
|
CompressedBlocks.DIORITE_3X.get(),
|
||||||
|
CompressedBlocks.DIORITE_4X.get(),
|
||||||
|
|
||||||
|
CompressedBlocks.GRANITE_1X.get(),
|
||||||
|
CompressedBlocks.GRANITE_2X.get(),
|
||||||
|
CompressedBlocks.GRANITE_3X.get(),
|
||||||
|
CompressedBlocks.GRANITE_4X.get(),
|
||||||
|
|
||||||
|
CompressedBlocks.CBLOCK_MINING.get()
|
||||||
|
);
|
||||||
|
|
||||||
|
this.tag(BlockTags.NEEDS_STONE_TOOL)
|
||||||
|
.add(
|
||||||
|
CompressedBlocks.COBBLESTONE_1X.get(),
|
||||||
|
CompressedBlocks.ANDESITE_1X.get(),
|
||||||
|
CompressedBlocks.DIORITE_1X.get(),
|
||||||
|
CompressedBlocks.GRANITE_1X.get()
|
||||||
|
);
|
||||||
|
|
||||||
|
this.tag(BlockTags.NEEDS_IRON_TOOL)
|
||||||
|
.add(
|
||||||
|
CompressedBlocks.COBBLESTONE_2X.get(),
|
||||||
|
CompressedBlocks.ANDESITE_2X.get(),
|
||||||
|
CompressedBlocks.DIORITE_2X.get(),
|
||||||
|
CompressedBlocks.GRANITE_2X.get(),
|
||||||
|
|
||||||
|
CompressedBlocks.COBBLESTONE_3X.get(),
|
||||||
|
CompressedBlocks.ANDESITE_3X.get(),
|
||||||
|
CompressedBlocks.DIORITE_3X.get(),
|
||||||
|
CompressedBlocks.GRANITE_3X.get()
|
||||||
|
);
|
||||||
|
|
||||||
|
this.tag(BlockTags.NEEDS_DIAMOND_TOOL)
|
||||||
|
.add(
|
||||||
|
CompressedBlocks.COBBLESTONE_4X.get(),
|
||||||
|
CompressedBlocks.ANDESITE_4X.get(),
|
||||||
|
CompressedBlocks.DIORITE_4X.get(),
|
||||||
|
CompressedBlocks.GRANITE_4X.get(),
|
||||||
|
CompressedBlocks.CBLOCK_MINING.get()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -1,5 +1,7 @@
|
|||||||
package com.jenny.compressedblocks;
|
package com.jenny.compressedblocks.datagen;
|
||||||
|
|
||||||
|
import com.jenny.compressedblocks.CompressedBlocks;
|
||||||
|
import com.jenny.compressedblocks.Tools;
|
||||||
import net.minecraft.data.PackOutput;
|
import net.minecraft.data.PackOutput;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.world.item.Item;
|
import net.minecraft.world.item.Item;
|
@ -0,0 +1,24 @@
|
|||||||
|
package com.jenny.compressedblocks.datagen;
|
||||||
|
|
||||||
|
import com.jenny.compressedblocks.CompressedBlocks;
|
||||||
|
import net.minecraft.core.HolderLookup;
|
||||||
|
import net.minecraft.data.PackOutput;
|
||||||
|
import net.minecraft.data.tags.ItemTagsProvider;
|
||||||
|
import net.minecraft.world.level.block.Block;
|
||||||
|
import net.minecraftforge.common.data.ExistingFileHelper;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
|
public class ModItemTagGenerator extends ItemTagsProvider {
|
||||||
|
public ModItemTagGenerator(PackOutput p_275343_, CompletableFuture<HolderLookup.Provider> p_275729_,
|
||||||
|
CompletableFuture<TagLookup<Block>> p_275322_, @Nullable ExistingFileHelper existingFileHelper) {
|
||||||
|
super(p_275343_, p_275729_, p_275322_, CompressedBlocks.MODID, existingFileHelper);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void addTags(@NotNull HolderLookup.Provider pProvider) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +0,0 @@
|
|||||||
{
|
|
||||||
"parent": "minecraft:item/handheld",
|
|
||||||
"textures": {
|
|
||||||
"layer0": "compressedblocks:item/ultra_pickaxe"
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,5 +0,0 @@
|
|||||||
{
|
|
||||||
"values": [
|
|
||||||
|
|
||||||
]
|
|
||||||
}
|
|
@ -1,5 +0,0 @@
|
|||||||
{
|
|
||||||
"values": [
|
|
||||||
|
|
||||||
]
|
|
||||||
}
|
|
@ -1,21 +0,0 @@
|
|||||||
{
|
|
||||||
"values": [
|
|
||||||
"compressedblocks:cobblestone_1x",
|
|
||||||
"compressedblocks:cobblestone_2x",
|
|
||||||
"compressedblocks:cobblestone_3x",
|
|
||||||
"compressedblocks:cobblestone_4x",
|
|
||||||
"compressedblocks:andesite_1x",
|
|
||||||
"compressedblocks:andesite_2x",
|
|
||||||
"compressedblocks:andesite_3x",
|
|
||||||
"compressedblocks:andesite_4x",
|
|
||||||
"compressedblocks:diorite_1x",
|
|
||||||
"compressedblocks:diorite_2x",
|
|
||||||
"compressedblocks:diorite_3x",
|
|
||||||
"compressedblocks:diorite_4x",
|
|
||||||
"compressedblocks:granite_1x",
|
|
||||||
"compressedblocks:granite_2x",
|
|
||||||
"compressedblocks:granite_3x",
|
|
||||||
"compressedblocks:granite_4x",
|
|
||||||
"compressedblocks:cblock_mining"
|
|
||||||
]
|
|
||||||
}
|
|
@ -1,5 +0,0 @@
|
|||||||
{
|
|
||||||
"values": [
|
|
||||||
|
|
||||||
]
|
|
||||||
}
|
|
@ -1,9 +0,0 @@
|
|||||||
{
|
|
||||||
"values": [
|
|
||||||
"compressedblocks:cobblestone_4x",
|
|
||||||
"compressedblocks:andesite_4x",
|
|
||||||
"compressedblocks:diorite_4x",
|
|
||||||
"compressedblocks:granite_4x",
|
|
||||||
"compressedblocks:cblock_mining"
|
|
||||||
]
|
|
||||||
}
|
|
@ -1,12 +0,0 @@
|
|||||||
{
|
|
||||||
"values": [
|
|
||||||
"compressedblocks:cobblestone_2x",
|
|
||||||
"compressedblocks:cobblestone_3x",
|
|
||||||
"compressedblocks:andesite_2x",
|
|
||||||
"compressedblocks:andesite_3x",
|
|
||||||
"compressedblocks:diorite_2x",
|
|
||||||
"compressedblocks:diorite_3x",
|
|
||||||
"compressedblocks:granite_2x",
|
|
||||||
"compressedblocks:granite_3x"
|
|
||||||
]
|
|
||||||
}
|
|
@ -1,8 +0,0 @@
|
|||||||
{
|
|
||||||
"values": [
|
|
||||||
"compressedblocks:cobblestone_1x",
|
|
||||||
"compressedblocks:andesite_1x",
|
|
||||||
"compressedblocks:diorite_1x",
|
|
||||||
"compressedblocks:granite_1x"
|
|
||||||
]
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user