Package Hexel.blocks.rules

Source Code of Hexel.blocks.rules.GrassKillRule

package Hexel.blocks.rules;

import Hexel.blocks.BlockDelta;
import Hexel.blocks.BlockRule;
import Hexel.blocks.BlockSimulator;
import Hexel.blocks.BlockSimulator.BlockDeltaAdder;
import Hexel.blocks.types.Block;
import Hexel.blocks.types.BlockDirt;
import Hexel.blocks.types.BlockEmpty;
import Hexel.blocks.types.BlockLeaf;
import Hexel.chunk.Chunk;
import Hexel.chunk.Chunks;
import Hexel.chunk.HighestBlockChunk;
import Hexel.math.Vector3i;

public class GrassKillRule implements BlockRule {

  private Vector3i tmp3i = new Vector3i();

  @Override
  public int run(int bx, int by, int bz, boolean fastMode, Block b, Chunk c,
      HighestBlockChunk hbc, Chunks chunks, int step, BlockDeltaAdder blockDeltaAdder) {
    BlockDirt bd = (BlockDirt)b;
    if (bd.hasGrass){
      if (bd.health < bd.getMaxHealth()){
        blockDeltaAdder.addBlockDelta(BlockDelta.Aquire(bx, by, bz, BlockDirt.Make(b.getHealth(), false), chunks.getStepsToSim(bx, by, bz, tmp3i, c)));
      }
      else {
        Block ab = chunks.getBlock(bx, by, bz+1, tmp3i, c);
        if (!(ab instanceof BlockEmpty) && !(ab instanceof BlockLeaf)){
          blockDeltaAdder.addBlockDelta(BlockDelta.Aquire(bx, by, bz, BlockDirt.Make(b.getHealth(), false), chunks.getStepsToSim(bx, by, bz, tmp3i, c)));
        }
      }
    }
    return BlockSimulator.DONT_RUN;
  }
}
TOP

Related Classes of Hexel.blocks.rules.GrassKillRule

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.