Continued externalization of generators.

- Please ignore all the errors, I am not commiting all the classes I
have changed.
This commit is contained in:
boy0001 2014-10-08 16:53:09 +11:00
parent c476e07c28
commit 0d55e1a2dc
10 changed files with 1194 additions and 31 deletions

View File

@ -0,0 +1,176 @@
package com.intellectualcrafters.plot;
import org.bukkit.block.Biome;
public class Configuration {
public static final SettingValue STRING = new SettingValue("STRING") {
@Override
public boolean validateValue(String string) {
return true;
}
@Override
public Object parseString(String string) {
return string;
}
};
public static final SettingValue STRINGLIST = new SettingValue("STRINGLIST") {
@Override
public boolean validateValue(String string) {
return true;
}
@Override
public Object parseString(String string) {
return string.split(",");
}
};
public static final SettingValue INTEGER = new SettingValue("INTEGER") {
@Override
public boolean validateValue(String string) {
try {
Integer.parseInt(string);
return true;
} catch (Exception e) {
return false;
}
}
@Override
public Object parseString(String string) {
return Integer.parseInt(string);
}
};
public static final SettingValue BOOLEAN = new SettingValue("BOOLEAN") {
@Override
public boolean validateValue(String string) {
try {
Boolean.parseBoolean(string);
return true;
} catch (Exception e) {
return false;
}
}
@Override
public Object parseString(String string) {
return Boolean.parseBoolean(string);
}
};
public static final SettingValue DOUBLE = new SettingValue("DOUBLE") {
@Override
public boolean validateValue(String string) {
try {
Double.parseDouble(string);
return true;
} catch (Exception e) {
return false;
}
}
@Override
public Object parseString(String string) {
return Double.parseDouble(string);
}
};
public static final SettingValue BIOME = new SettingValue("BIOME") {
@Override
public boolean validateValue(String string) {
try {
Biome.valueOf(string.toUpperCase());
return true;
} catch (Exception e) {
return false;
}
}
@Override
public Object parseString(String string) {
return Biome.valueOf(string.toUpperCase());
}
};
public static final SettingValue BLOCK = new SettingValue("BLOCK") {
@Override
public boolean validateValue(String string) {
try {
if (string.contains(":")) {
String[] split = string.split(":");
Short.parseShort(split[0]);
Short.parseShort(split[1]);
} else {
Short.parseShort(string);
}
return true;
} catch (Exception e) {
return false;
}
}
@Override
public Object parseString(String string) {
if (string.contains(":")) {
String[] split = string.split(":");
return new PlotBlock(Short.parseShort(split[0]), Byte.parseByte(split[1]));
} else {
return new PlotBlock(Short.parseShort(string), (byte) 0);
}
}
};
public static final SettingValue BLOCKLIST = new SettingValue("BLOCKLIST") {
@Override
public boolean validateValue(String string) {
try {
for (String block : string.split(",")) {
if (block.contains(":")) {
String[] split = block.split(":");
Short.parseShort(split[0]);
Short.parseShort(split[1]);
} else {
Short.parseShort(block);
}
}
return true;
} catch (Exception e) {
return false;
}
}
@Override
public Object parseString(String string) {
String[] blocks = string.split(",");
PlotBlock[] values = new PlotBlock[blocks.length];
for (int i = 0; i<blocks.length; i++) {
if (string.contains(":")) {
String[] split = string.split(":");
values[i] = new PlotBlock(Short.parseShort(split[0]), Byte.parseByte(split[1]));
} else {
values[i] = new PlotBlock(Short.parseShort(string), (byte) 0);
}
}
return values;
}
};
public static abstract class SettingValue {
private String type;
public SettingValue(String type) {
this.type = type;
}
public String getType() {
return this.type;
}
public abstract Object parseString(String string);
public abstract boolean validateValue(String string);
}
}

View File

@ -13,7 +13,7 @@ public class ConfigurationNode {
private Object value = 0;
private SettingValue type;
public ConfigurationNode(String constant, Object default_value, String description, SettingValue type) {
public ConfigurationNode(String constant, Object default_value, String description, SettingValue type, boolean required) {
this.constant = constant;
this.default_value = default_value;
this.description = description;
@ -28,7 +28,7 @@ public class ConfigurationNode {
if (!this.type.validateValue(string)) {
return false;
}
this.value = this.type.parseValue(string);
this.value = this.type.parseString(string);
return true;
}

View File

@ -1,9 +1,9 @@
package com.intellectualcrafters.plot;
public class PlotBlock {
public int id;
public short id;
public byte data;
public PlotBlock(int id, byte data) {
public PlotBlock(short id, byte data) {
this.id = id;
this.data = data;
}

View File

@ -0,0 +1,16 @@
package com.intellectualcrafters.plot;
import org.bukkit.generator.BlockPopulator;
import org.bukkit.generator.ChunkGenerator;
public abstract class PlotGenerator {
public PlotGenerator(String world){
}
public abstract PlotWorld getPlotWorld(String world);
public abstract ChunkGenerator getChunkGenerator(PlotWorld plotworld, String world);
public abstract PlotManager getPlotManager(PlotWorld plotworld);
}

View File

@ -20,7 +20,7 @@ import com.intellectualcrafters.plot.Settings;
public class plugin extends SubCommand {
public plugin() {
super("plugin", "", "Show plugin information", "plugin", "pl", CommandCategory.INFO);
super("plugin", "plots.use", "Show plugin information", "plugin", "pl", CommandCategory.INFO);
}
@Override

View File

@ -11,17 +11,13 @@ public class DefaultPlotGenerator extends PlotGenerator {
private final PlotWorld plotworld;
private final ChunkGenerator generator;
private static BlockPopulator populator = null;
private static PlotManager manager = null;
public DefaultPlotGenerator(String worldname) {
super(worldname);
this.plotworld = new DefaultPlotWorld(worldname);
this.generator = new WorldGenerator(worldname);
if (populator==null) {
populator = new XPopulator((DefaultPlotWorld) this.plotworld);
}
this.generator = new WorldGenerator(plotworld, worldname);
if (manager==null) {
DefaultPlotGenerator.manager = new DefaultPlotManager();
}
@ -33,15 +29,10 @@ public class DefaultPlotGenerator extends PlotGenerator {
}
@Override
public ChunkGenerator getChunkGenerator(String worldname) {
public ChunkGenerator getChunkGenerator(PlotWorld plotworld, String worldname) {
return this.generator;
}
@Override
public BlockPopulator getBlockPopulator(PlotWorld plotworld) {
return populator;
}
@Override
public PlotManager getPlotManager(PlotWorld plotworld) {
return manager;

View File

@ -114,7 +114,7 @@ public class DefaultPlotManager extends PlotManager {
public boolean clearSign(Player player, Plot plot, boolean mega) {
World world = player.getWorld();
DefaultPlotWorld plotworld = (DefaultPlotWorld) PlotMain.getWorldSettings(world);
Location pl = new Location(world, PlotHelper.getPlotBottomLoc(world, plot.id).getBlockX(), plotworld.ROAD_HEIGHT + 1, getPlotBottomLoc(world, plot.id).getBlockZ());
Location pl = new Location(world, PlotHelper.getPlotBottomLoc(world, plot.id).getBlockX(), plotworld.ROAD_HEIGHT + 1, PlotHelper.getPlotBottomLoc(world, plot.id).getBlockZ());
Block bs = pl.add(0, 0, -1).getBlock();
bs.setType(Material.AIR);
return true;

View File

@ -3,9 +3,13 @@ package com.intellectualcrafters.plot.generator;
import java.util.ArrayList;
import java.util.List;
import org.apache.commons.lang.StringUtils;
import org.bukkit.Material;
import org.bukkit.block.Biome;
import org.bukkit.configuration.ConfigurationSection;
import com.intellectualcrafters.plot.Configuration.*;
import com.intellectualcrafters.plot.Configuration;
import com.intellectualcrafters.plot.ConfigurationNode;
import com.intellectualcrafters.plot.Flag;
import com.intellectualcrafters.plot.PlotBlock;
@ -75,7 +79,7 @@ public class DefaultPlotWorld extends PlotWorld {
/**
* Default main block: 1
*/
public static PlotBlock[] MAIN_BLOCK_DEFAULT = new PlotBlock[] { new PlotBlock(1, (byte) 0) };
public static PlotBlock[] MAIN_BLOCK_DEFAULT = new PlotBlock[] { new PlotBlock((short) 1, (byte) 0) };
/**
* Top blocks
*/
@ -83,7 +87,7 @@ public class DefaultPlotWorld extends PlotWorld {
/**
* Default top blocks: {"2"}
*/
public static PlotBlock[] TOP_BLOCK_DEFAULT = new PlotBlock[] { new PlotBlock(2, (byte) 0) };
public static PlotBlock[] TOP_BLOCK_DEFAULT = new PlotBlock[] { new PlotBlock((short) 2, (byte) 0) };
/**
* Wall block
@ -101,7 +105,7 @@ public class DefaultPlotWorld extends PlotWorld {
/**
* Default wall filling: 1
*/
public static PlotBlock WALL_FILLING_DEFAULT = new PlotBlock(1, (byte) 0);
public static PlotBlock WALL_FILLING_DEFAULT = new PlotBlock((short) 1, (byte) 0);
/**
* Road stripes
@ -110,7 +114,7 @@ public class DefaultPlotWorld extends PlotWorld {
/**
* Default road stripes: 35
*/
public static PlotBlock ROAD_STRIPES_DEFAULT = new PlotBlock(98, (byte) 0);
public static PlotBlock ROAD_STRIPES_DEFAULT = new PlotBlock((short) 98, (byte) 0);
/**
* enable road stripes
*/
@ -123,7 +127,7 @@ public class DefaultPlotWorld extends PlotWorld {
/**
* Default road block: 155
*/
public static PlotBlock ROAD_BLOCK_DEFAULT = new PlotBlock(155, (byte) 0);
public static PlotBlock ROAD_BLOCK_DEFAULT = new PlotBlock((short) 155, (byte) 0);
/**
* plot chat?
@ -165,7 +169,7 @@ public class DefaultPlotWorld extends PlotWorld {
/**
* Default default flags
*/
public static String[] DEFAULT_FLAGS_DEFAULT = new String[] {};
public static Flag[] DEFAULT_FLAGS_DEFAULT = new Flag[] {};
public boolean USE_ECONOMY;
public static boolean USE_ECONOMY_DEFAULT = false;
@ -178,21 +182,62 @@ public class DefaultPlotWorld extends PlotWorld {
public DefaultPlotWorld(String worldname) {
super(worldname);
}
@Override
public ConfigurationNode[] getSettingNodes() {
// TODO Auto-generated method stub
return null;
// TODO return a set of configuration nodes (used for setup command)
return
new ConfigurationNode[] {
new ConfigurationNode("plot.auto_merge", AUTO_MERGE, "Enable Auto plot merging", Configuration.BOOLEAN, false),
new ConfigurationNode("plot.height", PLOT_HEIGHT, "Plot height", Configuration.INTEGER, true),
new ConfigurationNode("plot.width", PLOT_WIDTH, "Plot width", Configuration.INTEGER, true),
new ConfigurationNode("plot.biome", PLOT_BIOME, "Plot biome", Configuration.BIOME, true),
new ConfigurationNode("plot.filling", MAIN_BLOCK, "Plot block", Configuration.BLOCKLIST, true),
new ConfigurationNode("plot.floor", TOP_BLOCK, "Plot floor block", Configuration.BLOCKLIST, true),
new ConfigurationNode("wall.block", WALL_BLOCK, "Top wall block", Configuration.BLOCK, true),
new ConfigurationNode("road.width", ROAD_WIDTH, "Road width", Configuration.INTEGER, true),
new ConfigurationNode("road.height", ROAD_HEIGHT, "Road height", Configuration.INTEGER, true),
new ConfigurationNode("road.enable_stripes", ROAD_STRIPES_ENABLED, "Enable road stripes", Configuration.BOOLEAN, true),
new ConfigurationNode("road.block", ROAD_BLOCK, "Road block", Configuration.BLOCK, true),
new ConfigurationNode("road.stripes", ROAD_STRIPES, "Road stripe block", Configuration.BLOCK, true),
new ConfigurationNode("wall.filling", WALL_FILLING, "Wall filling block", Configuration.BLOCK, true),
new ConfigurationNode("wall.height", WALL_HEIGHT, "Wall height", Configuration.INTEGER, true),
new ConfigurationNode("schematic.on_claim", SCHEMATIC_ON_CLAIM, "Enable schematic paste on claim", Configuration.BOOLEAN, false),
new ConfigurationNode("schematic.file", SCHEMATIC_FILE, "Schematic file directory", Configuration.STRING, false),
new ConfigurationNode("schematic.specify_on_claim", SCHEMATIC_CLAIM_SPECIFY, "Enable specifying schematics on claim", Configuration.BOOLEAN, false),
new ConfigurationNode("schematic.schematics", SCHEMATICS, "List of schematic paths", Configuration.STRINGLIST, false),
new ConfigurationNode("economy.use", USE_ECONOMY, "Enable economy features", Configuration.BOOLEAN, false),
new ConfigurationNode("economy.prices.claim", PLOT_PRICE, "Plot claim price", Configuration.DOUBLE, false),
new ConfigurationNode("economy.prices.merge", MERGE_PRICE, "Plot merge price", Configuration.DOUBLE, false),
new ConfigurationNode("chat.enabled", PLOT_CHAT, "Enable plot chat", Configuration.BOOLEAN, false)
};
}
@Override
public void setSettingNode(String key, String value) {
switch (key) {
}
public void loadConfiguration(ConfigurationSection config) {
this.AUTO_MERGE = config.getBoolean("plot.auto_merge");
this.PLOT_HEIGHT = config.getInt("plot.height");
this.PLOT_WIDTH = config.getInt("plot.width");
this.PLOT_BIOME = (Biome) Configuration.BIOME.parseString(config.getString("plot.biome"));
this.MAIN_BLOCK = (PlotBlock[]) Configuration.BLOCKLIST.parseString(StringUtils.join(config.getStringList("plot.filling"),','));
this.TOP_BLOCK = (PlotBlock[]) Configuration.BLOCKLIST.parseString(StringUtils.join(config.getStringList("plot.floor"),','));
this.WALL_BLOCK = (PlotBlock) Configuration.BLOCK.parseString(config.getString("wall.block"));
this.ROAD_WIDTH = config.getInt("road.width");
this.ROAD_HEIGHT = config.getInt("road.height");
this.ROAD_STRIPES_ENABLED = config.getBoolean("road.enable_stripes");
this.ROAD_BLOCK = (PlotBlock) Configuration.BLOCK.parseString(config.getString("road.block"));
this.ROAD_STRIPES = (PlotBlock) Configuration.BLOCK.parseString(config.getString("road.stripes"));
this.WALL_FILLING = (PlotBlock) Configuration.BLOCK.parseString(config.getString("wall.filling"));
this.WALL_HEIGHT = config.getInt("wall.height");
this.SCHEMATIC_ON_CLAIM = config.getBoolean("schematic.on_claim");
this.SCHEMATIC_FILE = config.getString("schematic.file");
this.SCHEMATIC_CLAIM_SPECIFY = config.getBoolean("schematic.specify_on_claim");
this.SCHEMATICS = config.getStringList("schematic.schematics");
this.USE_ECONOMY = config.getBoolean("economy.use");
this.PLOT_PRICE = config.getDouble("economy.prices.claim");
this.MERGE_PRICE = config.getDouble("economy.prices.merge");
this.PLOT_CHAT = config.getBoolean("chat.enabled");
}
}

View File

@ -0,0 +1,468 @@
package com.intellectualcrafters.plot.generator;
import java.util.Arrays;
import java.util.List;
import java.util.Random;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.block.Biome;
import org.bukkit.generator.BlockPopulator;
import org.bukkit.generator.ChunkGenerator;
import com.intellectualcrafters.plot.PlotBlock;
import com.intellectualcrafters.plot.PlotWorld;
/**
*
* @auther Empire92
* @author Citymonstret
*
*/
public class WorldGenerator extends ChunkGenerator {
private long state;
public final long nextLong() {
long a = this.state;
this.state = xorShift64(a);
return a;
}
public final long xorShift64(long a) {
a ^= (a << 21);
a ^= (a >>> 35);
a ^= (a << 4);
return a;
}
public final int random(int n) {
long r = ((nextLong() >>> 32) * n) >> 32;
return (int) r;
}
DefaultPlotWorld plotworld;
short[][] result;
int plotsize;
int pathsize;
PlotBlock wall;
PlotBlock wallfilling;
PlotBlock floor1;
PlotBlock floor2;
int size;
Biome biome;
int roadheight;
int wallheight;
int plotheight;
PlotBlock[] plotfloors;
PlotBlock[] filling;
public Short getBlock(String block) {
if (block.contains(":")) {
String[] split = block.split(":");
return Short.parseShort(split[0]);
}
return Short.parseShort(block);
}
public WorldGenerator(PlotWorld pw, String world) {
//
this.plotworld = (DefaultPlotWorld) pw;
// save configuration
plotsize = plotworld.PLOT_WIDTH;
pathsize = plotworld.ROAD_WIDTH;
floor1 = plotworld.ROAD_BLOCK;
floor2 = plotworld.ROAD_STRIPES;
wallfilling = plotworld.WALL_FILLING;
size = pathsize + plotsize;
wall = plotworld.WALL_BLOCK;
plotfloors = plotworld.TOP_BLOCK;
filling = plotworld.MAIN_BLOCK;
wallheight = plotworld.WALL_HEIGHT;
roadheight = plotworld.ROAD_HEIGHT;
plotheight = plotworld.PLOT_HEIGHT;
biome = plotworld.PLOT_BIOME;
}
@Override
public List<BlockPopulator> getDefaultPopulators(World world) {
world.setSpawnFlags(false, false);
return Arrays.asList((BlockPopulator) new XPopulator(plotworld));
}
@Override
public Location getFixedSpawnLocation(World world, Random random) {
return new Location(world, 0, plotworld.ROAD_HEIGHT + 2, 0);
}
public void setCuboidRegion(int x1, int x2, int y1, int y2, int z1, int z2, PlotBlock block) {
for (int x = x1; x < x2; x++) {
for (int z = z1; z < z2; z++) {
for (int y = y1; y < y2; y++) {
setBlock(this.result, x, y, z, block.data);
}
}
}
}
private void setCuboidRegion(int x1, int x2, int y1, int y2, int z1, int z2, PlotBlock[] blocks) {
if (blocks.length == 1) {
setCuboidRegion(x1, x2, y1, y2, z1, z2, blocks[0]);
} else {
for (int x = x1; x < x2; x++) {
for (int z = z1; z < z2; z++) {
for (int y = y1; y < y2; y++) {
int i = random(blocks.length);
setBlock(this.result, x, y, z, blocks[i].id);
}
}
}
}
}
@Override
public short[][] generateExtBlockSections(World world, Random random, int cx, int cz, BiomeGrid biomes) {
final int prime = 31;
int h = 1;
h = (prime * h) + cx;
h = (prime * h) + cz;
this.state = h;
int maxY = world.getMaxHeight();
this.result = new short[maxY / 16][];
double pathWidthLower;
if ((this.pathsize % 2) == 0) {
pathWidthLower = Math.floor(this.pathsize / 2) - 1;
} else {
pathWidthLower = Math.floor(this.pathsize / 2);
}
cx = (cx % this.size) + (8 * this.size);
cz = (cz % this.size) + (8 * this.size);
int absX = (int) ((((cx * 16) + 16) - pathWidthLower - 1) + (8 * this.size));
int absZ = (int) ((((cz * 16) + 16) - pathWidthLower - 1) + (8 * this.size));
int plotMinX = (((absX) % this.size));
int plotMinZ = (((absZ) % this.size));
int roadStartX = (plotMinX + this.pathsize);
int roadStartZ = (plotMinZ + this.pathsize);
if (roadStartX >= this.size) {
roadStartX -= this.size;
}
if (roadStartZ >= this.size) {
roadStartZ -= this.size;
}
// BOTTOM (1/1 cuboids)
for (int x = 0; x < 16; x++) {
for (int z = 0; z < 16; z++) {
setBlock(this.result, x, 0, z, (short) 7);
biomes.setBiome(x, z, this.biome);
}
}
// ROAD (0/24) The following is an inefficient placeholder as it is too
// much work to finish it
if ((this.pathsize > 16) && ((plotMinX > roadStartX) || (plotMinZ > roadStartZ)) && !((roadStartX < 16) && (roadStartZ < 16)) && (((roadStartX > 16) && (roadStartZ > 16)) || ((plotMinX > roadStartX) && (plotMinZ > roadStartZ)))) {
setCuboidRegion(0, 16, 1, this.roadheight + 1, 0, 16, this.floor1);
return this.result;
}
if (((plotMinZ + 1) <= 16) || ((roadStartZ <= 16) && (roadStartZ > 0))) {
int start = Math.max((16 - plotMinZ - this.pathsize) + 1, (16 - roadStartZ) + 1);
int end = Math.min(16 - plotMinZ - 1, (16 - roadStartZ) + this.pathsize);
if ((start >= 0) && (start <= 16) && (end < 0)) {
end = 16;
}
setCuboidRegion(0, 16, 1, this.roadheight + 1, Math.max(start, 0), Math.min(16, end), this.floor1);
}
if (((plotMinX + 1) <= 16) || ((roadStartX <= 16) && (roadStartX > 0))) {
int start = Math.max((16 - plotMinX - this.pathsize) + 1, (16 - roadStartX) + 1);
int end = Math.min(16 - plotMinX - 1, (16 - roadStartX) + this.pathsize);
if ((start >= 0) && (start <= 16) && (end < 0)) {
end = 16;
}
setCuboidRegion(Math.max(start, 0), Math.min(16, end), 1, this.roadheight + 1, 0, 16, this.floor1);
}
// ROAD STRIPES
if ((this.pathsize > 4) && this.plotworld.ROAD_STRIPES_ENABLED) {
if ((plotMinZ + 2) <= 16) {
int value = (plotMinZ + 2);
int start, end;
if ((plotMinX + 2) <= 16) {
start = 16 - plotMinX - 1;
} else {
start = 16;
}
if ((roadStartX - 1) <= 16) {
end = (16 - roadStartX) + 1;
} else {
end = 0;
}
if (!(((plotMinX + 2) <= 16) || ((roadStartX - 1) <= 16))) {
start = 0;
}
setCuboidRegion(0, end, this.wallheight, this.wallheight + 1, 16 - value, (16 - value) + 1, this.floor2); //
setCuboidRegion(start, 16, this.wallheight, this.wallheight + 1, 16 - value, (16 - value) + 1, this.floor2); //
}
if ((plotMinX + 2) <= 16) {
int value = (plotMinX + 2);
int start, end;
if ((plotMinZ + 2) <= 16) {
start = 16 - plotMinZ - 1;
} else {
start = 16;
}
if ((roadStartZ - 1) <= 16) {
end = (16 - roadStartZ) + 1;
} else {
end = 0;
}
if (!(((plotMinZ + 2) <= 16) || ((roadStartZ - 1) <= 16))) {
start = 0;
}
setCuboidRegion(16 - value, (16 - value) + 1, this.wallheight, this.wallheight + 1, 0, end, this.floor2); //
setCuboidRegion(16 - value, (16 - value) + 1, this.wallheight, this.wallheight + 1, start, 16, this.floor2); //
}
if ((roadStartZ <= 16) && (roadStartZ > 1)) {
int val = roadStartZ;
int start, end;
if ((plotMinX + 2) <= 16) {
start = 16 - plotMinX - 1;
} else {
start = 16;
}
if ((roadStartX - 1) <= 16) {
end = (16 - roadStartX) + 1;
} else {
end = 0;
}
if (!(((plotMinX + 2) <= 16) || ((roadStartX - 1) <= 16))) {
start = 0;
}
setCuboidRegion(0, end, this.wallheight, this.wallheight + 1, (16 - val) + 1, (16 - val) + 2, this.floor2);
setCuboidRegion(start, 16, this.wallheight, this.wallheight + 1, (16 - val) + 1, (16 - val) + 2, this.floor2);
}
if ((roadStartX <= 16) && (roadStartX > 1)) {
int val = roadStartX;
int start, end;
if ((plotMinZ + 2) <= 16) {
start = 16 - plotMinZ - 1;
} else {
start = 16;
}
if ((roadStartZ - 1) <= 16) {
end = (16 - roadStartZ) + 1;
} else {
end = 0;
}
if (!(((plotMinZ + 2) <= 16) || ((roadStartZ - 1) <= 16))) {
start = 0;
}
setCuboidRegion((16 - val) + 1, (16 - val) + 2, this.wallheight, this.wallheight + 1, 0, end, this.floor2); //
setCuboidRegion((16 - val) + 1, (16 - val) + 2, this.wallheight, this.wallheight + 1, start, 16, this.floor2); //
}
}
// Plot filling (28/28 cuboids) (10x2 + 4x2)
if (this.plotsize > 16) {
if (roadStartX <= 16) {
if (roadStartZ <= 16) {
setCuboidRegion(0, 16 - roadStartX, 1, this.plotheight, 0, 16 - roadStartZ, this.filling);
setCuboidRegion(0, 16 - roadStartX, this.plotheight, this.plotheight + 1, 0, 16 - roadStartZ, this.plotfloors);
}
if (plotMinZ <= 16) {
setCuboidRegion(0, 16 - roadStartX, 1, this.plotheight, 16 - plotMinZ, 16, this.filling);
setCuboidRegion(0, 16 - roadStartX, this.plotheight, this.plotheight + 1, 16 - plotMinZ, 16, this.plotfloors);
}
} else {
if (roadStartZ <= 16) {
if (plotMinX > 16) {
setCuboidRegion(0, 16, 1, this.plotheight, 0, 16 - roadStartZ, this.filling);
setCuboidRegion(0, 16, this.plotheight, this.plotheight + 1, 0, 16 - roadStartZ, this.plotfloors);
}
}
}
if (plotMinX <= 16) {
if (plotMinZ <= 16) {
setCuboidRegion(16 - plotMinX, 16, 1, this.plotheight, 16 - plotMinZ, 16, this.filling);
setCuboidRegion(16 - plotMinX, 16, this.plotheight, this.plotheight + 1, 16 - plotMinZ, 16, this.plotfloors);
} else {
int z = 16 - roadStartZ;
if (z < 0) {
z = 16;
}
setCuboidRegion(16 - plotMinX, 16, 1, this.plotheight, 0, z, this.filling);
setCuboidRegion(16 - plotMinX, 16, this.plotheight, this.plotheight + 1, 0, z, this.plotfloors);
}
if (roadStartZ <= 16) {
setCuboidRegion(16 - plotMinX, 16, 1, this.plotheight, 0, 16 - roadStartZ, this.filling);
setCuboidRegion(16 - plotMinX, 16, this.plotheight, this.plotheight + 1, 0, 16 - roadStartZ, this.plotfloors);
} else {
if (roadStartX <= 16) {
if (plotMinZ > 16) {
int x = 16 - roadStartX;
if (x < 0) {
x = 16;
}
setCuboidRegion(0, x, 1, this.plotheight, 0, 16, this.filling);
setCuboidRegion(0, x, this.plotheight, this.plotheight + 1, 0, 16, this.plotfloors);
}
}
}
} else {
if (plotMinZ <= 16) {
if (roadStartX > 16) {
int x = 16 - roadStartX;
if (x < 0) {
x = 16;
}
setCuboidRegion(0, x, 1, this.plotheight, 16 - plotMinZ, 16, this.filling);
setCuboidRegion(0, x, this.plotheight, this.plotheight + 1, 16 - plotMinZ, 16, this.plotfloors);
}
} else {
if (roadStartZ > 16) {
int x = 16 - roadStartX;
if (x < 0) {
x = 16;
}
int z = 16 - roadStartZ;
if (z < 0) {
z = 16;
}
if (roadStartX > 16) {
setCuboidRegion(0, x, 1, this.plotheight, 0, z, this.filling);
setCuboidRegion(0, x, this.plotheight, this.plotheight + 1, 0, z, this.plotfloors);
} else {
setCuboidRegion(0, x, 1, this.plotheight, 0, z, this.filling);
setCuboidRegion(0, x, this.plotheight, this.plotheight + 1, 0, z, this.plotfloors);
}
}
}
}
} else {
if (roadStartX <= 16) {
if (roadStartZ <= 16) {
setCuboidRegion(0, 16 - roadStartX, 1, this.plotheight, 0, 16 - roadStartZ, this.filling);
setCuboidRegion(0, 16 - roadStartX, this.plotheight, this.plotheight + 1, 0, 16 - roadStartZ, this.plotfloors);
}
if (plotMinZ <= 16) {
setCuboidRegion(0, 16 - roadStartX, 1, this.plotheight, 16 - plotMinZ, 16, this.filling);
setCuboidRegion(0, 16 - roadStartX, this.plotheight, this.plotheight + 1, 16 - plotMinZ, 16, this.plotfloors);
}
}
if (plotMinX <= 16) {
if (plotMinZ <= 16) {
setCuboidRegion(16 - plotMinX, 16, 1, this.plotheight, 16 - plotMinZ, 16, this.filling);
setCuboidRegion(16 - plotMinX, 16, this.plotheight, this.plotheight + 1, 16 - plotMinZ, 16, this.plotfloors);
}
if (roadStartZ <= 16) {
setCuboidRegion(16 - plotMinX, 16, 1, this.plotheight, 0, 16 - roadStartZ, this.filling);
setCuboidRegion(16 - plotMinX, 16, this.plotheight, this.plotheight + 1, 0, 16 - roadStartZ, this.plotfloors);
}
}
}
// WALLS (16/16 cuboids)
if (this.pathsize > 0) {
if ((plotMinZ + 1) <= 16) {
int start, end;
if ((plotMinX + 2) <= 16) {
start = 16 - plotMinX - 1;
} else {
start = 16;
}
if ((roadStartX - 1) <= 16) {
end = (16 - roadStartX) + 1;
} else {
end = 0;
}
if (!(((plotMinX + 2) <= 16) || ((roadStartX - 1) <= 16))) {
start = 0;
}
setCuboidRegion(0, end, 1, this.wallheight + 1, 16 - plotMinZ - 1, 16 - plotMinZ, this.wallfilling);
setCuboidRegion(0, end, this.wallheight + 1, this.wallheight + 2, 16 - plotMinZ - 1, 16 - plotMinZ, this.wall);
setCuboidRegion(start, 16, 1, this.wallheight + 1, 16 - plotMinZ - 1, 16 - plotMinZ, this.wallfilling);
setCuboidRegion(start, 16, this.wallheight + 1, this.wallheight + 2, 16 - plotMinZ - 1, 16 - plotMinZ, this.wall);
}
if ((plotMinX + 1) <= 16) {
int start, end;
if ((plotMinZ + 2) <= 16) {
start = 16 - plotMinZ - 1;
} else {
start = 16;
}
if ((roadStartZ - 1) <= 16) {
end = (16 - roadStartZ) + 1;
} else {
end = 0;
}
if (!(((plotMinZ + 2) <= 16) || ((roadStartZ - 1) <= 16))) {
start = 0;
}
setCuboidRegion(16 - plotMinX - 1, 16 - plotMinX, 1, this.wallheight + 1, 0, end, this.wallfilling);
setCuboidRegion(16 - plotMinX - 1, 16 - plotMinX, this.wallheight + 1, this.wallheight + 2, 0, end, this.wall);
setCuboidRegion(16 - plotMinX - 1, 16 - plotMinX, 1, this.wallheight + 1, start, 16, this.wallfilling);
setCuboidRegion(16 - plotMinX - 1, 16 - plotMinX, this.wallheight + 1, this.wallheight + 2, start, 16, this.wall);
}
if ((roadStartZ <= 16) && (roadStartZ > 0)) {
int start, end;
if ((plotMinX + 1) <= 16) {
start = 16 - plotMinX;
} else {
start = 16;
}
if ((roadStartX + 1) <= 16) {
end = (16 - roadStartX) + 1;
} else {
end = 0;
}
if (!(((plotMinX + 1) <= 16) || (roadStartX <= 16))) {
start = 0;
}
setCuboidRegion(0, end, 1, this.wallheight + 1, 16 - roadStartZ, (16 - roadStartZ) + 1, this.wallfilling);
setCuboidRegion(0, end, this.wallheight + 1, this.wallheight + 2, 16 - roadStartZ, (16 - roadStartZ) + 1, this.wall);
setCuboidRegion(start, 16, 1, this.wallheight + 1, 16 - roadStartZ, (16 - roadStartZ) + 1, this.wallfilling);
setCuboidRegion(start, 16, this.wallheight + 1, this.wallheight + 2, 16 - roadStartZ, (16 - roadStartZ) + 1, this.wall);
}
if ((roadStartX <= 16) && (roadStartX > 0)) {
int start, end;
if ((plotMinZ + 1) <= 16) {
start = 16 - plotMinZ;
} else {
start = 16;
}
if ((roadStartZ + 1) <= 16) {
end = (16 - roadStartZ) + 1;
} else {
end = 0;
}
if (!(((plotMinZ + 1) <= 16) || ((roadStartZ + 1) <= 16))) {
start = 0;
}
setCuboidRegion(16 - roadStartX, (16 - roadStartX) + 1, 1, this.wallheight + 1, 0, end, this.wallfilling);
setCuboidRegion(16 - roadStartX, (16 - roadStartX) + 1, this.wallheight + 1, this.roadheight + 2, 0, end, this.wall);
setCuboidRegion(16 - roadStartX, (16 - roadStartX) + 1, 1, this.wallheight + 1, start, 16, this.wallfilling);
setCuboidRegion(16 - roadStartX, (16 - roadStartX) + 1, this.wallheight + 1, this.wallheight + 2, start, 16, this.wall);
}
}
return this.result;
}
private void setBlock(short[][] result, int x, int y, int z, short blkid) {
if (result[y >> 4] == null) {
result[y >> 4] = new short[4096];
}
result[y >> 4][((y & 0xF) << 8) | (z << 4) | x] = blkid;
}
}

View File

@ -0,0 +1,467 @@
package com.intellectualcrafters.plot.generator;
import java.util.Random;
import org.bukkit.Chunk;
import org.bukkit.World;
import org.bukkit.generator.BlockPopulator;
import com.intellectualcrafters.plot.PlotWorld;
/**
*
* @author Citymonstret
*
*/
public class XPopulator extends BlockPopulator {
private int X;
private int Z;
private long state;
public final long nextLong() {
long a = this.state;
this.state = xorShift64(a);
return a;
}
public final long xorShift64(long a) {
a ^= (a << 21);
a ^= (a >>> 35);
a ^= (a << 4);
return a;
}
public final int random(int n) {
long result = ((nextLong() >>> 32) * n) >> 32;
return (int) result;
}
public void setCuboidRegion(int x1, int x2, int y1, int y2, int z1, int z2, short id, byte data, World w) {
if (data == 0) {
return;
}
for (int x = x1; x < x2; x++) {
for (int z = z1; z < z2; z++) {
for (int y = y1; y < y2; y++) {
setBlock(w, x, y, z, id, data);
}
}
}
}
private void setCuboidRegion(int x1, int x2, int y1, int y2, int z1, int z2, short[] id, short[] v, World w) {
if (id.length == 1) {
setCuboidRegion(x1, x2, y1, y2, z1, z2, id[0], (byte) v[0], w);
} else {
for (int x = x1; x < x2; x++) {
for (int z = z1; z < z2; z++) {
for (int y = y1; y < y2; y++) {
int i = random(id.length);
if (v[i] != 0) {
setBlock(w, x, y, z, id[i], (byte) v[i]);
}
}
}
}
}
}
public short[] getBlock(String block) {
if (block.contains(":")) {
String[] split = block.split(":");
return new short[] { Short.parseShort(split[0]), Short.parseShort(split[1]) };
}
return new short[] { Short.parseShort(block), 0 };
}
private int plotsize, pathsize, plotheight, wallheight, roadheight, size;
private byte w_v, f1_v, wf_v, f2_v;
private short w_id, f1_id, wf_id, f2_id;
private short[] p_id, p_v, f_id, f_v;
private double pathWidthLower;
private DefaultPlotWorld plotworld;
public XPopulator(PlotWorld pw) {
this.plotworld = (DefaultPlotWorld) pw;
// save configuration
plotsize = plotworld.PLOT_WIDTH;
pathsize = plotworld.ROAD_WIDTH;
floor1 = plotworld.ROAD_BLOCK;
floor2 = plotworld.ROAD_STRIPES;
wallfilling = plotworld.WALL_FILLING;
size = pathsize + plotsize;
wall = plotworld.WALL_BLOCK;
plotfloors = plotworld.TOP_BLOCK;
filling = plotworld.MAIN_BLOCK;
wallheight = plotworld.WALL_HEIGHT;
roadheight = plotworld.ROAD_HEIGHT;
plotheight = plotworld.PLOT_HEIGHT;
// WALL
short[] result_w = getBlock(plotworld.WALL_BLOCK);
this.w_id = result_w[0];
this.w_v = (byte) result_w[1];
// WALL FILLING
short[] result_wf = getBlock(plotworld.WALL_FILLING);
this.wf_id = result_wf[0];
this.wf_v = (byte) result_wf[1];
// ROAD
short[] result_f1 = getBlock(plotworld.ROAD_BLOCK);
this.f1_id = result_f1[0];
this.f1_v = (byte) result_f1[1];
//
// Floor 2
short[] result_f2 = getBlock(plotworld.ROAD_STRIPES);
this.f2_id = result_f2[0];
this.f2_v = (byte) result_f2[1];
//
this.p_id = new short[plotworld.MAIN_BLOCK.length];
this.p_v = new short[plotworld.MAIN_BLOCK.length];
this.f_id = new short[plotworld.TOP_BLOCK.length];
this.f_v = new short[plotworld.TOP_BLOCK.length];
for (int i = 0; i < plotworld.MAIN_BLOCK.length; i++) {
short[] result = getBlock(plotworld.MAIN_BLOCK[i]);
this.p_id[i] = result[0];
this.p_v[i] = result[1];
}
for (int i = 0; i < plotworld.TOP_BLOCK.length; i++) {
short[] result = getBlock(plotworld.TOP_BLOCK[i]);
this.f_id[i] = result[0];
this.f_v[i] = result[1];
}
if ((this.pathsize % 2) == 0) {
this.pathWidthLower = Math.floor(this.pathsize / 2) - 1;
} else {
this.pathWidthLower = Math.floor(this.pathsize / 2);
}
}
@Override
public void populate(World w, Random r, Chunk c) {
int cx = c.getX(), cz = c.getZ();
final int prime = 31;
int h = 1;
h = (prime * h) + cx;
h = (prime * h) + cz;
this.state = h;
this.X = cx << 4;
this.Z = cz << 4;
cx = (cx % this.size) + (8 * this.size);
cz = (cz % this.size) + (8 * this.size);
double absX = ((((cx * 16) + 16) - this.pathWidthLower - 1) + (8 * this.size)), absZ = ((((cz * 16) + 16) - this.pathWidthLower - 1) + (8 * this.size));
int plotMinX = (int) (((absX) % this.size));
int plotMinZ = (int) (((absZ) % this.size));
int roadStartX = (plotMinX + this.pathsize);
int roadStartZ = (plotMinZ + this.pathsize);
if (roadStartX >= this.size) {
roadStartX -= this.size;
}
if (roadStartZ >= this.size) {
roadStartZ -= this.size;
}
// ROADS
if ((this.pathsize > 16) && ((plotMinX > roadStartX) || (plotMinZ > roadStartZ)) && !((roadStartX < 16) && (roadStartZ < 16)) && (((roadStartX > 16) && (roadStartZ > 16)) || ((plotMinX > roadStartX) && (plotMinZ > roadStartZ)))) {
setCuboidRegion(0, 16, 1, this.roadheight + 1, 0, 16, this.f1_id, this.f1_v, w);
return;
}
if (((plotMinZ + 1) <= 16) || ((roadStartZ <= 16) && (roadStartZ > 0))) {
int start = Math.max((16 - plotMinZ - this.pathsize) + 1, (16 - roadStartZ) + 1);
int end = Math.min(16 - plotMinZ - 1, (16 - roadStartZ) + this.pathsize);
if ((start >= 0) && (start <= 16) && (end < 0)) {
end = 16;
}
setCuboidRegion(0, 16, 1, this.roadheight + 1, Math.max(start, 0), Math.min(16, end), this.f1_id, this.f1_v, w);
}
if (((plotMinX + 1) <= 16) || ((roadStartX <= 16) && (roadStartX > 0))) {
int start = Math.max((16 - plotMinX - this.pathsize) + 1, (16 - roadStartX) + 1);
int end = Math.min(16 - plotMinX - 1, (16 - roadStartX) + this.pathsize);
if ((start >= 0) && (start <= 16) && (end < 0)) {
end = 16;
}
setCuboidRegion(Math.max(start, 0), Math.min(16, end), 1, this.roadheight + 1, 0, 16, this.f1_id, this.f1_v, w);
}
// STRIPES
if ((this.pathsize > 4) && this.plotworld.ROAD_STRIPES_ENABLED) {
if ((plotMinZ + 2) <= 16) {
int value = (plotMinZ + 2);
int start, end;
if ((plotMinX + 2) <= 16) {
start = 16 - plotMinX - 1;
} else {
start = 16;
}
if ((roadStartX - 1) <= 16) {
end = (16 - roadStartX) + 1;
} else {
end = 0;
}
if (!(((plotMinX + 2) <= 16) || ((roadStartX - 1) <= 16))) {
start = 0;
}
setCuboidRegion(0, end, this.roadheight, this.roadheight + 1, 16 - value, (16 - value) + 1, this.f2_id, this.f2_v, w); //
setCuboidRegion(start, 16, this.roadheight, this.roadheight + 1, 16 - value, (16 - value) + 1, this.f2_id, this.f2_v, w); //
}
if ((plotMinX + 2) <= 16) {
int value = (plotMinX + 2);
int start, end;
if ((plotMinZ + 2) <= 16) {
start = 16 - plotMinZ - 1;
} else {
start = 16;
}
if ((roadStartZ - 1) <= 16) {
end = (16 - roadStartZ) + 1;
} else {
end = 0;
}
if (!(((plotMinZ + 2) <= 16) || ((roadStartZ - 1) <= 16))) {
start = 0;
}
setCuboidRegion(16 - value, (16 - value) + 1, this.roadheight, this.roadheight + 1, 0, end, this.f2_id, this.f2_v, w); //
setCuboidRegion(16 - value, (16 - value) + 1, this.roadheight, this.roadheight + 1, start, 16, this.f2_id, this.f2_v, w); //
}
if ((roadStartZ <= 16) && (roadStartZ > 1)) {
int val = roadStartZ;
int start, end;
if ((plotMinX + 2) <= 16) {
start = 16 - plotMinX - 1;
} else {
start = 16;
}
if ((roadStartX - 1) <= 16) {
end = (16 - roadStartX) + 1;
} else {
end = 0;
}
if (!(((plotMinX + 2) <= 16) || ((roadStartX - 1) <= 16))) {
start = 0;
}
setCuboidRegion(0, end, this.roadheight, this.roadheight + 1, (16 - val) + 1, (16 - val) + 2, this.f2_id, this.f2_v, w);
setCuboidRegion(start, 16, this.roadheight, this.roadheight + 1, (16 - val) + 1, (16 - val) + 2, this.f2_id, this.f2_v, w);
}
if ((roadStartX <= 16) && (roadStartX > 1)) {
int val = roadStartX;
int start, end;
if ((plotMinZ + 2) <= 16) {
start = 16 - plotMinZ - 1;
} else {
start = 16;
}
if ((roadStartZ - 1) <= 16) {
end = (16 - roadStartZ) + 1;
} else {
end = 0;
}
if (!(((plotMinZ + 2) <= 16) || ((roadStartZ - 1) <= 16))) {
start = 0;
}
setCuboidRegion((16 - val) + 1, (16 - val) + 2, this.roadheight, this.roadheight + 1, 0, end, this.f2_id, this.f2_v, w); //
setCuboidRegion((16 - val) + 1, (16 - val) + 2, this.roadheight, this.roadheight + 1, start, 16, this.f2_id, this.f2_v, w); //
}
}
// WALLS
if (this.pathsize > 0) {
if ((plotMinZ + 1) <= 16) {
int start, end;
if ((plotMinX + 2) <= 16) {
start = 16 - plotMinX - 1;
} else {
start = 16;
}
if ((roadStartX - 1) <= 16) {
end = (16 - roadStartX) + 1;
} else {
end = 0;
}
if (!(((plotMinX + 2) <= 16) || ((roadStartX - 1) <= 16))) {
start = 0;
}
setCuboidRegion(0, end, 1, this.wallheight + 1, 16 - plotMinZ - 1, 16 - plotMinZ, this.wf_id, this.wf_v, w);
setCuboidRegion(0, end, this.wallheight + 1, this.wallheight + 2, 16 - plotMinZ - 1, 16 - plotMinZ, this.w_id, this.w_v, w);
setCuboidRegion(start, 16, 1, this.wallheight + 1, 16 - plotMinZ - 1, 16 - plotMinZ, this.wf_id, this.wf_v, w);
setCuboidRegion(start, 16, this.wallheight + 1, this.wallheight + 2, 16 - plotMinZ - 1, 16 - plotMinZ, this.w_id, this.w_v, w);
}
if ((plotMinX + 1) <= 16) {
int start, end;
if ((plotMinZ + 2) <= 16) {
start = 16 - plotMinZ - 1;
} else {
start = 16;
}
if ((roadStartZ - 1) <= 16) {
end = (16 - roadStartZ) + 1;
} else {
end = 0;
}
if (!(((plotMinZ + 2) <= 16) || ((roadStartZ - 1) <= 16))) {
start = 0;
}
setCuboidRegion(16 - plotMinX - 1, 16 - plotMinX, 1, this.wallheight + 1, 0, end, this.wf_id, this.wf_v, w);
setCuboidRegion(16 - plotMinX - 1, 16 - plotMinX, this.wallheight + 1, this.wallheight + 2, 0, end, this.w_id, this.w_v, w);
setCuboidRegion(16 - plotMinX - 1, 16 - plotMinX, 1, this.wallheight + 1, start, 16, this.wf_id, this.wf_v, w);
setCuboidRegion(16 - plotMinX - 1, 16 - plotMinX, this.wallheight + 1, this.wallheight + 2, start, 16, this.w_id, this.w_v, w);
}
if ((roadStartZ <= 16) && (roadStartZ > 0)) {
int start, end;
if ((plotMinX + 1) <= 16) {
start = 16 - plotMinX;
} else {
start = 16;
}
if ((roadStartX + 1) <= 16) {
end = (16 - roadStartX) + 1;
} else {
end = 0;
}
if (!(((plotMinX + 1) <= 16) || (roadStartX <= 16))) {
start = 0;
}
setCuboidRegion(0, end, 1, this.wallheight + 1, 16 - roadStartZ, (16 - roadStartZ) + 1, this.wf_id, this.wf_v, w);
setCuboidRegion(0, end, this.wallheight + 1, this.wallheight + 2, 16 - roadStartZ, (16 - roadStartZ) + 1, this.w_id, this.w_v, w);
setCuboidRegion(start, 16, 1, this.wallheight + 1, 16 - roadStartZ, (16 - roadStartZ) + 1, this.wf_id, this.wf_v, w);
setCuboidRegion(start, 16, this.wallheight + 1, this.wallheight + 2, 16 - roadStartZ, (16 - roadStartZ) + 1, this.w_id, this.w_v, w);
}
if ((roadStartX <= 16) && (roadStartX > 0)) {
int start, end;
if ((plotMinZ + 1) <= 16) {
start = 16 - plotMinZ;
} else {
start = 16;
}
if ((roadStartZ + 1) <= 16) {
end = (16 - roadStartZ) + 1;
} else {
end = 0;
}
if (!(((plotMinZ + 1) <= 16) || ((roadStartZ + 1) <= 16))) {
start = 0;
}
setCuboidRegion(16 - roadStartX, (16 - roadStartX) + 1, 1, this.wallheight + 1, 0, end, this.wf_id, this.wf_v, w);
setCuboidRegion(16 - roadStartX, (16 - roadStartX) + 1, this.wallheight + 1, this.roadheight + 2, 0, end, this.w_id, this.w_v, w);
setCuboidRegion(16 - roadStartX, (16 - roadStartX) + 1, 1, this.wallheight + 1, start, 16, this.wf_id, this.wf_v, w);
setCuboidRegion(16 - roadStartX, (16 - roadStartX) + 1, this.wallheight + 1, this.wallheight + 2, start, 16, this.w_id, this.w_v, w);
}
}
// PLOT
if (this.plotsize > 16) {
if (roadStartX <= 16) {
if (roadStartZ <= 16) {
setCuboidRegion(0, 16 - roadStartX, 1, this.plotheight, 0, 16 - roadStartZ, this.p_id, this.p_v, w);
setCuboidRegion(0, 16 - roadStartX, this.plotheight, this.plotheight + 1, 0, 16 - roadStartZ, this.f_id, this.f_v, w);
}
if (plotMinZ <= 16) {
setCuboidRegion(0, 16 - roadStartX, 1, this.plotheight, 16 - plotMinZ, 16, this.p_id, this.p_v, w);
setCuboidRegion(0, 16 - roadStartX, this.plotheight, this.plotheight + 1, 16 - plotMinZ, 16, this.f_id, this.f_v, w);
}
} else {
if (roadStartZ <= 16) {
if (plotMinX > 16) {
setCuboidRegion(0, 16, 1, this.plotheight, 0, 16 - roadStartZ, this.p_id, this.p_v, w);
setCuboidRegion(0, 16, this.plotheight, this.plotheight + 1, 0, 16 - roadStartZ, this.f_id, this.f_v, w);
}
}
}
if (plotMinX <= 16) {
if (plotMinZ <= 16) {
setCuboidRegion(16 - plotMinX, 16, 1, this.plotheight, 16 - plotMinZ, 16, this.p_id, this.p_v, w);
setCuboidRegion(16 - plotMinX, 16, this.plotheight, this.plotheight + 1, 16 - plotMinZ, 16, this.f_id, this.f_v, w);
} else {
int z = 16 - roadStartZ;
if (z < 0) {
z = 16;
}
setCuboidRegion(16 - plotMinX, 16, 1, this.plotheight, 0, z, this.p_id, this.p_v, w);
setCuboidRegion(16 - plotMinX, 16, this.plotheight, this.plotheight + 1, 0, z, this.f_id, this.f_v, w);
}
if (roadStartZ <= 16) {
setCuboidRegion(16 - plotMinX, 16, 1, this.plotheight, 0, 16 - roadStartZ, this.p_id, this.p_v, w);
setCuboidRegion(16 - plotMinX, 16, this.plotheight, this.plotheight + 1, 0, 16 - roadStartZ, this.f_id, this.f_v, w);
} else {
if (roadStartX <= 16) {
if (plotMinZ > 16) {
int x = 16 - roadStartX;
if (x < 0) {
x = 16;
}
setCuboidRegion(0, x, 1, this.plotheight, 0, 16, this.p_id, this.p_v, w);
setCuboidRegion(0, x, this.plotheight, this.plotheight + 1, 0, 16, this.f_id, this.f_v, w);
}
}
}
} else {
if (plotMinZ <= 16) {
if (roadStartX > 16) {
int x = 16 - roadStartX;
if (x < 0) {
x = 16;
}
setCuboidRegion(0, x, 1, this.plotheight, 16 - plotMinZ, 16, this.p_id, this.p_v, w);
setCuboidRegion(0, x, this.plotheight, this.plotheight + 1, 16 - plotMinZ, 16, this.f_id, this.f_v, w);
}
} else {
if (roadStartZ > 16) {
int x = 16 - roadStartX;
if (x < 0) {
x = 16;
}
int z = 16 - roadStartZ;
if (z < 0) {
z = 16;
}
if (roadStartX > 16) {
setCuboidRegion(0, x, 1, this.plotheight, 0, z, this.p_id, this.p_v, w);
setCuboidRegion(0, x, this.plotheight, this.plotheight + 1, 0, z, this.f_id, this.f_v, w);
} else {
setCuboidRegion(0, x, 1, this.plotheight, 0, z, this.p_id, this.p_v, w);
setCuboidRegion(0, x, this.plotheight, this.plotheight + 1, 0, z, this.f_id, this.f_v, w);
}
}
}
}
} else {
if (roadStartX <= 16) {
if (roadStartZ <= 16) {
setCuboidRegion(0, 16 - roadStartX, 1, this.plotheight, 0, 16 - roadStartZ, this.p_id, this.p_v, w);
setCuboidRegion(0, 16 - roadStartX, this.plotheight, this.plotheight + 1, 0, 16 - roadStartZ, this.f_id, this.f_v, w);
}
if (plotMinZ <= 16) {
setCuboidRegion(0, 16 - roadStartX, 1, this.plotheight, 16 - plotMinZ, 16, this.p_id, this.p_v, w);
setCuboidRegion(0, 16 - roadStartX, this.plotheight, this.plotheight + 1, 16 - plotMinZ, 16, this.f_id, this.f_v, w);
}
}
if (plotMinX <= 16) {
if (plotMinZ <= 16) {
setCuboidRegion(16 - plotMinX, 16, 1, this.plotheight, 16 - plotMinZ, 16, this.p_id, this.p_v, w);
setCuboidRegion(16 - plotMinX, 16, this.plotheight, this.plotheight + 1, 16 - plotMinZ, 16, this.f_id, this.f_v, w);
}
if (roadStartZ <= 16) {
setCuboidRegion(16 - plotMinX, 16, 1, this.plotheight, 0, 16 - roadStartZ, this.p_id, this.p_v, w);
setCuboidRegion(16 - plotMinX, 16, this.plotheight, this.plotheight + 1, 0, 16 - roadStartZ, this.f_id, this.f_v, w);
}
}
}
}
private void setBlock(World w, int x, int y, int z, short id, byte val) {
w.getBlockAt(this.X + x, y, this.Z + z).setData(val, false);
}
}