net.minecraftforge.eventbus.api.IEventBus Java Examples

The following examples show how to use net.minecraftforge.eventbus.api.IEventBus. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MiningGadgets.java    From MiningGadgets with MIT License 6 votes vote down vote up
public MiningGadgets() {
    IEventBus event = FMLJavaModLoadingContext.get().getModEventBus();

    // Register all of our items, blocks, item blocks, etc
    ModItems.ITEMS.register(event);
    ModItems.UPGRADE_ITEMS.register(event);
    ModBlocks.BLOCKS.register(event);
    ModBlocks.TILES_ENTITIES.register(event);
    ModContainers.CONTAINERS.register(event);

    event.addListener(this::setup);
    event.addListener(this::setupClient);

    ModLoadingContext.get().registerConfig(ModConfig.Type.CLIENT, Config.CLIENT_CONFIG);
    ModLoadingContext.get().registerConfig(ModConfig.Type.COMMON, Config.COMMON_CONFIG);

    // Register the setup method for modloading
    event.addListener(this::setup);
    MinecraftForge.EVENT_BUS.register(this);

    Config.loadConfig(Config.CLIENT_CONFIG, FMLPaths.CONFIGDIR.get().resolve(MOD_ID + "-client.toml"));
    Config.loadConfig(Config.COMMON_CONFIG, FMLPaths.CONFIGDIR.get().resolve(MOD_ID + "-common.toml"));
}
 
Example #2
Source File: SurvivalistMod.java    From Survivalist with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public SurvivalistMod()
{
    instance = this;

    ModLoadingContext modLoadingContext = ModLoadingContext.get();
    IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();

    HELPER.subscribeEvents(modEventBus);
    SurvivalistBlocks.HELPER.subscribeEvents(modEventBus);
    SurvivalistItems.HELPER.subscribeEvents(modEventBus);
    SurvivalistTileEntityTypes.HELPER.subscribeEvents(modEventBus);

    modEventBus.addGenericListener(ContainerType.class, this::registerContainers);
    modEventBus.addGenericListener(IRecipeSerializer.class, this::registerRecipeSerializers);
    modEventBus.addGenericListener(GlobalLootModifierSerializer.class, this::lootModifiers);
    modEventBus.addListener(this::commonSetup);
    modEventBus.addListener(this::clientSetup);
    modEventBus.addListener(this::gatherData);

    MinecraftForge.EVENT_BUS.addListener(this::serverStarting);

    modLoadingContext.registerConfig(ModConfig.Type.SERVER, ConfigManager.SERVER_SPEC);
}
 
Example #3
Source File: XRay.java    From XRay-Mod with GNU General Public License v3.0 5 votes vote down vote up
public XRay() {
	IEventBus eventBus = FMLJavaModLoadingContext.get().getModEventBus();

	eventBus.addListener(this::onSetup);
	eventBus.addListener(this::onLoadComplete);
	eventBus.addListener(this::onExit);

	ModLoadingContext.get().registerConfig(ModConfig.Type.CLIENT, Configuration.SPEC);

	// Keybindings
	MinecraftForge.EVENT_BUS.register(KeyBindings.class);
}
 
Example #4
Source File: EventNetworkChannel.java    From patchwork-api with GNU Lesser General Public License v2.1 4 votes vote down vote up
private void handleError(IEventBus bus, Event event, IEventListener[] listeners, int i, Throwable throwable) {
	// Forge: NO-OP
}
 
Example #5
Source File: FMLJavaModLoadingContext.java    From patchwork-api with GNU Lesser General Public License v2.1 4 votes vote down vote up
/**
 * @return The mod's event bus, to allow subscription to Mod specific events
 */
public IEventBus getModEventBus() {
	return container.getEventBus();
}
 
Example #6
Source File: FMLModContainer.java    From patchwork-api with GNU Lesser General Public License v2.1 4 votes vote down vote up
public FMLModContainer(String id, IEventBus bus) {
	super(id);

	this.eventBus = bus;
}
 
Example #7
Source File: FMLModContainer.java    From patchwork-api with GNU Lesser General Public License v2.1 4 votes vote down vote up
public IEventBus getEventBus() {
	return eventBus;
}
 
Example #8
Source File: FMLModContainer.java    From patchwork-api with GNU Lesser General Public License v2.1 4 votes vote down vote up
private void onEventFailed(IEventBus iEventBus, Event event, IEventListener[] listeners, int i, Throwable throwable) {
	// TODO
}
 
Example #9
Source File: ModelRegistryHelper.java    From CodeChickenLib with GNU Lesser General Public License v2.1 4 votes vote down vote up
public ModelRegistryHelper(IEventBus eventBus) {
    eventBus.register(this);
}
 
Example #10
Source File: MultiRegistryHelper.java    From CodeChickenLib with GNU Lesser General Public License v2.1 4 votes vote down vote up
public MultiRegistryHelper(String modId, IEventBus eventBus) {
    this.modId = modId;
    eventBus.addListener(this::onRegister);
}
 
Example #11
Source File: SpriteRegistryHelper.java    From CodeChickenLib with GNU Lesser General Public License v2.1 4 votes vote down vote up
public SpriteRegistryHelper(IEventBus eventBus) {
    eventBus.register(this);
}
 
Example #12
Source File: RegSitter.java    From Survivalist with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public final void subscribeEvents(IEventBus bus)
{
    registerList.forEach(def -> def.register(bus));
}