Skip to content

Commit

Permalink
Minor tweaks to the custom research (#79)
Browse files Browse the repository at this point in the history
* The new research needed to have a parent set to hide it until accessible

* Tie the replacement recipes to their appropriate research
  • Loading branch information
rndmorris authored Jan 13, 2025
1 parent 74f8f15 commit acc4c4d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ private static IArcaneRecipe[][] exampleRodRecipes() {
scepterList.toArray(new IArcaneRecipe[0]), staffList.toArray(new IArcaneRecipe[0]), };
}

private static ResearchItem maybeRegister(ReplaceWandComponentSettings settings, String key, String siblingKey,
private static ResearchItem maybeRegister(ReplaceWandComponentSettings settings, String key, String parentKey,
PlaceholderItem placeholderItem, IArcaneRecipe[]... recipeSets) {
if (!settings.isEnabled()) {
return null;
Expand All @@ -218,6 +218,8 @@ private static ResearchItem maybeRegister(ReplaceWandComponentSettings settings,
row,
1,
new ItemStack(placeholderItem, 0, OreDictionary.WILDCARD_VALUE)).setConcealed()
.setParents(parentKey)
.setStub()
.setSpecial();
final var pages = new ArrayList<ResearchPage>();
pages.add(new ResearchPage("tc.research_page." + fullKey + ".0"));
Expand All @@ -232,9 +234,9 @@ private static ResearchItem maybeRegister(ReplaceWandComponentSettings settings,
research.setPages(pages.toArray(new ResearchPage[0]));
research.registerResearchItem();

final var sibling = ResearchCategories.getResearch(siblingKey);
final var sibling = ResearchCategories.getResearch(parentKey);
if (sibling == null) {
LOG.error("Could not locate research {} for {}.", siblingKey, fullKey);
LOG.error("Could not locate research {} for {}.", parentKey, fullKey);
return research;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import com.github.bsideup.jabel.Desugar;

import dev.rndmorris.salisarcana.common.CustomResearch;
import dev.rndmorris.salisarcana.config.ConfigModuleRoot;
import dev.rndmorris.salisarcana.lib.AspectHelper;
import dev.rndmorris.salisarcana.lib.WandHelper;
Expand All @@ -25,6 +26,10 @@ public class ReplaceWandCapsRecipe implements IArcaneRecipe {

@Override
public boolean matches(IInventory tableInv, World world, EntityPlayer player) {
if (!ThaumcraftApiHelper.isResearchComplete(player.getCommandSenderName(), getResearch())) {
return false;
}

final var scanResult = scanTable(tableInv);
if (scanResult == null || scanResult.invalidInputs()) {
return false;
Expand Down Expand Up @@ -93,7 +98,7 @@ public AspectList getAspects(IInventory tableInv) {

@Override
public String getResearch() {
return "";
return CustomResearch.replaceCapsResearch.key;
}

private @Nullable InvScanResult scanTable(IInventory tableInv) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import com.github.bsideup.jabel.Desugar;

import dev.rndmorris.salisarcana.common.CustomResearch;
import dev.rndmorris.salisarcana.config.ConfigModuleRoot;
import dev.rndmorris.salisarcana.lib.AspectHelper;
import dev.rndmorris.salisarcana.lib.WandHelper;
Expand All @@ -25,6 +26,9 @@ public class ReplaceWandCoreRecipe implements IArcaneRecipe {

@Override
public boolean matches(IInventory tableInv, World world, EntityPlayer player) {
if (!ThaumcraftApiHelper.isResearchComplete(player.getCommandSenderName(), getResearch())) {
return false;
}
final var scanResult = scanTable(tableInv);
if (scanResult == null || scanResult.invalidInputs()) {
return false;
Expand Down Expand Up @@ -104,7 +108,7 @@ public AspectList getAspects(IInventory tableInv) {

@Override
public String getResearch() {
return "";
return CustomResearch.replaceCoreResearch.key;
}

private @Nullable InvScanResult scanTable(IInventory tableInv) {
Expand Down

0 comments on commit acc4c4d

Please sign in to comment.