From a4125d14adefa32953f922c480ff47c7183b8440 Mon Sep 17 00:00:00 2001 From: CraivMan Date: Sat, 3 Dec 2022 23:06:22 -0600 Subject: Added cuboid generator (clear layers) --- .../java/com/MylesAndMore/tumble/api/Generator.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (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 632627d..5a1feba 100644 --- a/src/main/java/com/MylesAndMore/tumble/api/Generator.java +++ b/src/main/java/com/MylesAndMore/tumble/api/Generator.java @@ -24,4 +24,22 @@ public class Generator { } } } + + public static void generateCuboid(Location firstPos, Location secondPos, Material material) { + World world = firstPos.getWorld(); + int fX = firstPos.getBlockX(); + int fY = firstPos.getBlockY(); + int fZ = firstPos.getBlockZ(); + int sX = secondPos.getBlockX(); + int sY = secondPos.getBlockY(); + int sZ = secondPos.getBlockZ(); + + for (int x = fX; x <= sX; x++) { + for (int y = fY; y <= sY; y++) { + for (int z = fZ; z <= sZ; z++) { + world.getBlockAt(x, y, z).setType(material); + } + } + } + } } -- cgit v1.2.3 From 14b9a1aec413fc0affe7de02e5d875e251bb15dd Mon Sep 17 00:00:00 2001 From: Myles <43725835+MylesAndMore@users.noreply.github.com> Date: Mon, 5 Dec 2022 19:20:54 +0000 Subject: reformatting (this may break things) removed some flagged imports and changed some of the regen code might need to revert the commit... --- src/main/java/com/MylesAndMore/tumble/api/Generator.java | 1 - 1 file changed, 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 5a1feba..1be071d 100644 --- a/src/main/java/com/MylesAndMore/tumble/api/Generator.java +++ b/src/main/java/com/MylesAndMore/tumble/api/Generator.java @@ -17,7 +17,6 @@ public class Generator { for (int x = Cx - radius; x <= Cx + radius; x++) { for (int z = Cz - radius; z <= Cz + radius; z++) { if ((Cx - x) * (Cx - x) + (Cz - z) * (Cz - z) <= rSq) { - Location block = new Location(world, x, y, z); world.getBlockAt(x, y, z).setType(material); } } -- cgit v1.2.3 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 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 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 blocks, List 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 From cf6bdc376b91e3c1ab5403e018470a7fee589986 Mon Sep 17 00:00:00 2001 From: Myles Date: Sat, 10 Dec 2022 14:59:58 -0600 Subject: THE CLUMPS WORK --- .../com/MylesAndMore/tumble/api/Generator.java | 40 ++++++++++++++++++---- 1 file changed, 33 insertions(+), 7 deletions(-) (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 533ee97..f4439b6 100644 --- a/src/main/java/com/MylesAndMore/tumble/api/Generator.java +++ b/src/main/java/com/MylesAndMore/tumble/api/Generator.java @@ -1,12 +1,14 @@ package com.MylesAndMore.tumble.api; +import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.World; import org.bukkit.block.Block; -import org.bukkit.util.BlockVector; +import org.bukkit.block.BlockFace; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import java.util.Random; @@ -45,21 +47,45 @@ public class Generator { /** * 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. + * @param blockList A list of block Locations that this method is allowed to edit + * @param materialList 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 blocks, List materials) { + public static void generateClumps(List blockList, List materialList) { // Define random class Random random = new Random(); - // This for loop will run until there are no blocks left to change - for (Block aBlock : blocks) { + // Define new blocks list so we can manipulate it + List blocks = new ArrayList<>(blockList); + // Define new shuffled Materials list + List materials = new ArrayList<>(materialList); + Collections.shuffle(materials); + // This loop will run until there are no blocks left to change + while (blocks.size() > 0) { // Get a random Material from the provided materials list Material randomMaterial = materials.get(random.nextInt(materials.size())); + // Gets the first Block from the list, to modify + Block aBlock = blocks.get(0); + // Modifies the block aBlock.setType(randomMaterial); // Get the blocks around that and change it to that same material - // ... + if (blocks.contains(aBlock.getRelative(BlockFace.NORTH))) { + aBlock.getRelative(BlockFace.NORTH).setType(randomMaterial); + blocks.remove(aBlock.getRelative(BlockFace.NORTH)); + } + if (blocks.contains(aBlock.getRelative(BlockFace.SOUTH))) { + aBlock.getRelative(BlockFace.SOUTH).setType(randomMaterial); + blocks.remove(aBlock.getRelative(BlockFace.SOUTH)); + } + if (blocks.contains(aBlock.getRelative(BlockFace.EAST))) { + aBlock.getRelative(BlockFace.EAST).setType(randomMaterial); + blocks.remove(aBlock.getRelative(BlockFace.EAST)); + } + if (blocks.contains(aBlock.getRelative(BlockFace.WEST))) { + aBlock.getRelative(BlockFace.WEST).setType(randomMaterial); + blocks.remove(aBlock.getRelative(BlockFace.WEST)); + } + blocks.remove(aBlock); } } -- cgit v1.2.3 From b3a697e36b2f86ac215ee766c2b6f7ddf123e0fb Mon Sep 17 00:00:00 2001 From: Myles <43725835+MylesAndMore@users.noreply.github.com> Date: Sun, 11 Dec 2022 17:49:35 +0000 Subject: make rounds timed --- src/main/java/com/MylesAndMore/tumble/api/Generator.java | 1 - 1 file changed, 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 f4439b6..d66352a 100644 --- a/src/main/java/com/MylesAndMore/tumble/api/Generator.java +++ b/src/main/java/com/MylesAndMore/tumble/api/Generator.java @@ -1,6 +1,5 @@ package com.MylesAndMore.tumble.api; -import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.World; -- cgit v1.2.3 From 143d998a9d6df2ce69594e90e88cc9e9be8c48a1 Mon Sep 17 00:00:00 2001 From: Myles Date: Sun, 11 Dec 2022 16:32:32 -0600 Subject: add new layer types and gen types --- .../com/MylesAndMore/tumble/api/Generator.java | 51 ++++++++++++---------- 1 file changed, 27 insertions(+), 24 deletions(-) (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 d66352a..0a35767 100644 --- a/src/main/java/com/MylesAndMore/tumble/api/Generator.java +++ b/src/main/java/com/MylesAndMore/tumble/api/Generator.java @@ -44,6 +44,33 @@ public class Generator { return blocks; } + /** + * 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 List generateCuboid(Location firstPos, Location secondPos, Material material) { + World world = firstPos.getWorld(); + List blocks = new ArrayList<>(); + int fX = firstPos.getBlockX(); + int fY = firstPos.getBlockY(); + int fZ = firstPos.getBlockZ(); + int sX = secondPos.getBlockX(); + int sY = secondPos.getBlockY(); + int sZ = secondPos.getBlockZ(); + + for (int x = fX; x <= sX; x++) { + for (int y = fY; y <= sY; y++) { + for (int z = fZ; z <= sZ; z++) { + world.getBlockAt(x, y, z).setType(material); + blocks.add(world.getBlockAt(x, y, z)); + } + } + } + return blocks; + } + /** * Generates clumps in a pre-generated layer. * @param blockList A list of block Locations that this method is allowed to edit @@ -87,28 +114,4 @@ public class Generator { blocks.remove(aBlock); } } - - /** - * 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(); - int fY = firstPos.getBlockY(); - int fZ = firstPos.getBlockZ(); - int sX = secondPos.getBlockX(); - int sY = secondPos.getBlockY(); - int sZ = secondPos.getBlockZ(); - - for (int x = fX; x <= sX; x++) { - for (int y = fY; y <= sY; y++) { - for (int z = fZ; z <= sZ; z++) { - world.getBlockAt(x, y, z).setType(material); - } - } - } - } } -- cgit v1.2.3 From 23429bbd3fe7e35ab9877e536f9ff9a2e71a9afc Mon Sep 17 00:00:00 2001 From: Myles <43725835+MylesAndMore@users.noreply.github.com> Date: Mon, 12 Dec 2022 19:21:09 +0000 Subject: refactoring to prep for release!! - refactor a bit of code - add a bit more documentations - remove music code--we can't redistribute the music in a pack :( - remove old readme--writing the new docs tonight or tmrw we got this! --- src/main/java/com/MylesAndMore/tumble/api/Generator.java | 3 +++ 1 file changed, 3 insertions(+) (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 0a35767..db8bacc 100644 --- a/src/main/java/com/MylesAndMore/tumble/api/Generator.java +++ b/src/main/java/com/MylesAndMore/tumble/api/Generator.java @@ -11,6 +11,9 @@ import java.util.Collections; import java.util.List; import java.util.Random; +/** + * This class holds the methods that generate blocks in-game such as cylinders, cubiods, and clump logic. + */ public class Generator { /** * Generates a layer (bascally just a cylinder) as best as it can w/ blocks -- cgit v1.2.3