From 84398377b14155ee3d37cf35db45e433d04e2cac Mon Sep 17 00:00:00 2001 From: alisolarflare Date: Sun, 2 Apr 2017 08:22:09 -0400 Subject: [PATCH] Allowed Cube to become Cuboid Allows for flat places --- .../minecraft/place/PlaceComponent.java | 4 +- .../buttondevteam/minecraft/place/Writer.java | 54 ++++++++++++++++--- .../place/commands/{Cube.java => Cuboid.java} | 4 +- 3 files changed, 50 insertions(+), 12 deletions(-) rename src/main/java/buttondevteam/minecraft/place/commands/{Cube.java => Cuboid.java} (88%) diff --git a/src/main/java/buttondevteam/minecraft/place/PlaceComponent.java b/src/main/java/buttondevteam/minecraft/place/PlaceComponent.java index 928ca99..d518adc 100644 --- a/src/main/java/buttondevteam/minecraft/place/PlaceComponent.java +++ b/src/main/java/buttondevteam/minecraft/place/PlaceComponent.java @@ -3,7 +3,7 @@ package buttondevteam.minecraft.place; import org.bukkit.plugin.java.JavaPlugin; import buttondevteam.architecture.Component; -import buttondevteam.minecraft.place.commands.Cube; +import buttondevteam.minecraft.place.commands.Cuboid; public class PlaceComponent extends Component{ public Writer writer; @@ -12,7 +12,7 @@ public class PlaceComponent extends Component{ @Override public void register(JavaPlugin plugin) { - this.registerCommand(plugin, new Cube(this)); + this.registerCommand(plugin, new Cuboid(this)); this.writer = new Writer(); this.reader = new Reader(); diff --git a/src/main/java/buttondevteam/minecraft/place/Writer.java b/src/main/java/buttondevteam/minecraft/place/Writer.java index 1c927b7..119df00 100644 --- a/src/main/java/buttondevteam/minecraft/place/Writer.java +++ b/src/main/java/buttondevteam/minecraft/place/Writer.java @@ -5,25 +5,63 @@ import org.bukkit.Material; import org.bukkit.World; public class Writer { + final int maxSize = 20; + public Cuboid cube; - public int cubeSize = 4; + public class Cuboid{ + private int size; + public int xlen; + public int ylen; + public int zlen; + + public Cuboid(){ + size = 4; + xlen = size; + ylen = size; + zlen = size; + } + public Cuboid(int cubeSize){ + size = cubeSize; + xlen = size; + ylen = size; + zlen = size; + } + public int size(){ + return size; + } + public int size(int newSize){ + this.size = newSize; + xlen = size; + ylen = size; + zlen = size; + return size; + } + } + + public Writer(){ + this.cube = new Cuboid(); + } + public Writer(int cubeSize){ + this.cube = new Cuboid(cubeSize); + } public void hardWrite(Location location, Material material){ - writeCube( - location.getBlockX() - (location.getBlockX() % cubeSize), + writeCuboid( + location.getBlockX() - (location.getBlockX() % cube.xlen), location.getBlockY(), - location.getBlockZ() - (location.getBlockZ() % cubeSize), + location.getBlockZ() - (location.getBlockZ() % cube.zlen), location.getWorld(), material); } - public void writeCube(int x, int y, int z, World world, Material material){ - for(int i = 0; i < cubeSize; i++){ - for (int j = 0; j < cubeSize; j++){ - for(int k = 0; k < cubeSize; k++){ + public void writeCuboid(int x, int y, int z, World world, Material material){ + for(int i = 0; i < cube.xlen; i++){ + for (int j = 0; j < cube.ylen; j++){ + for(int k = 0; k < cube.zlen; k++){ world.getBlockAt(x + i, y + j, z + k).setType(material); } } } } + } diff --git a/src/main/java/buttondevteam/minecraft/place/commands/Cube.java b/src/main/java/buttondevteam/minecraft/place/commands/Cuboid.java similarity index 88% rename from src/main/java/buttondevteam/minecraft/place/commands/Cube.java rename to src/main/java/buttondevteam/minecraft/place/commands/Cuboid.java index d8d991f..319c002 100644 --- a/src/main/java/buttondevteam/minecraft/place/commands/Cube.java +++ b/src/main/java/buttondevteam/minecraft/place/commands/Cuboid.java @@ -8,9 +8,9 @@ import buttondevteam.minecraft.place.PlaceComponent; //Tests the Writer's hardWrite method -public class Cube extends ModCommand{ +public class Cuboid extends ModCommand{ PlaceComponent place; - public Cube(PlaceComponent place){ + public Cuboid(PlaceComponent place){ this.place = place; } @Override