package net.minecraft.world.gen.layer;

import net.minecraft.world.WorldType;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraft.world.gen.ChunkProviderSettings;

/**
 * + 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 GenLayerBiome extends GenLayer {
	private BiomeGenBase[] field_151623_c = new BiomeGenBase[] { BiomeGenBase.desert, BiomeGenBase.desert,
			BiomeGenBase.desert, BiomeGenBase.savanna, BiomeGenBase.savanna, BiomeGenBase.plains,
			BiomeGenBase.enderForest };
	private BiomeGenBase[] field_151621_d = new BiomeGenBase[] { BiomeGenBase.forest, BiomeGenBase.roofedForest,
			BiomeGenBase.extremeHills, BiomeGenBase.plains, BiomeGenBase.birchForest, BiomeGenBase.swampland };
	private BiomeGenBase[] field_151622_e = new BiomeGenBase[] { BiomeGenBase.forest, BiomeGenBase.extremeHills,
			BiomeGenBase.taiga, BiomeGenBase.plains };
	private BiomeGenBase[] field_151620_f = new BiomeGenBase[] { BiomeGenBase.icePlains, BiomeGenBase.icePlains,
			BiomeGenBase.icePlains, BiomeGenBase.coldTaiga };
	private final ChunkProviderSettings field_175973_g;

	public GenLayerBiome(long parLong1, GenLayer parGenLayer, WorldType parWorldType, String parString1) {
		super(parLong1);
		this.parent = parGenLayer;
		if (parWorldType == WorldType.DEFAULT_1_1) {
			this.field_151623_c = new BiomeGenBase[] { BiomeGenBase.desert, BiomeGenBase.forest,
					BiomeGenBase.extremeHills, BiomeGenBase.swampland, BiomeGenBase.plains, BiomeGenBase.taiga,
					BiomeGenBase.enderForest };
			this.field_175973_g = null;
		} else if (parWorldType == WorldType.CUSTOMIZED) {
			this.field_175973_g = ChunkProviderSettings.Factory.jsonToFactory(parString1).func_177864_b();
		} else {
			this.field_175973_g = null;
		}

	}

	/**
	 * + 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 i, int j, int k, int l) {
		int[] aint = this.parent.getInts(i, j, k, l);
		int[] aint1 = IntCache.getIntCache(k * l);

		for (int i1 = 0; i1 < l; ++i1) {
			for (int j1 = 0; j1 < k; ++j1) {
				this.initChunkSeed((long) (j1 + i), (long) (i1 + j));
				int k1 = aint[j1 + i1 * k];
				int l1 = (k1 & 3840) >> 8;
				k1 = k1 & -3841;
				if (this.field_175973_g != null && this.field_175973_g.fixedBiome >= 0) {
					aint1[j1 + i1 * k] = this.field_175973_g.fixedBiome;
				} else if (isBiomeOceanic(k1)) {
					aint1[j1 + i1 * k] = k1;
				} else if (k1 == BiomeGenBase.mushroomIsland.biomeID) {
					aint1[j1 + i1 * k] = k1;
				} else if (k1 == 1) {
					if (l1 > 0) {
						if (this.nextInt(3) == 0) {
							aint1[j1 + i1 * k] = BiomeGenBase.mesaPlateau.biomeID;
						} else {
							aint1[j1 + i1 * k] = BiomeGenBase.mesaPlateau_F.biomeID;
						}
					} else {
						aint1[j1 + i1 * k] = this.field_151623_c[this.nextInt(this.field_151623_c.length)].biomeID;
					}
				} else if (k1 == 2) {
					if (l1 > 0) {
						aint1[j1 + i1 * k] = BiomeGenBase.jungle.biomeID;
					} else {
						aint1[j1 + i1 * k] = this.field_151621_d[this.nextInt(this.field_151621_d.length)].biomeID;
					}
				} else if (k1 == 3) {
					if (l1 > 0) {
						aint1[j1 + i1 * k] = BiomeGenBase.megaTaiga.biomeID;
					} else {
						aint1[j1 + i1 * k] = this.field_151622_e[this.nextInt(this.field_151622_e.length)].biomeID;
					}
				} else if (k1 == 4) {
					aint1[j1 + i1 * k] = this.field_151620_f[this.nextInt(this.field_151620_f.length)].biomeID;
				} else {
					aint1[j1 + i1 * k] = BiomeGenBase.mushroomIsland.biomeID;
				}
			}
		}

		return aint1;
	}
}
