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.PlotAreaType;
|
||||
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.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.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.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@ -63,19 +60,27 @@ public class AugmentedUtils {
|
||||
if (!enabled) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// The coordinates of the block on the
|
||||
// least positive corner of the chunk
|
||||
final int blockX = chunkX << 4;
|
||||
final int blockZ = chunkZ << 4;
|
||||
// Create a region that contains the
|
||||
// entire chunk
|
||||
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);
|
||||
if (areas.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
boolean toReturn = false;
|
||||
boolean generationResult = false;
|
||||
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) {
|
||||
return false;
|
||||
}
|
||||
// This means that full vanilla generation is used
|
||||
// so we do not interfere
|
||||
if (area.getTerrain() == PlotAreaTerrainType.ALL) {
|
||||
continue;
|
||||
}
|
||||
@ -87,50 +92,38 @@ public class AugmentedUtils {
|
||||
}
|
||||
LocalBlockQueue primaryMask;
|
||||
// coordinates
|
||||
int bxx;
|
||||
int bzz;
|
||||
int txx;
|
||||
int tzz;
|
||||
// gen
|
||||
int relativeBottomX;
|
||||
int relativeBottomZ;
|
||||
int relativeTopX;
|
||||
int relativeTopZ;
|
||||
// Generation
|
||||
if (area.getType() == PlotAreaType.PARTIAL) {
|
||||
bxx = Math.max(0, area.getRegion().getMinimumPoint().getX() - blockX);
|
||||
bzz = Math.max(0, area.getRegion().getMinimumPoint().getZ() - blockZ);
|
||||
txx = Math.min(15, area.getRegion().getMaximumPoint().getX() - blockX);
|
||||
tzz = 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;
|
||||
}
|
||||
relativeBottomX = Math.max(0, area.getRegion().getMinimumPoint().getX() - blockX);
|
||||
relativeBottomZ = Math.max(0, area.getRegion().getMinimumPoint().getZ() - blockZ);
|
||||
relativeTopX = Math.min(15, area.getRegion().getMaximumPoint().getX() - blockX);
|
||||
relativeTopZ = Math.min(15, area.getRegion().getMaximumPoint().getZ() - blockZ);
|
||||
|
||||
@Override public boolean setBiome(int x, int z, BiomeType biome) {
|
||||
if (area.contains(x, z)) {
|
||||
return super.setBiome(x, z, biome);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
primaryMask = new AreaBoundDelegateLocalBlockQueue(area, queue);
|
||||
} else {
|
||||
bxx = bzz = 0;
|
||||
txx = tzz = 15;
|
||||
relativeBottomX = relativeBottomZ = 0;
|
||||
relativeTopX = relativeTopZ = 15;
|
||||
primaryMask = queue;
|
||||
}
|
||||
|
||||
LocalBlockQueue secondaryMask;
|
||||
BlockState air = BlockTypes.AIR.getDefaultState();
|
||||
if (area.getTerrain() == PlotAreaTerrainType.ROAD) {
|
||||
PlotManager manager = area.getPlotManager();
|
||||
final boolean[][] canPlace = new boolean[16][16];
|
||||
boolean has = false;
|
||||
for (int x = bxx; x <= txx; x++) {
|
||||
for (int z = bzz; z <= tzz; z++) {
|
||||
int rx = x + blockX;
|
||||
int rz = z + blockZ;
|
||||
boolean can = manager.getPlotId(rx, 0, rz) == null;
|
||||
for (int x = relativeBottomX; x <= relativeTopX; x++) {
|
||||
for (int z = relativeBottomZ; z <= relativeTopZ; z++) {
|
||||
int worldX = x + blockX;
|
||||
int worldZ = z + blockZ;
|
||||
boolean can = manager.getPlotId(worldX, 0, worldZ) == null;
|
||||
if (can) {
|
||||
for (int y = 1; y < 128; y++) {
|
||||
queue.setBlock(rx, y, rz, air);
|
||||
queue.setBlock(worldX, y, worldZ, air);
|
||||
}
|
||||
canPlace[x][z] = true;
|
||||
has = true;
|
||||
@ -140,47 +133,19 @@ public class AugmentedUtils {
|
||||
if (!has) {
|
||||
continue;
|
||||
}
|
||||
toReturn = true;
|
||||
secondaryMask = new DelegateLocalBlockQueue(primaryMask) {
|
||||
@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);
|
||||
}
|
||||
};
|
||||
generationResult = true;
|
||||
secondaryMask = new LocationOffsetDelegateLocalBlockQueue(canPlace, blockX,
|
||||
blockZ, primaryMask);
|
||||
} else {
|
||||
secondaryMask = primaryMask;
|
||||
for (int x = bxx; x <= txx; x++) {
|
||||
for (int z = bzz; z <= tzz; z++) {
|
||||
for (int x = relativeBottomX; x <= relativeTopX; x++) {
|
||||
for (int z = relativeBottomZ; z <= relativeTopZ; z++) {
|
||||
for (int y = 1; y < 128; y++) {
|
||||
queue.setBlock(blockX + x, y, blockZ + z, air);
|
||||
}
|
||||
}
|
||||
}
|
||||
toReturn = true;
|
||||
generationResult = true;
|
||||
}
|
||||
primaryMask.setChunkObject(chunkObject);
|
||||
primaryMask.setForceSync(true);
|
||||
@ -196,6 +161,7 @@ public class AugmentedUtils {
|
||||
queue.setForceSync(true);
|
||||
queue.flush();
|
||||
}
|
||||
return toReturn;
|
||||
return generationResult;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -70,11 +70,11 @@ public class HybridGen extends IndependentPlotGenerator {
|
||||
Preconditions.checkNotNull(result, "result cannot be null");
|
||||
Preconditions.checkNotNull(settings, "settings cannot be null");
|
||||
|
||||
HybridPlotWorld hpw = (HybridPlotWorld) settings;
|
||||
HybridPlotWorld hybridPlotWorld = (HybridPlotWorld) settings;
|
||||
// Biome
|
||||
result.fillBiome(hpw.getPlotBiome());
|
||||
result.fillBiome(hybridPlotWorld.getPlotBiome());
|
||||
// Bedrock
|
||||
if (hpw.PLOT_BEDROCK) {
|
||||
if (hybridPlotWorld.PLOT_BEDROCK) {
|
||||
for (short x = 0; x < 16; x++) {
|
||||
for (short z = 0; z < 16; z++) {
|
||||
result.setBlock(x, 0, z, BlockTypes.BEDROCK.getDefaultState());
|
||||
@ -83,110 +83,122 @@ public class HybridGen extends IndependentPlotGenerator {
|
||||
}
|
||||
// Coords
|
||||
Location min = result.getMin();
|
||||
int bx = (min.getX()) - hpw.ROAD_OFFSET_X;
|
||||
int bz = (min.getZ()) - hpw.ROAD_OFFSET_Z;
|
||||
short rbx;
|
||||
int bx = (min.getX()) - hybridPlotWorld.ROAD_OFFSET_X;
|
||||
int bz = (min.getZ()) - hybridPlotWorld.ROAD_OFFSET_Z;
|
||||
// The relative X-coordinate (within the plot) of the minimum X coordinate
|
||||
// contained in the scoped queue
|
||||
short relativeOffsetX;
|
||||
if (bx < 0) {
|
||||
rbx = (short) (hpw.SIZE + (bx % hpw.SIZE));
|
||||
relativeOffsetX = (short) (hybridPlotWorld.SIZE + (bx % hybridPlotWorld.SIZE));
|
||||
} 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) {
|
||||
rbz = (short) (hpw.SIZE + (bz % hpw.SIZE));
|
||||
relativeOffsetZ = (short) (hybridPlotWorld.SIZE + (bz % hybridPlotWorld.SIZE));
|
||||
} else {
|
||||
rbz = (short) (bz % hpw.SIZE);
|
||||
relativeOffsetZ = (short) (bz % hybridPlotWorld.SIZE);
|
||||
}
|
||||
short[] rx = new short[16];
|
||||
boolean[] gx = new boolean[16];
|
||||
boolean[] wx = new boolean[16];
|
||||
// The X-coordinate of a given X coordinate, relative to the
|
||||
// plot (Counting from the corner with the least positive
|
||||
// coordinates)
|
||||
short[] relativeX = new short[16];
|
||||
boolean[] insideRoadX = new boolean[16];
|
||||
boolean[] insideWallX = new boolean[16];
|
||||
for (short i = 0; i < 16; i++) {
|
||||
short v = (short) (rbx + i);
|
||||
if (v >= hpw.SIZE) {
|
||||
v -= hpw.SIZE;
|
||||
short v = (short) (relativeOffsetX + i);
|
||||
if (v >= hybridPlotWorld.SIZE) {
|
||||
v -= hybridPlotWorld.SIZE;
|
||||
}
|
||||
rx[i] = v;
|
||||
if (hpw.ROAD_WIDTH != 0) {
|
||||
gx[i] = v < hpw.PATH_WIDTH_LOWER || v > hpw.PATH_WIDTH_UPPER;
|
||||
wx[i] = v == hpw.PATH_WIDTH_LOWER || v == hpw.PATH_WIDTH_UPPER;
|
||||
relativeX[i] = v;
|
||||
if (hybridPlotWorld.ROAD_WIDTH != 0) {
|
||||
insideRoadX[i] = v < hybridPlotWorld.PATH_WIDTH_LOWER || v > hybridPlotWorld.PATH_WIDTH_UPPER;
|
||||
insideWallX[i] = v == hybridPlotWorld.PATH_WIDTH_LOWER || v == hybridPlotWorld.PATH_WIDTH_UPPER;
|
||||
}
|
||||
}
|
||||
short[] rz = new short[16];
|
||||
boolean[] gz = new boolean[16];
|
||||
boolean[] wz = new boolean[16];
|
||||
// The Z-coordinate of a given Z coordinate, relative to the
|
||||
// plot (Counting from the corner with the least positive
|
||||
// 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++) {
|
||||
short v = (short) (rbz + i);
|
||||
if (v >= hpw.SIZE) {
|
||||
v -= hpw.SIZE;
|
||||
short v = (short) (relativeOffsetZ + i);
|
||||
if (v >= hybridPlotWorld.SIZE) {
|
||||
v -= hybridPlotWorld.SIZE;
|
||||
}
|
||||
rz[i] = v;
|
||||
if (hpw.ROAD_WIDTH != 0) {
|
||||
gz[i] = v < hpw.PATH_WIDTH_LOWER || v > hpw.PATH_WIDTH_UPPER;
|
||||
wz[i] = v == hpw.PATH_WIDTH_LOWER || v == hpw.PATH_WIDTH_UPPER;
|
||||
relativeZ[i] = v;
|
||||
if (hybridPlotWorld.ROAD_WIDTH != 0) {
|
||||
insideRoadZ[i] = v < hybridPlotWorld.PATH_WIDTH_LOWER || v > hybridPlotWorld.PATH_WIDTH_UPPER;
|
||||
insideWallZ[i] = v == hybridPlotWorld.PATH_WIDTH_LOWER || v == hybridPlotWorld.PATH_WIDTH_UPPER;
|
||||
}
|
||||
}
|
||||
// generation
|
||||
for (short x = 0; x < 16; x++) {
|
||||
if (gx[x]) {
|
||||
if (insideRoadX[x]) {
|
||||
for (short z = 0; z < 16; z++) {
|
||||
// Road
|
||||
for (int y = 1; y <= hpw.ROAD_HEIGHT; y++) {
|
||||
result.setBlock(x, y, z, hpw.ROAD_BLOCK.toPattern());
|
||||
for (int y = 1; y <= hybridPlotWorld.ROAD_HEIGHT; y++) {
|
||||
result.setBlock(x, y, z, hybridPlotWorld.ROAD_BLOCK.toPattern());
|
||||
}
|
||||
if (hpw.ROAD_SCHEMATIC_ENABLED) {
|
||||
placeSchem(hpw, result, rx[x], rz[z], x, z, true);
|
||||
if (hybridPlotWorld.ROAD_SCHEMATIC_ENABLED) {
|
||||
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++) {
|
||||
if (gz[z]) {
|
||||
if (insideRoadZ[z]) {
|
||||
// road
|
||||
for (int y = 1; y <= hpw.ROAD_HEIGHT; y++) {
|
||||
result.setBlock(x, y, z, hpw.ROAD_BLOCK.toPattern());
|
||||
for (int y = 1; y <= hybridPlotWorld.ROAD_HEIGHT; y++) {
|
||||
result.setBlock(x, y, z, hybridPlotWorld.ROAD_BLOCK.toPattern());
|
||||
}
|
||||
if (hpw.ROAD_SCHEMATIC_ENABLED) {
|
||||
placeSchem(hpw, result, rx[x], rz[z], x, z, true);
|
||||
if (hybridPlotWorld.ROAD_SCHEMATIC_ENABLED) {
|
||||
placeSchem(hybridPlotWorld, result, relativeX[x], relativeZ[z], x, z, true);
|
||||
}
|
||||
} else {
|
||||
// wall
|
||||
for (int y = 1; y <= hpw.WALL_HEIGHT; y++) {
|
||||
result.setBlock(x, y, z, hpw.WALL_FILLING.toPattern());
|
||||
for (int y = 1; y <= hybridPlotWorld.WALL_HEIGHT; y++) {
|
||||
result.setBlock(x, y, z, hybridPlotWorld.WALL_FILLING.toPattern());
|
||||
}
|
||||
if (!hpw.ROAD_SCHEMATIC_ENABLED) {
|
||||
result.setBlock(x, hpw.WALL_HEIGHT + 1, z, hpw.WALL_BLOCK.toPattern());
|
||||
if (!hybridPlotWorld.ROAD_SCHEMATIC_ENABLED) {
|
||||
result.setBlock(x, hybridPlotWorld.WALL_HEIGHT + 1, z, hybridPlotWorld.WALL_BLOCK.toPattern());
|
||||
} else {
|
||||
placeSchem(hpw, result, rx[x], rz[z], x, z, true);
|
||||
placeSchem(hybridPlotWorld, result, relativeX[x], relativeZ[z], x, z, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (short z = 0; z < 16; z++) {
|
||||
if (gz[z]) {
|
||||
if (insideRoadZ[z]) {
|
||||
// road
|
||||
for (int y = 1; y <= hpw.ROAD_HEIGHT; y++) {
|
||||
result.setBlock(x, y, z, hpw.ROAD_BLOCK.toPattern());
|
||||
for (int y = 1; y <= hybridPlotWorld.ROAD_HEIGHT; y++) {
|
||||
result.setBlock(x, y, z, hybridPlotWorld.ROAD_BLOCK.toPattern());
|
||||
}
|
||||
if (hpw.ROAD_SCHEMATIC_ENABLED) {
|
||||
placeSchem(hpw, result, rx[x], rz[z], x, z, true);
|
||||
if (hybridPlotWorld.ROAD_SCHEMATIC_ENABLED) {
|
||||
placeSchem(hybridPlotWorld, result, relativeX[x], relativeZ[z], x, z, true);
|
||||
}
|
||||
} else if (wz[z]) {
|
||||
} else if (insideWallZ[z]) {
|
||||
// wall
|
||||
for (int y = 1; y <= hpw.WALL_HEIGHT; y++) {
|
||||
result.setBlock(x, y, z, hpw.WALL_FILLING.toPattern());
|
||||
for (int y = 1; y <= hybridPlotWorld.WALL_HEIGHT; y++) {
|
||||
result.setBlock(x, y, z, hybridPlotWorld.WALL_FILLING.toPattern());
|
||||
}
|
||||
if (!hpw.ROAD_SCHEMATIC_ENABLED) {
|
||||
result.setBlock(x, hpw.WALL_HEIGHT + 1, z, hpw.WALL_BLOCK.toPattern());
|
||||
if (!hybridPlotWorld.ROAD_SCHEMATIC_ENABLED) {
|
||||
result.setBlock(x, hybridPlotWorld.WALL_HEIGHT + 1, z, hybridPlotWorld.WALL_BLOCK.toPattern());
|
||||
} else {
|
||||
placeSchem(hpw, result, rx[x], rz[z], x, z, true);
|
||||
placeSchem(hybridPlotWorld, result, relativeX[x], relativeZ[z], x, z, true);
|
||||
}
|
||||
} else {
|
||||
// plot
|
||||
for (int y = 1; y < hpw.PLOT_HEIGHT; y++) {
|
||||
result.setBlock(x, y, z, hpw.MAIN_BLOCK.toPattern());
|
||||
for (int y = 1; y < hybridPlotWorld.PLOT_HEIGHT; y++) {
|
||||
result.setBlock(x, y, z, hybridPlotWorld.MAIN_BLOCK.toPattern());
|
||||
}
|
||||
result.setBlock(x, hpw.PLOT_HEIGHT, z, hpw.TOP_BLOCK.toPattern());
|
||||
if (hpw.PLOT_SCHEMATIC) {
|
||||
placeSchem(hpw, result, rx[x], rz[z], x, z, false);
|
||||
result.setBlock(x, hybridPlotWorld.PLOT_HEIGHT, z, hybridPlotWorld.TOP_BLOCK.toPattern());
|
||||
if (hybridPlotWorld.PLOT_SCHEMATIC) {
|
||||
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) {
|
||||
return new HybridPlotWorld(world, id, this, min, max);
|
||||
}
|
||||
|
@ -209,13 +209,15 @@ public class HybridPlotManager extends ClassicPlotManager {
|
||||
// The component blocks
|
||||
final Pattern plotfloor = hybridPlotWorld.TOP_BLOCK.toPattern();
|
||||
final Pattern filling = hybridPlotWorld.MAIN_BLOCK.toPattern();
|
||||
|
||||
final BlockState bedrock;
|
||||
final BlockState air = BlockTypes.AIR.getDefaultState();
|
||||
if (hybridPlotWorld.PLOT_BEDROCK) {
|
||||
bedrock = BlockUtil.get((short) 7, (byte) 0);
|
||||
bedrock = BlockTypes.BEDROCK.getDefaultState();
|
||||
} 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 LocalBlockQueue queue = hybridPlotWorld.getQueue(false);
|
||||
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