diff --git a/Common/src/main/java/dev/upcraft/sparkweave/SparkweaveMod.java b/Common/src/main/java/dev/upcraft/sparkweave/SparkweaveMod.java index 122476b..77f1ff8 100644 --- a/Common/src/main/java/dev/upcraft/sparkweave/SparkweaveMod.java +++ b/Common/src/main/java/dev/upcraft/sparkweave/SparkweaveMod.java @@ -1,10 +1,14 @@ package dev.upcraft.sparkweave; -import com.google.common.base.Preconditions; +import dev.upcraft.sparkweave.api.SparkweaveApi; import dev.upcraft.sparkweave.api.entrypoint.MainEntryPoint; import dev.upcraft.sparkweave.api.event.CommandEvents; import dev.upcraft.sparkweave.api.platform.ModContainer; +import dev.upcraft.sparkweave.api.platform.services.RegistryService; +import dev.upcraft.sparkweave.api.registry.RegistryHandler; import dev.upcraft.sparkweave.command.SparkweaveCommandRoot; +import dev.upcraft.sparkweave.util.SparkweaveDevCreativeTab; +import net.minecraft.core.registries.Registries; import net.minecraft.resources.ResourceLocation; import org.apache.commons.lang3.Validate; @@ -18,6 +22,13 @@ public class SparkweaveMod implements MainEntryPoint { @Override public void onInitialize(ModContainer mod) { CommandEvents.REGISTER.register(SparkweaveCommandRoot::register); + var service = RegistryService.get(); + + if(SparkweaveApi.DEVELOPMENT_ENVIRONMENT) { + var creativeTabsRegister = RegistryHandler.create(Registries.CREATIVE_MODE_TAB, SparkweaveMod.MODID); + creativeTabsRegister.register(SparkweaveDevCreativeTab.DEBUG_MODE_TAB, SparkweaveDevCreativeTab::buildTab); + creativeTabsRegister.accept(service); + } } public static ResourceLocation id(String path) { diff --git a/Common/src/main/java/dev/upcraft/sparkweave/util/SparkweaveDevCreativeTab.java b/Common/src/main/java/dev/upcraft/sparkweave/util/SparkweaveDevCreativeTab.java new file mode 100644 index 0000000..cf098a7 --- /dev/null +++ b/Common/src/main/java/dev/upcraft/sparkweave/util/SparkweaveDevCreativeTab.java @@ -0,0 +1,29 @@ +package dev.upcraft.sparkweave.util; + +import dev.upcraft.sparkweave.SparkweaveMod; +import dev.upcraft.sparkweave.api.item.CreativeTabHelper; +import net.minecraft.core.registries.Registries; +import net.minecraft.resources.ResourceKey; +import net.minecraft.world.item.CreativeModeTab; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; +import net.minecraft.world.level.block.LightBlock; + +public class SparkweaveDevCreativeTab { + + public static final ResourceKey DEBUG_MODE_TAB = ResourceKey.create(Registries.CREATIVE_MODE_TAB, SparkweaveMod.id("debug_tab")); + + public static CreativeModeTab buildTab() { + return CreativeTabHelper.newBuilder(DEBUG_MODE_TAB).icon(Items.COMMAND_BLOCK::getDefaultInstance).displayItems((itemDisplayParameters, output) -> { + output.accept(Items.COMMAND_BLOCK); + output.accept(Items.CHAIN_COMMAND_BLOCK); + output.accept(Items.STRUCTURE_BLOCK); + output.accept(Items.STRUCTURE_VOID); + for(int light : new int[]{ 15, 7, 3, 1 }) { + output.accept(LightBlock.setLightOnStack(new ItemStack(Items.LIGHT), light)); + } + + + }).build(); + } +}