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

personthecat.catlib.util.DimInjector Maven / Gradle / Ivy

Go to download

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

The newest version!
package personthecat.catlib.util;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import personthecat.catlib.registry.DynamicRegistries;

import java.util.Collections;
import java.util.Set;
import java.util.WeakHashMap;
import java.util.concurrent.ConcurrentHashMap;
import net.minecraft.class_2791;
import net.minecraft.class_2874;

public interface DimInjector {
    Set> UNSUPPORTED = ConcurrentHashMap.newKeySet();
    Set MAPPED = Collections.newSetFromMap(Collections.synchronizedMap(new WeakHashMap<>()));
    Logger LOG = LogManager.getLogger(DimInjector.class);

    void setType(final @NotNull class_2874 type);
    @Nullable class_2874 getType();

    static void setType(final class_2791 chunk, final @NotNull class_2874 type) {
        if (chunk instanceof DimInjector) {
            ((DimInjector) chunk).setType(type);
            if (MAPPED.add(type)) {
                LOG.info("Successfully injecting dim keys for {}", DynamicRegistries.DIMENSION_TYPES.getKey(type));
            }
        } else if (UNSUPPORTED.add(chunk.getClass())) {
            LOG.error("Cannot inject into chunk of type {}", chunk.getClass());
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy