Skip to content

Commit

Permalink
feat: add JEI and remove useless skeleton details
Browse files Browse the repository at this point in the history
  • Loading branch information
GaeaKat committed Mar 3, 2024
1 parent 8efa2ca commit aede09b
Show file tree
Hide file tree
Showing 9 changed files with 154 additions and 64 deletions.
Binary file added .DS_Store
Binary file not shown.
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ tasks.named('processResources', ProcessResources).configure {
loader_version_range: loader_version_range,
mod_id : mod_id, mod_name: mod_name, mod_license: mod_license, mod_version: mod_version,
mod_authors : mod_authors, mod_description: mod_description,
occultism_version_range: occultism_version_range, create_version_range: create_version_range
]
inputs.properties replaceProperties

Expand Down
7 changes: 5 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ minecraft_version=1.19.2
# Snapshots, pre-releases, and release candidates are not guaranteed to sort properly
# as they do not follow standard versioning conventions.
minecraft_version_range=[1.19.2,1.20)

occultism_version_range=[1.43.0,)
create_version_range=[0.5.1.e-44,)
# The Forge version must agree with the Minecraft version to get a valid artifact
forge_version=43.3.8
# The Forge version range can use any version of Forge as bounds or match the loader version range
Expand Down Expand Up @@ -56,7 +59,7 @@ theurgy_version=1.1.1
# Must match the String constant located in the main mod class annotated with @Mod.
mod_id=occultcreate
# The human-readable display name for the mod.
mod_name=Occult Creater
mod_name=Occult Creations
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
mod_license=All Rights Reserved
# The mod version. See https://semver.org/
Expand All @@ -68,4 +71,4 @@ mod_group_id=dev.katcodes.occultcreate
# The authors of the mod. This is a simple text string that is used for display purposes in the mod list.
mod_authors=GaeaKat
# The description of the mod. This is a simple multiline text string that is used for display purposes in the mod list.
mod_description=Example mod description.\nNewline characters can be used and will be replaced properly.
mod_description=Adds a few minor features to bridge the gap between Occultism and Create.
32 changes: 0 additions & 32 deletions src/main/java/dev/katcodes/occultcreate/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,45 +20,13 @@ public class Config
{
private static final ForgeConfigSpec.Builder BUILDER = new ForgeConfigSpec.Builder();

private static final ForgeConfigSpec.BooleanValue LOG_DIRT_BLOCK = BUILDER
.comment("Whether to log the dirt block on common setup")
.define("logDirtBlock", true);

private static final ForgeConfigSpec.IntValue MAGIC_NUMBER = BUILDER
.comment("A magic number")
.defineInRange("magicNumber", 42, 0, Integer.MAX_VALUE);

public static final ForgeConfigSpec.ConfigValue<String> MAGIC_NUMBER_INTRODUCTION = BUILDER
.comment("What you want the introduction message to be for the magic number")
.define("magicNumberIntroduction", "The magic number is... ");

// a list of strings that are treated as resource locations for items
private static final ForgeConfigSpec.ConfigValue<List<? extends String>> ITEM_STRINGS = BUILDER
.comment("A list of items to log on common setup.")
.defineListAllowEmpty(Collections.singletonList("items"), () -> List.of("minecraft:iron_ingot"), Config::validateItemName);

static final ForgeConfigSpec SPEC = BUILDER.build();

public static boolean logDirtBlock;
public static int magicNumber;
public static String magicNumberIntroduction;
public static Set<Item> items;

private static boolean validateItemName(final Object obj)
{
return obj instanceof final String itemName && ForgeRegistries.ITEMS.containsKey(new ResourceLocation(itemName));
}

@SubscribeEvent
static void onLoad(final ModConfigEvent event)
{
logDirtBlock = LOG_DIRT_BLOCK.get();
magicNumber = MAGIC_NUMBER.get();
magicNumberIntroduction = MAGIC_NUMBER_INTRODUCTION.get();

// convert the list of strings into a set of items
items = ITEM_STRINGS.get().stream()
.map(itemName -> ForgeRegistries.ITEMS.getValue(new ResourceLocation(itemName)))
.collect(Collectors.toSet());
}
}
30 changes: 0 additions & 30 deletions src/main/java/dev/katcodes/occultcreate/OccultCreate.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,28 +42,13 @@ public class OccultCreate
public static final String MODID = "occultcreate";
// Directly reference a slf4j logger
private static final Logger LOGGER = LogUtils.getLogger();
// Create a Deferred Register to hold Blocks which will all be registered under the "examplemod" namespace
public static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, MODID);
// Create a Deferred Register to hold Items which will all be registered under the "examplemod" namespace
public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, MODID);

