/* * Iris is a World Generator for Minecraft Bukkit Servers * Copyright (c) 2021 Arcane Arts (Volmit Software) * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ package com.volmit.iris.util; public class ChunkPosition { private int x; private int z; public ChunkPosition(int x, int z) { this.x = x; this.z = z; } public int getX() { return x; } public void setX(int x) { this.x = x; } public int getZ() { return z; } public void setZ(int z) { this.z = z; } @Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + x; result = prime * result + z; return result; } @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (!(obj instanceof ChunkPosition other)) { return false; } return x == other.x && z == other.z; } public double distance(ChunkPosition center) { return Math.pow(center.getX() - x, 2) + Math.pow(center.getZ() - z, 2); } }