mirror of
https://github.com/GTNewHorizons/Gadomancy.git
synced 2026-11-26 23:03:18 +00:00
Expose essentia cost ranges of randomized aspect lists to ARI (#64)
This commit is contained in:
1 parent
d4256d85f9
commit
a3b160bdbd
4 files changed
+52
-3
No files matched your search
+2
-1
@@ -6,7 +6,8 @@ dependencies {
|
||||
api("com.github.GTNewHorizons:GTNHLib:0.11.35:dev")
|
||||
|
||||
compileOnly('com.github.GTNewHorizons:ThaumicEnergistics:1.7.58-GTNH:dev') { transitive = false }
|
||||
runtimeOnlyNonPublishable("com.github.GTNewHorizons:AspectRecipeIndex:1.1.3:dev")
|
||||
compileOnly('com.github.GTNewHorizons:AspectRecipeIndex:1.2.3:dev') { transitive = false }
|
||||
runtimeOnlyNonPublishable("com.github.GTNewHorizons:AspectRecipeIndex:1.2.3:dev")
|
||||
|
||||
compileOnly('com.github.GTNewHorizons:waila:1.19.31:dev') { transitive = false }
|
||||
compileOnly('com.github.GTNewHorizons:ThaumicHorizons:1.8.22:dev') { transitive = false }
|
||||
|
||||
@@ -10,6 +10,7 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.CraftingManager;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
|
||||
import cpw.mods.fml.common.FMLLog;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import makeo.gadomancy.api.golems.AdditionalGolemType;
|
||||
import makeo.gadomancy.common.Gadomancy;
|
||||
@@ -109,6 +110,22 @@ public class RegisteredRecipes {
|
||||
|
||||
public static InfusionEnchantmentRecipe recipeRevealer;
|
||||
|
||||
/**
|
||||
* Creates the randomized aspect lists used by the infusion recipes below. If Aspect Recipe Index (or a version
|
||||
* providing its range api) is present, a variant implementing the range interface is used so NEI can show the
|
||||
* possible cost ranges; otherwise the plain list is returned. The ranged class is loaded reflectively because
|
||||
* linking it directly would make Gadomancy fail to start without Aspect Recipe Index.
|
||||
*/
|
||||
private static RandomizedAspectList createRandomizedAspectList() {
|
||||
try {
|
||||
return (RandomizedAspectList) Class.forName("makeo.gadomancy.common.utils.RandomizedAspectListRanged")
|
||||
.getDeclaredConstructor().newInstance();
|
||||
} catch (ReflectiveOperationException | LinkageError e) {
|
||||
FMLLog.info("[Gadomancy] Aspect Recipe Index range api not available, cost range tooltips disabled");
|
||||
return new RandomizedAspectList();
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static void init() {
|
||||
AdditionalGolemType typeSilverwood = RegisteredGolemStuff.typeSilverwood;
|
||||
@@ -594,7 +611,7 @@ public class RegisteredRecipes {
|
||||
Gadomancy.MODID.toUpperCase() + ".AURA_CORE",
|
||||
blankCore,
|
||||
6,
|
||||
new RandomizedAspectList().setHalfCap(true).addAspectRandomBase(Aspect.AURA, 9)
|
||||
createRandomizedAspectList().setHalfCap(true).addAspectRandomBase(Aspect.AURA, 9)
|
||||
.addAspectRandomBase(Aspect.MAGIC, 19).addAspectRandomBase(Aspect.ELDRITCH, 17)
|
||||
.addAspectRandomBase(Aspect.VOID, 34),
|
||||
new ItemStack(ConfigItems.itemResource, 1, 15),
|
||||
@@ -691,7 +708,7 @@ public class RegisteredRecipes {
|
||||
Gadomancy.MODID.toUpperCase() + ".ESSENTIA_COMPRESSOR",
|
||||
new ItemStack(RegisteredItems.itemElement, 1, ItemElement.EnumElementType.DARKNESS.ordinal()),
|
||||
6,
|
||||
new RandomizedAspectList().setHalfCap(true).addAspectRandomBase(Aspect.VOID, 22)
|
||||
createRandomizedAspectList().setHalfCap(true).addAspectRandomBase(Aspect.VOID, 22)
|
||||
.addAspectRandomBase(Aspect.DARKNESS, 18).addAspectRandomBase(Aspect.ELDRITCH, 20)
|
||||
.addAspectRandomBase(Aspect.AURA, 10),
|
||||
new ItemStack(ConfigItems.itemResource, 1, 17),
|
||||
|
||||
@@ -30,6 +30,26 @@ public class RandomizedAspectList extends AspectList {
|
||||
return this;
|
||||
}
|
||||
|
||||
// Exposed to Aspect Recipe Index through RandomizedAspectListRanged; kept here so the range logic
|
||||
// lives next to the roll logic it describes.
|
||||
public int getMinAmount(Aspect aspect) {
|
||||
Integer base = this.aspectMap.get(aspect);
|
||||
if (base == null) {
|
||||
return -1;
|
||||
}
|
||||
// halfCap rolls land in [c/2, 2*(c/2)-1]; without halfCap a zero roll drops the aspect
|
||||
// entirely, so 0 (may be absent) is the honest floor
|
||||
return this.halfCap ? base / 2 : 0;
|
||||
}
|
||||
|
||||
public int getMaxAmount(Aspect aspect) {
|
||||
Integer base = this.aspectMap.get(aspect);
|
||||
if (base == null) {
|
||||
return -1;
|
||||
}
|
||||
return this.halfCap ? 2 * (base / 2) - 1 : base - 1;
|
||||
}
|
||||
|
||||
private void checkRandomization() {
|
||||
if ((System.currentTimeMillis() - this.lastRandomization) > 500) {
|
||||
super.aspects.clear();
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
package makeo.gadomancy.common.utils;
|
||||
|
||||
import com.gtnewhorizons.aspectrecipeindex.api.IAspectRangeList;
|
||||
|
||||
/**
|
||||
* Variant of {@link RandomizedAspectList} that also implements Aspect Recipe Index's range api, so NEI can show the
|
||||
* possible cost ranges. Only instantiated reflectively from RegisteredRecipes, because loading this class requires an
|
||||
* Aspect Recipe Index version providing {@link IAspectRangeList}; Gadomancy itself has to keep working without it.
|
||||
*/
|
||||
public class RandomizedAspectListRanged extends RandomizedAspectList implements IAspectRangeList {
|
||||
}
|
||||
Reference in new issue
Block a user