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

cn.nukkit.level.util.BlockIndex Maven / Gradle / Ivy

There is a newer version: 1.20.40-r1
Show newest version
package cn.nukkit.level.util;

import cn.nukkit.api.PowerNukkitXOnly;
import cn.nukkit.api.Since;

@PowerNukkitXOnly
@Since("1.6.0.0-PNX")
public record BlockIndex(int x, int y, int z, int layer, long hash) {

    public static BlockIndex of(int x, int y, int z, int layer) {
        return new BlockIndex(x, y, z, layer, ((long) x) << 38 | ((long) y) << 27 | ((long) z) << 1 | layer);
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        BlockIndex that = (BlockIndex) o;

        if (hash != that.hash) return false;
        if (x != that.x) return false;
        if (y != that.y) return false;
        if (z != that.z) return false;
        return layer == that.layer;
    }

    @Override
    public int hashCode() {
        int result = x;
        result = 31 * result + y;
        result = 31 * result + z;
        result = 31 * result + layer;
        return result;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy