Skip to content

Commit

Permalink
Add effect list config option for mana beans
Browse files Browse the repository at this point in the history
Also nerf instant effects
  • Loading branch information
IcarussOne committed Jan 29, 2025
1 parent fcb4196 commit 551bacc
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package mod.icarus.crimsonrevelations;

import mod.icarus.crimsonrevelations.compat.CRCompatHandler;
import mod.icarus.crimsonrevelations.config.CRConfigLists;
import mod.icarus.crimsonrevelations.events.CRClientEvents;
import mod.icarus.crimsonrevelations.events.CREvents;
import mod.icarus.crimsonrevelations.init.*;
Expand Down Expand Up @@ -37,7 +38,7 @@ public void preInit(FMLPreInitializationEvent event) {
@EventHandler
public void init(FMLInitializationEvent event) {
CRCompatHandler.init();

CRConfigLists.initLists();
CRResearchRegistry.init();

CRRecipes.initArcaneCrafting();
Expand Down
41 changes: 41 additions & 0 deletions src/main/java/mod/icarus/crimsonrevelations/config/CRConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,46 @@ public static class GeneralSettings {
@Config.RequiresMcRestart
public int MANA_BEAN_ASPECT = 5;

@Config.Name("Mana Bean: Effect List")
@Config.Comment("Configurable list of possible effects that eaten Mana Beans can apply.")
public String[] MANA_BEAN_EFFECT_LIST = new String[]{
"minecraft:absorption",
"minecraft:blindness",
"minecraft:fire_resistance",
"minecraft:haste",
"minecraft:health_boost",
"minecraft:hunger",
"minecraft:instant_damage",
"minecraft:instant_health",
"minecraft:invisibility",
"minecraft:jump_boost",
"minecraft:levitation",
"minecraft:luck",
"minecraft:mining_fatigue",
"minecraft:nausea",
"minecraft:night_vision",
"minecraft:poison",
"minecraft:regeneration",
"minecraft:resistance",
"minecraft:saturation",
"minecraft:slowness",
"minecraft:speed",
"minecraft:strength",
"minecraft:unluck",
"minecraft:water_breathing",
"minecraft:weakness",
"minecraft:wither",
"thaumcraft:blurredvision",
"thaumcraft:deathgaze",
"thaumcraft:fluxtaint",
"thaumcraft:infectiousvisexhaust",
"thaumcraft:sunscorned",
"thaumcraft:thaumarhia",
"thaumcraft:unnaturalhunger",
"thaumcraft:visexhaust",
"thaumcraft:warpward"
};

@Config.Name("Primordial Scribing Tools: Curiosity Chance")
@Config.Comment("The chance for a curiosity to be obtained from the Primordial Scribing Tools. [default: 0.3]")
@Config.RangeDouble(min = 0.0D, max = 1.0D)
Expand Down Expand Up @@ -133,6 +173,7 @@ public static class EventHandler {
public static void onConfigChanged(final ConfigChangedEvent.OnConfigChangedEvent event) {
if (event.getModID().equals(NewCrimsonRevelations.MODID)) {
ConfigManager.sync(NewCrimsonRevelations.MODID, Config.Type.INSTANCE);
CRConfigLists.initLists();
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package mod.icarus.crimsonrevelations.config;

import java.util.ArrayList;
import java.util.List;

import net.minecraft.potion.Potion;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.common.registry.ForgeRegistries;

public class CRConfigLists {
public static List<Potion> manaBeanEffects = new ArrayList<>();

public static void initLists() {
manaBeanEffects.clear();

try {
for (String entry : CRConfig.general_settings.MANA_BEAN_EFFECT_LIST) {
ResourceLocation resLoc = new ResourceLocation(entry);

if (ForgeRegistries.POTIONS.containsKey(resLoc)) {
manaBeanEffects.add(ForgeRegistries.POTIONS.getValue(resLoc));
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import mod.icarus.crimsonrevelations.NewCrimsonRevelations;
import mod.icarus.crimsonrevelations.config.CRConfig;
import mod.icarus.crimsonrevelations.config.CRConfigLists;
import mod.icarus.crimsonrevelations.init.CRBlocks;
import mod.icarus.crimsonrevelations.init.CRItems;
import mod.icarus.crimsonrevelations.tile.CRTileManaPod;
Expand All @@ -25,7 +26,6 @@
import net.minecraft.world.World;
import net.minecraft.world.biome.Biome;
import net.minecraftforge.common.BiomeDictionary;
import net.minecraftforge.fml.common.registry.ForgeRegistries;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import thaumcraft.api.aspects.Aspect;
Expand Down Expand Up @@ -54,9 +54,9 @@ public static ItemStack makeManaBean(Aspect aspect, int stackSize) {
if (aspect == null) {
return null;
} else {
ItemStack is = new ItemStack(CRItems.MANA_BEAN, stackSize, 0);
((IEssentiaContainerItem) CRItems.MANA_BEAN).setAspects(is, (new AspectList()).add(aspect, CRConfig.general_settings.MANA_BEAN_ASPECT));
return is;
ItemStack stack = new ItemStack(CRItems.MANA_BEAN, stackSize, 0);
((IEssentiaContainerItem) CRItems.MANA_BEAN).setAspects(stack, (new AspectList()).add(aspect, CRConfig.general_settings.MANA_BEAN_ASPECT));
return stack;
}
}

Expand All @@ -65,17 +65,17 @@ public int getMaxItemUseDuration(ItemStack par1ItemStack) {
return this.itemUseDuration;
}

// Apply various random effects after eating (TODO: Add a configurable list of effects to prevent issues with unintended mod effects)
// Apply various random effects from a configurable list after eating
@Override
protected void onFoodEaten(ItemStack stack, World world, EntityPlayer player) {
if (!world.isRemote) {
Potion p = ForgeRegistries.POTIONS.getValues().get(world.rand.nextInt(ForgeRegistries.POTIONS.getValues().size()));
Potion effect = CRConfigLists.manaBeanEffects.get(world.rand.nextInt(CRConfigLists.manaBeanEffects.size()));

if (p != null) {
if (p.isInstant()) {
p.affectEntity(player, player, player, 2, 3.0D);
if (effect != null) {
if (effect.isInstant()) {
effect.affectEntity(player, player, player, 0, 3.0D);
} else {
player.addPotionEffect(new PotionEffect(p, 160 + world.rand.nextInt(80), 0));
player.addPotionEffect(new PotionEffect(effect, 8 * 20 + world.rand.nextInt(80), 0));
}
}
}
Expand All @@ -87,9 +87,9 @@ public void getSubItems(CreativeTabs tab, NonNullList<ItemStack> items) {
if (tab == NewCrimsonRevelations.tabCR || tab == CreativeTabs.SEARCH) {

for (Aspect tag : Aspect.aspects.values()) {
ItemStack i = new ItemStack(this);
this.setAspects(i, (new AspectList()).add(tag, CRConfig.general_settings.MANA_BEAN_ASPECT));
items.add(i);
ItemStack stack = new ItemStack(this);
this.setAspects(stack, (new AspectList()).add(tag, CRConfig.general_settings.MANA_BEAN_ASPECT));
items.add(stack);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ crimsonrevelations.research.overgrown_taintacle.stage.0=During one of my treks i

# Research: Fundamentals
crimsonrevelations.research.mana_pods.title=Mana Pods
crimsonrevelations.research.mana_pods.stage.0=This strange, pod-like plant is only found growing on trees in Magical Forests. They grow very slowly and when harvested, usually only yield one or two colorful beans.<BR>These beans, that I call Mana Beans, contain concentrated amounts of essentia. They can also be consumed for more knowledge on research, though the results afterwards are often a bit unpredictable.<PAGE>They can be replanted on the roof of a block in a Magical Forest, but cultivation proves to be difficult and time-consuming. Bone meal also seems to have no effect on them unlike other plants.<BR>Wild mana pods usually only produce primal aspects, though it is said that planting beans adjacent to existing ones sometimes result in beans with compound aspects.<BR>Fully learning the proper way to farm a specific aspect that I really need would be useful for my studies.
crimsonrevelations.research.mana_pods.stage.0=This strange, pod-like plant is only found growing on trees in Magical Forests. They grow very slowly and when harvested, usually only yield one or two colorful beans.<BR>These beans, that I call Mana Beans, contain concentrated amounts of essentia. They can also be consumed for more knowledge on research, though the results afterwards are often a bit unpredictable.<PAGE>They can be replanted on the roof of a log in a Magical Forest, but cultivation proves to be difficult and time-consuming. Bone meal also seems to have no effect on them unlike other plants.<BR>Wild mana pods usually only produce primal aspects, though it is said that planting beans adjacent to existing ones sometimes result in beans with compound aspects.<BR>Fully learning the proper way to farm a specific aspect that I really need would be useful for my studies.

# Research: Bestiary
crimsonrevelations.research.cult_bestiary.title=The Cult Bestiary
Expand Down

0 comments on commit 551bacc

Please sign in to comment.