diff options
| author | Myles <43725835+MylesAndMore@users.noreply.github.com> | 2022-12-09 17:33:51 +0000 | 
|---|---|---|
| committer | Myles <43725835+MylesAndMore@users.noreply.github.com> | 2022-12-09 17:33:51 +0000 | 
| commit | 074bd245939ae6cd29d5e2a55840fdecc512716e (patch) | |
| tree | e52e2cf688fc85f99cf46fb4a429f9305f7dfba6 | |
| parent | 3e63a58dba76ab0720711f6c5c602848f606d903 (diff) | |
| download | Tumble-074bd245939ae6cd29d5e2a55840fdecc512716e.tar.gz Tumble-074bd245939ae6cd29d5e2a55840fdecc512716e.tar.bz2 Tumble-074bd245939ae6cd29d5e2a55840fdecc512716e.zip | |
start on the clump generation
| -rw-r--r-- | src/main/java/com/MylesAndMore/tumble/api/Generator.java | 47 | ||||
| -rw-r--r-- | src/main/java/com/MylesAndMore/tumble/commands/SetAutoStart.java | 1 | 
2 files changed, 46 insertions, 2 deletions
| 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(); diff --git a/src/main/java/com/MylesAndMore/tumble/commands/SetAutoStart.java b/src/main/java/com/MylesAndMore/tumble/commands/SetAutoStart.java index 0dcb4d9..4b97d9a 100644 --- a/src/main/java/com/MylesAndMore/tumble/commands/SetAutoStart.java +++ b/src/main/java/com/MylesAndMore/tumble/commands/SetAutoStart.java @@ -1,7 +1,6 @@  package com.MylesAndMore.tumble.commands;  import com.MylesAndMore.tumble.TumbleManager; -import org.bukkit.Bukkit;  import org.bukkit.ChatColor;  import org.bukkit.command.Command;  import org.bukkit.command.CommandExecutor; | 
