Made roads generate outside cuboids not inside them
This commit is contained in:
@@ -2,12 +2,15 @@ package com.majinnaibu.bukkitplugins.metropolis;
|
|||||||
|
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import javax.persistence.Embeddable;
|
||||||
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
|
||||||
|
|
||||||
import com.sk89q.worldedit.BlockVector;
|
import com.sk89q.worldedit.BlockVector;
|
||||||
import com.sk89q.worldedit.bukkit.selections.Selection;
|
import com.sk89q.worldedit.bukkit.selections.Selection;
|
||||||
|
|
||||||
|
@Embeddable
|
||||||
public class Cuboid implements Comparable<Cuboid> {
|
public class Cuboid implements Comparable<Cuboid> {
|
||||||
private int id;
|
private int id;
|
||||||
|
|
||||||
|
|||||||
@@ -47,6 +47,11 @@ public class MetropolisPlugin extends JavaPlugin {
|
|||||||
public static final Logger log=Logger.getLogger("Minecraft");
|
public static final Logger log=Logger.getLogger("Minecraft");
|
||||||
private static final int version = 1;
|
private static final int version = 1;
|
||||||
|
|
||||||
|
public static final int ROAD_NORTH=1;
|
||||||
|
public static final int ROAD_SOUTH=2;
|
||||||
|
public static final int ROAD_EAST=4;
|
||||||
|
public static final int ROAD_WEST=8;
|
||||||
|
|
||||||
public PluginDescriptionFile pdf = null;
|
public PluginDescriptionFile pdf = null;
|
||||||
public WorldGuardPlugin worldGuard = null;
|
public WorldGuardPlugin worldGuard = null;
|
||||||
public WorldEditPlugin worldEdit = null;
|
public WorldEditPlugin worldEdit = null;
|
||||||
@@ -405,7 +410,7 @@ public class MetropolisPlugin extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createRoads(Cuboid plotCuboid) {
|
private void createRoads(Cuboid plotCuboid, int roadMask){
|
||||||
if(roadWidth>0){
|
if(roadWidth>0){
|
||||||
int x=0;
|
int x=0;
|
||||||
int y= roadLevel;
|
int y= roadLevel;
|
||||||
@@ -418,8 +423,85 @@ public class MetropolisPlugin extends JavaPlugin {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(x=plotCuboid.minX; x<plotCuboid.minX + roadWidth/2; x++){
|
//North West Corner
|
||||||
for(z=plotCuboid.minZ; z<=plotCuboid.maxZ; z++){
|
if((roadMask & (ROAD_NORTH | ROAD_WEST)) != 0){
|
||||||
|
for(x=plotCuboid.minX - roadWidth; x<plotCuboid.minX; x++){
|
||||||
|
for(z=plotCuboid.minZ - roadWidth; z<plotCuboid.minZ; z++){
|
||||||
|
setRoad(x, y, z);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//North Strip
|
||||||
|
if((roadMask & ROAD_NORTH) != 0){
|
||||||
|
for(x=plotCuboid.minX; x<plotCuboid.maxX; x++){
|
||||||
|
for(z=plotCuboid.minZ - roadWidth; z<plotCuboid.minZ; z++){
|
||||||
|
setRoad(x, y, z);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//North East Corner
|
||||||
|
if((roadMask & (ROAD_NORTH | ROAD_EAST)) != 0){
|
||||||
|
for(x=plotCuboid.maxX; x<plotCuboid.maxX + roadWidth;x++){
|
||||||
|
for(z=plotCuboid.minZ-roadWidth; z<plotCuboid.minZ; z++){
|
||||||
|
setRoad(x, y, z);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//East Strip
|
||||||
|
if((roadMask & ROAD_EAST) != 0){
|
||||||
|
for(x=plotCuboid.maxX; x<plotCuboid.maxX + roadWidth; x++){
|
||||||
|
for(z=plotCuboid.minZ; z<plotCuboid.maxZ; z++){
|
||||||
|
setRoad(x, y, z);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//South East Corner
|
||||||
|
if((roadMask & (ROAD_SOUTH | ROAD_EAST)) != 0){
|
||||||
|
for(x=plotCuboid.maxX; x<plotCuboid.maxX + roadWidth; x++){
|
||||||
|
for(z=plotCuboid.maxZ; z<plotCuboid.maxZ + roadWidth; z++){
|
||||||
|
setRoad(x, y, z);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//South Strip
|
||||||
|
if((roadMask & ROAD_SOUTH) != 0){
|
||||||
|
for(x=plotCuboid.minX; x<plotCuboid.maxX; x++){
|
||||||
|
for(z=plotCuboid.maxZ; z<plotCuboid.maxZ+roadWidth; z++){
|
||||||
|
setRoad(x, y, z);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//South West Corner
|
||||||
|
if((roadMask & (ROAD_SOUTH | ROAD_WEST)) != 0){
|
||||||
|
for(x=plotCuboid.minX - roadWidth; x<plotCuboid.minX; x++){
|
||||||
|
for(z=plotCuboid.maxZ; z<plotCuboid.maxZ + roadWidth; z++){
|
||||||
|
setRoad(x, y, z);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//West Strip
|
||||||
|
if((roadMask & ROAD_WEST) != 0){
|
||||||
|
for(x=plotCuboid.minX - roadWidth; x<plotCuboid.minX; x++){
|
||||||
|
for(z=plotCuboid.minZ; z<plotCuboid.maxZ; z++){
|
||||||
|
setRoad(x, y, z);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void createRoads(Cuboid plotCuboid) {
|
||||||
|
createRoads(plotCuboid, ROAD_NORTH|ROAD_SOUTH|ROAD_EAST|ROAD_WEST);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setRoad(int x, int y, int z) {
|
||||||
Block block = world.getBlockAt(x, y, z);
|
Block block = world.getBlockAt(x, y, z);
|
||||||
//Set the road block
|
//Set the road block
|
||||||
block.setType(roadMaterial);
|
block.setType(roadMaterial);
|
||||||
@@ -437,72 +519,6 @@ public class MetropolisPlugin extends JavaPlugin {
|
|||||||
block.setType(Material.AIR);
|
block.setType(Material.AIR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
for(x=plotCuboid.maxX - roadWidth/2+1; x<=plotCuboid.maxX; x++){
|
|
||||||
for(z=plotCuboid.minZ; z<=plotCuboid.maxZ; z++){
|
|
||||||
Block block = world.getBlockAt(x, y, z);
|
|
||||||
//Set the road block
|
|
||||||
block.setType(roadMaterial);
|
|
||||||
//Set the support
|
|
||||||
if(generateRoadSupports && isPhysicsMaterial(block.getType())){
|
|
||||||
Block blockUnder = world.getBlockAt(x, y-1, z);
|
|
||||||
if(!isSolidMaterial(blockUnder.getType())){
|
|
||||||
blockUnder.setType(roadSupportMaterial);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//Clear the space above
|
|
||||||
for(int y1 = 0; y1 < spaceAboveRoad; y1++){
|
|
||||||
block = world.getBlockAt(x, y+y1+1, z);
|
|
||||||
block.setType(Material.AIR);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for(z=plotCuboid.minZ; z<plotCuboid.minZ + roadWidth/2; z++){
|
|
||||||
for(x=plotCuboid.minX; x<=plotCuboid.maxX; x++){
|
|
||||||
Block block = world.getBlockAt(x, y, z);
|
|
||||||
//Set the road block
|
|
||||||
block.setType(roadMaterial);
|
|
||||||
//Set the support
|
|
||||||
if(generateRoadSupports && isPhysicsMaterial(block.getType())){
|
|
||||||
Block blockUnder = world.getBlockAt(x, y-1, z);
|
|
||||||
if(!isSolidMaterial(blockUnder.getType())){
|
|
||||||
blockUnder.setType(roadSupportMaterial);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//Clear the space above
|
|
||||||
for(int y1 = 0; y1 < spaceAboveRoad; y1++){
|
|
||||||
block = world.getBlockAt(x, y+y1+1, z);
|
|
||||||
block.setType(Material.AIR);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for(z=plotCuboid.maxZ - roadWidth/2+1; z<=plotCuboid.maxZ; z++){
|
|
||||||
for(x=plotCuboid.minX; x<=plotCuboid.maxX; x++){
|
|
||||||
Block block = world.getBlockAt(x, y, z);
|
|
||||||
//Set the road block
|
|
||||||
block.setType(roadMaterial);
|
|
||||||
//Set the support
|
|
||||||
if(generateRoadSupports && isPhysicsMaterial(block.getType())){
|
|
||||||
Block blockUnder = world.getBlockAt(x, y-1, z);
|
|
||||||
if(!isSolidMaterial(blockUnder.getType())){
|
|
||||||
blockUnder.setType(roadSupportMaterial);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//Clear the space above
|
|
||||||
for(int y1 = 0; y1 < spaceAboveRoad; y1++){
|
|
||||||
block = world.getBlockAt(x, y+y1+1, z);
|
|
||||||
block.setType(Material.AIR);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isSolidMaterial(Material material) {
|
private boolean isSolidMaterial(Material material) {
|
||||||
return material.isBlock() &&
|
return material.isBlock() &&
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ public class Plot implements Comparable<Plot>{
|
|||||||
public void setId(int id){_id = id;}
|
public void setId(int id){_id = id;}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
|
|
||||||
private Cuboid _cuboid;
|
private Cuboid _cuboid;
|
||||||
public Cuboid getCuboid(){return _cuboid;}
|
public Cuboid getCuboid(){return _cuboid;}
|
||||||
public void setCuboid(Cuboid cuboid){_cuboid = cuboid;}
|
public void setCuboid(Cuboid cuboid){_cuboid = cuboid;}
|
||||||
|
|||||||
Reference in New Issue
Block a user