mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 13:16:45 +01:00
Merge remote-tracking branch 'origin/features/v5/internal-updates' into features/v5/internal-updates
This commit is contained in:
commit
c5590440d6
@ -31,16 +31,13 @@ import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
|
|||||||
import com.github.intellectualsites.plotsquared.plot.object.PlotAreaTerrainType;
|
import com.github.intellectualsites.plotsquared.plot.object.PlotAreaTerrainType;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.PlotAreaType;
|
import com.github.intellectualsites.plotsquared.plot.object.PlotAreaType;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.PlotManager;
|
import com.github.intellectualsites.plotsquared.plot.object.PlotManager;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.block.DelegateLocalBlockQueue;
|
import com.github.intellectualsites.plotsquared.plot.util.block.AreaBoundDelegateLocalBlockQueue;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.block.GlobalBlockQueue;
|
import com.github.intellectualsites.plotsquared.plot.util.block.GlobalBlockQueue;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.block.LocalBlockQueue;
|
import com.github.intellectualsites.plotsquared.plot.util.block.LocalBlockQueue;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.util.block.LocationOffsetDelegateLocalBlockQueue;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.block.ScopedLocalBlockQueue;
|
import com.github.intellectualsites.plotsquared.plot.util.block.ScopedLocalBlockQueue;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.world.RegionUtil;
|
import com.github.intellectualsites.plotsquared.plot.util.world.RegionUtil;
|
||||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
|
||||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
|
||||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
@ -63,19 +60,27 @@ public class AugmentedUtils {
|
|||||||
if (!enabled) {
|
if (!enabled) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
// The coordinates of the block on the
|
||||||
|
// least positive corner of the chunk
|
||||||
final int blockX = chunkX << 4;
|
final int blockX = chunkX << 4;
|
||||||
final int blockZ = chunkZ << 4;
|
final int blockZ = chunkZ << 4;
|
||||||
|
// Create a region that contains the
|
||||||
|
// entire chunk
|
||||||
CuboidRegion region = RegionUtil.createRegion(blockX, blockX + 15, blockZ, blockZ + 15);
|
CuboidRegion region = RegionUtil.createRegion(blockX, blockX + 15, blockZ, blockZ + 15);
|
||||||
|
// Query for plot areas in the chunk
|
||||||
Set<PlotArea> areas = PlotSquared.get().getPlotAreas(world, region);
|
Set<PlotArea> areas = PlotSquared.get().getPlotAreas(world, region);
|
||||||
if (areas.isEmpty()) {
|
if (areas.isEmpty()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
boolean toReturn = false;
|
boolean generationResult = false;
|
||||||
for (final PlotArea area : areas) {
|
for (final PlotArea area : areas) {
|
||||||
|
// A normal plot world may not contain any clusters
|
||||||
|
// and so there's no reason to continue searching
|
||||||
if (area.getType() == PlotAreaType.NORMAL) {
|
if (area.getType() == PlotAreaType.NORMAL) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
// This means that full vanilla generation is used
|
||||||
|
// so we do not interfere
|
||||||
if (area.getTerrain() == PlotAreaTerrainType.ALL) {
|
if (area.getTerrain() == PlotAreaTerrainType.ALL) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -87,50 +92,38 @@ public class AugmentedUtils {
|
|||||||
}
|
}
|
||||||
LocalBlockQueue primaryMask;
|
LocalBlockQueue primaryMask;
|
||||||
// coordinates
|
// coordinates
|
||||||
int bxx;
|
int relativeBottomX;
|
||||||
int bzz;
|
int relativeBottomZ;
|
||||||
int txx;
|
int relativeTopX;
|
||||||
int tzz;
|
int relativeTopZ;
|
||||||
// gen
|
// Generation
|
||||||
if (area.getType() == PlotAreaType.PARTIAL) {
|
if (area.getType() == PlotAreaType.PARTIAL) {
|
||||||
bxx = Math.max(0, area.getRegion().getMinimumPoint().getX() - blockX);
|
relativeBottomX = Math.max(0, area.getRegion().getMinimumPoint().getX() - blockX);
|
||||||
bzz = Math.max(0, area.getRegion().getMinimumPoint().getZ() - blockZ);
|
relativeBottomZ = Math.max(0, area.getRegion().getMinimumPoint().getZ() - blockZ);
|
||||||
txx = Math.min(15, area.getRegion().getMaximumPoint().getX() - blockX);
|
relativeTopX = Math.min(15, area.getRegion().getMaximumPoint().getX() - blockX);
|
||||||
tzz = Math.min(15, area.getRegion().getMaximumPoint().getZ() - blockZ);
|
relativeTopZ = Math.min(15, area.getRegion().getMaximumPoint().getZ() - blockZ);
|
||||||
primaryMask = new DelegateLocalBlockQueue(queue) {
|
|
||||||
@Override public boolean setBlock(int x, int y, int z, BlockState id) {
|
|
||||||
if (area.contains(x, z)) {
|
|
||||||
return super.setBlock(x, y, z, id);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public boolean setBiome(int x, int z, BiomeType biome) {
|
primaryMask = new AreaBoundDelegateLocalBlockQueue(area, queue);
|
||||||
if (area.contains(x, z)) {
|
|
||||||
return super.setBiome(x, z, biome);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
} else {
|
} else {
|
||||||
bxx = bzz = 0;
|
relativeBottomX = relativeBottomZ = 0;
|
||||||
txx = tzz = 15;
|
relativeTopX = relativeTopZ = 15;
|
||||||
primaryMask = queue;
|
primaryMask = queue;
|
||||||
}
|
}
|
||||||
|
|
||||||
LocalBlockQueue secondaryMask;
|
LocalBlockQueue secondaryMask;
|
||||||
BlockState air = BlockTypes.AIR.getDefaultState();
|
BlockState air = BlockTypes.AIR.getDefaultState();
|
||||||
if (area.getTerrain() == PlotAreaTerrainType.ROAD) {
|
if (area.getTerrain() == PlotAreaTerrainType.ROAD) {
|
||||||
PlotManager manager = area.getPlotManager();
|
PlotManager manager = area.getPlotManager();
|
||||||
final boolean[][] canPlace = new boolean[16][16];
|
final boolean[][] canPlace = new boolean[16][16];
|
||||||
boolean has = false;
|
boolean has = false;
|
||||||
for (int x = bxx; x <= txx; x++) {
|
for (int x = relativeBottomX; x <= relativeTopX; x++) {
|
||||||
for (int z = bzz; z <= tzz; z++) {
|
for (int z = relativeBottomZ; z <= relativeTopZ; z++) {
|
||||||
int rx = x + blockX;
|
int worldX = x + blockX;
|
||||||
int rz = z + blockZ;
|
int worldZ = z + blockZ;
|
||||||
boolean can = manager.getPlotId(rx, 0, rz) == null;
|
boolean can = manager.getPlotId(worldX, 0, worldZ) == null;
|
||||||
if (can) {
|
if (can) {
|
||||||
for (int y = 1; y < 128; y++) {
|
for (int y = 1; y < 128; y++) {
|
||||||
queue.setBlock(rx, y, rz, air);
|
queue.setBlock(worldX, y, worldZ, air);
|
||||||
}
|
}
|
||||||
canPlace[x][z] = true;
|
canPlace[x][z] = true;
|
||||||
has = true;
|
has = true;
|
||||||
@ -140,47 +133,19 @@ public class AugmentedUtils {
|
|||||||
if (!has) {
|
if (!has) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
toReturn = true;
|
generationResult = true;
|
||||||
secondaryMask = new DelegateLocalBlockQueue(primaryMask) {
|
secondaryMask = new LocationOffsetDelegateLocalBlockQueue(canPlace, blockX,
|
||||||
@Override public boolean setBlock(int x, int y, int z, BlockState id) {
|
blockZ, primaryMask);
|
||||||
if (canPlace[x - blockX][z - blockZ]) {
|
|
||||||
return super.setBlock(x, y, z, id);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public boolean setBlock(int x, int y, int z, BaseBlock id) {
|
|
||||||
try {
|
|
||||||
if (canPlace[x - blockX][z - blockZ]) {
|
|
||||||
return super.setBlock(x, y, z, id);
|
|
||||||
}
|
|
||||||
} catch (final Exception e) {
|
|
||||||
PlotSquared.debug(String.format("Failed to set block at: %d;%d;%d (to = %s) with offset %d;%d."
|
|
||||||
+ " Translated to: %d;%d", x, y, z, id, blockX, blockZ, x - blockX, z - blockZ));
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public boolean setBlock(int x, int y, int z, Pattern pattern) {
|
|
||||||
final BlockVector3 blockVector3 = BlockVector3.at(x + blockX, y, z + blockZ);
|
|
||||||
return this.setBlock(x, y, z, pattern.apply(blockVector3));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public boolean setBiome(int x, int y, BiomeType biome) {
|
|
||||||
return super.setBiome(x, y, biome);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
} else {
|
} else {
|
||||||
secondaryMask = primaryMask;
|
secondaryMask = primaryMask;
|
||||||
for (int x = bxx; x <= txx; x++) {
|
for (int x = relativeBottomX; x <= relativeTopX; x++) {
|
||||||
for (int z = bzz; z <= tzz; z++) {
|
for (int z = relativeBottomZ; z <= relativeTopZ; z++) {
|
||||||
for (int y = 1; y < 128; y++) {
|
for (int y = 1; y < 128; y++) {
|
||||||
queue.setBlock(blockX + x, y, blockZ + z, air);
|
queue.setBlock(blockX + x, y, blockZ + z, air);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
toReturn = true;
|
generationResult = true;
|
||||||
}
|
}
|
||||||
primaryMask.setChunkObject(chunkObject);
|
primaryMask.setChunkObject(chunkObject);
|
||||||
primaryMask.setForceSync(true);
|
primaryMask.setForceSync(true);
|
||||||
@ -196,6 +161,7 @@ public class AugmentedUtils {
|
|||||||
queue.setForceSync(true);
|
queue.setForceSync(true);
|
||||||
queue.flush();
|
queue.flush();
|
||||||
}
|
}
|
||||||
return toReturn;
|
return generationResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -70,11 +70,11 @@ public class HybridGen extends IndependentPlotGenerator {
|
|||||||
Preconditions.checkNotNull(result, "result cannot be null");
|
Preconditions.checkNotNull(result, "result cannot be null");
|
||||||
Preconditions.checkNotNull(settings, "settings cannot be null");
|
Preconditions.checkNotNull(settings, "settings cannot be null");
|
||||||
|
|
||||||
HybridPlotWorld hpw = (HybridPlotWorld) settings;
|
HybridPlotWorld hybridPlotWorld = (HybridPlotWorld) settings;
|
||||||
// Biome
|
// Biome
|
||||||
result.fillBiome(hpw.getPlotBiome());
|
result.fillBiome(hybridPlotWorld.getPlotBiome());
|
||||||
// Bedrock
|
// Bedrock
|
||||||
if (hpw.PLOT_BEDROCK) {
|
if (hybridPlotWorld.PLOT_BEDROCK) {
|
||||||
for (short x = 0; x < 16; x++) {
|
for (short x = 0; x < 16; x++) {
|
||||||
for (short z = 0; z < 16; z++) {
|
for (short z = 0; z < 16; z++) {
|
||||||
result.setBlock(x, 0, z, BlockTypes.BEDROCK.getDefaultState());
|
result.setBlock(x, 0, z, BlockTypes.BEDROCK.getDefaultState());
|
||||||
@ -83,110 +83,122 @@ public class HybridGen extends IndependentPlotGenerator {
|
|||||||
}
|
}
|
||||||
// Coords
|
// Coords
|
||||||
Location min = result.getMin();
|
Location min = result.getMin();
|
||||||
int bx = (min.getX()) - hpw.ROAD_OFFSET_X;
|
int bx = (min.getX()) - hybridPlotWorld.ROAD_OFFSET_X;
|
||||||
int bz = (min.getZ()) - hpw.ROAD_OFFSET_Z;
|
int bz = (min.getZ()) - hybridPlotWorld.ROAD_OFFSET_Z;
|
||||||
short rbx;
|
// The relative X-coordinate (within the plot) of the minimum X coordinate
|
||||||
|
// contained in the scoped queue
|
||||||
|
short relativeOffsetX;
|
||||||
if (bx < 0) {
|
if (bx < 0) {
|
||||||
rbx = (short) (hpw.SIZE + (bx % hpw.SIZE));
|
relativeOffsetX = (short) (hybridPlotWorld.SIZE + (bx % hybridPlotWorld.SIZE));
|
||||||
} else {
|
} else {
|
||||||
rbx = (short) (bx % hpw.SIZE);
|
relativeOffsetX = (short) (bx % hybridPlotWorld.SIZE);
|
||||||
}
|
}
|
||||||
short rbz;
|
// The relative Z-coordinate (within the plot) of the minimum Z coordinate
|
||||||
|
// contained in the scoped queue
|
||||||
|
short relativeOffsetZ;
|
||||||
if (bz < 0) {
|
if (bz < 0) {
|
||||||
rbz = (short) (hpw.SIZE + (bz % hpw.SIZE));
|
relativeOffsetZ = (short) (hybridPlotWorld.SIZE + (bz % hybridPlotWorld.SIZE));
|
||||||
} else {
|
} else {
|
||||||
rbz = (short) (bz % hpw.SIZE);
|
relativeOffsetZ = (short) (bz % hybridPlotWorld.SIZE);
|
||||||
}
|
}
|
||||||
short[] rx = new short[16];
|
// The X-coordinate of a given X coordinate, relative to the
|
||||||
boolean[] gx = new boolean[16];
|
// plot (Counting from the corner with the least positive
|
||||||
boolean[] wx = new boolean[16];
|
// coordinates)
|
||||||
|
short[] relativeX = new short[16];
|
||||||
|
boolean[] insideRoadX = new boolean[16];
|
||||||
|
boolean[] insideWallX = new boolean[16];
|
||||||
for (short i = 0; i < 16; i++) {
|
for (short i = 0; i < 16; i++) {
|
||||||
short v = (short) (rbx + i);
|
short v = (short) (relativeOffsetX + i);
|
||||||
if (v >= hpw.SIZE) {
|
if (v >= hybridPlotWorld.SIZE) {
|
||||||
v -= hpw.SIZE;
|
v -= hybridPlotWorld.SIZE;
|
||||||
}
|
}
|
||||||
rx[i] = v;
|
relativeX[i] = v;
|
||||||
if (hpw.ROAD_WIDTH != 0) {
|
if (hybridPlotWorld.ROAD_WIDTH != 0) {
|
||||||
gx[i] = v < hpw.PATH_WIDTH_LOWER || v > hpw.PATH_WIDTH_UPPER;
|
insideRoadX[i] = v < hybridPlotWorld.PATH_WIDTH_LOWER || v > hybridPlotWorld.PATH_WIDTH_UPPER;
|
||||||
wx[i] = v == hpw.PATH_WIDTH_LOWER || v == hpw.PATH_WIDTH_UPPER;
|
insideWallX[i] = v == hybridPlotWorld.PATH_WIDTH_LOWER || v == hybridPlotWorld.PATH_WIDTH_UPPER;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
short[] rz = new short[16];
|
// The Z-coordinate of a given Z coordinate, relative to the
|
||||||
boolean[] gz = new boolean[16];
|
// plot (Counting from the corner with the least positive
|
||||||
boolean[] wz = new boolean[16];
|
// coordinates)
|
||||||
|
short[] relativeZ = new short[16];
|
||||||
|
// Whether or not the given Z coordinate belongs to the road
|
||||||
|
boolean[] insideRoadZ = new boolean[16];
|
||||||
|
// Whether or not the given Z coordinate belongs to the wall
|
||||||
|
boolean[] insideWallZ = new boolean[16];
|
||||||
for (short i = 0; i < 16; i++) {
|
for (short i = 0; i < 16; i++) {
|
||||||
short v = (short) (rbz + i);
|
short v = (short) (relativeOffsetZ + i);
|
||||||
if (v >= hpw.SIZE) {
|
if (v >= hybridPlotWorld.SIZE) {
|
||||||
v -= hpw.SIZE;
|
v -= hybridPlotWorld.SIZE;
|
||||||
}
|
}
|
||||||
rz[i] = v;
|
relativeZ[i] = v;
|
||||||
if (hpw.ROAD_WIDTH != 0) {
|
if (hybridPlotWorld.ROAD_WIDTH != 0) {
|
||||||
gz[i] = v < hpw.PATH_WIDTH_LOWER || v > hpw.PATH_WIDTH_UPPER;
|
insideRoadZ[i] = v < hybridPlotWorld.PATH_WIDTH_LOWER || v > hybridPlotWorld.PATH_WIDTH_UPPER;
|
||||||
wz[i] = v == hpw.PATH_WIDTH_LOWER || v == hpw.PATH_WIDTH_UPPER;
|
insideWallZ[i] = v == hybridPlotWorld.PATH_WIDTH_LOWER || v == hybridPlotWorld.PATH_WIDTH_UPPER;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// generation
|
// generation
|
||||||
for (short x = 0; x < 16; x++) {
|
for (short x = 0; x < 16; x++) {
|
||||||
if (gx[x]) {
|
if (insideRoadX[x]) {
|
||||||
for (short z = 0; z < 16; z++) {
|
for (short z = 0; z < 16; z++) {
|
||||||
// Road
|
// Road
|
||||||
for (int y = 1; y <= hpw.ROAD_HEIGHT; y++) {
|
for (int y = 1; y <= hybridPlotWorld.ROAD_HEIGHT; y++) {
|
||||||
result.setBlock(x, y, z, hpw.ROAD_BLOCK.toPattern());
|
result.setBlock(x, y, z, hybridPlotWorld.ROAD_BLOCK.toPattern());
|
||||||
}
|
}
|
||||||
if (hpw.ROAD_SCHEMATIC_ENABLED) {
|
if (hybridPlotWorld.ROAD_SCHEMATIC_ENABLED) {
|
||||||
placeSchem(hpw, result, rx[x], rz[z], x, z, true);
|
placeSchem(hybridPlotWorld, result, relativeX[x], relativeZ[z], x, z, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (wx[x]) {
|
} else if (insideWallX[x]) {
|
||||||
for (short z = 0; z < 16; z++) {
|
for (short z = 0; z < 16; z++) {
|
||||||
if (gz[z]) {
|
if (insideRoadZ[z]) {
|
||||||
// road
|
// road
|
||||||
for (int y = 1; y <= hpw.ROAD_HEIGHT; y++) {
|
for (int y = 1; y <= hybridPlotWorld.ROAD_HEIGHT; y++) {
|
||||||
result.setBlock(x, y, z, hpw.ROAD_BLOCK.toPattern());
|
result.setBlock(x, y, z, hybridPlotWorld.ROAD_BLOCK.toPattern());
|
||||||
}
|
}
|
||||||
if (hpw.ROAD_SCHEMATIC_ENABLED) {
|
if (hybridPlotWorld.ROAD_SCHEMATIC_ENABLED) {
|
||||||
placeSchem(hpw, result, rx[x], rz[z], x, z, true);
|
placeSchem(hybridPlotWorld, result, relativeX[x], relativeZ[z], x, z, true);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// wall
|
// wall
|
||||||
for (int y = 1; y <= hpw.WALL_HEIGHT; y++) {
|
for (int y = 1; y <= hybridPlotWorld.WALL_HEIGHT; y++) {
|
||||||
result.setBlock(x, y, z, hpw.WALL_FILLING.toPattern());
|
result.setBlock(x, y, z, hybridPlotWorld.WALL_FILLING.toPattern());
|
||||||
}
|
}
|
||||||
if (!hpw.ROAD_SCHEMATIC_ENABLED) {
|
if (!hybridPlotWorld.ROAD_SCHEMATIC_ENABLED) {
|
||||||
result.setBlock(x, hpw.WALL_HEIGHT + 1, z, hpw.WALL_BLOCK.toPattern());
|
result.setBlock(x, hybridPlotWorld.WALL_HEIGHT + 1, z, hybridPlotWorld.WALL_BLOCK.toPattern());
|
||||||
} else {
|
} else {
|
||||||
placeSchem(hpw, result, rx[x], rz[z], x, z, true);
|
placeSchem(hybridPlotWorld, result, relativeX[x], relativeZ[z], x, z, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (short z = 0; z < 16; z++) {
|
for (short z = 0; z < 16; z++) {
|
||||||
if (gz[z]) {
|
if (insideRoadZ[z]) {
|
||||||
// road
|
// road
|
||||||
for (int y = 1; y <= hpw.ROAD_HEIGHT; y++) {
|
for (int y = 1; y <= hybridPlotWorld.ROAD_HEIGHT; y++) {
|
||||||
result.setBlock(x, y, z, hpw.ROAD_BLOCK.toPattern());
|
result.setBlock(x, y, z, hybridPlotWorld.ROAD_BLOCK.toPattern());
|
||||||
}
|
}
|
||||||
if (hpw.ROAD_SCHEMATIC_ENABLED) {
|
if (hybridPlotWorld.ROAD_SCHEMATIC_ENABLED) {
|
||||||
placeSchem(hpw, result, rx[x], rz[z], x, z, true);
|
placeSchem(hybridPlotWorld, result, relativeX[x], relativeZ[z], x, z, true);
|
||||||
}
|
}
|
||||||
} else if (wz[z]) {
|
} else if (insideWallZ[z]) {
|
||||||
// wall
|
// wall
|
||||||
for (int y = 1; y <= hpw.WALL_HEIGHT; y++) {
|
for (int y = 1; y <= hybridPlotWorld.WALL_HEIGHT; y++) {
|
||||||
result.setBlock(x, y, z, hpw.WALL_FILLING.toPattern());
|
result.setBlock(x, y, z, hybridPlotWorld.WALL_FILLING.toPattern());
|
||||||
}
|
}
|
||||||
if (!hpw.ROAD_SCHEMATIC_ENABLED) {
|
if (!hybridPlotWorld.ROAD_SCHEMATIC_ENABLED) {
|
||||||
result.setBlock(x, hpw.WALL_HEIGHT + 1, z, hpw.WALL_BLOCK.toPattern());
|
result.setBlock(x, hybridPlotWorld.WALL_HEIGHT + 1, z, hybridPlotWorld.WALL_BLOCK.toPattern());
|
||||||
} else {
|
} else {
|
||||||
placeSchem(hpw, result, rx[x], rz[z], x, z, true);
|
placeSchem(hybridPlotWorld, result, relativeX[x], relativeZ[z], x, z, true);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// plot
|
// plot
|
||||||
for (int y = 1; y < hpw.PLOT_HEIGHT; y++) {
|
for (int y = 1; y < hybridPlotWorld.PLOT_HEIGHT; y++) {
|
||||||
result.setBlock(x, y, z, hpw.MAIN_BLOCK.toPattern());
|
result.setBlock(x, y, z, hybridPlotWorld.MAIN_BLOCK.toPattern());
|
||||||
}
|
}
|
||||||
result.setBlock(x, hpw.PLOT_HEIGHT, z, hpw.TOP_BLOCK.toPattern());
|
result.setBlock(x, hybridPlotWorld.PLOT_HEIGHT, z, hybridPlotWorld.TOP_BLOCK.toPattern());
|
||||||
if (hpw.PLOT_SCHEMATIC) {
|
if (hybridPlotWorld.PLOT_SCHEMATIC) {
|
||||||
placeSchem(hpw, result, rx[x], rz[z], x, z, false);
|
placeSchem(hybridPlotWorld, result, relativeX[x], relativeZ[z], x, z, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -194,68 +206,6 @@ public class HybridGen extends IndependentPlotGenerator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* @Override public boolean populateChunk(ScopedLocalBlockQueue result, PlotArea settings) {
|
|
||||||
HybridPlotWorld hpw = (HybridPlotWorld) settings;
|
|
||||||
if (hpw.G_SCH_STATE != null) {
|
|
||||||
Location min = result.getMin();
|
|
||||||
int cx = min.getX() >> 4;
|
|
||||||
int cz = min.getZ() >> 4;
|
|
||||||
int p1x = cx << 4;
|
|
||||||
int p1z = cz << 4;
|
|
||||||
int bx = p1x - hpw.ROAD_OFFSET_X;
|
|
||||||
int bz = p1z - hpw.ROAD_OFFSET_Z;
|
|
||||||
short rbx;
|
|
||||||
if (bx < 0) {
|
|
||||||
rbx = (short) (hpw.SIZE + (bx % hpw.SIZE));
|
|
||||||
} else {
|
|
||||||
rbx = (short) (bx % hpw.SIZE);
|
|
||||||
}
|
|
||||||
short rbz;
|
|
||||||
if (bz < 0) {
|
|
||||||
rbz = (short) (hpw.SIZE + (bz % hpw.SIZE));
|
|
||||||
} else {
|
|
||||||
rbz = (short) (bz % hpw.SIZE);
|
|
||||||
}
|
|
||||||
short[] rx = new short[16];
|
|
||||||
for (short i = 0; i < 16; i++) {
|
|
||||||
short v = (short) (rbx + i);
|
|
||||||
if (v >= hpw.SIZE) {
|
|
||||||
v -= hpw.SIZE;
|
|
||||||
}
|
|
||||||
rx[i] = v;
|
|
||||||
}
|
|
||||||
short[] rz = new short[16];
|
|
||||||
for (short i = 0; i < 16; i++) {
|
|
||||||
short v = (short) (rbz + i);
|
|
||||||
if (v >= hpw.SIZE) {
|
|
||||||
v -= hpw.SIZE;
|
|
||||||
}
|
|
||||||
rz[i] = v;
|
|
||||||
}
|
|
||||||
LocalBlockQueue queue = null;
|
|
||||||
for (short x = 0; x < 16; x++) {
|
|
||||||
for (short z = 0; z < 16; z++) {
|
|
||||||
int pair = MathMan.pair(rx[x], rz[z]);
|
|
||||||
HashMap<Integer, CompoundTag> map = hpw.G_SCH_STATE.get(pair);
|
|
||||||
if (map != null) {
|
|
||||||
for (Entry<Integer, CompoundTag> entry : map.entrySet()) {
|
|
||||||
if (queue == null) {
|
|
||||||
queue = GlobalBlockQueue.IMP.getNewQueue(hpw.worldname, false);
|
|
||||||
}
|
|
||||||
CompoundTag tag = entry.getValue();
|
|
||||||
SchematicHandler.manager
|
|
||||||
.restoreTile(queue, tag, p1x + x, entry.getKey(), p1z + z);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (queue != null) {
|
|
||||||
queue.flush();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}*/
|
|
||||||
|
|
||||||
@Override public PlotArea getNewPlotArea(String world, String id, PlotId min, PlotId max) {
|
@Override public PlotArea getNewPlotArea(String world, String id, PlotId min, PlotId max) {
|
||||||
return new HybridPlotWorld(world, id, this, min, max);
|
return new HybridPlotWorld(world, id, this, min, max);
|
||||||
}
|
}
|
||||||
|
@ -209,13 +209,15 @@ public class HybridPlotManager extends ClassicPlotManager {
|
|||||||
// The component blocks
|
// The component blocks
|
||||||
final Pattern plotfloor = hybridPlotWorld.TOP_BLOCK.toPattern();
|
final Pattern plotfloor = hybridPlotWorld.TOP_BLOCK.toPattern();
|
||||||
final Pattern filling = hybridPlotWorld.MAIN_BLOCK.toPattern();
|
final Pattern filling = hybridPlotWorld.MAIN_BLOCK.toPattern();
|
||||||
|
|
||||||
final BlockState bedrock;
|
final BlockState bedrock;
|
||||||
|
final BlockState air = BlockTypes.AIR.getDefaultState();
|
||||||
if (hybridPlotWorld.PLOT_BEDROCK) {
|
if (hybridPlotWorld.PLOT_BEDROCK) {
|
||||||
bedrock = BlockUtil.get((short) 7, (byte) 0);
|
bedrock = BlockTypes.BEDROCK.getDefaultState();
|
||||||
} else {
|
} else {
|
||||||
bedrock = BlockUtil.get((short) 0, (byte) 0);
|
bedrock = air;
|
||||||
}
|
}
|
||||||
final BlockState air = BlockUtil.get((short) 0, (byte) 0);
|
|
||||||
final BiomeType biome = hybridPlotWorld.getPlotBiome();
|
final BiomeType biome = hybridPlotWorld.getPlotBiome();
|
||||||
final LocalBlockQueue queue = hybridPlotWorld.getQueue(false);
|
final LocalBlockQueue queue = hybridPlotWorld.getQueue(false);
|
||||||
ChunkManager.chunkTask(pos1, pos2, new RunnableVal<int[]>() {
|
ChunkManager.chunkTask(pos1, pos2, new RunnableVal<int[]>() {
|
||||||
|
@ -0,0 +1,77 @@
|
|||||||
|
/*
|
||||||
|
* _____ _ _ _____ _
|
||||||
|
* | __ \| | | | / ____| | |
|
||||||
|
* | |__) | | ___ | |_| (___ __ _ _ _ __ _ _ __ ___ __| |
|
||||||
|
* | ___/| |/ _ \| __|\___ \ / _` | | | |/ _` | '__/ _ \/ _` |
|
||||||
|
* | | | | (_) | |_ ____) | (_| | |_| | (_| | | | __/ (_| |
|
||||||
|
* |_| |_|\___/ \__|_____/ \__, |\__,_|\__,_|_| \___|\__,_|
|
||||||
|
* | |
|
||||||
|
* |_|
|
||||||
|
* PlotSquared plot management system for Minecraft
|
||||||
|
* Copyright (C) 2020 IntellectualSites
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package com.github.intellectualsites.plotsquared.plot.util.block;
|
||||||
|
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
|
||||||
|
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||||
|
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||||
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
|
import lombok.Getter;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
public class AreaBoundDelegateLocalBlockQueue extends DelegateLocalBlockQueue {
|
||||||
|
|
||||||
|
@Getter private final PlotArea area;
|
||||||
|
|
||||||
|
public AreaBoundDelegateLocalBlockQueue(@NotNull final PlotArea area,
|
||||||
|
@Nullable final LocalBlockQueue parent) {
|
||||||
|
super(parent);
|
||||||
|
this.area = Objects.requireNonNull(area);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public boolean setBlock(int x, int y, int z, BlockState id) {
|
||||||
|
if (area.contains(x, z)) {
|
||||||
|
return super.setBlock(x, y, z, id);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public boolean setBlock(int x, int y, int z, BaseBlock id) {
|
||||||
|
if (area.contains(x, z)) {
|
||||||
|
return super.setBlock(x, y, z, id);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public boolean setBlock(int x, int y, int z, Pattern pattern) {
|
||||||
|
if (area.contains(x, z)) {
|
||||||
|
return super.setBlock(x, y, z, pattern);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public boolean setBiome(int x, int z, BiomeType biome) {
|
||||||
|
if (area.contains(x, z)) {
|
||||||
|
return super.setBiome(x, z, biome);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,81 @@
|
|||||||
|
/*
|
||||||
|
* _____ _ _ _____ _
|
||||||
|
* | __ \| | | | / ____| | |
|
||||||
|
* | |__) | | ___ | |_| (___ __ _ _ _ __ _ _ __ ___ __| |
|
||||||
|
* | ___/| |/ _ \| __|\___ \ / _` | | | |/ _` | '__/ _ \/ _` |
|
||||||
|
* | | | | (_) | |_ ____) | (_| | |_| | (_| | | | __/ (_| |
|
||||||
|
* |_| |_|\___/ \__|_____/ \__, |\__,_|\__,_|_| \___|\__,_|
|
||||||
|
* | |
|
||||||
|
* |_|
|
||||||
|
* PlotSquared plot management system for Minecraft
|
||||||
|
* Copyright (C) 2020 IntellectualSites
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package com.github.intellectualsites.plotsquared.plot.util.block;
|
||||||
|
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
||||||
|
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
|
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||||
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
public class LocationOffsetDelegateLocalBlockQueue extends DelegateLocalBlockQueue {
|
||||||
|
|
||||||
|
private final boolean[][] canPlace;
|
||||||
|
private final int blockX;
|
||||||
|
private final int blockZ;
|
||||||
|
|
||||||
|
public LocationOffsetDelegateLocalBlockQueue(final boolean[][] canPlace,
|
||||||
|
final int blockX, final int blockZ,
|
||||||
|
@Nullable LocalBlockQueue parent) {
|
||||||
|
super(parent);
|
||||||
|
this.canPlace = canPlace;
|
||||||
|
this.blockX = blockX;
|
||||||
|
this.blockZ = blockZ;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public boolean setBlock(int x, int y, int z, BlockState id) {
|
||||||
|
if (canPlace[x - blockX][z - blockZ]) {
|
||||||
|
return super.setBlock(x, y, z, id);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public boolean setBlock(int x, int y, int z, BaseBlock id) {
|
||||||
|
try {
|
||||||
|
if (canPlace[x - blockX][z - blockZ]) {
|
||||||
|
return super.setBlock(x, y, z, id);
|
||||||
|
}
|
||||||
|
} catch (final Exception e) {
|
||||||
|
PlotSquared.debug(String.format("Failed to set block at: %d;%d;%d (to = %s) with offset %d;%d."
|
||||||
|
+ " Translated to: %d;%d", x, y, z, id, blockX, blockZ, x - blockX, z - blockZ));
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public boolean setBlock(int x, int y, int z, Pattern pattern) {
|
||||||
|
final BlockVector3 blockVector3 = BlockVector3.at(x + blockX, y, z + blockZ);
|
||||||
|
return this.setBlock(x, y, z, pattern.apply(blockVector3));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public boolean setBiome(int x, int y, BiomeType biome) {
|
||||||
|
return super.setBiome(x, y, biome);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user