All Downloads are FREE. Search and download functionalities are using the official Maven repository.

personthecat.catlib.registry.RegistryHandle Maven / Gradle / Ivy

Go to download

Utilities for serialization, commands, noise generation, IO, and some new data types.

The newest version!
package personthecat.catlib.registry;

import org.jetbrains.annotations.Nullable;

import java.util.Collection;
import java.util.Collections;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.function.BiConsumer;
import java.util.stream.Stream;
import net.minecraft.class_2378;
import net.minecraft.class_2960;
import net.minecraft.class_5321;
import net.minecraft.class_6862;
import net.minecraft.class_6880;
import net.minecraft.class_6885;

public interface RegistryHandle extends Iterable {
    @Nullable class_2960 getKey(final T t);
    @Nullable T lookup(final class_2960 id);
     V register(final class_2960 id, V v);
    void forEach(final BiConsumer f);
    boolean isRegistered(final class_2960 id);
    @Nullable class_6880 getHolder(final class_2960 id);
    Map, class_6885.class_6888> getTags();
    @Nullable class_5321> key();
    Set keySet();
    Set, T>> entrySet();
    Stream stream();

    default Collection getTag(final class_6862 key) {
        return this.getTags().get(key).method_40239().map(class_6880::comp_349).toList();
    }

    default Collection getTag(final class_2960 id) {
        final class_5321> key = this.key();
        return key != null ? this.getTag(class_6862.method_40092(key, id)) : Collections.emptySet();
    }

    default class_5321> keyOrThrow() {
        return Objects.requireNonNull(this.key(), "Polled key from dummy container");
    }

    default Stream streamKeys() {
        return this.keySet().stream();
    }

    default Stream, T>> streamEntries() {
        return this.entrySet().stream();
    }

    default int getId() {
        return System.identityHashCode(this);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy