Redesign CreativeTab collection event to be a lot more straight forward. (#9198)
This commit is contained in:
parent
d2f2e94511
commit
8adb648b8d
1 changed files with 7 additions and 2 deletions
|
@ -58,8 +58,7 @@ public class ExampleMod
|
|||
MinecraftForge.EVENT_BUS.register(this);
|
||||
|
||||
// Register the item to a creative tab
|
||||
modEventBus.addListener((CreativeModeTabEvent.BuildContents event) -> event.registerSimple(CreativeModeTabs.BUILDING_BLOCKS,
|
||||
EXAMPLE_BLOCK_ITEM.get()));
|
||||
modEventBus.addListener(this::addCreative);
|
||||
}
|
||||
|
||||
private void commonSetup(final FMLCommonSetupEvent event)
|
||||
|
@ -69,6 +68,12 @@ public class ExampleMod
|
|||
LOGGER.info("DIRT BLOCK >> {}", ForgeRegistries.BLOCKS.getKey(Blocks.DIRT));
|
||||
}
|
||||
|
||||
private void addCreative(CreativeModeTabEvent.BuildContents event)
|
||||
{
|
||||
if (event.getTab() == CreativeModeTabs.BUILDING_BLOCKS)
|
||||
event.accept(EXAMPLE_BLOCK_ITEM);
|
||||
}
|
||||
|
||||
// You can use SubscribeEvent and let the Event Bus discover methods to call
|
||||
@SubscribeEvent
|
||||
public void onServerStarting(ServerStartingEvent event)
|
||||
|
|
Loading…
Reference in a new issue