2021-10-05 00:10:05 +02:00
|
|
|
/*
|
2022-04-14 03:42:00 +00:00
|
|
|
* Copyright (c) Forge Development LLC and contributors
|
2022-02-28 13:41:23 -08:00
|
|
|
* SPDX-License-Identifier: LGPL-2.1-only
|
2021-10-05 00:10:05 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
package net.minecraftforge.event;
|
|
|
|
|
|
|
|
|
|
import net.minecraft.server.packs.PackType;
|
2022-11-22 13:32:47 -06:00
|
|
|
import net.minecraft.server.packs.repository.PackRepository;
|
2021-10-05 00:10:05 +02:00
|
|
|
import net.minecraft.server.packs.repository.RepositorySource;
|
|
|
|
|
import net.minecraftforge.eventbus.api.Event;
|
|
|
|
|
import net.minecraftforge.fml.event.IModBusEvent;
|
|
|
|
|
|
|
|
|
|
import java.util.function.Consumer;
|
|
|
|
|
|
|
|
|
|
/**
|
2022-11-22 13:32:47 -06:00
|
|
|
* Fired on {@link PackRepository} creation to allow mods to add new pack finders.
|
2021-10-05 00:10:05 +02:00
|
|
|
*/
|
2025-04-19 13:18:48 +01:00
|
|
|
public final class AddPackFindersEvent extends Event implements IModBusEvent {
|
2021-10-05 00:10:05 +02:00
|
|
|
private final PackType packType;
|
|
|
|
|
private final Consumer<RepositorySource> sources;
|
|
|
|
|
|
2023-09-07 20:23:27 -07:00
|
|
|
public AddPackFindersEvent(PackType packType, Consumer<RepositorySource> sources) {
|
2021-10-05 00:10:05 +02:00
|
|
|
this.packType = packType;
|
|
|
|
|
this.sources = sources;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Adds a new source to the list of pack finders.
|
|
|
|
|
* @param source the pack finder
|
|
|
|
|
*/
|
2023-09-07 20:23:27 -07:00
|
|
|
public void addRepositorySource(RepositorySource source) {
|
2021-10-05 00:10:05 +02:00
|
|
|
sources.accept(source);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2022-11-22 13:32:47 -06:00
|
|
|
* @return the {@link PackType} of the pack repository being constructed.
|
2021-10-05 00:10:05 +02:00
|
|
|
*/
|
2023-09-07 20:23:27 -07:00
|
|
|
public PackType getPackType() {
|
2021-10-05 00:10:05 +02:00
|
|
|
return packType;
|
|
|
|
|
}
|
|
|
|
|
}
|