-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
142b72e
commit dbbfefd
Showing
3 changed files
with
78 additions
and
10 deletions.
There are no files selected for viewing
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
50 changes: 50 additions & 0 deletions
50
src/main/java/com/obsilab/mcsc/event/CreativeTabEvents.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 |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package com.obsilab.mcsc.event; | ||
|
||
import com.obsilab.mcsc.MCSC; | ||
import com.obsilab.mcsc.block.ModBlocks; | ||
import com.obsilab.mcsc.block.custom.CrystalIngotBlock; | ||
import com.obsilab.mcsc.item.ModItems; | ||
import net.minecraft.network.chat.Component; | ||
import net.minecraft.resources.ResourceLocation; | ||
import net.minecraft.world.item.CreativeModeTab; | ||
import net.minecraft.world.item.Item; | ||
import net.minecraft.world.item.ItemStack; | ||
import net.minecraft.world.level.block.Block; | ||
import net.minecraftforge.event.CreativeModeTabEvent; | ||
import net.minecraftforge.eventbus.api.SubscribeEvent; | ||
import net.minecraftforge.registries.RegistryObject; | ||
|
||
import java.util.Collection; | ||
|
||
public class CreativeTabEvents { | ||
|
||
public static CreativeModeTab MCSC_TAB; | ||
|
||
@SubscribeEvent | ||
public static void onCreativeTabEvent(CreativeModeTabEvent.Register event) { | ||
MCSC_TAB = event.registerCreativeModeTab(new ResourceLocation(MCSC.MOD_ID, "mcsc_tab"), | ||
builder -> builder | ||
.icon(() -> new ItemStack(ModItems.ETCHED_WAFER_ITEM.get())) | ||
.title(Component.literal("item_group." + MCSC.MOD_ID + ".tab")) | ||
.displayItems((enabledFlags, populator, hasPermissions) -> { | ||
Collection<RegistryObject<Item>> ModItemsList = ModItems.ITEMS.getEntries(); | ||
Collection<RegistryObject<Block>> ModBlocksList = ModBlocks.BLOCKS.getEntries(); | ||
for (RegistryObject<Item> mod_item : ModItemsList) { | ||
populator.accept(new ItemStack(mod_item.get())); | ||
} | ||
for (RegistryObject<Block> mod_block : ModBlocksList) { | ||
//check if the block is a crop block | ||
if (mod_block.get() instanceof CrystalIngotBlock) { // if(mod_block.get().getName().equals("crystal_ingot")) | ||
//continue; // remove crop block, prevents crashing | ||
} else { | ||
populator.accept(new ItemStack(mod_block.get())); | ||
} | ||
|
||
//event.accept(mod_block.get()); | ||
} | ||
}) | ||
.build() | ||
); | ||
} | ||
|
||
} |
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