001package net.tnemc.plugincore.core.compatibility; 002 003/* 004 * The New Plugin Core 005 * Copyright (C) 2022 - 2024 Daniel "creatorfromhell" Vidmar 006 * 007 * This program is free software: you can redistribute it and/or modify 008 * it under the terms of the GNU Affero General Public License as published by 009 * the Free Software Foundation, either version 3 of the License, or 010 * (at your option) any later version. 011 * 012 * This program is distributed in the hope that it will be useful, 013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 015 * GNU Affero General Public License for more details. 016 * 017 * You should have received a copy of the GNU Affero General Public License 018 * along with this program. If not, see <http://www.gnu.org/licenses/>. 019 */ 020 021import org.jetbrains.annotations.NotNull; 022 023/** 024 * Location 025 * 026 * @author creatorfromhell 027 * @since 0.1.2.0 028 */ 029public class Location { 030 031 private String world; 032 private double x; 033 private double y; 034 private double z; 035 036 public Location(String world, double x, double y, double z) { 037 this.world = world; 038 this.x = x; 039 this.y = y; 040 this.z = z; 041 } 042 043 public String getWorld() { 044 return world; 045 } 046 047 public void setWorld(String world) { 048 this.world = world; 049 } 050 051 public int getChunkX() { 052 return (int)(x / 16); 053 } 054 055 public int getChunkZ() { 056 return (int)(z / 16); 057 } 058 059 public double distance(@NotNull final Location location) { 060 return Math.sqrt(Math.pow(x - location.x, 2) + Math.pow(y - location.y, 2) + Math.pow(z - location.z, 2)); 061 } 062 063 public double getX() { 064 return x; 065 } 066 067 public void setX(double x) { 068 this.x = x; 069 } 070 071 public double getY() { 072 return y; 073 } 074 075 public void setY(double y) { 076 this.y = y; 077 } 078 079 public double getZ() { 080 return z; 081 } 082 083 public void setZ(double z) { 084 this.z = z; 085 } 086}