Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package pl.arivi.sectors.utils;
- import org.bukkit.Location;
- import org.bukkit.World;
- import pl.arivi.sectors.data.Sector;
- import pl.arivi.sectors.managers.SectorManager;
- public class KncokUtil
- {
- public static Location correctedPosition(Location loc, int knock)
- {
- double xLoc = loc.getX();
- double zLoc = loc.getZ();
- double yLoc = loc.getY();
- Sector sector = SectorManager.getSector();
- int minX = sector.getMinX();
- int maxX = sector.getMaxX();
- int minZ = sector.getMinZ();
- int maxZ = sector.getMaxZ();
- if (xLoc <= minX)
- xLoc = minX + knock;
- else if (xLoc >= maxX) {
- xLoc = maxX - knock;
- }
- if (zLoc <= minZ)
- zLoc = minZ + knock;
- else if (zLoc >= maxZ) {
- zLoc = maxZ - knock;
- }
- double y = loc.getWorld().getHighestBlockYAt((int)xLoc, (int)zLoc) + 1.5F;
- return new Location(loc.getWorld(), Math.floor(xLoc) + 0.5D, y, Math.floor(zLoc) + 0.5D, loc.getYaw(), loc.getPitch());
- }
- public static Location pvp(Location loc, int knock)
- {
- double xLoc = loc.getX();
- double zLoc = loc.getZ();
- double yLoc = loc.getY();
- Sector sector = SectorManager.getSector();
- int minX = sector.getMinX();
- int maxX = sector.getMaxX();
- int minZ = sector.getMinZ();
- int maxZ = sector.getMaxZ();
- if (xLoc - 12.0D <= minX)
- xLoc = minX + knock;
- else if (xLoc + 12.0D >= maxX) {
- xLoc = maxX - knock;
- }
- if (zLoc - 12.0D <= minZ)
- zLoc = minZ + knock;
- else if (zLoc + 12.0D >= maxZ) {
- zLoc = maxZ - knock;
- }
- double y = loc.getWorld().getHighestBlockYAt((int)xLoc, (int)zLoc) + 1.5F;
- return new Location(loc.getWorld(), Math.floor(xLoc) + 0.5D, y, Math.floor(zLoc) + 0.5D, loc.getYaw(), loc.getPitch());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement