summaryrefslogtreecommitdiff
path: root/src/main/java/com/example
diff options
context:
space:
mode:
authorLexManos <LexManos@gmail.com>2022-12-10 15:03:23 -0800
committerGitHub <noreply@github.com>2022-12-10 15:03:23 -0800
commit8adb648b8d07de30c9666aa0dc77879bbf21b945 (patch)
tree1e734b0c6d0dd47d1c0ccc591e02003ae7c86da9 /src/main/java/com/example
parentd2f2e9451193cff9298af470301b99214cfac6ce (diff)
Redesign CreativeTab collection event to be a lot more straight forward. (#9198)
Diffstat (limited to 'src/main/java/com/example')
-rw-r--r--src/main/java/com/example/examplemod/ExampleMod.java9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/main/java/com/example/examplemod/ExampleMod.java b/src/main/java/com/example/examplemod/ExampleMod.java
index e4013ff..44199e6 100644
--- a/src/main/java/com/example/examplemod/ExampleMod.java
+++ b/src/main/java/com/example/examplemod/ExampleMod.java
@@ -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)