001/*
002 * PlotSquared, a land and world management plugin for Minecraft.
003 * Copyright (C) IntellectualSites <https://intellectualsites.com>
004 * Copyright (C) IntellectualSites team and contributors
005 *
006 * This program is free software: you can redistribute it and/or modify
007 * it under the terms of the GNU General Public License as published by
008 * the Free Software Foundation, either version 3 of the License, or
009 * (at your option) any later version.
010 *
011 * This program is distributed in the hope that it will be useful,
012 * but WITHOUT ANY WARRANTY; without even the implied warranty of
013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
014 * GNU General Public License for more details.
015 *
016 * You should have received a copy of the GNU General Public License
017 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
018 */
019package com.plotsquared.core.util;
020
021/**
022 * plot functions
023 *
024 * @deprecated Do not use
025 */
026@Deprecated(forRemoval = true, since = "6.0.0")
027public class MainUtil {
028
029    /**
030     * Cache of mapping x,y,z coordinates to the chunk array<br>
031     * - Used for efficient world generation<br>
032     */
033    @Deprecated(forRemoval = true, since = "6.0.0")
034    public static short[][] x_loc;
035    @Deprecated(forRemoval = true, since = "6.0.0")
036    public static short[][] y_loc;
037    @Deprecated(forRemoval = true, since = "6.0.0")
038    public static short[][] z_loc;
039    @Deprecated(forRemoval = true, since = "6.0.0")
040    public static short[][][] CACHE_I = null;
041    @Deprecated(forRemoval = true, since = "6.0.0")
042    public static short[][][] CACHE_J = null;
043
044    /**
045     * This cache is used for world generation and just saves a bit of calculation time when checking if something is in the plot area.
046     */
047    @Deprecated(forRemoval = true, since = "6.0.0")
048    public static void initCache() {
049        if (x_loc == null) {
050            x_loc = new short[16][4096];
051            y_loc = new short[16][4096];
052            z_loc = new short[16][4096];
053            for (int i = 0; i < 16; i++) {
054                int i4 = i << 4;
055                for (int j = 0; j < 4096; j++) {
056                    int y = i4 + (j >> 8);
057                    int a = j - ((y & 0xF) << 8);
058                    int z1 = a >> 4;
059                    int x1 = a - (z1 << 4);
060                    x_loc[i][j] = (short) x1;
061                    y_loc[i][j] = (short) y;
062                    z_loc[i][j] = (short) z1;
063                }
064            }
065        }
066        if (CACHE_I == null) {
067            CACHE_I = new short[256][16][16];
068            CACHE_J = new short[256][16][16];
069            for (int x = 0; x < 16; x++) {
070                for (int z = 0; z < 16; z++) {
071                    for (int y = 0; y < 256; y++) {
072                        short i = (short) (y >> 4);
073                        short j = (short) ((y & 0xF) << 8 | z << 4 | x);
074                        CACHE_I[y][x][z] = i;
075                        CACHE_J[y][x][z] = j;
076                    }
077                }
078            }
079        }
080    }
081
082}