// Creates a new Block with the id "examplemod:example_block", combining the namespace and path
public static final RegistryObject<Block> EXAMPLE_BLOCK = BLOCKS.register("example_block", () -> new Block(BlockBehaviour.Properties.of(Material.STONE)));
// Creates a new BlockItem with the id "examplemod:example_block", combining the namespace and path
public static final RegistryObject<Item> EXAMPLE_BLOCK_ITEM = ITEMS.register("example_block", () -> new BlockItem(EXAMPLE_BLOCK.get(), new Item.Properties().tab(CreativeModeTab.TAB_BUILDING_BLOCKS)));

public OccultCreate()
{
IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();

// Register the commonSetup method for modloading
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 ourselves for server and other game events we are interested in
MinecraftForge.EVENT_BUS.register(this);

Expand All @@ -73,25 +58,13 @@ public OccultCreate()

private void commonSetup(final FMLCommonSetupEvent event)
{
// Some common setup code
LOGGER.info("HELLO FROM COMMON SETUP");
//AllFanProcessingTypes

if (Config.logDirtBlock)
LOGGER.info("DIRT BLOCK >> {}", ForgeRegistries.BLOCKS.getKey(Blocks.DIRT));

LOGGER.info(Config.magicNumberIntroduction + Config.magicNumber);

Config.items.forEach((item) -> LOGGER.info("ITEM >> {}", item.toString()));
FanProcessingTypeRegistry.register(new ResourceLocation(MODID,"spirit_fire_blasting"),new SpiritProcessing());
}

// You can use SubscribeEvent and let the Event Bus discover methods to call
@SubscribeEvent
public void onServerStarting(ServerStartingEvent event)
{
// Do something when the server starts
LOGGER.info("HELLO from server starting");
}

// You can use EventBusSubscriber to automatically register all static methods in the class annotated with @SubscribeEvent
Expand All @@ -101,9 +74,6 @@ public static class ClientModEvents
@SubscribeEvent
public static void onClientSetup(FMLClientSetupEvent event)
{
// Some client setup code
LOGGER.info("HELLO FROM CLIENT SETUP");
LOGGER.info("MINECRAFT NAME >> {}", Minecraft.getInstance().getUser().getName());
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package dev.katcodes.occultcreate.compat;

import com.klikli_dev.occultism.crafting.recipe.SpiritFireRecipe;
import org.jetbrains.annotations.NotNull;

import com.klikli_dev.occultism.registry.OccultismBlocks;
import com.mojang.blaze3d.vertex.PoseStack;
import com.simibubi.create.compat.jei.category.ProcessingViaFanCategory;
import com.simibubi.create.compat.jei.category.animations.AnimatedKinetics;
import com.simibubi.create.foundation.gui.AllGuiTextures;
import com.simibubi.create.foundation.gui.element.GuiGameElement;

import net.minecraft.world.item.crafting.SmokingRecipe;
import net.minecraft.world.level.block.Blocks;

public class FanSpiritingCategory extends ProcessingViaFanCategory<SpiritFireRecipe> {

public FanSpiritingCategory(Info<SpiritFireRecipe> info) {
super(info);
}

@Override
protected AllGuiTextures getBlockShadow() {
return AllGuiTextures.JEI_LIGHT;
}

@Override
protected void renderAttachedBlock(@NotNull PoseStack matrixStack) {
GuiGameElement.of(OccultismBlocks.SPIRIT_FIRE.get().defaultBlockState())
.scale(SCALE)
.atLocal(0, 0, 2)
.lighting(AnimatedKinetics.DEFAULT_LIGHTING)
.render(matrixStack);
}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
package dev.katcodes.occultcreate.compat;

import static com.simibubi.create.compat.jei.CreateJEI.*;
import static dev.katcodes.occultcreate.OccultCreate.MODID;

import com.klikli_dev.occultism.crafting.recipe.SpiritFireRecipe;
import com.klikli_dev.occultism.registry.OccultismBlocks;
import com.klikli_dev.occultism.registry.OccultismRecipes;
import com.simibubi.create.AllItems;
import com.simibubi.create.Create;
import com.simibubi.create.compat.jei.CreateJEI;
import com.simibubi.create.compat.jei.DoubleItemIcon;
import com.simibubi.create.compat.jei.EmptyBackground;
import com.simibubi.create.compat.jei.ItemIcon;
import com.simibubi.create.compat.jei.category.CreateRecipeCategory;

import com.simibubi.create.compat.jei.category.FanBlastingCategory;
import com.simibubi.create.compat.jei.category.ProcessingViaFanCategory;
import com.simibubi.create.foundation.config.ConfigBase;
import com.simibubi.create.foundation.recipe.IRecipeTypeInfo;
import com.simibubi.create.foundation.utility.Components;
import com.simibubi.create.foundation.utility.Lang;
import com.simibubi.create.infrastructure.config.AllConfigs;
import com.simibubi.create.infrastructure.config.CRecipes;
import mezz.jei.api.gui.drawable.IDrawable;
import mezz.jei.api.registration.IRecipeCatalystRegistration;
import mezz.jei.api.registration.IRecipeRegistration;
import net.minecraft.resources.ResourceLocation;

import mezz.jei.api.IModPlugin;
import mezz.jei.api.JeiPlugin;
import mezz.jei.api.registration.IRecipeCategoryRegistration;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.item.crafting.Recipe;
import net.minecraft.world.item.crafting.RecipeType;
import net.minecraft.world.level.ItemLike;
import org.jetbrains.annotations.NotNull;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.function.Supplier;

@JeiPlugin
public class OccultCreationsJEI implements IModPlugin {
private static final ResourceLocation ID = new ResourceLocation(MODID,"jei_plugin");

private final List<CreateRecipeCategory<?>> allCategories = new ArrayList<>();
@Override
public ResourceLocation getPluginUid() {
return ID;
}

@Override
public void registerCategories(IRecipeCategoryRegistration registration) {
IModPlugin.super.registerCategories(registration);
allCategories.clear();

// OccultismRecipes.SPIRIT_FIRE_TYPE
Supplier<List<SpiritFireRecipe>> recipesSupplier = () -> {
List<SpiritFireRecipe> recipes = new ArrayList<>();
CreateJEI.<SpiritFireRecipe>consumeTypedRecipes(recipes::add, OccultismRecipes.SPIRIT_FIRE_TYPE.get());
return recipes;
};

CreateRecipeCategory<SpiritFireRecipe> category = getSpiritFireRecipeCreateRecipeCategory(recipesSupplier);
allCategories.add(category);
registration.addRecipeCategories(category);

}

private static @NotNull CreateRecipeCategory<SpiritFireRecipe> getSpiritFireRecipeCreateRecipeCategory(Supplier<List<SpiritFireRecipe>> recipesSupplier) {
CreateRecipeCategory.Info<SpiritFireRecipe> info = new CreateRecipeCategory.Info<>(
new mezz.jei.api.recipe.RecipeType<>(new ResourceLocation(MODID,"spirit_fire_blasting"), SpiritFireRecipe.class),
Components.translatable("occult_creations.recipe.spirit_fire_blasting" ), new EmptyBackground(178,72), new DoubleItemIcon(() -> new ItemStack(AllItems.PROPELLER.get()), () -> new ItemStack(OccultismBlocks.SPIRIT_FIRE.get())), recipesSupplier, new ArrayList<>(){ { add(ProcessingViaFanCategory.getFan("spirit_fire_blasting"));}});

return new FanSpiritingCategory(info);
}

@Override
public void registerRecipes(IRecipeRegistration registration) {
IModPlugin.super.registerRecipes(registration);
allCategories.forEach(c -> c.registerRecipes(registration));
}

@Override
public void registerRecipeCatalysts(IRecipeCatalystRegistration registration) {
allCategories.forEach(c -> c.registerCatalysts(registration));
}
}
12 changes: 12 additions & 0 deletions src/main/resources/META-INF/mods.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,18 @@ ordering="NONE"
side="BOTH"
# Here's another dependency
[[dependencies.${mod_id}]]
modId="occultism"
mandatory=true
versionRange="${occultism_version_range}"
ordering="AFTER"
side="BOTH"
[[dependencies.${mod_id}]]
modId="create"
mandatory=true
versionRange="${create_version_range}"
ordering="AFTER"
side="BOTH"
[[dependencies.${mod_id}]]
modId="minecraft"
mandatory=true
# This version range declares a minimum of the current minecraft version up to but not including the next major version
Expand Down
4 changes: 4 additions & 0 deletions src/main/resources/assets/occultcreate/lang/en_us.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"occult_creations.recipe.spirit_fire_blasting": "Bulk Spirit Processing",
"create.recipe.spirit_fire_blasting.fan": "Fan behind Spirit Flame"
}

0 comments on commit aede09b

Please sign in to comment.