Skip to content

Commit

Permalink
Merge pull request #12 from GTNewHorizons/ImproveConfigItemToggles
Browse files Browse the repository at this point in the history
Improve item config toggles
  • Loading branch information
Dream-Master committed Mar 19, 2023
2 parents 41f97e9 + 28f13d1 commit f2696b5
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/main/java/openblocks/NEIOpenBlocksConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import net.minecraft.item.ItemStack;
import net.minecraftforge.oredict.OreDictionary;

import openblocks.common.item.MetasGeneric;
import openblocks.common.item.MetasGenericUnstackable;
import openmods.Log;
import codechicken.nei.api.IConfigureNEI;

Expand All @@ -27,6 +29,14 @@ public void loadConfig() {
API$hideItem(new ItemStack(OpenBlocks.Items.heightMap, 1, OreDictionary.WILDCARD_VALUE));
}

if (!MetasGeneric.subItemEnabled()) {
API$hideItem(new ItemStack(OpenBlocks.Items.generic, 1, OreDictionary.WILDCARD_VALUE));
}

if (!MetasGenericUnstackable.subItemEnabled()) {
API$hideItem(new ItemStack(OpenBlocks.Items.genericUnstackable, 1, OreDictionary.WILDCARD_VALUE));
}

Log.info("OpenBlocks NEI Integration loaded successfully");
}

Expand Down
58 changes: 58 additions & 0 deletions src/main/java/openblocks/common/item/MetasGeneric.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ public IMetaItem createMetaItem() {
new ShapedOreRecipe(result, " sl", "sll", "lll", 's', "stickWood", 'l', Items.leather),
new ShapedOreRecipe(result, "ls ", "lls", "lll", 's', "stickWood", 'l', Items.leather));
}

@Override
public boolean isEnabled() {
return OpenBlocks.Items.hangGlider != null;
}
},
beam {

Expand Down Expand Up @@ -56,6 +61,11 @@ public IMetaItem createMetaItem() {
'y',
"dyeYellow"));
}

@Override
public boolean isEnabled() {
return OpenBlocks.Items.craneBackpack != null;
}
},
craneEngine {

Expand All @@ -76,6 +86,11 @@ public IMetaItem createMetaItem() {
'r',
"dustRedstone"));
}

@Override
public boolean isEnabled() {
return OpenBlocks.Items.craneBackpack != null;
}
},
craneMagnet {

Expand Down Expand Up @@ -109,6 +124,12 @@ public IMetaItem createMetaItem() {
'y',
"dyeYellow"));
}

@Override
public boolean isEnabled() {
return OpenBlocks.Items.craneBackpack != null
|| (Loader.isModLoaded(openmods.Mods.OPENPERIPHERALCORE) && Config.enableCraneTurtles);
}
},
miracleMagnet {

Expand Down Expand Up @@ -156,6 +177,11 @@ public IMetaItem createMetaItem() {
"line",
new ShapedOreRecipe(result, "sss", "bbb", "sss", 's', Items.string, 'b', "slimeball"));
}

@Override
public boolean isEnabled() {
return OpenBlocks.Items.craneBackpack != null;
}
},
mapController {

Expand All @@ -166,6 +192,11 @@ public IMetaItem createMetaItem() {
"map_controller",
new ShapedOreRecipe(result, " r ", "rgr", " r ", 'r', "dustRedstone", 'g', "ingotGold"));
}

@Override
public boolean isEnabled() {
return OpenBlocks.Items.emptyMap != null;
}
},
mapMemory {

Expand All @@ -176,6 +207,11 @@ public IMetaItem createMetaItem() {
"map_memory",
new ShapedOreRecipe(result, "rg", "rg", "rg", 'g', "nuggetGold", 'r', "dustRedstone"));
}

@Override
public boolean isEnabled() {
return OpenBlocks.Items.emptyMap != null;
}
},
/**
* Deprecated. Moved to ItemCursor Can't remove it from here because it'll re-index everyones items.. I guess the
Expand Down Expand Up @@ -211,6 +247,11 @@ public IMetaItem createMetaItem() {
'r',
"dustRedstone"));
}

@Override
public boolean isEnabled() {
return OpenBlocks.Items.cartographer != null;
}
},
unpreparedStencil {

Expand All @@ -221,6 +262,11 @@ public IMetaItem createMetaItem() {
"unprepared_stencil",
new ShapedOreRecipe(result, " p ", "pip", " p ", 'p', Items.paper, 'i', "ingotIron"));
}

@Override
public boolean isEnabled() {
return OpenBlocks.Blocks.drawingTable != null;
}
},
sketchingPencil {

Expand All @@ -239,6 +285,11 @@ public IMetaItem createMetaItem() {
's',
"stickWood"));
}

@Override
public boolean isEnabled() {
return OpenBlocks.Blocks.drawingTable != null;
}
};

public ItemStack newItemStack(int size) {
Expand Down Expand Up @@ -275,4 +326,11 @@ public Iterable<Entry> getBookEntries() {
}

}

public static boolean subItemEnabled() {
for (MetasGeneric m : values()) if (m.isEnabled()) {
return true;
}
return false;
}
}
12 changes: 12 additions & 0 deletions src/main/java/openblocks/common/item/MetasGenericUnstackable.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ protected IMetaItem createMetaItem() {
final ItemStack whiteWool = ColorMeta.WHITE.createStack(Blocks.wool, 1);
return new MetaPointer("pointer", new ShapedOreRecipe(result, "w ", "ww ", "w ", 'w', whiteWool));
}

@Override
public boolean isEnabled() {
return OpenBlocks.Blocks.cannon != null;
}
};

public ItemStack newItemStack(int size) {
Expand All @@ -43,4 +48,11 @@ public static void registerItems() {
for (MetasGenericUnstackable m : values())
if (m.isEnabled()) Items.genericUnstackable.registerItem(m.ordinal(), m.createMetaItem());
}

public static boolean subItemEnabled() {
for (MetasGenericUnstackable m : values()) if (m.isEnabled()) {
return true;
}
return false;
}
}

0 comments on commit f2696b5

Please sign in to comment.