Skip to content

Commit

Permalink
Add option for Pandora's Box loot table
Browse files Browse the repository at this point in the history
  • Loading branch information
Attack8 committed Dec 4, 2024
1 parent f18fe67 commit 4e3d4a7
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 23 deletions.
8 changes: 0 additions & 8 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -204,14 +204,6 @@ dependencies {
runtimeOnly fg.deobf("curse.maven:applied-energistics-2-223794:4136407")
runtimeOnly fg.deobf("curse.maven:modular-routers-250294:4984984")
// runtimeOnly fg.deobf("curse.maven:attackeight-quest-addon-946682:5401585")

compileOnly fg.deobf("curse.maven:wolds-vaults-official-mod-958799:5925360")
compileOnly fg.deobf("curse.maven:vault-hunters-api-1118899:5925356")
if (wolds_enable) {
runtimeOnly fg.deobf("curse.maven:wolds-vaults-official-mod-958799:5925360")
runtimeOnly fg.deobf("curse.maven:vault-hunters-api-1118899:5925356")
runtimeOnly fg.deobf("curse.maven:angel-ring-333396:4641783")
}
}

mixin {
Expand Down
4 changes: 1 addition & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,4 @@ gekolib_version = 3.0.57
jei_version = 9.7.2.281
curios_version = 5.0.9.0
arl_version = 1.7-53.110
quark_version = 3.2-358.1

wolds_enable = true
quark_version = 3.2-358.1
14 changes: 7 additions & 7 deletions src/main/java/dev/attackeight/the_vault_jei/TheVaultJEI.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package dev.attackeight.the_vault_jei;

import com.mojang.logging.LogUtils;
import dev.attackeight.the_vault_jei.utils.ModConfig;
import net.minecraft.resources.ResourceLocation;
import net.minecraftforge.fml.ModList;
import net.minecraftforge.fml.ModLoadingContext;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.config.ModConfig.Type;
import org.slf4j.Logger;

@Mod(TheVaultJEI.ID)
Expand All @@ -12,16 +14,14 @@ public class TheVaultJEI {
public static final String ID = "the_vault_jei";

// Directly reference a slf4j logger
private static final Logger LOGGER = LogUtils.getLogger();
public static final Logger LOGGER = LogUtils.getLogger();

public TheVaultJEI() {}
public TheVaultJEI() {
ModLoadingContext.get().registerConfig(Type.CLIENT, ModConfig.SPEC, ID + "-client.toml");
}

public static ResourceLocation rl(String path) {
return new ResourceLocation(TheVaultJEI.ID, path);
}

public static boolean hasWolds() {
return ModList.get().isLoaded("woldsvaults");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.world.item.ItemStack;
import net.minecraftforge.registries.ForgeRegistries;

import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
Expand Down Expand Up @@ -77,8 +78,19 @@ protected static List<LootInfo> getHostileEggLoot() {
return lootInfo;
}

protected static List<LootInfo> getPandorasBoxLoot() {
List<LootInfo> lootInfo = new ArrayList<>();
List<ItemStack> loot = new ArrayList<>();
int total = ModConfigs.PANDORAS_BOX.POOL.getTotalWeight();
ModConfigs.PANDORAS_BOX.POOL.forEach(b -> loot.add(addWeight(b, total)));
lootInfo.add(new LootInfo(loot));
return lootInfo;
}

protected static ItemStack addWeight(WeightedList.Entry<ProductEntry> productEntry, int totalWeight) {
ProductEntryAccessor entry = (ProductEntryAccessor) productEntry.value;
if (!ForgeRegistries.ITEMS.containsKey(productEntry.value.getItem().getRegistryName()))
return ItemStack.EMPTY;
ItemStack stack = new ItemStack(productEntry.value.getItem(), entry.getAmountMax());
CompoundTag nbt = stack.getOrCreateTagElement("display");
ListTag list = nbt.getList("Lore", 8);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import dev.attackeight.the_vault_jei.jei.category.*;
import static dev.attackeight.the_vault_jei.jei.JEIRecipeProvider.*;

import dev.attackeight.the_vault_jei.utils.ModConfig;
import iskallia.vault.init.ModBlocks;
import iskallia.vault.init.ModItems;
import iskallia.vault.integration.jei.lootinfo.LootInfo;
Expand All @@ -15,12 +16,11 @@
import mezz.jei.api.registration.IRecipeCatalystRegistration;
import mezz.jei.api.registration.IRecipeCategoryRegistration;
import mezz.jei.api.registration.IRecipeRegistration;
import net.minecraft.client.Minecraft;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.ItemLike;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.ModList;
import org.jetbrains.annotations.NotNull;
import org.lwjgl.system.CallbackI;

import javax.annotation.ParametersAreNonnullByDefault;

Expand All @@ -36,6 +36,7 @@ public class TheVaultJEIPlugin implements IModPlugin {
public static final RecipeType<LootInfo> MYSTERY_BOX = RecipeType.create("the_vault", "mystery_box", LootInfo.class);
public static final RecipeType<LootInfo> MYSTERY_EGG = RecipeType.create("the_vault", "mystery_egg", LootInfo.class);
public static final RecipeType<LootInfo> HOSTILE_EGG = RecipeType.create("the_vault", "hostile_egg", LootInfo.class);
public static final RecipeType<LootInfo> PANDORAS_BOX = RecipeType.create("the_vault", "pandoras_box", LootInfo.class);
public static final RecipeType<LabeledLootInfo> BLACK_MARKET = RecipeType.create("the_vault", "black_market", LabeledLootInfo.class);
public static final RecipeType<LabeledLootInfo> MOD_BOX = RecipeType.create("the_vault", "mod_box", LabeledLootInfo.class);
public static final RecipeType<LabeledLootInfo> BOUNTY_REWARDS = RecipeType.create("the_vault", "bounty_rewards", LabeledLootInfo.class);
Expand All @@ -56,6 +57,10 @@ public void registerRecipeCatalysts(IRecipeCatalystRegistration registration) {
registration.addRecipeCatalyst(new ItemStack(ModItems.MOD_BOX), MOD_BOX);
registration.addRecipeCatalyst(new ItemStack(ModBlocks.BOUNTY_BLOCK), BOUNTY_REWARDS);
registration.addRecipeCatalyst(new ItemStack(ModBlocks.VAULT_ALTAR), ALTAR_INGREDIENTS);

if (ModConfig.shouldShow()) {
registration.addRecipeCatalyst(new ItemStack(ModItems.PANDORAS_BOX), PANDORAS_BOX);
}
}

@Override
Expand All @@ -72,6 +77,10 @@ public void registerCategories(IRecipeCategoryRegistration registration) {
registration.addRecipeCategories(makeLabeledLootInfoCategory(guiHelper, MOD_BOX, ModItems.MOD_BOX));
registration.addRecipeCategories(makeLabeledLootInfoCategory(guiHelper, BOUNTY_REWARDS, ModBlocks.BOUNTY_BLOCK));
registration.addRecipeCategories(makeLabeledIngredientPoolCategory(guiHelper, ALTAR_INGREDIENTS, ModBlocks.VAULT_ALTAR));

if (ModConfig.shouldShow()) {
registration.addRecipeCategories(makeLootInfoCategory(guiHelper, PANDORAS_BOX, ModItems.PANDORAS_BOX));
}
}

@Override
Expand All @@ -87,13 +96,14 @@ public void registerRecipes(IRecipeRegistration registration) {
registration.addRecipes(MOD_BOX, getModBoxLoot());
registration.addRecipes(BOUNTY_REWARDS, getBountyRewards());
registration.addRecipes(ALTAR_INGREDIENTS, getAltarIngredients());
if (TheVaultJEI.hasWolds()) {

if (ModConfig.shouldShow()) {
registration.addRecipes(PANDORAS_BOX, getPandorasBoxLoot());
}
}

@Override
public ResourceLocation getPluginUid() {
public @NotNull ResourceLocation getPluginUid() {
return TheVaultJEI.rl("jei_integration");
}

Expand Down
20 changes: 20 additions & 0 deletions src/main/java/dev/attackeight/the_vault_jei/utils/ModConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package dev.attackeight.the_vault_jei.utils;

import net.minecraftforge.common.ForgeConfigSpec;

public class ModConfig {
public static final ForgeConfigSpec.Builder BUILDER = new ForgeConfigSpec.Builder();
public static final ForgeConfigSpec SPEC;

private static final ForgeConfigSpec.BooleanValue SHOW;

public static boolean shouldShow() {
return SHOW.get();
}

static {
SHOW = BUILDER.comment("Should JEI show loot tables for items not used in the base modpack")
.define("enable_hidden", false);
SPEC = BUILDER.build();
}
}

0 comments on commit 4e3d4a7

Please sign in to comment.