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

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

There is a newer version: 0.7.398+fe2125a-beta
Show newest version
package top.hendrixshen.magiclib.language.impl;

import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
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_3270;
import net.minecraft.class_3298;

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

    //#if MC > 11902
    //$$ public MagicLanguageResource(PackResources resources, ResourceLocation resourceLocation, Supplier inputStreamSupplier) {
    //$$     super(resources, inputStreamSupplier::get);
    //$$     this.resources = resources;
        //#else
        public MagicLanguageResource(String sourceName, class_2960 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 method_14483() {
        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 method_14481(@NotNull class_3270 metadataSectionSerializer) {
        return null;
    }

    @Override
    public void close() {
    }
    //#endif

    @Override
    public String method_14480() {
        //#if MC >= 11903
        //$$ return this.resources.packId();
        //#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.sourcePackId(), magicLanguageResource.sourcePackId());
                    //#else
                    && Objects.equals(this.sourceName, magicLanguageResource.sourceName);
                    //#endif
        }
    }

    // from SimpleResource
    @Override
    public int hashCode() {
        //#if MC >= 11903
        //$$ int i = this.sourcePackId() != null ? this.sourcePackId().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