001/* 002 * Trident - A Multithreaded Server Alternative 003 * Copyright 2014 The TridentSDK Team 004 * 005 * Licensed under the Apache License, Version 2.0 (the "License"); 006 * you may not use this file except in compliance with the License. 007 * You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017 018package net.tridentsdk.server.world.gen; 019 020import net.tridentsdk.base.Substance; 021import net.tridentsdk.server.world.ChunkSection; 022import net.tridentsdk.server.world.WorldUtils; 023import net.tridentsdk.world.ChunkLocation; 024import net.tridentsdk.world.gen.ChunkGenerator; 025 026import java.util.concurrent.atomic.AtomicReferenceArray; 027 028/** 029 * Generates a flat world 030 * 031 * @author The TridentSDK Team 032 */ 033public class FlatWorldGen extends ChunkGenerator { 034 public FlatWorldGen(long seed) { 035 super(seed); 036 } 037 038 @Override 039 public char[][] generateBlocks(ChunkLocation location, AtomicReferenceArray<Integer> heights) { 040 char[][] data = new char[1][ChunkSection.LENGTH]; 041 for (int x = 0; x < 16; x++) { 042 for (int z = 0; z < 16; z++) { 043 heights.set(WorldUtils.heightIndex(x, z), 3); 044 045 for (int y = 0; y < 4; y++ ) { 046 switch (y) { 047 case 0: 048 data[0][WorldUtils.blockArrayIndex(x,y,z)] = Substance.BEDROCK.asExtended(); 049 break; 050 case 1: 051 // fall through 052 case 2: 053 data[0][WorldUtils.blockArrayIndex(x,y,z)] = Substance.DIRT.asExtended(); 054 break; 055 case 3: 056 data[0][WorldUtils.blockArrayIndex(x,y,z)] = Substance.GRASS.asExtended(); 057 break; 058 } 059 060 } 061 } 062 } 063 return data; 064 } 065 066 @Override 067 public byte[][] generateData(ChunkLocation location) { 068 return new byte[0][]; 069 } 070}