Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class FeaturePoiseTree extends Feature<NoFeatureConfig> {
- public FeaturePoiseTree(Function<Dynamic<?>, ? extends NoFeatureConfig> configFactoryIn) {
- super(configFactoryIn);
- }
- @Override
- public boolean place(IWorld world, ChunkGenerator<? extends GenerationSettings> generator, Random rand, BlockPos pos, NoFeatureConfig config) {
- int treeHeight = rand.nextInt(19) + 13;
- //Random tree top size; small(45%), medium(40%), large(15%)
- float size = rand.nextFloat();
- if(size <= 0.45) {
- size = 0;
- } else if(size >= 0.45) {
- size = 1;
- } else if(size >= 0.85) {
- size = 2;
- }
- if(world.getBlockState(pos.down()) == EEBlocks.POISE_GRASS_BLOCK.getDefaultState() && this.isAreaOpen(world, pos) || world.getBlockState(pos.down()) == Blocks.END_STONE.getDefaultState() && this.isAreaOpen(world, pos)) {
- this.buildTreeBase(world, pos, rand);
- this.buildStem(world, pos, rand, treeHeight);
- this.buildTreeTop(world, pos, rand, treeHeight, (int) size);
- this.buildPoismossCircle(world, world, rand, pos);
- return true;
- }
- return false;
- }
- private void buildTreeBase(IWorld world, BlockPos pos, Random rand) {
- int[] sideRandValues = new int[] {
- rand.nextInt(8) + 2,
- rand.nextInt(8) + 2,
- rand.nextInt(8) + 2,
- rand.nextInt(8) + 2
- };
- for(int x = pos.getX() - 1; x < pos.getX() + 2; x++) {
- for(int z = pos.getZ() - 1; z < pos.getZ() + 2; z++) {
- this.setPoiseLog(world, new BlockPos(x, pos.getY(), z), rand, true, false);
- }
- }
- for(int xN = 1; xN < sideRandValues[0] + 1; xN++) {
- this.setPoiseLog(world, pos.north().up(xN), rand, true, false);
- }
- for(int xE = 1; xE < sideRandValues[1] + 1; xE++) {
- this.setPoiseLog(world, pos.east().up(xE), rand, true, false);
- }
- for(int xS = 1; xS < sideRandValues[2] + 1; xS++) {
- this.setPoiseLog(world, pos.south().up(xS), rand, true, false);
- }
- for(int xW = 1; xW < sideRandValues[3] + 1; xW++) {
- this.setPoiseLog(world, pos.west().up(xW), rand, true, false);
- }
- }
- private void buildStem(IWorld world, BlockPos pos, Random rand, int height) {
- for(int y = 1; y < height; y++) {
- boolean doBubbles = y <= height - 2 ? false : true;
- this.setPoiseLog(world, pos.up(y), rand, false, doBubbles);
- }
- }
- private void buildTreeTop(IWorld world, BlockPos pos, Random rand, int arrivedPos, int size) {
- if(size == 0 || size == 2) {
- for(int x = pos.getX() - 1; x <= pos.getX() + 1; x++) {
- for(int z = pos.getZ() - 1; z <= pos.getZ() + 1; z++) {
- this.setPoiseLog(world, new BlockPos(x, pos.up(arrivedPos).getY(), z), rand, false, true);
- }
- }
- for(int x = pos.getX() - 1; x <= pos.getX() + 1; x++) {
- for(int z = pos.getZ() - 1; z <= pos.getZ() + 1; z++) {
- this.setBlockState(world, new BlockPos(x, pos.up(arrivedPos + 1).getY(), z), EEBlocks.POISMOSS_EUMUS.getDefaultState());
- }
- }
- this.setPoiseLog(world, pos.up(arrivedPos).north(2), rand, false, true);
- this.setPoiseLog(world, pos.up(arrivedPos).east(2), rand, false, true);
- this.setPoiseLog(world, pos.up(arrivedPos).south(2), rand, false, true);
- this.setPoiseLog(world, pos.up(arrivedPos).west(2), rand, false, true);
- this.setPoiseLog(world, pos.up(arrivedPos).north(3).up(), rand, false, true);
- this.setPoiseLog(world, pos.up(arrivedPos).east(3).up(), rand, false, true);
- this.setPoiseLog(world, pos.up(arrivedPos).south(3).up(), rand, false, true);
- this.setPoiseLog(world, pos.up(arrivedPos).west(3).up(), rand, false, true);
- this.setPoiseLog(world, pos.up(arrivedPos).north(2).up().east(), rand, false, true);
- this.setPoiseLog(world, pos.up(arrivedPos).north(2).up().west(), rand, false, true);
- this.setPoiseLog(world, pos.up(arrivedPos).east(2).up().north(), rand, false, true);
- this.setPoiseLog(world, pos.up(arrivedPos).east(2).up().south(), rand, false, true);
- this.setPoiseLog(world, pos.up(arrivedPos).south(2).up().east(), rand, false, true);
- this.setPoiseLog(world, pos.up(arrivedPos).south(2).up().west(), rand, false, true);
- this.setPoiseLog(world, pos.up(arrivedPos).west(2).up().north(), rand, false, true);
- this.setPoiseLog(world, pos.up(arrivedPos).west(2).up().south(), rand, false, true);
- this.setBlockState(world, pos.up(arrivedPos).north(2).up(), EEBlocks.POISMOSS_EUMUS.getDefaultState());
- this.setBlockState(world, pos.up(arrivedPos).east(2).up(), EEBlocks.POISMOSS_EUMUS.getDefaultState());
- this.setBlockState(world, pos.up(arrivedPos).south(2).up(), EEBlocks.POISMOSS_EUMUS.getDefaultState());
- this.setBlockState(world, pos.up(arrivedPos).west(2).up(), EEBlocks.POISMOSS_EUMUS.getDefaultState());
- int[] sideRandValues = new int[] {
- rand.nextInt(3) + 1,
- rand.nextInt(3) + 1,
- rand.nextInt(3) + 1,
- rand.nextInt(3) + 1
- };
- for(int yn = 1; yn <= sideRandValues[0]; yn++) {
- this.setPoiseLog(world, pos.up(arrivedPos).north(3).up().up(yn), rand, false, true);
- if(yn == 1 && rand.nextFloat() <= 0.25F) {
- if(rand.nextBoolean()) {
- this.setPoiseLog(world, pos.up(arrivedPos).north(3).east().up().up(yn), rand, false, true);
- } else {
- this.setPoiseLog(world, pos.up(arrivedPos).north(3).west().up().up(yn), rand, false, true);
- }
- }
- }
- for(int ye = 1; ye <= sideRandValues[1]; ye++) {
- this.setPoiseLog(world, pos.up(arrivedPos).east(3).up().up(ye), rand, false, true);
- if(ye == 1 && rand.nextFloat() <= 0.25F) {
- if(rand.nextBoolean()) {
- this.setPoiseLog(world, pos.up(arrivedPos).east(3).south().up().up(ye), rand, false, true);
- } else {
- this.setPoiseLog(world, pos.up(arrivedPos).east(3).north().up().up(ye), rand, false, true);
- }
- }
- }
- for(int ys = 1; ys <= sideRandValues[2]; ys++) {
- this.setPoiseLog(world, pos.up(arrivedPos).south(3).up().up(ys), rand, false, true);
- if(ys == 1 && rand.nextFloat() <= 0.25F) {
- if(rand.nextBoolean()) {
- this.setPoiseLog(world, pos.up(arrivedPos).south(3).west().up().up(ys), rand, false, true);
- } else {
- this.setPoiseLog(world, pos.up(arrivedPos).south(3).east().up().up(ys), rand, false, true);
- }
- }
- }
- for(int yw = 1; yw <= sideRandValues[3]; yw++) {
- this.setPoiseLog(world, pos.up(arrivedPos).west(3).up().up(yw), rand, false, true);
- if(yw == 1 && rand.nextFloat() <= 0.25F) {
- if(rand.nextBoolean()) {
- this.setPoiseLog(world, pos.up(arrivedPos).west(3).north().up().up(yw), rand, false, true);
- } else {
- this.setPoiseLog(world, pos.up(arrivedPos).west(3).south().up().up(yw), rand, false, true);
- }
- }
- }
- this.addTreeDomeTop(world, pos, rand, arrivedPos, 0);
- } else if(size == 1) {
- BlockPos origin = pos.up(arrivedPos);
- this.setPoiseLog(world, origin, rand, false, true);
- this.setPoiseLog(world, origin.north(), rand, false, true);
- this.setPoiseLog(world, origin.east(), rand, false, true);
- this.setPoiseLog(world, origin.south(), rand, false, true);
- this.setPoiseLog(world, origin.west(), rand, false, true);
- for(int x = origin.getX() - 2; x <= origin.getX() + 2; x++) {
- for(int z = origin.getZ() - 1; z <= origin.getZ() + 1; z++) {
- this.setPoiseLog(world, new BlockPos(x, origin.up().getY(), z), rand, false, true);
- }
- }
- for(int x = origin.getX() - 1; x <= origin.getX() + 1; x++) {
- for(int z = origin.getZ() - 2; z <= origin.getZ() + 2; z++) {
- this.setPoiseLog(world, new BlockPos(x, origin.up().getY(), z), rand, false, true);
- }
- }
- this.setPoiseLog(world, origin.up(2).north(3), rand, false, true);
- this.setPoiseLog(world, origin.up(2).north(3).west(), rand, false, true);
- this.setPoiseLog(world, origin.up(2).north(3).east(), rand, false, true);
- this.setPoiseLog(world, origin.up(2).east(3), rand, false, true);
- this.setPoiseLog(world, origin.up(2).east(3).north(), rand, false, true);
- this.setPoiseLog(world, origin.up(2).east(3).south(), rand, false, true);
- this.setPoiseLog(world, origin.up(2).south(3), rand, false, true);
- this.setPoiseLog(world, origin.up(2).south(3).west(), rand, false, true);
- this.setPoiseLog(world, origin.up(2).south(3).east(), rand, false, true);
- this.setPoiseLog(world, origin.up(2).west(3), rand, false, true);
- this.setPoiseLog(world, origin.up(2).west(3).north(), rand, false, true);
- this.setPoiseLog(world, origin.up(2).west(3).south(), rand, false, true);
- this.setPoiseLog(world, origin.up(2).north(2).west(2), rand, false, true);
- this.setPoiseLog(world, origin.up(2).north(2).east(2), rand, false, true);
- this.setPoiseLog(world, origin.up(2).south(2).west(2), rand, false, true);
- this.setPoiseLog(world, origin.up(2).south(2).east(2), rand, false, true);
- for(int x = origin.getX() - 2; x <= origin.getX() + 2; x++) {
- for(int z = origin.getZ() - 1; z <= origin.getZ() + 1; z++) {
- world.setBlockState(new BlockPos(x, origin.up(2).getY(), z), EEBlocks.POISMOSS_EUMUS.getDefaultState(), 2);
- }
- }
- for(int x = origin.getX() - 1; x <= origin.getX() + 1; x++) {
- for(int z = origin.getZ() - 2; z <= origin.getZ() + 2; z++) {
- world.setBlockState(new BlockPos(x, origin.up(2).getY(), z), EEBlocks.POISMOSS_EUMUS.getDefaultState(), 2);
- }
- }
- int[] sideRandValues = new int[] {
- rand.nextInt(3) + 1,
- rand.nextInt(3) + 1,
- rand.nextInt(3) + 1,
- rand.nextInt(3) + 1
- };
- for(int yn = 1; yn <= sideRandValues[0]; yn++) {
- this.setPoiseLog(world, pos.up(arrivedPos).north(4).up(2).up(yn), rand, false, true);
- if(yn == 1 && rand.nextFloat() <= 0.25F) {
- if(rand.nextBoolean()) {
- this.setPoiseLog(world, pos.up(arrivedPos).north(4).east().up(2).up(yn), rand, false, true);
- } else {
- this.setPoiseLog(world, pos.up(arrivedPos).north(4).west().up(2).up(yn), rand, false, true);
- }
- }
- }
- for(int yn = 1; yn <= sideRandValues[1]; yn++) {
- this.setPoiseLog(world, pos.up(arrivedPos).east(4).up(2).up(yn), rand, false, true);
- if(yn == 1 && rand.nextFloat() <= 0.25F) {
- if(rand.nextBoolean()) {
- this.setPoiseLog(world, pos.up(arrivedPos).east(4).north().up(2).up(yn), rand, false, true);
- } else {
- this.setPoiseLog(world, pos.up(arrivedPos).east(4).south().up(2).up(yn), rand, false, true);
- }
- }
- }
- for(int yn = 1; yn <= sideRandValues[2]; yn++) {
- this.setPoiseLog(world, pos.up(arrivedPos).south(4).up(2).up(yn), rand, false, true);
- if(yn == 1 && rand.nextFloat() <= 0.25F) {
- if(rand.nextBoolean()) {
- this.setPoiseLog(world, pos.up(arrivedPos).south(4).east().up(2).up(yn), rand, false, true);
- } else {
- this.setPoiseLog(world, pos.up(arrivedPos).south(4).west().up(2).up(yn), rand, false, true);
- }
- }
- }
- for(int yn = 1; yn <= sideRandValues[3]; yn++) {
- this.setPoiseLog(world, pos.up(arrivedPos).west(4).up(2).up(yn), rand, false, true);
- if(yn == 1 && rand.nextFloat() <= 0.25F) {
- if(rand.nextBoolean()) {
- this.setPoiseLog(world, pos.up(arrivedPos).west(4).north().up(2).up(yn), rand, false, true);
- } else {
- this.setPoiseLog(world, pos.up(arrivedPos).west(4).south().up(2).up(yn), rand, false, true);
- }
- }
- }
- //Corner bits
- boolean[] doCornerFeature = new boolean[] {
- rand.nextInt(4) == 0 ? true : false,
- rand.nextInt(4) == 0 ? true : false,
- rand.nextInt(4) == 0 ? true : false,
- rand.nextInt(4) == 0 ? true : false,
- };
- if(doCornerFeature[0]) {
- BlockPos cornerOrigin = origin.up(3).north(3).west(2);
- if(rand.nextBoolean()) {
- this.setPoiseLog(world, cornerOrigin, rand, false, true);
- this.setPoiseLog(world, cornerOrigin.west(), rand, false, true);
- this.setPoiseLog(world, cornerOrigin.west().up(), rand, false, true);
- this.setPoiseLog(world, cornerOrigin.south().west(), rand, false, true);
- } else {
- this.setPoiseLog(world, cornerOrigin, rand, false, true);
- this.setPoiseLog(world, cornerOrigin.west().up(), rand, false, true);
- if(rand.nextBoolean()) this.setPoiseLog(world, cornerOrigin.west().up(2), rand, false, true);
- }
- }
- if(doCornerFeature[1]) {
- BlockPos cornerOrigin = origin.up(3).east(3).north(2);
- if(rand.nextBoolean()) {
- this.setPoiseLog(world, cornerOrigin, rand, false, true);
- this.setPoiseLog(world, cornerOrigin.north(), rand, false, true);
- this.setPoiseLog(world, cornerOrigin.north().up(), rand, false, true);
- this.setPoiseLog(world, cornerOrigin.west().north(), rand, false, true);
- } else {
- this.setPoiseLog(world, cornerOrigin, rand, false, true);
- this.setPoiseLog(world, cornerOrigin.north().up(), rand, false, true);
- if(rand.nextBoolean()) this.setPoiseLog(world, cornerOrigin.up(2).north(), rand, false, true);
- }
- }
- if(doCornerFeature[2]) {
- BlockPos cornerOrigin = origin.up(3).south(3).east(2);
- if(rand.nextBoolean()) {
- this.setPoiseLog(world, cornerOrigin, rand, false, true);
- this.setPoiseLog(world, cornerOrigin.east(), rand, false, true);
- this.setPoiseLog(world, cornerOrigin.east().up(), rand, false, true);
- this.setPoiseLog(world, cornerOrigin.north().east(), rand, false, true);
- } else {
- this.setPoiseLog(world, cornerOrigin, rand, false, true);
- this.setPoiseLog(world, cornerOrigin.east().up(), rand, false, true);
- if(rand.nextBoolean()) this.setPoiseLog(world, cornerOrigin.up(2).east(), rand, false, true);
- }
- }
- if(doCornerFeature[3]) {
- BlockPos cornerOrigin = origin.up(3).west(3).south(2);
- if(rand.nextBoolean()) {
- this.setPoiseLog(world, cornerOrigin, rand, false, true);
- this.setPoiseLog(world, cornerOrigin.south(), rand, false, true);
- this.setPoiseLog(world, cornerOrigin.south().up(), rand, false, true);
- this.setPoiseLog(world, cornerOrigin.east().south(), rand, false, true);
- } else {
- this.setPoiseLog(world, cornerOrigin, rand, false, true);
- this.setPoiseLog(world, cornerOrigin.up().south(), rand, false, true);
- if(rand.nextBoolean()) this.setPoiseLog(world, cornerOrigin.up(2).south(), rand, false, true);
- }
- }
- this.addTreeDomeTop(world, pos, rand, arrivedPos, 1);
- }
- }
- private void addTreeDomeTop(IWorld world, BlockPos pos, Random rand, int arrivedPos, int size) {
- BlockPos origin = pos.up(arrivedPos);
- if(size == 0) {
- //North
- GenerationUtils.fillAreaWithBlockCube(world, origin.north(3).up(2).west().getX(), origin.north(3).up(2).west().getY(), origin.north(3).up(2).east().getZ(), origin.north(3).up(2).east().getX(), origin.north(3).up(6).east().getY(), origin.north(3).up(2).east().getZ(), EEBlocks.POISE_CLUSTER.getDefaultState());
- GenerationUtils.fillAreaWithBlockCube(world, origin.north(3).up(3).west(2).getX(), origin.north(3).up(3).west(2).getY(), origin.north(3).up(3).west(2).getZ(), origin.north(3).up(3).west(2).getX(), origin.north(3).up(5).west(2).getY(), origin.north(3).up(3).west(2).getZ(), EEBlocks.POISE_CLUSTER.getDefaultState());
- GenerationUtils.fillAreaWithBlockCube(world, origin.north(3).up(3).east(2).getX(), origin.north(3).up(3).east(2).getY(), origin.north(3).up(3).east(2).getZ(), origin.north(3).up(3).east(2).getX(), origin.north(3).up(5).east(2).getY(), origin.north(3).up(3).east(2).getZ(), EEBlocks.POISE_CLUSTER.getDefaultState());
- //East
- GenerationUtils.fillAreaWithBlockCube(world, origin.east(3).up(2).north().getX(), origin.east(3).up(2).north().getY(), origin.east(3).up(2).north().getZ(), origin.east(3).up(2).south().getX(), origin.east(3).up(6).south().getY(), origin.east(3).up(2).south().getZ(), EEBlocks.POISE_CLUSTER.getDefaultState());
- GenerationUtils.fillAreaWithBlockCube(world, origin.east(3).up(3).north(2).getX(), origin.east(3).up(3).north(2).getY(), origin.east(3).up(3).north(2).getZ(), origin.east(3).up(3).north(2).getX(), origin.east(3).up(5).north(2).getY(), origin.east(3).up(3).north(2).getZ(), EEBlocks.POISE_CLUSTER.getDefaultState());
- GenerationUtils.fillAreaWithBlockCube(world, origin.east(3).up(3).south(2).getX(), origin.east(3).up(3).south(2).getY(), origin.east(3).up(3).south(2).getZ(), origin.east(3).up(3).south(2).getX(), origin.east(3).up(5).south(2).getY(), origin.east(3).up(3).south(2).getZ(), EEBlocks.POISE_CLUSTER.getDefaultState());
- //South
- GenerationUtils.fillAreaWithBlockCube(world, origin.south(3).up(2).west().getX(), origin.south(3).up(2).west().getY(), origin.south(3).up(2).west().getZ(), origin.south(3).up(2).east().getX(), origin.south(3).up(6).east().getY(), origin.south(3).up(2).east().getZ(), EEBlocks.POISE_CLUSTER.getDefaultState());
- GenerationUtils.fillAreaWithBlockCube(world, origin.south(3).up(3).west(2).getX(), origin.south(3).up(3).west(2).getY(), origin.south(3).up(3).west(2).getZ(), origin.south(3).up(3).west(2).getX(), origin.south(3).up(5).west(2).getY(), origin.south(3).up(3).west(2).getZ(), EEBlocks.POISE_CLUSTER.getDefaultState());
- GenerationUtils.fillAreaWithBlockCube(world, origin.south(3).up(3).east(2).getX(), origin.south(3).up(3).east(2).getY(), origin.south(3).up(3).east(2).getZ(), origin.south(3).up(3).east(2).getX(), origin.south(3).up(5).east(2).getY(), origin.south(3).up(3).east(2).getZ(), EEBlocks.POISE_CLUSTER.getDefaultState());
- //West
- GenerationUtils.fillAreaWithBlockCube(world, origin.west(3).up(2).north().getX(), origin.west(3).up(2).north().getY(), origin.west(3).up(2).north().getZ(), origin.west(3).up(2).south().getX(), origin.west(3).up(6).south().getY(), origin.west(3).up(2).south().getZ(), EEBlocks.POISE_CLUSTER.getDefaultState());
- GenerationUtils.fillAreaWithBlockCube(world, origin.west(3).up(3).north(2).getX(), origin.west(3).up(3).north(2).getY(), origin.west(3).up(3).north(2).getZ(), origin.west(3).up(3).north(2).getX(), origin.west(3).up(5).north(2).getY(), origin.west(3).up(3).north(2).getZ(), EEBlocks.POISE_CLUSTER.getDefaultState());
- GenerationUtils.fillAreaWithBlockCube(world, origin.west(3).up(3).south(2).getX(), origin.west(3).up(3).south(2).getY(), origin.west(3).up(3).south(2).getZ(), origin.west(3).up(3).south(2).getX(), origin.west(3).up(5).south(2).getY(), origin.west(3).up(3).south(2).getZ(), EEBlocks.POISE_CLUSTER.getDefaultState());
- //Corners
- this.setPoiseCluster(world, origin.north(2).up(2).west(2));
- this.setPoiseCluster(world, origin.north(2).up(2).east(2));
- this.setPoiseCluster(world, origin.north(2).up(6).west(2));
- this.setPoiseCluster(world, origin.north(2).up(6).east(2));
- this.setPoiseCluster(world, origin.east(2).up(2).north(2));
- this.setPoiseCluster(world, origin.east(2).up(2).south(2));
- this.setPoiseCluster(world, origin.east(2).up(6).north(2));
- this.setPoiseCluster(world, origin.east(2).up(6).south(2));
- this.setPoiseCluster(world, origin.south(2).up(2).east(2));
- this.setPoiseCluster(world, origin.south(2).up(2).west(2));
- this.setPoiseCluster(world, origin.south(2).up(6).east(2));
- this.setPoiseCluster(world, origin.south(2).up(6).west(2));
- this.setPoiseCluster(world, origin.west(2).up(2).south(2));
- this.setPoiseCluster(world, origin.west(2).up(2).north(2));
- this.setPoiseCluster(world, origin.west(2).up(6).south(2));
- this.setPoiseCluster(world, origin.west(2).up(6).north(2));
- //Top
- GenerationUtils.fillAreaWithBlockCube(world, origin.north().west(2).up(7).getX(), origin.north().west(2).up(7).getY(), origin.north().west(2).up(7).getZ(), origin.south().east(2).up(7).getX(), origin.south().east(2).up(7).getY(), origin.south().east(2).up(7).getZ(), EEBlocks.POISE_CLUSTER.getDefaultState());
- this.setPoiseCluster(world, origin.north(2).west().up(7));
- this.setPoiseCluster(world, origin.north(2).up(7));
- this.setPoiseCluster(world, origin.north(2).east().up(7));
- this.setPoiseCluster(world, origin.south(2).west().up(7));
- this.setPoiseCluster(world, origin.south(2).up(7));
- this.setPoiseCluster(world, origin.south(2).east().up(7));
- } else if(size == 1) {
- //North
- GenerationUtils.fillAreaWithBlockCube(world, origin.north(4).up(3).west().getX(), origin.north(4).up(3).west().getY(), origin.north(4).up(3).east().getZ(), origin.north(4).up(3).east().getX(), origin.north(4).up(7).east().getY(), origin.north(4).up(3).east().getZ(), EEBlocks.POISE_CLUSTER.getDefaultState());
- GenerationUtils.fillAreaWithBlockCube(world, origin.north(4).up(4).west(2).getX(), origin.north(4).up(4).west(2).getY(), origin.north(4).up(4).west(2).getZ(), origin.north(4).up(4).west(2).getX(), origin.north(4).up(6).west(2).getY(), origin.north(4).up(4).west(2).getZ(), EEBlocks.POISE_CLUSTER.getDefaultState());
- GenerationUtils.fillAreaWithBlockCube(world, origin.north(4).up(4).east(2).getX(), origin.north(4).up(4).east(2).getY(), origin.north(4).up(4).east(2).getZ(), origin.north(4).up(4).east(2).getX(), origin.north(4).up(6).east(2).getY(), origin.north(4).up(4).east(2).getZ(), EEBlocks.POISE_CLUSTER.getDefaultState());
- //East
- GenerationUtils.fillAreaWithBlockCube(world, origin.east(4).up(3).north().getX(), origin.east(4).up(3).north().getY(), origin.east(4).up(3).north().getZ(), origin.east(4).up(3).south().getX(), origin.east(4).up(7).south().getY(), origin.east(4).up(3).south().getZ(), EEBlocks.POISE_CLUSTER.getDefaultState());
- GenerationUtils.fillAreaWithBlockCube(world, origin.east(4).up(4).north(2).getX(), origin.east(4).up(4).north(2).getY(), origin.east(4).up(4).north(2).getZ(), origin.east(4).up(4).north(2).getX(), origin.east(4).up(6).north(2).getY(), origin.east(4).up(4).north(2).getZ(), EEBlocks.POISE_CLUSTER.getDefaultState());
- GenerationUtils.fillAreaWithBlockCube(world, origin.east(4).up(4).south(2).getX(), origin.east(4).up(4).south(2).getY(), origin.east(4).up(4).south(2).getZ(), origin.east(4).up(4).south(2).getX(), origin.east(4).up(6).south(2).getY(), origin.east(4).up(4).south(2).getZ(), EEBlocks.POISE_CLUSTER.getDefaultState());
- //South
- GenerationUtils.fillAreaWithBlockCube(world, origin.south(4).up(3).west().getX(), origin.south(4).up(3).west().getY(), origin.south(4).up(3).west().getZ(), origin.south(4).up(3).east().getX(), origin.south(4).up(7).east().getY(), origin.south(4).up(3).east().getZ(), EEBlocks.POISE_CLUSTER.getDefaultState());
- GenerationUtils.fillAreaWithBlockCube(world, origin.south(4).up(4).west(2).getX(), origin.south(4).up(4).west(2).getY(), origin.south(4).up(4).west(2).getZ(), origin.south(4).up(4).west(2).getX(), origin.south(4).up(6).west(2).getY(), origin.south(4).up(4).west(2).getZ(), EEBlocks.POISE_CLUSTER.getDefaultState());
- GenerationUtils.fillAreaWithBlockCube(world, origin.south(4).up(4).east(2).getX(), origin.south(4).up(4).east(2).getY(), origin.south(4).up(4).east(2).getZ(), origin.south(4).up(4).east(2).getX(), origin.south(4).up(6).east(2).getY(), origin.south(4).up(4).east(2).getZ(), EEBlocks.POISE_CLUSTER.getDefaultState());
- //West
- GenerationUtils.fillAreaWithBlockCube(world, origin.west(4).up(3).north().getX(), origin.west(4).up(3).north().getY(), origin.west(4).up(3).north().getZ(), origin.west(4).up(3).south().getX(), origin.west(4).up(7).south().getY(), origin.west(4).up(3).south().getZ(), EEBlocks.POISE_CLUSTER.getDefaultState());
- GenerationUtils.fillAreaWithBlockCube(world, origin.west(4).up(4).north(2).getX(), origin.west(4).up(4).north(2).getY(), origin.west(4).up(4).north(2).getZ(), origin.west(4).up(4).north(2).getX(), origin.west(4).up(6).north(2).getY(), origin.west(4).up(4).north(2).getZ(), EEBlocks.POISE_CLUSTER.getDefaultState());
- GenerationUtils.fillAreaWithBlockCube(world, origin.west(4).up(4).south(2).getX(), origin.west(4).up(4).south(2).getY(), origin.west(4).up(4).south(2).getZ(), origin.west(4).up(4).south(2).getX(), origin.west(4).up(6).south(2).getY(), origin.west(4).up(4).south(2).getZ(), EEBlocks.POISE_CLUSTER.getDefaultState());
- //Corners
- this.setPoiseCluster(world, origin.up(3).north(3).west(2));
- this.setPoiseCluster(world, origin.up(3).north(3).west(3));
- this.setPoiseCluster(world, origin.up(3).north(2).west(3));
- this.setPoiseCluster(world, origin.up(4).north(3).west(3));
- this.setPoiseCluster(world, origin.up(5).north(3).west(3));
- this.setPoiseCluster(world, origin.up(6).north(3).west(3));
- this.setPoiseCluster(world, origin.up(7).north(3).west(2));
- this.setPoiseCluster(world, origin.up(7).north(3).west(3));
- this.setPoiseCluster(world, origin.up(7).north(2).west(3));
- this.setPoiseCluster(world, origin.up(3).east(3).north(2));
- this.setPoiseCluster(world, origin.up(3).east(3).north(3));
- this.setPoiseCluster(world, origin.up(3).east(2).north(3));
- this.setPoiseCluster(world, origin.up(4).east(3).north(3));
- this.setPoiseCluster(world, origin.up(5).east(3).north(3));
- this.setPoiseCluster(world, origin.up(6).east(3).north(3));
- this.setPoiseCluster(world, origin.up(7).east(3).north(2));
- this.setPoiseCluster(world, origin.up(7).east(3).north(3));
- this.setPoiseCluster(world, origin.up(7).east(2).north(3));
- this.setPoiseCluster(world, origin.up(3).south(3).east(2));
- this.setPoiseCluster(world, origin.up(3).south(3).east(3));
- this.setPoiseCluster(world, origin.up(3).south(2).east(3));
- this.setPoiseCluster(world, origin.up(4).south(3).east(3));
- this.setPoiseCluster(world, origin.up(5).south(3).east(3));
- this.setPoiseCluster(world, origin.up(6).south(3).east(3));
- this.setPoiseCluster(world, origin.up(7).south(3).east(2));
- this.setPoiseCluster(world, origin.up(7).south(3).east(3));
- this.setPoiseCluster(world, origin.up(7).south(2).east(3));
- this.setPoiseCluster(world, origin.up(3).west(3).south(2));
- this.setPoiseCluster(world, origin.up(3).west(3).south(3));
- this.setPoiseCluster(world, origin.up(3).west(2).south(3));
- this.setPoiseCluster(world, origin.up(4).west(3).south(3));
- this.setPoiseCluster(world, origin.up(5).west(3).south(3));
- this.setPoiseCluster(world, origin.up(6).west(3).south(3));
- this.setPoiseCluster(world, origin.up(7).west(3).south(2));
- this.setPoiseCluster(world, origin.up(7).west(3).south(3));
- this.setPoiseCluster(world, origin.up(7).west(2).south(3));
- //Top
- this.setPoiseCluster(world, origin.up(8).west(2).south(2));
- this.setPoiseCluster(world, origin.up(8).south(2).east(2));
- this.setPoiseCluster(world, origin.up(8).east(2).north(2));
- this.setPoiseCluster(world, origin.up(8).north(2).west(2));
- this.setPoiseCluster(world, origin.up(8).north(3).west());
- this.setPoiseCluster(world, origin.up(8).north(3));
- this.setPoiseCluster(world, origin.up(8).north(3).east());
- this.setPoiseCluster(world, origin.up(8).east(3).north());
- this.setPoiseCluster(world, origin.up(8).east(3));
- this.setPoiseCluster(world, origin.up(8).east(3).south());
- this.setPoiseCluster(world, origin.up(8).south(3).east());
- this.setPoiseCluster(world, origin.up(8).south(3));
- this.setPoiseCluster(world, origin.up(8).south(3).west());
- this.setPoiseCluster(world, origin.up(8).west(3).south());
- this.setPoiseCluster(world, origin.up(8).west(3));
- this.setPoiseCluster(world, origin.up(8).west(3).north());
- GenerationUtils.fillAreaWithBlockCube(world, origin.north().west(2).up(9).getX(), origin.north().west(2).up(9).getY(), origin.north().west(2).up(9).getZ(), origin.south().east(2).up(9).getX(), origin.south().east(2).up(9).getY(), origin.south().east(2).up(9).getZ(), EEBlocks.POISE_CLUSTER.getDefaultState());
- this.setPoiseCluster(world, origin.north(2).west().up(9));
- this.setPoiseCluster(world, origin.north(2).up(9));
- this.setPoiseCluster(world, origin.north(2).east().up(9));
- this.setPoiseCluster(world, origin.south(2).west().up(9));
- this.setPoiseCluster(world, origin.south(2).up(9));
- this.setPoiseCluster(world, origin.south(2).east().up(9));
- }
- }
- private void buildSideBubble(IWorld world, BlockPos pos, Random rand) {
- int variant = rand.nextInt(100);
- if(variant >= 49) {
- Direction randDir = Direction.byIndex(rand.nextInt(4) + 2);
- this.setPoiseCluster(world, pos.offset(randDir));
- } else if(variant <= 15) {
- world.setBlockState(pos.up(), EEBlocks.POISE_LOG_GLOWING.getDefaultState(), 2);
- this.setPoiseCluster(world, pos.north());
- this.setPoiseCluster(world, pos.east());
- this.setPoiseCluster(world, pos.south());
- this.setPoiseCluster(world, pos.west());
- this.setPoiseCluster(world, pos.north().up());
- this.setPoiseCluster(world, pos.east().up());
- this.setPoiseCluster(world, pos.south().up());
- this.setPoiseCluster(world, pos.west().up());
- } else if(variant >= 16) {
- Direction randDir = Direction.byIndex(rand.nextInt(4) + 2);
- if(randDir == Direction.NORTH) {
- world.setBlockState(pos.up(), EEBlocks.POISE_LOG_GLOWING.getDefaultState(), 2);
- this.setPoiseCluster(world, pos.north());
- this.setPoiseCluster(world, pos.north().east());
- this.setPoiseCluster(world, pos.east());
- this.setPoiseCluster(world, pos.north().up());
- this.setPoiseCluster(world, pos.north().east().up());
- this.setPoiseCluster(world, pos.east().up());
- } else if(randDir == Direction.EAST) {
- world.setBlockState(pos.up(), EEBlocks.POISE_LOG_GLOWING.getDefaultState(), 2);
- this.setPoiseCluster(world, pos.east());
- this.setPoiseCluster(world, pos.east().south());
- this.setPoiseCluster(world, pos.south());
- this.setPoiseCluster(world, pos.east().up());
- this.setPoiseCluster(world, pos.east().south().up());
- this.setPoiseCluster(world, pos.south().up());
- } else if(randDir == Direction.SOUTH) {
- world.setBlockState(pos.up(), EEBlocks.POISE_LOG_GLOWING.getDefaultState(), 2);
- this.setPoiseCluster(world, pos.south());
- this.setPoiseCluster(world, pos.south().west());
- this.setPoiseCluster(world, pos.west());
- this.setPoiseCluster(world, pos.south().up());
- this.setPoiseCluster(world, pos.south().west().up());
- this.setPoiseCluster(world, pos.west().up());
- } else if(randDir == Direction.WEST) {
- world.setBlockState(pos.up(), EEBlocks.POISE_LOG_GLOWING.getDefaultState(), 2);
- this.setPoiseCluster(world, pos.west());
- this.setPoiseCluster(world, pos.west().north());
- this.setPoiseCluster(world, pos.north());
- this.setPoiseCluster(world, pos.west().up());
- this.setPoiseCluster(world, pos.west().north().up());
- this.setPoiseCluster(world, pos.north().up());
- }
- } else if(variant >= 30) {
- Direction randDir = Direction.byIndex(rand.nextInt(4) + 2);
- if(randDir == Direction.NORTH) {
- world.setBlockState(pos.up(), EEBlocks.POISE_LOG_GLOWING.getDefaultState(), 2);
- this.setPoiseCluster(world, pos.north());
- this.setPoiseCluster(world, pos.north().west());
- this.setPoiseCluster(world, pos.north(2).west());
- this.setPoiseCluster(world, pos.north().west().up());
- this.setPoiseCluster(world, pos.north().west().down());
- this.setPoiseCluster(world, pos.north().west(2));
- this.setPoiseCluster(world, pos.west());
- } else if(randDir == Direction.EAST) {
- world.setBlockState(pos.up(), EEBlocks.POISE_LOG_GLOWING.getDefaultState(), 2);
- this.setPoiseCluster(world, pos.east());
- this.setPoiseCluster(world, pos.east().north());
- this.setPoiseCluster(world, pos.east(2).north());
- this.setPoiseCluster(world, pos.east().north().up());
- this.setPoiseCluster(world, pos.east().north().down());
- this.setPoiseCluster(world, pos.east().north(2));
- this.setPoiseCluster(world, pos.north());
- } else if(randDir == Direction.SOUTH) {
- world.setBlockState(pos.up(), EEBlocks.POISE_LOG_GLOWING.getDefaultState(), 2);
- this.setPoiseCluster(world, pos.south());
- this.setPoiseCluster(world, pos.south().east());
- this.setPoiseCluster(world, pos.south(2).east());
- this.setPoiseCluster(world, pos.south().east().up());
- this.setPoiseCluster(world, pos.south().east().down());
- this.setPoiseCluster(world, pos.south().east(2));
- this.setPoiseCluster(world, pos.east());
- } else if(randDir == Direction.WEST) {
- world.setBlockState(pos.up(), EEBlocks.POISE_LOG_GLOWING.getDefaultState(), 2);
- this.setPoiseCluster(world, pos.west());
- this.setPoiseCluster(world, pos.west().south());
- this.setPoiseCluster(world, pos.west(2).south());
- this.setPoiseCluster(world, pos.west().south().up());
- this.setPoiseCluster(world, pos.west().south().down());
- this.setPoiseCluster(world, pos.west().south(2));
- this.setPoiseCluster(world, pos.south());
- }
- }
- }
- public void buildPoismossCircle(IWorld world, IWorldGenerationReader reader, Random random, BlockPos pos) {
- this.placePoismossCircle(world, reader, pos.west().north());
- this.placePoismossCircle(world, reader, pos.east(2).north());
- this.placePoismossCircle(world, reader, pos.west().south(2));
- this.placePoismossCircle(world, reader, pos.east(2).south(2));
- for(int i = 0; i < 5; ++i) {
- int j = random.nextInt(64);
- int k = j % 8;
- int l = j / 8;
- if (k == 0 || k == 7 || l == 0 || l == 7) {
- this.placePoismossCircle(world, reader, pos.add(-3 + k, 0, -3 + l));
- }
- }
- }
- private void placePoismossCircle(IWorld world, IWorldGenerationReader reader, BlockPos center) {
- for(int i = -2; i <= 2; ++i) {
- for(int j = -2; j <= 2; ++j) {
- if (Math.abs(i) != 2 || Math.abs(j) != 2) {
- this.placePoismossAt(world, reader, center.add(i, 0, j));
- }
- }
- }
- }
- private void placePoismossAt(IWorld world, IWorldGenerationReader reader, BlockPos pos) {
- for(int i = 2; i >= -3; --i) {
- BlockPos blockpos = pos.up(i);
- if(world.getBlockState(blockpos).getBlock() == EEBlocks.EUMUS || world.getBlockState(blockpos).getBlock() == Blocks.END_STONE) {
- BlockState newGround = world.getBlockState(blockpos).getBlock() == EEBlocks.EUMUS ? EEBlocks.POISMOSS_EUMUS.getDefaultState() : EEBlocks.POISE_GRASS_BLOCK.getDefaultState();
- this.setBlockState(reader, blockpos, newGround);
- break;
- }
- if(!GenerationUtils.isAir(reader, blockpos) && i < 0) {
- break;
- }
- }
- }
- private void setPoiseLog(IWorld world, BlockPos pos, Random rand, boolean isTreeBase, boolean noBubbles) {
- BlockState logState = rand.nextFloat() <= 0.11F ? EEBlocks.POISE_LOG_GLOWING.getDefaultState() : EEBlocks.POISE_LOG.getDefaultState();
- if(world.getBlockState(pos).getMaterial().isReplaceable() || world.getBlockState(pos).getBlock() == EEBlocks.POISE_CLUSTER) {
- world.setBlockState(pos, logState, 2);
- if(!noBubbles && logState == EEBlocks.POISE_LOG_GLOWING.getDefaultState()) {
- if(!isTreeBase) {
- boolean willCollide = world.getBlockState(pos.down()).getBlock() == EEBlocks.POISE_LOG_GLOWING || world.getBlockState(pos.down(2)).getBlock() == EEBlocks.POISE_LOG_GLOWING || world.getBlockState(pos.down(3)).getBlock() == EEBlocks.POISE_LOG_GLOWING
- || world.getBlockState(pos.up()).getBlock() == EEBlocks.POISE_LOG_GLOWING || world.getBlockState(pos.up(2)).getBlock() == EEBlocks.POISE_LOG_GLOWING || world.getBlockState(pos.up(3)).getBlock() == EEBlocks.POISE_LOG_GLOWING;
- if(rand.nextFloat() <= 0.70F && !willCollide
- && world.getBlockState(pos.north()).getMaterial().isReplaceable() && world.getBlockState(pos.east()).getMaterial().isReplaceable()
- && world.getBlockState(pos.south()).getMaterial().isReplaceable() && world.getBlockState(pos.west()).getMaterial().isReplaceable())
- this.buildSideBubble(world, pos, rand);
- } else {
- boolean willCollide = world.getBlockState(pos.down()).getBlock() == EEBlocks.POISE_LOG_GLOWING || world.getBlockState(pos.down(2)).getBlock() == EEBlocks.POISE_LOG_GLOWING || world.getBlockState(pos.down(3)).getBlock() == EEBlocks.POISE_LOG_GLOWING
- || world.getBlockState(pos.up()).getBlock() == EEBlocks.POISE_LOG_GLOWING || world.getBlockState(pos.up(2)).getBlock() == EEBlocks.POISE_LOG_GLOWING || world.getBlockState(pos.up(3)).getBlock() == EEBlocks.POISE_LOG_GLOWING;
- if(rand.nextFloat() <= 0.40F && !willCollide) {
- this.buildSideBubble(world, pos, rand);
- }
- }
- }
- }
- }
- private void setPoiseCluster(IWorld world, BlockPos pos) {
- if(world.getBlockState(pos).getMaterial().isReplaceable()) {
- world.setBlockState(pos, EEBlocks.POISE_CLUSTER.getDefaultState(), 2);
- }
- }
- public boolean isAreaOpen(IWorld world, BlockPos pos) {
- for(int y = pos.getY(); y < pos.getY() + 1; y++) {
- for(int x = pos.getX() - 1; x < pos.getX() + 2; x++) {
- for(int z = pos.getZ() - 1; z < pos.getZ() + 2; z++) {
- if(!world.getBlockState(new BlockPos(x, y, z)).getMaterial().isReplaceable()) {
- return false;
- }
- }
- }
- }
- return true;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement