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 */ 017package net.tridentsdk.server.world.gen.brush; 018 019import net.tridentsdk.base.Substance; 020import net.tridentsdk.server.world.WorldUtils; 021import net.tridentsdk.world.ChunkLocation; 022import net.tridentsdk.world.gen.FeatureGenerator; 023import net.tridentsdk.world.gen.GeneratorRandom; 024 025import java.util.concurrent.atomic.AtomicReferenceArray; 026 027/** 028 * Creates tall grass in the world 029 * 030 * @author The TridentSDK Team 031 */ 032public class TallGrassBrush extends FeatureGenerator { 033 public TallGrassBrush(long seed) { 034 super(seed); 035 } 036 037 @Override 038 public void generate(ChunkLocation location, int relX, int relZ, GeneratorRandom random, AtomicReferenceArray<Integer> heights, ChunkManipulator manipulator) { 039 int i = WorldUtils.heightIndex(relX, relZ); 040 int top = heights.get(i); 041 if (random.under(99) < 40 && manipulator.blockAt(relX, top, relZ).substance() == Substance.GRASS) { 042 int y = top + 1; 043 manipulator.manipulate(relX, y, relZ, Substance.LONG_GRASS, (byte) 0x01); 044 } 045 } 046}