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

cn.nukkit.utils.Hash Maven / Gradle / Ivy

Go to download

A Minecraft Bedrock Edition server software implementation made in Java from scratch which supports all new features.

There is a newer version: 1.6.0.1-PN
Show newest version
package cn.nukkit.utils;

import cn.nukkit.math.Vector3;

public class Hash {
    public static long hashBlock(int x, int y, int z) {
        return y + (((long) x & 0x3FFFFFF) << 8) + (((long) z & 0x3FFFFFF) << 34);
    }


    public static final int hashBlockX(long triple) {
        return (int) ((((triple >> 8) & 0x3FFFFFF) << 38) >> 38);
    }

    public static final int hashBlockY(long triple) {
        return (int) (triple & 0xFF);
    }

    public static final int hashBlockZ(long triple) {
        return (int) ((((triple >> 34) & 0x3FFFFFF) << 38) >> 38);
    }

    /**
     * @since 1.2.1.0-PN
     */
    public static long hashBlock(Vector3 blockPos) {
        return hashBlock(blockPos.getFloorX(), blockPos.getFloorY(), blockPos.getFloorZ());
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy