mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-14 01:04:24 +00:00
Most events in Forge are not designed to be extended by mod devs but technically allowed it before this PR, leading to a risk of unintentional breaking changes for those that do. If you need to extend a Forge event, please let us know so that we can explicitly support that and design it with extending in mind. Note that this change does not affect making your own events that directly extend from EventBus' `Event` class.
43 lines
1.2 KiB
Java
43 lines
1.2 KiB
Java
/*
|
|
* Copyright (c) Forge Development LLC and contributors
|
|
* SPDX-License-Identifier: LGPL-2.1-only
|
|
*/
|
|
|
|
package net.minecraftforge.event;
|
|
|
|
import net.minecraft.server.packs.PackType;
|
|
import net.minecraft.server.packs.repository.PackRepository;
|
|
import net.minecraft.server.packs.repository.RepositorySource;
|
|
import net.minecraftforge.eventbus.api.Event;
|
|
import net.minecraftforge.fml.event.IModBusEvent;
|
|
|
|
import java.util.function.Consumer;
|
|
|
|
/**
|
|
* Fired on {@link PackRepository} creation to allow mods to add new pack finders.
|
|
*/
|
|
public final class AddPackFindersEvent extends Event implements IModBusEvent {
|
|
private final PackType packType;
|
|
private final Consumer<RepositorySource> sources;
|
|
|
|
public AddPackFindersEvent(PackType packType, Consumer<RepositorySource> sources) {
|
|
this.packType = packType;
|
|
this.sources = sources;
|
|
}
|
|
|
|
/**
|
|
* Adds a new source to the list of pack finders.
|
|
* @param source the pack finder
|
|
*/
|
|
public void addRepositorySource(RepositorySource source) {
|
|
sources.accept(source);
|
|
}
|
|
|
|
/**
|
|
* @return the {@link PackType} of the pack repository being constructed.
|
|
*/
|
|
public PackType getPackType() {
|
|
return packType;
|
|
}
|
|
}
|