From 074bd245939ae6cd29d5e2a55840fdecc512716e Mon Sep 17 00:00:00 2001
From: Myles <43725835+MylesAndMore@users.noreply.github.com>
Date: Fri, 9 Dec 2022 17:33:51 +0000
Subject: start on the clump generation

---
 .../com/MylesAndMore/tumble/api/Generator.java     | 47 +++++++++++++++++++++-
 1 file changed, 46 insertions(+), 1 deletion(-)

(limited to 'src/main/java/com/MylesAndMore/tumble/api/Generator.java')

diff --git a/src/main/java/com/MylesAndMore/tumble/api/Generator.java b/src/main/java/com/MylesAndMore/tumble/api/Generator.java
index 1be071d..533ee97 100644
--- a/src/main/java/com/MylesAndMore/tumble/api/Generator.java
+++ b/src/main/java/com/MylesAndMore/tumble/api/Generator.java
@@ -3,13 +3,30 @@ package com.MylesAndMore.tumble.api;
 import org.bukkit.Location;
 import org.bukkit.Material;
 import org.bukkit.World;
+import org.bukkit.block.Block;
+import org.bukkit.util.BlockVector;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Random;
 
 public class Generator {
-    public static void generateLayer(Location center, int radius, int height, Material material) {
+    /**
+     * Generates a layer (bascally just a cylinder) as best as it can w/ blocks
+     * 
+     * @return A list of Blocks containing all the blocks it just changed
+     * 
+     * @param center The center of the layer (Location)
+     * @param radius The whole number radius of the circle
+     * @param height The whole number height of the circle (1 for a flat layer)
+     * @param material The Material to use for generation
+     */
+    public static List<Block> generateLayer(Location center, int radius, int height, Material material) {
         int Cx = center.getBlockX();
         int Cy = center.getBlockY();
         int Cz = center.getBlockZ();
         World world = center.getWorld();
+        List<Block> blocks = new ArrayList<>();
 
         int rSq = radius * radius;
 
@@ -18,12 +35,40 @@ public class Generator {
                 for (int z = Cz - radius; z <= Cz + radius; z++) {
                     if ((Cx - x) * (Cx - x) + (Cz - z) * (Cz - z) <= rSq) {
                         world.getBlockAt(x, y, z).setType(material);
+                        blocks.add(world.getBlockAt(x, y, z));
                     }
                 }
             }
         }
+        return blocks;
+    }
+
+    /**
+     * Generates clumps in a pre-generated layer.
+     * @param blocks A list of block Locations that this method is allowed to edit
+     * @param materials A list of Materials for the generator to randomly choose from.
+     * Keep in mind that not all Materials may be used, the amount used depends on the size of the layer.
+     * More Materials = more randomization
+     */
+    public static void generateClumps(List<Block> blocks, List<Material> materials) {
+        // Define random class
+        Random random = new Random();
+        // This for loop will run until there are no blocks left to change
+        for (Block aBlock : blocks) {
+            // Get a random Material from the provided materials list
+            Material randomMaterial = materials.get(random.nextInt(materials.size()));
+            aBlock.setType(randomMaterial);
+            // Get the blocks around that and change it to that same material
+            // ...
+        }
     }
 
+    /**
+     * Generates a cubiod (literally just a ripoff fill command)
+     * @param firstPos The first Location to fill (first three coords in a fill command)
+     * @param secondPos The second Location to fill to (second three coords)
+     * @param material The Material to fill
+     */
     public static void generateCuboid(Location firstPos, Location secondPos, Material material) {
         World world = firstPos.getWorld();
         int fX = firstPos.getBlockX();
-- 
cgit v1.2.3