Advertisement
Guest User

Untitled

a guest
Aug 21st, 2019
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 36.14 KB | None | 0 0
  1. public class FeaturePoiseTree extends Feature<NoFeatureConfig> {
  2.  
  3.     public FeaturePoiseTree(Function<Dynamic<?>, ? extends NoFeatureConfig> configFactoryIn) {
  4.         super(configFactoryIn);
  5.     }
  6.    
  7.     @Override
  8.     public boolean place(IWorld world, ChunkGenerator<? extends GenerationSettings> generator, Random rand, BlockPos pos, NoFeatureConfig config) {
  9.         int treeHeight = rand.nextInt(19) + 13;
  10.         //Random tree top size; small(45%), medium(40%), large(15%)
  11.         float size = rand.nextFloat();
  12.         if(size <= 0.45) {
  13.             size = 0;
  14.         } else if(size >= 0.45) {
  15.             size = 1;
  16.         } else if(size >= 0.85) {
  17.             size = 2;
  18.         }
  19.         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)) {
  20.             this.buildTreeBase(world, pos, rand);
  21.             this.buildStem(world, pos, rand, treeHeight);
  22.             this.buildTreeTop(world, pos, rand, treeHeight, (int) size);
  23.            
  24.             this.buildPoismossCircle(world, world, rand, pos);
  25.             return true;
  26.         }
  27.         return false;
  28.     }
  29.    
  30.     private void buildTreeBase(IWorld world, BlockPos pos, Random rand) {
  31.         int[] sideRandValues = new int[] {
  32.             rand.nextInt(8) + 2,
  33.             rand.nextInt(8) + 2,
  34.             rand.nextInt(8) + 2,
  35.             rand.nextInt(8) + 2
  36.         };
  37.         for(int x = pos.getX() - 1; x < pos.getX() + 2; x++) {
  38.             for(int z = pos.getZ() - 1; z < pos.getZ() + 2; z++) {
  39.                 this.setPoiseLog(world, new BlockPos(x, pos.getY(), z), rand, true, false);
  40.             }
  41.         }
  42.         for(int xN = 1; xN < sideRandValues[0] + 1; xN++) {
  43.             this.setPoiseLog(world, pos.north().up(xN), rand, true, false);
  44.         }
  45.         for(int xE = 1; xE < sideRandValues[1] + 1; xE++) {
  46.             this.setPoiseLog(world, pos.east().up(xE), rand, true, false);
  47.         }
  48.         for(int xS = 1; xS < sideRandValues[2] + 1; xS++) {
  49.             this.setPoiseLog(world, pos.south().up(xS), rand, true, false);
  50.         }
  51.         for(int xW = 1; xW < sideRandValues[3] + 1; xW++) {
  52.             this.setPoiseLog(world, pos.west().up(xW), rand, true, false);
  53.         }
  54.     }
  55.    
  56.     private void buildStem(IWorld world, BlockPos pos, Random rand, int height) {
  57.         for(int y = 1; y < height; y++) {
  58.             boolean doBubbles = y <= height - 2 ? false : true;
  59.             this.setPoiseLog(world, pos.up(y), rand, false, doBubbles);
  60.         }
  61.     }
  62.    
  63.     private void buildTreeTop(IWorld world, BlockPos pos, Random rand, int arrivedPos, int size) {
  64.         if(size == 0 || size == 2) {
  65.             for(int x = pos.getX() - 1; x <= pos.getX() + 1; x++) {
  66.                 for(int z = pos.getZ() - 1; z <= pos.getZ() + 1; z++) {
  67.                     this.setPoiseLog(world, new BlockPos(x, pos.up(arrivedPos).getY(), z), rand, false, true);
  68.                 }
  69.             }
  70.             for(int x = pos.getX() - 1; x <= pos.getX() + 1; x++) {
  71.                 for(int z = pos.getZ() - 1; z <= pos.getZ() + 1; z++) {
  72.                     this.setBlockState(world, new BlockPos(x, pos.up(arrivedPos + 1).getY(), z), EEBlocks.POISMOSS_EUMUS.getDefaultState());
  73.                 }
  74.             }
  75.             this.setPoiseLog(world, pos.up(arrivedPos).north(2), rand, false, true);
  76.             this.setPoiseLog(world, pos.up(arrivedPos).east(2), rand, false, true);
  77.             this.setPoiseLog(world, pos.up(arrivedPos).south(2), rand, false, true);
  78.             this.setPoiseLog(world, pos.up(arrivedPos).west(2), rand, false, true);
  79.            
  80.             this.setPoiseLog(world, pos.up(arrivedPos).north(3).up(), rand, false, true);
  81.             this.setPoiseLog(world, pos.up(arrivedPos).east(3).up(), rand, false, true);
  82.             this.setPoiseLog(world, pos.up(arrivedPos).south(3).up(), rand, false, true);
  83.             this.setPoiseLog(world, pos.up(arrivedPos).west(3).up(), rand, false, true);
  84.            
  85.             this.setPoiseLog(world, pos.up(arrivedPos).north(2).up().east(), rand, false, true);
  86.             this.setPoiseLog(world, pos.up(arrivedPos).north(2).up().west(), rand, false, true);
  87.             this.setPoiseLog(world, pos.up(arrivedPos).east(2).up().north(), rand, false, true);
  88.             this.setPoiseLog(world, pos.up(arrivedPos).east(2).up().south(), rand, false, true);
  89.             this.setPoiseLog(world, pos.up(arrivedPos).south(2).up().east(), rand, false, true);
  90.             this.setPoiseLog(world, pos.up(arrivedPos).south(2).up().west(), rand, false, true);
  91.             this.setPoiseLog(world, pos.up(arrivedPos).west(2).up().north(), rand, false, true);
  92.             this.setPoiseLog(world, pos.up(arrivedPos).west(2).up().south(), rand, false, true);
  93.            
  94.             this.setBlockState(world, pos.up(arrivedPos).north(2).up(), EEBlocks.POISMOSS_EUMUS.getDefaultState());
  95.             this.setBlockState(world, pos.up(arrivedPos).east(2).up(), EEBlocks.POISMOSS_EUMUS.getDefaultState());
  96.             this.setBlockState(world, pos.up(arrivedPos).south(2).up(), EEBlocks.POISMOSS_EUMUS.getDefaultState());
  97.             this.setBlockState(world, pos.up(arrivedPos).west(2).up(), EEBlocks.POISMOSS_EUMUS.getDefaultState());
  98.            
  99.             int[] sideRandValues = new int[] {
  100.                 rand.nextInt(3) + 1,
  101.                 rand.nextInt(3) + 1,
  102.                 rand.nextInt(3) + 1,
  103.                 rand.nextInt(3) + 1
  104.             };
  105.             for(int yn = 1; yn <= sideRandValues[0]; yn++) {
  106.                 this.setPoiseLog(world, pos.up(arrivedPos).north(3).up().up(yn), rand, false, true);
  107.                 if(yn == 1 && rand.nextFloat() <= 0.25F) {
  108.                     if(rand.nextBoolean()) {
  109.                         this.setPoiseLog(world, pos.up(arrivedPos).north(3).east().up().up(yn), rand, false, true);
  110.                     } else {
  111.                         this.setPoiseLog(world, pos.up(arrivedPos).north(3).west().up().up(yn), rand, false, true);
  112.                     }
  113.                 }
  114.             }
  115.             for(int ye = 1; ye <= sideRandValues[1]; ye++) {
  116.                 this.setPoiseLog(world, pos.up(arrivedPos).east(3).up().up(ye), rand, false, true);
  117.                 if(ye == 1 && rand.nextFloat() <= 0.25F) {
  118.                     if(rand.nextBoolean()) {
  119.                         this.setPoiseLog(world, pos.up(arrivedPos).east(3).south().up().up(ye), rand, false, true);
  120.                     } else {
  121.                         this.setPoiseLog(world, pos.up(arrivedPos).east(3).north().up().up(ye), rand, false, true);
  122.                     }
  123.                 }
  124.             }
  125.             for(int ys = 1; ys <= sideRandValues[2]; ys++) {
  126.                 this.setPoiseLog(world, pos.up(arrivedPos).south(3).up().up(ys), rand, false, true);
  127.                 if(ys == 1 && rand.nextFloat() <= 0.25F) {
  128.                     if(rand.nextBoolean()) {
  129.                         this.setPoiseLog(world, pos.up(arrivedPos).south(3).west().up().up(ys), rand, false, true);
  130.                     } else {
  131.                         this.setPoiseLog(world, pos.up(arrivedPos).south(3).east().up().up(ys), rand, false, true);
  132.                     }
  133.                 }
  134.             }
  135.             for(int yw = 1; yw <= sideRandValues[3]; yw++) {
  136.                 this.setPoiseLog(world, pos.up(arrivedPos).west(3).up().up(yw), rand, false, true);
  137.                 if(yw == 1 && rand.nextFloat() <= 0.25F) {
  138.                     if(rand.nextBoolean()) {
  139.                         this.setPoiseLog(world, pos.up(arrivedPos).west(3).north().up().up(yw), rand, false, true);
  140.                     } else {
  141.                         this.setPoiseLog(world, pos.up(arrivedPos).west(3).south().up().up(yw), rand, false, true);
  142.                     }
  143.                 }
  144.             }
  145.             this.addTreeDomeTop(world, pos, rand, arrivedPos, 0);
  146.         } else if(size == 1) {
  147.             BlockPos origin = pos.up(arrivedPos);
  148.             this.setPoiseLog(world, origin, rand, false, true);
  149.             this.setPoiseLog(world, origin.north(), rand, false, true);
  150.             this.setPoiseLog(world, origin.east(), rand, false, true);
  151.             this.setPoiseLog(world, origin.south(), rand, false, true);
  152.             this.setPoiseLog(world, origin.west(), rand, false, true);
  153.            
  154.             for(int x = origin.getX() - 2; x <= origin.getX() + 2; x++) {
  155.                 for(int z = origin.getZ() - 1; z <= origin.getZ() + 1; z++) {
  156.                     this.setPoiseLog(world, new BlockPos(x, origin.up().getY(), z), rand, false, true);
  157.                 }
  158.             }
  159.             for(int x = origin.getX() - 1; x <= origin.getX() + 1; x++) {
  160.                 for(int z = origin.getZ() - 2; z <= origin.getZ() + 2; z++) {
  161.                     this.setPoiseLog(world, new BlockPos(x, origin.up().getY(), z), rand, false, true);
  162.                 }
  163.             }
  164.            
  165.             this.setPoiseLog(world, origin.up(2).north(3), rand, false, true);
  166.             this.setPoiseLog(world, origin.up(2).north(3).west(), rand, false, true);
  167.             this.setPoiseLog(world, origin.up(2).north(3).east(), rand, false, true);
  168.            
  169.             this.setPoiseLog(world, origin.up(2).east(3), rand, false, true);
  170.             this.setPoiseLog(world, origin.up(2).east(3).north(), rand, false, true);
  171.             this.setPoiseLog(world, origin.up(2).east(3).south(), rand, false, true);
  172.            
  173.             this.setPoiseLog(world, origin.up(2).south(3), rand, false, true);
  174.             this.setPoiseLog(world, origin.up(2).south(3).west(), rand, false, true);
  175.             this.setPoiseLog(world, origin.up(2).south(3).east(), rand, false, true);
  176.            
  177.             this.setPoiseLog(world, origin.up(2).west(3), rand, false, true);
  178.             this.setPoiseLog(world, origin.up(2).west(3).north(), rand, false, true);
  179.             this.setPoiseLog(world, origin.up(2).west(3).south(), rand, false, true);
  180.            
  181.             this.setPoiseLog(world, origin.up(2).north(2).west(2), rand, false, true);
  182.             this.setPoiseLog(world, origin.up(2).north(2).east(2), rand, false, true);
  183.             this.setPoiseLog(world, origin.up(2).south(2).west(2), rand, false, true);
  184.             this.setPoiseLog(world, origin.up(2).south(2).east(2), rand, false, true);
  185.            
  186.             for(int x = origin.getX() - 2; x <= origin.getX() + 2; x++) {
  187.                 for(int z = origin.getZ() - 1; z <= origin.getZ() + 1; z++) {
  188.                     world.setBlockState(new BlockPos(x, origin.up(2).getY(), z), EEBlocks.POISMOSS_EUMUS.getDefaultState(), 2);
  189.                 }
  190.             }
  191.             for(int x = origin.getX() - 1; x <= origin.getX() + 1; x++) {
  192.                 for(int z = origin.getZ() - 2; z <= origin.getZ() + 2; z++) {
  193.                     world.setBlockState(new BlockPos(x, origin.up(2).getY(), z), EEBlocks.POISMOSS_EUMUS.getDefaultState(), 2);
  194.                 }
  195.             }
  196.            
  197.             int[] sideRandValues = new int[] {
  198.                 rand.nextInt(3) + 1,
  199.                 rand.nextInt(3) + 1,
  200.                 rand.nextInt(3) + 1,
  201.                 rand.nextInt(3) + 1
  202.             };
  203.             for(int yn = 1; yn <= sideRandValues[0]; yn++) {
  204.                 this.setPoiseLog(world, pos.up(arrivedPos).north(4).up(2).up(yn), rand, false, true);
  205.                 if(yn == 1 && rand.nextFloat() <= 0.25F) {
  206.                     if(rand.nextBoolean()) {
  207.                         this.setPoiseLog(world, pos.up(arrivedPos).north(4).east().up(2).up(yn), rand, false, true);
  208.                     } else {
  209.                         this.setPoiseLog(world, pos.up(arrivedPos).north(4).west().up(2).up(yn), rand, false, true);
  210.                     }
  211.                 }
  212.             }
  213.             for(int yn = 1; yn <= sideRandValues[1]; yn++) {
  214.                 this.setPoiseLog(world, pos.up(arrivedPos).east(4).up(2).up(yn), rand, false, true);
  215.                 if(yn == 1 && rand.nextFloat() <= 0.25F) {
  216.                     if(rand.nextBoolean()) {
  217.                         this.setPoiseLog(world, pos.up(arrivedPos).east(4).north().up(2).up(yn), rand, false, true);
  218.                     } else {
  219.                         this.setPoiseLog(world, pos.up(arrivedPos).east(4).south().up(2).up(yn), rand, false, true);
  220.                     }
  221.                 }
  222.             }
  223.             for(int yn = 1; yn <= sideRandValues[2]; yn++) {
  224.                 this.setPoiseLog(world, pos.up(arrivedPos).south(4).up(2).up(yn), rand, false, true);
  225.                 if(yn == 1 && rand.nextFloat() <= 0.25F) {
  226.                     if(rand.nextBoolean()) {
  227.                         this.setPoiseLog(world, pos.up(arrivedPos).south(4).east().up(2).up(yn), rand, false, true);
  228.                     } else {
  229.                         this.setPoiseLog(world, pos.up(arrivedPos).south(4).west().up(2).up(yn), rand, false, true);
  230.                     }
  231.                 }
  232.             }
  233.             for(int yn = 1; yn <= sideRandValues[3]; yn++) {
  234.                 this.setPoiseLog(world, pos.up(arrivedPos).west(4).up(2).up(yn), rand, false, true);
  235.                 if(yn == 1 && rand.nextFloat() <= 0.25F) {
  236.                     if(rand.nextBoolean()) {
  237.                         this.setPoiseLog(world, pos.up(arrivedPos).west(4).north().up(2).up(yn), rand, false, true);
  238.                     } else {
  239.                         this.setPoiseLog(world, pos.up(arrivedPos).west(4).south().up(2).up(yn), rand, false, true);
  240.                     }
  241.                 }
  242.             }
  243.             //Corner bits
  244.             boolean[] doCornerFeature = new boolean[] {
  245.                 rand.nextInt(4) == 0 ? true : false,
  246.                 rand.nextInt(4) == 0 ? true : false,
  247.                 rand.nextInt(4) == 0 ? true : false,
  248.                 rand.nextInt(4) == 0 ? true : false,
  249.             };
  250.             if(doCornerFeature[0]) {
  251.                 BlockPos cornerOrigin = origin.up(3).north(3).west(2);
  252.                 if(rand.nextBoolean()) {
  253.                     this.setPoiseLog(world, cornerOrigin, rand, false, true);
  254.                     this.setPoiseLog(world, cornerOrigin.west(), rand, false, true);
  255.                     this.setPoiseLog(world, cornerOrigin.west().up(), rand, false, true);
  256.                     this.setPoiseLog(world, cornerOrigin.south().west(), rand, false, true);
  257.                 } else {
  258.                     this.setPoiseLog(world, cornerOrigin, rand, false, true);
  259.                     this.setPoiseLog(world, cornerOrigin.west().up(), rand, false, true);
  260.                     if(rand.nextBoolean()) this.setPoiseLog(world, cornerOrigin.west().up(2), rand, false, true);
  261.                 }
  262.             }
  263.             if(doCornerFeature[1]) {
  264.                 BlockPos cornerOrigin = origin.up(3).east(3).north(2);
  265.                 if(rand.nextBoolean()) {
  266.                     this.setPoiseLog(world, cornerOrigin, rand, false, true);
  267.                     this.setPoiseLog(world, cornerOrigin.north(), rand, false, true);
  268.                     this.setPoiseLog(world, cornerOrigin.north().up(), rand, false, true);
  269.                     this.setPoiseLog(world, cornerOrigin.west().north(), rand, false, true);
  270.                 } else {
  271.                     this.setPoiseLog(world, cornerOrigin, rand, false, true);
  272.                     this.setPoiseLog(world, cornerOrigin.north().up(), rand, false, true);
  273.                     if(rand.nextBoolean()) this.setPoiseLog(world, cornerOrigin.up(2).north(), rand, false, true);
  274.                 }
  275.             }
  276.             if(doCornerFeature[2]) {
  277.                 BlockPos cornerOrigin = origin.up(3).south(3).east(2);
  278.                 if(rand.nextBoolean()) {
  279.                     this.setPoiseLog(world, cornerOrigin, rand, false, true);
  280.                     this.setPoiseLog(world, cornerOrigin.east(), rand, false, true);
  281.                     this.setPoiseLog(world, cornerOrigin.east().up(), rand, false, true);
  282.                     this.setPoiseLog(world, cornerOrigin.north().east(), rand, false, true);
  283.                 } else {
  284.                     this.setPoiseLog(world, cornerOrigin, rand, false, true);
  285.                     this.setPoiseLog(world, cornerOrigin.east().up(), rand, false, true);
  286.                     if(rand.nextBoolean()) this.setPoiseLog(world, cornerOrigin.up(2).east(), rand, false, true);
  287.                 }
  288.             }
  289.             if(doCornerFeature[3]) {
  290.                 BlockPos cornerOrigin = origin.up(3).west(3).south(2);
  291.                 if(rand.nextBoolean()) {
  292.                     this.setPoiseLog(world, cornerOrigin, rand, false, true);
  293.                     this.setPoiseLog(world, cornerOrigin.south(), rand, false, true);
  294.                     this.setPoiseLog(world, cornerOrigin.south().up(), rand, false, true);
  295.                     this.setPoiseLog(world, cornerOrigin.east().south(), rand, false, true);
  296.                 } else {
  297.                     this.setPoiseLog(world, cornerOrigin, rand, false, true);
  298.                     this.setPoiseLog(world, cornerOrigin.up().south(), rand, false, true);
  299.                     if(rand.nextBoolean()) this.setPoiseLog(world, cornerOrigin.up(2).south(), rand, false, true);
  300.                 }
  301.             }
  302.             this.addTreeDomeTop(world, pos, rand, arrivedPos, 1);
  303.         }
  304.     }
  305.    
  306.     private void addTreeDomeTop(IWorld world, BlockPos pos, Random rand, int arrivedPos, int size) {
  307.         BlockPos origin = pos.up(arrivedPos);
  308.         if(size == 0) {
  309.             //North
  310.             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());
  311.             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());
  312.             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());
  313.        
  314.             //East
  315.             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());
  316.             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());
  317.             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());
  318.  
  319.             //South
  320.             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());
  321.             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());
  322.             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());
  323.            
  324.             //West
  325.             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());
  326.             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());
  327.             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());
  328.            
  329.             //Corners
  330.             this.setPoiseCluster(world, origin.north(2).up(2).west(2));
  331.             this.setPoiseCluster(world, origin.north(2).up(2).east(2));
  332.             this.setPoiseCluster(world, origin.north(2).up(6).west(2));
  333.             this.setPoiseCluster(world, origin.north(2).up(6).east(2));
  334.            
  335.             this.setPoiseCluster(world, origin.east(2).up(2).north(2));
  336.             this.setPoiseCluster(world, origin.east(2).up(2).south(2));
  337.             this.setPoiseCluster(world, origin.east(2).up(6).north(2));
  338.             this.setPoiseCluster(world, origin.east(2).up(6).south(2));
  339.            
  340.             this.setPoiseCluster(world, origin.south(2).up(2).east(2));
  341.             this.setPoiseCluster(world, origin.south(2).up(2).west(2));
  342.             this.setPoiseCluster(world, origin.south(2).up(6).east(2));
  343.             this.setPoiseCluster(world, origin.south(2).up(6).west(2));
  344.            
  345.             this.setPoiseCluster(world, origin.west(2).up(2).south(2));
  346.             this.setPoiseCluster(world, origin.west(2).up(2).north(2));
  347.             this.setPoiseCluster(world, origin.west(2).up(6).south(2));
  348.             this.setPoiseCluster(world, origin.west(2).up(6).north(2));
  349.            
  350.             //Top
  351.             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());
  352.             this.setPoiseCluster(world, origin.north(2).west().up(7));
  353.             this.setPoiseCluster(world, origin.north(2).up(7));
  354.             this.setPoiseCluster(world, origin.north(2).east().up(7));
  355.             this.setPoiseCluster(world, origin.south(2).west().up(7));
  356.             this.setPoiseCluster(world, origin.south(2).up(7));
  357.             this.setPoiseCluster(world, origin.south(2).east().up(7));
  358.         } else if(size == 1) {
  359.             //North
  360.             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());
  361.             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());
  362.             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());
  363.        
  364.             //East
  365.             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());
  366.             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());
  367.             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());
  368.  
  369.             //South
  370.             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());
  371.             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());
  372.             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());
  373.            
  374.             //West
  375.             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());
  376.             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());
  377.             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());
  378.        
  379.             //Corners
  380.             this.setPoiseCluster(world, origin.up(3).north(3).west(2));
  381.             this.setPoiseCluster(world, origin.up(3).north(3).west(3));
  382.             this.setPoiseCluster(world, origin.up(3).north(2).west(3));
  383.             this.setPoiseCluster(world, origin.up(4).north(3).west(3));
  384.             this.setPoiseCluster(world, origin.up(5).north(3).west(3));
  385.             this.setPoiseCluster(world, origin.up(6).north(3).west(3));
  386.             this.setPoiseCluster(world, origin.up(7).north(3).west(2));
  387.             this.setPoiseCluster(world, origin.up(7).north(3).west(3));
  388.             this.setPoiseCluster(world, origin.up(7).north(2).west(3));
  389.            
  390.             this.setPoiseCluster(world, origin.up(3).east(3).north(2));
  391.             this.setPoiseCluster(world, origin.up(3).east(3).north(3));
  392.             this.setPoiseCluster(world, origin.up(3).east(2).north(3));
  393.             this.setPoiseCluster(world, origin.up(4).east(3).north(3));
  394.             this.setPoiseCluster(world, origin.up(5).east(3).north(3));
  395.             this.setPoiseCluster(world, origin.up(6).east(3).north(3));
  396.             this.setPoiseCluster(world, origin.up(7).east(3).north(2));
  397.             this.setPoiseCluster(world, origin.up(7).east(3).north(3));
  398.             this.setPoiseCluster(world, origin.up(7).east(2).north(3));
  399.            
  400.             this.setPoiseCluster(world, origin.up(3).south(3).east(2));
  401.             this.setPoiseCluster(world, origin.up(3).south(3).east(3));
  402.             this.setPoiseCluster(world, origin.up(3).south(2).east(3));
  403.             this.setPoiseCluster(world, origin.up(4).south(3).east(3));
  404.             this.setPoiseCluster(world, origin.up(5).south(3).east(3));
  405.             this.setPoiseCluster(world, origin.up(6).south(3).east(3));
  406.             this.setPoiseCluster(world, origin.up(7).south(3).east(2));
  407.             this.setPoiseCluster(world, origin.up(7).south(3).east(3));
  408.             this.setPoiseCluster(world, origin.up(7).south(2).east(3));
  409.            
  410.             this.setPoiseCluster(world, origin.up(3).west(3).south(2));
  411.             this.setPoiseCluster(world, origin.up(3).west(3).south(3));
  412.             this.setPoiseCluster(world, origin.up(3).west(2).south(3));
  413.             this.setPoiseCluster(world, origin.up(4).west(3).south(3));
  414.             this.setPoiseCluster(world, origin.up(5).west(3).south(3));
  415.             this.setPoiseCluster(world, origin.up(6).west(3).south(3));
  416.             this.setPoiseCluster(world, origin.up(7).west(3).south(2));
  417.             this.setPoiseCluster(world, origin.up(7).west(3).south(3));
  418.             this.setPoiseCluster(world, origin.up(7).west(2).south(3));
  419.            
  420.             //Top
  421.             this.setPoiseCluster(world, origin.up(8).west(2).south(2));
  422.             this.setPoiseCluster(world, origin.up(8).south(2).east(2));
  423.             this.setPoiseCluster(world, origin.up(8).east(2).north(2));
  424.             this.setPoiseCluster(world, origin.up(8).north(2).west(2));
  425.            
  426.             this.setPoiseCluster(world, origin.up(8).north(3).west());
  427.             this.setPoiseCluster(world, origin.up(8).north(3));
  428.             this.setPoiseCluster(world, origin.up(8).north(3).east());
  429.            
  430.             this.setPoiseCluster(world, origin.up(8).east(3).north());
  431.             this.setPoiseCluster(world, origin.up(8).east(3));
  432.             this.setPoiseCluster(world, origin.up(8).east(3).south());
  433.            
  434.             this.setPoiseCluster(world, origin.up(8).south(3).east());
  435.             this.setPoiseCluster(world, origin.up(8).south(3));
  436.             this.setPoiseCluster(world, origin.up(8).south(3).west());
  437.            
  438.             this.setPoiseCluster(world, origin.up(8).west(3).south());
  439.             this.setPoiseCluster(world, origin.up(8).west(3));
  440.             this.setPoiseCluster(world, origin.up(8).west(3).north());
  441.            
  442.             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());
  443.             this.setPoiseCluster(world, origin.north(2).west().up(9));
  444.             this.setPoiseCluster(world, origin.north(2).up(9));
  445.             this.setPoiseCluster(world, origin.north(2).east().up(9));
  446.             this.setPoiseCluster(world, origin.south(2).west().up(9));
  447.             this.setPoiseCluster(world, origin.south(2).up(9));
  448.             this.setPoiseCluster(world, origin.south(2).east().up(9));
  449.         }
  450.     }
  451.    
  452.     private void buildSideBubble(IWorld world, BlockPos pos, Random rand) {
  453.         int variant = rand.nextInt(100);
  454.         if(variant >= 49) {
  455.             Direction randDir = Direction.byIndex(rand.nextInt(4) + 2);
  456.             this.setPoiseCluster(world, pos.offset(randDir));
  457.         } else if(variant <= 15) {
  458.             world.setBlockState(pos.up(), EEBlocks.POISE_LOG_GLOWING.getDefaultState(), 2);
  459.             this.setPoiseCluster(world, pos.north());
  460.             this.setPoiseCluster(world, pos.east());
  461.             this.setPoiseCluster(world, pos.south());
  462.             this.setPoiseCluster(world, pos.west());
  463.             this.setPoiseCluster(world, pos.north().up());
  464.             this.setPoiseCluster(world, pos.east().up());
  465.             this.setPoiseCluster(world, pos.south().up());
  466.             this.setPoiseCluster(world, pos.west().up());
  467.         } else if(variant >= 16) {
  468.             Direction randDir = Direction.byIndex(rand.nextInt(4) + 2);
  469.             if(randDir == Direction.NORTH) {
  470.                 world.setBlockState(pos.up(), EEBlocks.POISE_LOG_GLOWING.getDefaultState(), 2);
  471.                 this.setPoiseCluster(world, pos.north());
  472.                 this.setPoiseCluster(world, pos.north().east());
  473.                 this.setPoiseCluster(world, pos.east());
  474.                 this.setPoiseCluster(world, pos.north().up());
  475.                 this.setPoiseCluster(world, pos.north().east().up());
  476.                 this.setPoiseCluster(world, pos.east().up());
  477.             } else if(randDir == Direction.EAST) {
  478.                 world.setBlockState(pos.up(), EEBlocks.POISE_LOG_GLOWING.getDefaultState(), 2);
  479.                 this.setPoiseCluster(world, pos.east());
  480.                 this.setPoiseCluster(world, pos.east().south());
  481.                 this.setPoiseCluster(world, pos.south());
  482.                 this.setPoiseCluster(world, pos.east().up());
  483.                 this.setPoiseCluster(world, pos.east().south().up());
  484.                 this.setPoiseCluster(world, pos.south().up());
  485.             } else if(randDir == Direction.SOUTH) {
  486.                 world.setBlockState(pos.up(), EEBlocks.POISE_LOG_GLOWING.getDefaultState(), 2);
  487.                 this.setPoiseCluster(world, pos.south());
  488.                 this.setPoiseCluster(world, pos.south().west());
  489.                 this.setPoiseCluster(world, pos.west());
  490.                 this.setPoiseCluster(world, pos.south().up());
  491.                 this.setPoiseCluster(world, pos.south().west().up());
  492.                 this.setPoiseCluster(world, pos.west().up());
  493.             } else if(randDir == Direction.WEST) {
  494.                 world.setBlockState(pos.up(), EEBlocks.POISE_LOG_GLOWING.getDefaultState(), 2);
  495.                 this.setPoiseCluster(world, pos.west());
  496.                 this.setPoiseCluster(world, pos.west().north());
  497.                 this.setPoiseCluster(world, pos.north());
  498.                 this.setPoiseCluster(world, pos.west().up());
  499.                 this.setPoiseCluster(world, pos.west().north().up());
  500.                 this.setPoiseCluster(world, pos.north().up());
  501.             }
  502.         } else if(variant >= 30) {
  503.             Direction randDir = Direction.byIndex(rand.nextInt(4) + 2);
  504.             if(randDir == Direction.NORTH) {
  505.                 world.setBlockState(pos.up(), EEBlocks.POISE_LOG_GLOWING.getDefaultState(), 2);
  506.                 this.setPoiseCluster(world, pos.north());
  507.                 this.setPoiseCluster(world, pos.north().west());
  508.                 this.setPoiseCluster(world, pos.north(2).west());
  509.                 this.setPoiseCluster(world, pos.north().west().up());
  510.                 this.setPoiseCluster(world, pos.north().west().down());
  511.                 this.setPoiseCluster(world, pos.north().west(2));
  512.                 this.setPoiseCluster(world, pos.west());
  513.             } else if(randDir == Direction.EAST) {
  514.                 world.setBlockState(pos.up(), EEBlocks.POISE_LOG_GLOWING.getDefaultState(), 2);
  515.                 this.setPoiseCluster(world, pos.east());
  516.                 this.setPoiseCluster(world, pos.east().north());
  517.                 this.setPoiseCluster(world, pos.east(2).north());
  518.                 this.setPoiseCluster(world, pos.east().north().up());
  519.                 this.setPoiseCluster(world, pos.east().north().down());
  520.                 this.setPoiseCluster(world, pos.east().north(2));
  521.                 this.setPoiseCluster(world, pos.north());
  522.             } else if(randDir == Direction.SOUTH) {
  523.                 world.setBlockState(pos.up(), EEBlocks.POISE_LOG_GLOWING.getDefaultState(), 2);
  524.                 this.setPoiseCluster(world, pos.south());
  525.                 this.setPoiseCluster(world, pos.south().east());
  526.                 this.setPoiseCluster(world, pos.south(2).east());
  527.                 this.setPoiseCluster(world, pos.south().east().up());
  528.                 this.setPoiseCluster(world, pos.south().east().down());
  529.                 this.setPoiseCluster(world, pos.south().east(2));
  530.                 this.setPoiseCluster(world, pos.east());
  531.             } else if(randDir == Direction.WEST) {
  532.                 world.setBlockState(pos.up(), EEBlocks.POISE_LOG_GLOWING.getDefaultState(), 2);
  533.                 this.setPoiseCluster(world, pos.west());
  534.                 this.setPoiseCluster(world, pos.west().south());
  535.                 this.setPoiseCluster(world, pos.west(2).south());
  536.                 this.setPoiseCluster(world, pos.west().south().up());
  537.                 this.setPoiseCluster(world, pos.west().south().down());
  538.                 this.setPoiseCluster(world, pos.west().south(2));
  539.                 this.setPoiseCluster(world, pos.south());
  540.             }
  541.         }
  542.     }
  543.    
  544.     public void buildPoismossCircle(IWorld world, IWorldGenerationReader reader, Random random, BlockPos pos) {
  545.         this.placePoismossCircle(world, reader, pos.west().north());
  546.         this.placePoismossCircle(world, reader, pos.east(2).north());
  547.         this.placePoismossCircle(world, reader, pos.west().south(2));
  548.         this.placePoismossCircle(world, reader, pos.east(2).south(2));
  549.  
  550.         for(int i = 0; i < 5; ++i) {
  551.             int j = random.nextInt(64);
  552.             int k = j % 8;
  553.             int l = j / 8;
  554.             if (k == 0 || k == 7 || l == 0 || l == 7) {
  555.                 this.placePoismossCircle(world, reader, pos.add(-3 + k, 0, -3 + l));
  556.             }
  557.         }
  558.     }
  559.    
  560.     private void placePoismossCircle(IWorld world, IWorldGenerationReader reader, BlockPos center) {
  561.         for(int i = -2; i <= 2; ++i) {
  562.             for(int j = -2; j <= 2; ++j) {
  563.                 if (Math.abs(i) != 2 || Math.abs(j) != 2) {
  564.                     this.placePoismossAt(world, reader, center.add(i, 0, j));
  565.                 }
  566.             }
  567.         }
  568.     }
  569.    
  570.     private void placePoismossAt(IWorld world, IWorldGenerationReader reader, BlockPos pos) {
  571.         for(int i = 2; i >= -3; --i) {
  572.             BlockPos blockpos = pos.up(i);
  573.             if(world.getBlockState(blockpos).getBlock() == EEBlocks.EUMUS || world.getBlockState(blockpos).getBlock() == Blocks.END_STONE) {
  574.                 BlockState newGround = world.getBlockState(blockpos).getBlock() == EEBlocks.EUMUS ? EEBlocks.POISMOSS_EUMUS.getDefaultState() : EEBlocks.POISE_GRASS_BLOCK.getDefaultState();
  575.                 this.setBlockState(reader, blockpos, newGround);
  576.                 break;
  577.             }
  578.  
  579.             if(!GenerationUtils.isAir(reader, blockpos) && i < 0) {
  580.                 break;
  581.             }
  582.         }
  583.     }
  584.  
  585.     private void setPoiseLog(IWorld world, BlockPos pos, Random rand, boolean isTreeBase, boolean noBubbles) {
  586.         BlockState logState = rand.nextFloat() <= 0.11F ? EEBlocks.POISE_LOG_GLOWING.getDefaultState() : EEBlocks.POISE_LOG.getDefaultState();
  587.         if(world.getBlockState(pos).getMaterial().isReplaceable() || world.getBlockState(pos).getBlock() == EEBlocks.POISE_CLUSTER) {
  588.             world.setBlockState(pos, logState, 2);
  589.             if(!noBubbles && logState == EEBlocks.POISE_LOG_GLOWING.getDefaultState()) {
  590.                 if(!isTreeBase) {
  591.                     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
  592.                         || 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;
  593.                     if(rand.nextFloat() <= 0.70F && !willCollide
  594.                         && world.getBlockState(pos.north()).getMaterial().isReplaceable() && world.getBlockState(pos.east()).getMaterial().isReplaceable()
  595.                         && world.getBlockState(pos.south()).getMaterial().isReplaceable() && world.getBlockState(pos.west()).getMaterial().isReplaceable())
  596.                             this.buildSideBubble(world, pos, rand);
  597.                 } else {
  598.                     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
  599.                         || 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;
  600.                     if(rand.nextFloat() <= 0.40F && !willCollide) {
  601.                         this.buildSideBubble(world, pos, rand);
  602.                     }
  603.                 }
  604.             }
  605.         }
  606.     }
  607.    
  608.     private void setPoiseCluster(IWorld world, BlockPos pos) {
  609.         if(world.getBlockState(pos).getMaterial().isReplaceable()) {
  610.             world.setBlockState(pos, EEBlocks.POISE_CLUSTER.getDefaultState(), 2);
  611.         }
  612.     }
  613.    
  614.     public boolean isAreaOpen(IWorld world, BlockPos pos) {
  615.         for(int y = pos.getY(); y < pos.getY() + 1; y++) {
  616.             for(int x = pos.getX() - 1; x < pos.getX() + 2; x++) {
  617.                 for(int z = pos.getZ() - 1; z < pos.getZ() + 2; z++) {
  618.                     if(!world.getBlockState(new BlockPos(x, y, z)).getMaterial().isReplaceable()) {
  619.                         return false;
  620.                     }
  621.                 }
  622.             }
  623.         }
  624.         return true;
  625.     }
  626.    
  627. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement