Use default state a bit more.

This commit is contained in:
Matthew Miller
2018-06-19 11:55:35 +10:00
parent 282eca7663
commit 70aceb3837
16 changed files with 59 additions and 54 deletions

View File

@ -24,6 +24,7 @@ import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.blocks.type.BlockState;
import com.sk89q.worldedit.blocks.type.BlockTypes;
import com.sk89q.worldedit.function.LayerFunction;
import com.sk89q.worldedit.function.mask.BlockMask;
@ -38,9 +39,9 @@ import static com.google.common.base.Preconditions.checkNotNull;
*/
public class Naturalizer implements LayerFunction {
private static final BaseBlock grass = new BaseBlock(BlockTypes.GRASS_BLOCK);
private static final BaseBlock dirt = new BaseBlock(BlockTypes.DIRT);
private static final BaseBlock stone = new BaseBlock(BlockTypes.STONE);
private static final BlockState grass = BlockTypes.GRASS_BLOCK.getDefaultState();
private static final BlockState dirt = BlockTypes.DIRT.getDefaultState();
private static final BlockState stone = BlockTypes.STONE.getDefaultState();
private final EditSession editSession;
private final Mask mask;

View File

@ -22,7 +22,6 @@ package com.sk89q.worldedit.function.generator;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.blocks.type.BlockStateHolder;
import com.sk89q.worldedit.blocks.type.BlockTypes;
import com.sk89q.worldedit.function.RegionFunction;
@ -84,9 +83,9 @@ public class FloraGenerator implements RegionFunction {
*/
public static Pattern getDesertPattern() {
RandomPattern pattern = new RandomPattern();
pattern.add(new BlockPattern(new BaseBlock(BlockTypes.DEAD_BUSH)), 30);
pattern.add(new BlockPattern(new BaseBlock(BlockTypes.CACTUS)), 20);
pattern.add(new BlockPattern(new BaseBlock(BlockTypes.AIR)), 300);
pattern.add(new BlockPattern(BlockTypes.DEAD_BUSH.getDefaultState()), 30);
pattern.add(new BlockPattern(BlockTypes.CACTUS.getDefaultState()), 20);
pattern.add(new BlockPattern(BlockTypes.AIR.getDefaultState()), 300);
return pattern;
}
@ -97,9 +96,9 @@ public class FloraGenerator implements RegionFunction {
*/
public static Pattern getTemperatePattern() {
RandomPattern pattern = new RandomPattern();
pattern.add(new BlockPattern(new BaseBlock(BlockTypes.GRASS)), 300);
pattern.add(new BlockPattern(new BaseBlock(BlockTypes.POPPY)), 5);
pattern.add(new BlockPattern(new BaseBlock(BlockTypes.DANDELION)), 5);
pattern.add(new BlockPattern(BlockTypes.GRASS.getDefaultState()), 300);
pattern.add(new BlockPattern(BlockTypes.POPPY.getDefaultState()), 5);
pattern.add(new BlockPattern(BlockTypes.DANDELION.getDefaultState()), 5);
return pattern;
}

View File

@ -58,11 +58,11 @@ public class ForestGenerator implements RegionFunction {
treeGenerator.generate(editSession, position.add(0, 1, 0));
return true;
} else if (t == BlockTypes.TALL_GRASS || t == BlockTypes.DEAD_BUSH || t == BlockTypes.POPPY || t == BlockTypes.DANDELION) { // TODO: This list needs to be moved
editSession.setBlock(position, new BaseBlock(BlockTypes.AIR));
editSession.setBlock(position, BlockTypes.AIR.getDefaultState());
treeGenerator.generate(editSession, position);
return true;
} else if (t == BlockTypes.SNOW) {
editSession.setBlock(position, new BaseBlock(BlockTypes.AIR));
editSession.setBlock(position, BlockTypes.AIR.getDefaultState());
return false;
} else { // Trees won't grow on this!
return false;

View File

@ -214,6 +214,6 @@ public class GardenPatchGenerator implements RegionFunction {
* @return a melon pattern
*/
public static Pattern getMelonPattern() {
return new BlockPattern(new BaseBlock(BlockTypes.MELON_BLOCK));
return new BlockPattern(BlockTypes.MELON_BLOCK.getDefaultState());
}
}