package net.minecraft.world.gen.layer;

import net.minecraft.world.biome.BiomeGenBase;

/**
 * + This portion of EaglercraftX contains deobfuscated Minecraft 1.8 source
 * code.
 *
 * Minecraft 1.8.8 bytecode is (c) 2015 Mojang AB. "Do not distribute!" Mod
 * Coder Pack v9.18 deobfuscation configs are (c) Copyright by the MCP Team
 *
 * EaglercraftX 1.8 patch files (c) 2022-2025 lax1dude, ayunami2000. All Rights
 * Reserved.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 *
 */
public class GenLayerDeepOcean extends GenLayer {
	public GenLayerDeepOcean(long parLong1, GenLayer parGenLayer) {
		super(parLong1);
		this.parent = parGenLayer;
	}

	/**
	 * + Returns a list of integer values generated by this layer. These may be
	 * interpreted as temperatures, rainfall amounts, or biomeList[] indices based
	 * on the particular GenLayer subclass.
	 */
	@Override
	public int[] getInts(int areaX, int areaY, int areaWidth, int areaHeight) {
		int i = areaX - 1;
		int j = areaY - 1;
		int k = areaWidth + 2;
		int l = areaHeight + 2;
		int[] aint = this.parent.getInts(i, j, k, l);
		int[] aint1 = IntCache.getIntCache(areaWidth * areaHeight);

		for (int i1 = 0; i1 < areaHeight; ++i1) {
			for (int j1 = 0; j1 < areaWidth; ++j1) {
				int k1 = aint[j1 + 1 + (i1 + 1 - 1) * (areaWidth + 2)];
				int l1 = aint[j1 + 1 + 1 + (i1 + 1) * (areaWidth + 2)];
				int i2 = aint[j1 + 1 - 1 + (i1 + 1) * (areaWidth + 2)];
				int j2 = aint[j1 + 1 + (i1 + 1 + 1) * (areaWidth + 2)];
				int k2 = aint[j1 + 1 + (i1 + 1) * k];
				int l2 = 0;
				if (k1 == 0) {
					++l2;
				}

				if (l1 == 0) {
					++l2;
				}

				if (i2 == 0) {
					++l2;
				}

				if (j2 == 0) {
					++l2;
				}

				if (k2 == 0 && l2 > 3) {
					aint1[j1 + i1 * areaWidth] = BiomeGenBase.deepOcean.biomeID;
				} else {
					aint1[j1 + i1 * areaWidth] = k2;
				}
			}
		}

		return aint1;
	}
}
