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

top.hendrixshen.magiclib.language.impl.MagicLanguageResource Maven / Gradle / Ivy

The newest version!
package top.hendrixshen.magiclib.language.impl;

import org.jetbrains.annotations.NotNull;

import java.io.InputStream;
import java.util.Objects;
import java.util.function.Supplier;
import net.minecraft.class_2960;
import net.minecraft.class_3262;
import net.minecraft.class_3298;

//#if MC > 11802
public class MagicLanguageResource extends class_3298 {
//#else
//$$ public class MagicLanguageResource implements Resource {
    //#endif
    //#if MC >= 11903
    private final class_3262 resources;
    //#else
    //$$ private final String sourceName;
    //#endif
    private final class_2960 location;
    private final Supplier inputStreamSupplier;

    //#if MC > 11902
    public MagicLanguageResource(class_3262 resources, class_2960 resourceLocation, Supplier inputStreamSupplier) {
        super(resources, inputStreamSupplier::get);
        this.resources = resources;
        //#else
        //$$ public MagicLanguageResource(String sourceName, ResourceLocation resourceLocation, Supplier inputStreamSupplier) {
        //#if MC > 11802
        //$$     super(sourceName, inputStreamSupplier::get);
        //#endif
        //$$     this.sourceName = sourceName;
        //#endif
        this.location = resourceLocation;
        this.inputStreamSupplier = inputStreamSupplier;
    }

    //#if MC <= 11802
    //$$ @Override
    //#endif
    public class_2960 getLocation() {
        return this.location;
    }

    @Override
    public InputStream method_14482() {
        return inputStreamSupplier.get();
    }

    //#if MC <= 11802
    //#if MC > 11605
    //$$ @Override
    //$$ public boolean hasMetadata() {
    //$$     return false;
    //$$ }
    //#endif
    //$$
    //$$ @Nullable
    //$$ @Override
    //$$ public  T getMetadata(@NotNull MetadataSectionSerializer metadataSectionSerializer) {
    //$$     return null;
    //$$ }
    //$$
    //$$ @Override
    //$$ public void close() {
    //$$ }
    //#endif

    @Override
    public String method_14480() {
        //#if MC >= 11903
        return this.resources.method_14409();
        //#else
        //$$ return this.sourceName;
        //#endif
    }

    @Override
    public boolean equals(Object object) {
        if (this == object) {
            return true;
        } else if (!(object instanceof MagicLanguageResource)) {
            return false;
        } else {
            MagicLanguageResource magicLanguageResource = (MagicLanguageResource) object;
            return Objects.equals(this.location, magicLanguageResource.location)
                    //#if MC >= 11903
                    && Objects.equals(this.method_14480(), magicLanguageResource.method_14480());
                    //#else
                    //$$ && Objects.equals(this.sourceName, magicLanguageResource.sourceName);
                    //#endif
        }
    }

    // from SimpleResource
    @Override
    public int hashCode() {
        //#if MC >= 11903
        int i = this.method_14480() != null ? this.method_14480().hashCode() : 0;
        //#else
        //$$ int i = this.sourceName != null ? this.sourceName.hashCode() : 0;
        //#endif
        i = 31 * i + (this.location != null ? this.location.hashCode() : 0);
        return i;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy