Allowed Cube to become Cuboid

Allows for flat places
This commit is contained in:
alisolarflare 2017-04-02 08:22:09 -04:00
parent 5a23fd7b15
commit 84398377b1
3 changed files with 50 additions and 12 deletions

View file

@ -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();

View file

@ -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);
}
}
}
}
}

View file

@ -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