1 package me.shedaniel.lightoverlay.common;
3 import net.minecraft.core.BlockPos;
5 import java.util.Objects;
7 public class CubicChunkPos {
12 public CubicChunkPos(int x, int y, int z) {
18 public CubicChunkPos(long l) {
24 public CubicChunkPos(BlockPos blockPos) {
25 this.x = blockPos.getX() >> 4;
26 this.y = blockPos.getY() >> 4;
27 this.z = blockPos.getZ() >> 4;
30 public long toLong() {
31 return asLong(this.x, this.y, this.z);
34 // Allocate 24 bits to x, 12 bits to y, 24 bits to z
35 public static long asLong(int x, int y, int z) {
36 return ((x & 0xffffffL) << 36) | ((y & 0xfffL) << 24) | (z & 0xffffffL);
39 public static int getX(long l) {
40 return (int) (l >> 36 & 0xffffffL);
43 public static int getY(long l) {
44 return (int) (l >> 24 & 0xfffL);
47 public static int getZ(long l) {
48 return (int) (l & 0xffffffL);
51 public int getMinBlockX() {
55 public int getMinBlockY() {
59 public int getMinBlockZ() {
63 public int getMaxBlockX() {
64 return (this.x << 4) + 15;
67 public int getMaxBlockY() {
68 return (this.y << 4) + 15;
71 public int getMaxBlockZ() {
72 return (this.z << 4) + 15;
76 public boolean equals(Object o) {
77 if (this == o) return true;
78 if (o == null || getClass() != o.getClass()) return false;
79 CubicChunkPos that = (CubicChunkPos) o;
80 return x == that.x && y == that.y && z == that.z;
84 public int hashCode() {
85 return Objects.hash(x, y, z);