-
-
Notifications
You must be signed in to change notification settings - Fork 534
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add items to the appropriate and logical vanilla creative tabs as well
- Loading branch information
1 parent
578aef6
commit 04d67f7
Showing
5 changed files
with
253 additions
and
36 deletions.
There are no files selected for viewing
59 changes: 50 additions & 9 deletions
59
src/additions/java/mekanism/additions/common/registries/AdditionsCreativeTabs.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,63 @@ | ||
package mekanism.additions.common.registries; | ||
|
||
import java.util.Map; | ||
import mekanism.additions.common.AdditionsLang; | ||
import mekanism.additions.common.MekanismAdditions; | ||
import mekanism.api.providers.IBlockProvider; | ||
import mekanism.api.text.EnumColor; | ||
import mekanism.common.registration.impl.CreativeTabDeferredRegister; | ||
import mekanism.common.registration.impl.CreativeTabRegistryObject; | ||
import mekanism.common.registries.MekanismCreativeTabs; | ||
import net.minecraft.resources.ResourceKey; | ||
import net.minecraft.world.item.CreativeModeTab; | ||
import net.minecraft.world.item.CreativeModeTabs; | ||
import net.minecraftforge.event.BuildCreativeModeTabContentsEvent; | ||
|
||
public class AdditionsCreativeTabs { | ||
|
||
public static final CreativeTabDeferredRegister CREATIVE_TABS = new CreativeTabDeferredRegister(MekanismAdditions.MODID); | ||
public static final CreativeTabDeferredRegister CREATIVE_TABS = new CreativeTabDeferredRegister(MekanismAdditions.MODID, AdditionsCreativeTabs::addToExistingTabs); | ||
|
||
public static final CreativeTabRegistryObject ADDITIONS = CREATIVE_TABS.registerMain(AdditionsLang.MEKANISM_ADDITIONS, AdditionsBlocks.OBSIDIAN_TNT, builder -> | ||
builder.withBackgroundLocation(MekanismAdditions.rl("textures/gui/creative_tab.png")) | ||
.withSearchBar(65)//Allow our tabs to be searchable for convenience purposes | ||
.withTabsBefore(MekanismCreativeTabs.MEKANISM.key()) | ||
.displayItems((displayParameters, output) -> { | ||
CreativeTabDeferredRegister.addToDisplay(AdditionsItems.ITEMS, output); | ||
CreativeTabDeferredRegister.addToDisplay(AdditionsBlocks.BLOCKS, output); | ||
}) | ||
public static final CreativeTabRegistryObject ADDITIONS = CREATIVE_TABS.registerMain(AdditionsLang.MEKANISM_ADDITIONS, | ||
AdditionsItems.BALLOONS.get(EnumColor.BRIGHT_GREEN), builder -> | ||
builder.withBackgroundLocation(MekanismAdditions.rl("textures/gui/creative_tab.png")) | ||
.withSearchBar(65)//Allow our tabs to be searchable for convenience purposes | ||
.withTabsBefore(MekanismCreativeTabs.MEKANISM.key()) | ||
.displayItems((displayParameters, output) -> { | ||
CreativeTabDeferredRegister.addToDisplay(AdditionsItems.ITEMS, output); | ||
CreativeTabDeferredRegister.addToDisplay(AdditionsBlocks.BLOCKS, output); | ||
}) | ||
); | ||
|
||
private static void addToExistingTabs(BuildCreativeModeTabContentsEvent event) { | ||
ResourceKey<CreativeModeTab> tabKey = event.getTabKey(); | ||
if (tabKey == CreativeModeTabs.BUILDING_BLOCKS) { | ||
addToDisplay(event, AdditionsBlocks.PLASTIC_BLOCKS, AdditionsBlocks.SLICK_PLASTIC_BLOCKS, AdditionsBlocks.PLASTIC_GLOW_BLOCKS, | ||
AdditionsBlocks.REINFORCED_PLASTIC_BLOCKS, AdditionsBlocks.PLASTIC_ROADS, AdditionsBlocks.TRANSPARENT_PLASTIC_BLOCKS, AdditionsBlocks.PLASTIC_STAIRS, | ||
AdditionsBlocks.PLASTIC_SLABS, AdditionsBlocks.PLASTIC_FENCES, AdditionsBlocks.PLASTIC_FENCE_GATES, AdditionsBlocks.PLASTIC_GLOW_STAIRS, | ||
AdditionsBlocks.PLASTIC_GLOW_SLABS, AdditionsBlocks.TRANSPARENT_PLASTIC_STAIRS, AdditionsBlocks.TRANSPARENT_PLASTIC_SLABS); | ||
} else if (tabKey == CreativeModeTabs.COLORED_BLOCKS) { | ||
addToDisplay(event, AdditionsBlocks.GLOW_PANELS, AdditionsBlocks.PLASTIC_BLOCKS, AdditionsBlocks.SLICK_PLASTIC_BLOCKS, AdditionsBlocks.PLASTIC_GLOW_BLOCKS, | ||
AdditionsBlocks.REINFORCED_PLASTIC_BLOCKS, AdditionsBlocks.PLASTIC_ROADS, AdditionsBlocks.TRANSPARENT_PLASTIC_BLOCKS, AdditionsBlocks.PLASTIC_STAIRS, | ||
AdditionsBlocks.PLASTIC_SLABS, AdditionsBlocks.PLASTIC_FENCES, AdditionsBlocks.PLASTIC_FENCE_GATES, AdditionsBlocks.PLASTIC_GLOW_STAIRS, | ||
AdditionsBlocks.PLASTIC_GLOW_SLABS, AdditionsBlocks.TRANSPARENT_PLASTIC_STAIRS, AdditionsBlocks.TRANSPARENT_PLASTIC_SLABS); | ||
} else if (tabKey == CreativeModeTabs.FUNCTIONAL_BLOCKS) { | ||
addToDisplay(event, AdditionsBlocks.GLOW_PANELS, AdditionsBlocks.PLASTIC_GLOW_BLOCKS, AdditionsBlocks.PLASTIC_GLOW_STAIRS, AdditionsBlocks.PLASTIC_GLOW_SLABS); | ||
} else if (tabKey == CreativeModeTabs.REDSTONE_BLOCKS) { | ||
CreativeTabDeferredRegister.addToDisplay(event, AdditionsBlocks.OBSIDIAN_TNT); | ||
} else if (tabKey == CreativeModeTabs.COMBAT) { | ||
CreativeTabDeferredRegister.addToDisplay(event, AdditionsBlocks.OBSIDIAN_TNT); | ||
} else if (tabKey == CreativeModeTabs.SPAWN_EGGS) { | ||
CreativeTabDeferredRegister.addToDisplay(event, AdditionsItems.BABY_CREEPER_SPAWN_EGG, AdditionsItems.BABY_ENDERMAN_SPAWN_EGG, | ||
AdditionsItems.BABY_SKELETON_SPAWN_EGG, AdditionsItems.BABY_STRAY_SPAWN_EGG, AdditionsItems.BABY_WITHER_SKELETON_SPAWN_EGG); | ||
} | ||
} | ||
|
||
@SafeVarargs | ||
private static void addToDisplay(CreativeModeTab.Output output, Map<EnumColor, ? extends IBlockProvider>... blocks) { | ||
for (Map<EnumColor, ? extends IBlockProvider> blockMap : blocks) { | ||
for (IBlockProvider block : blockMap.values()) { | ||
CreativeTabDeferredRegister.addToDisplay(output, block); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.