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(final String world, final double x, final double y, final double z) {
037
038    this.world = world;
039    this.x = x;
040    this.y = y;
041    this.z = z;
042  }
043
044  public String getWorld() {
045
046    return world;
047  }
048
049  public void setWorld(final String world) {
050
051    this.world = world;
052  }
053
054  public int getChunkX() {
055
056    return (int)(x / 16);
057  }
058
059  public int getChunkY() {
060
061    return (int)(y / 16);
062  }
063
064  public int getChunkZ() {
065
066    return (int)(z / 16);
067  }
068
069  public double distance(@NotNull final Location location) {
070
071    return Math.sqrt(Math.pow(x - location.x, 2) + Math.pow(y - location.y, 2) + Math.pow(z - location.z, 2));
072  }
073
074  public double getX() {
075
076    return x;
077  }
078
079  public void setX(final double x) {
080
081    this.x = x;
082  }
083
084  public double getY() {
085
086    return y;
087  }
088
089  public void setY(final double y) {
090
091    this.y = y;
092  }
093
094  public double getZ() {
095
096    return z;
097  }
098
099  public void setZ(final double z) {
100
101    this.z = z;
102  }
103}