mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2025-06-25 02:04:44 +02:00
Use patterns instead of BlockBucket
Still use BlockBucket for loading/saving from config
This commit is contained in:
@ -65,8 +65,6 @@ import com.github.intellectualsites.plotsquared.plot.util.WorldUtil;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.block.QueueProvider;
|
||||
import com.github.intellectualsites.plotsquared.plot.uuid.UUIDWrapper;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import com.sk89q.worldedit.bukkit.BukkitCommandSender;
|
||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import io.papermc.lib.PaperLib;
|
||||
|
@ -2,15 +2,13 @@ package com.github.intellectualsites.plotsquared.bukkit.generator;
|
||||
|
||||
import com.github.intellectualsites.plotsquared.bukkit.util.BukkitUtil;
|
||||
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
||||
import com.github.intellectualsites.plotsquared.plot.generator.HybridPlotWorld;
|
||||
import com.github.intellectualsites.plotsquared.plot.generator.IndependentPlotGenerator;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.BlockBucket;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Location;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotId;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.MathMan;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.world.BlockUtil;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.block.ScopedLocalBlockQueue;
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Biome;
|
||||
@ -37,30 +35,6 @@ import java.util.Random;
|
||||
return PlotSquared.get().IMP.getDefaultGenerator().getNewPlotArea(world, id, min, max);
|
||||
}
|
||||
|
||||
@Override public BlockBucket[][] generateBlockBucketChunk(PlotArea settings) {
|
||||
BlockBucket[][] blockBuckets = new BlockBucket[16][];
|
||||
HybridPlotWorld hpw = (HybridPlotWorld) settings;
|
||||
// Bedrock
|
||||
if (hpw.PLOT_BEDROCK) {
|
||||
for (short x = 0; x < 16; x++) {
|
||||
for (short z = 0; z < 16; z++) {
|
||||
blockBuckets[0][(z << 4) | x] =
|
||||
BlockBucket.withSingle(BlockUtil.get("bedrock"));
|
||||
}
|
||||
}
|
||||
}
|
||||
for (short x = 0; x < 16; x++) {
|
||||
for (short z = 0; z < 16; z++) {
|
||||
for (int y = 1; y < hpw.PLOT_HEIGHT; y++) {
|
||||
blockBuckets[y >> 4][((y & 0xF) << 8) | (z << 4) | x] = hpw.MAIN_BLOCK;
|
||||
}
|
||||
blockBuckets[hpw.PLOT_HEIGHT >> 4][((hpw.PLOT_HEIGHT & 0xF) << 8) | (z << 4) | x] =
|
||||
hpw.MAIN_BLOCK;
|
||||
}
|
||||
}
|
||||
return blockBuckets;
|
||||
}
|
||||
|
||||
@Override public void generateChunk(final ScopedLocalBlockQueue result, PlotArea settings) {
|
||||
World world = BukkitUtil.getWorld(this.world);
|
||||
Location min = result.getMin();
|
||||
@ -71,7 +45,7 @@ import java.util.Random;
|
||||
ChunkGenerator.BiomeGrid grid = new ChunkGenerator.BiomeGrid() {
|
||||
@Override public void setBiome(@Range(from = 0, to = 15) int x,
|
||||
@Range(from = 0, to = 15) int z, Biome biome) {
|
||||
result.setBiome(x, z, biome.name());
|
||||
result.setBiome(x, z, BukkitAdapter.adapt(biome));
|
||||
}
|
||||
|
||||
@Override @NotNull public Biome getBiome(int x, int z) {
|
||||
|
@ -12,7 +12,6 @@ import com.github.intellectualsites.plotsquared.plot.util.PlotWeather;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.StringMan;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler;
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.world.item.ItemType;
|
||||
import io.papermc.lib.PaperLib;
|
||||
|
@ -9,19 +9,19 @@ import com.github.intellectualsites.plotsquared.plot.object.Location;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotLoc;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.world.RegionUtil;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.ChunkManager;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.TaskManager;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.world.BlockUtil;
|
||||
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.ScopedLocalBlockQueue;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.world.RegionUtil;
|
||||
import com.sk89q.worldedit.bukkit.BukkitWorld;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import io.papermc.lib.PaperLib;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
@ -370,7 +370,7 @@ public class BukkitChunkManager extends ChunkManager {
|
||||
if (id != null) {
|
||||
value.setBlock(x1, y, z1, id);
|
||||
} else {
|
||||
value.setBlock(x1, y, z1, BlockUtil.get("air"));
|
||||
value.setBlock(x1, y, z1, BlockTypes.AIR.getDefaultState());
|
||||
}
|
||||
}
|
||||
for (int y = Math.min(128, ids.length);
|
||||
|
@ -1,321 +1,8 @@
|
||||
package com.github.intellectualsites.plotsquared.bukkit.util;
|
||||
|
||||
import com.github.intellectualsites.plotsquared.bukkit.generator.BukkitPlotGenerator;
|
||||
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Settings;
|
||||
import com.github.intellectualsites.plotsquared.plot.generator.HybridPlotWorld;
|
||||
import com.github.intellectualsites.plotsquared.plot.generator.HybridUtils;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.BlockBucket;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Location;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.ChunkManager;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.MathMan;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.TaskManager;
|
||||
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.expiry.PlotAnalysis;
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.block.data.Directional;
|
||||
import org.bukkit.generator.ChunkGenerator;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class BukkitHybridUtils extends HybridUtils {
|
||||
|
||||
@Override public void analyzeRegion(final String world, final CuboidRegion region,
|
||||
final RunnableVal<PlotAnalysis> whenDone) {
|
||||
// int diff, int variety, int vertices, int rotation, int height_sd
|
||||
/*
|
||||
* diff: compare to base by looping through all blocks
|
||||
* variety: add to HashSet for each BlockState
|
||||
* height_sd: loop over all blocks and get top block
|
||||
*
|
||||
* vertices: store air map and compare with neighbours
|
||||
* for each block check the adjacent
|
||||
* - Store all blocks then go through in second loop
|
||||
* - recheck each block
|
||||
*
|
||||
*/
|
||||
TaskManager.runTaskAsync(() -> {
|
||||
final LocalBlockQueue queue = GlobalBlockQueue.IMP.getNewQueue(world, false);
|
||||
final World worldObj = Bukkit.getWorld(world);
|
||||
final ChunkGenerator chunkGenerator = worldObj.getGenerator();
|
||||
if (!(chunkGenerator instanceof BukkitPlotGenerator)) {
|
||||
return;
|
||||
}
|
||||
|
||||
final Location bot = new Location(world, region.getMinimumPoint().getX(), region.getMinimumPoint().getY(), region.getMinimumPoint().getZ());
|
||||
final Location top = new Location(world, region.getMaximumPoint().getX(), region.getMaximumPoint().getY(), region.getMaximumPoint().getZ());
|
||||
|
||||
final int bx = bot.getX();
|
||||
final int bz = bot.getZ();
|
||||
final int tx = top.getX();
|
||||
final int tz = top.getZ();
|
||||
final int cbx = bx >> 4;
|
||||
final int cbz = bz >> 4;
|
||||
final int ctx = tx >> 4;
|
||||
final int ctz = tz >> 4;
|
||||
MainUtil.initCache();
|
||||
final int width = tx - bx + 1;
|
||||
final int length = tz - bz + 1;
|
||||
|
||||
System.gc();
|
||||
System.gc();
|
||||
final BlockBucket[][][] oldBlocks = new BlockBucket[256][width][length];
|
||||
final BlockState[][][] newBlocks = new BlockState[256][width][length];
|
||||
final BlockBucket airBucket = BlockBucket.withSingle(BlockTypes.AIR.getDefaultState());
|
||||
|
||||
PlotArea area = PlotSquared.get().getPlotArea(world, null);
|
||||
|
||||
if (!(area instanceof HybridPlotWorld)) {
|
||||
return;
|
||||
}
|
||||
|
||||
HybridPlotWorld hpw = (HybridPlotWorld) area;
|
||||
final BlockBucket[][] result = hpw.getBlockBucketChunk();
|
||||
|
||||
if (result == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (hpw.PLOT_SCHEMATIC) {
|
||||
short[] rx = new short[16];
|
||||
short[] rz = new short[16];
|
||||
short rbx;
|
||||
short rbz;
|
||||
if (bx < 0) {
|
||||
rbx = (short) (hpw.SIZE + (bx % hpw.SIZE));
|
||||
} else {
|
||||
rbx = (short) (bx % hpw.SIZE);
|
||||
}
|
||||
if (bz < 0) {
|
||||
rbz = (short) (hpw.SIZE + (bz % hpw.SIZE));
|
||||
} else {
|
||||
rbz = (short) (bz % hpw.SIZE);
|
||||
}
|
||||
for (short i = 0; i < 16; i++) {
|
||||
short v = (short) (rbx + i);
|
||||
if (v >= hpw.SIZE) {
|
||||
v -= hpw.SIZE;
|
||||
}
|
||||
rx[i] = v;
|
||||
}
|
||||
for (short i = 0; i < 16; i++) {
|
||||
short v = (short) (rbz + i);
|
||||
if (v >= hpw.SIZE) {
|
||||
v -= hpw.SIZE;
|
||||
}
|
||||
rz[i] = v;
|
||||
}
|
||||
int minY;
|
||||
if (Settings.Schematics.PASTE_ON_TOP) {
|
||||
minY = hpw.SCHEM_Y;
|
||||
} else {
|
||||
minY = 1;
|
||||
}
|
||||
for (short x = 0; x < 16; x++) {
|
||||
for (short z = 0; z < 16; z++) {
|
||||
BaseBlock[] blocks = hpw.G_SCH.get(MathMan.pair(rx[x], rz[z]));
|
||||
for (int y = 0; y < blocks.length; y++) {
|
||||
if (blocks[y] != null) {
|
||||
result[(minY + y) >> 4][(((minY + y) & 0xF) << 8) | (z << 4) | x] =
|
||||
BlockBucket.withSingle(blocks[y].toImmutableState());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final Runnable run = () -> ChunkManager.chunkTask(bot, top, new RunnableVal<int[]>() {
|
||||
@Override public void run(int[] value) {
|
||||
// [chunkx, chunkz, pos1x, pos1z, pos2x, pos2z, isedge]
|
||||
int X = value[0];
|
||||
int Z = value[1];
|
||||
int xb = (X << 4) - bx;
|
||||
int zb = (Z << 4) - bz;
|
||||
for (int i = 0; i < result.length; i++) {
|
||||
if (result[i] == null) {
|
||||
for (int j = 0; j < 4096; j++) {
|
||||
int x = MainUtil.x_loc[i][j] + xb;
|
||||
if (x < 0 || x >= width) {
|
||||
continue;
|
||||
}
|
||||
int z = MainUtil.z_loc[i][j] + zb;
|
||||
if (z < 0 || z >= length) {
|
||||
continue;
|
||||
}
|
||||
int y = MainUtil.y_loc[i][j];
|
||||
oldBlocks[y][x][z] = airBucket;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
for (int j = 0; j < result[i].length; j++) {
|
||||
int x = MainUtil.x_loc[i][j] + xb;
|
||||
if (x < 0 || x >= width) {
|
||||
continue;
|
||||
}
|
||||
int z = MainUtil.z_loc[i][j] + zb;
|
||||
if (z < 0 || z >= length) {
|
||||
continue;
|
||||
}
|
||||
int y = MainUtil.y_loc[i][j];
|
||||
oldBlocks[y][x][z] = result[i][j] != null ? result[i][j] : airBucket;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}, () -> TaskManager.runTaskAsync(() -> {
|
||||
int size = width * length;
|
||||
int[] changes = new int[size];
|
||||
int[] faces = new int[size];
|
||||
int[] data = new int[size];
|
||||
int[] air = new int[size];
|
||||
int[] variety = new int[size];
|
||||
int i = 0;
|
||||
for (int x = 0; x < width; x++) {
|
||||
for (int z = 0; z < length; z++) {
|
||||
Set<BlockType> types = new HashSet<>();
|
||||
for (int y = 0; y < 256; y++) {
|
||||
BlockBucket old = oldBlocks[y][x][z];
|
||||
try {
|
||||
if (old == null) {
|
||||
old = airBucket;
|
||||
}
|
||||
BlockState now = newBlocks[y][x][z];
|
||||
if (!old.getBlocks().contains(now)) {
|
||||
changes[i]++;
|
||||
}
|
||||
if (now.getBlockType().getMaterial().isAir()) {
|
||||
air[i]++;
|
||||
} else {
|
||||
// check vertices
|
||||
// modifications_adjacent
|
||||
if (x > 0 && z > 0 && y > 0 && x < width - 1 && z < length - 1
|
||||
&& y < 255) {
|
||||
if (newBlocks[y - 1][x][z].getBlockType().getMaterial().isAir()) {
|
||||
faces[i]++;
|
||||
}
|
||||
if (newBlocks[y][x - 1][z].getBlockType().getMaterial().isAir()) {
|
||||
faces[i]++;
|
||||
}
|
||||
if (newBlocks[y][x][z - 1].getBlockType().getMaterial().isAir()) {
|
||||
faces[i]++;
|
||||
}
|
||||
if (newBlocks[y + 1][x][z].getBlockType().getMaterial().isAir()) {
|
||||
faces[i]++;
|
||||
}
|
||||
if (newBlocks[y][x + 1][z].getBlockType().getMaterial().isAir()) {
|
||||
faces[i]++;
|
||||
}
|
||||
if (newBlocks[y][x][z + 1].getBlockType().getMaterial().isAir()) {
|
||||
faces[i]++;
|
||||
}
|
||||
}
|
||||
|
||||
Material material = BukkitAdapter.adapt(now.getBlockType());
|
||||
if (material != null) {
|
||||
BlockData blockData = material.createBlockData();
|
||||
if (blockData instanceof Directional) {
|
||||
data[i] += 8;
|
||||
} else if (!blockData.getClass().equals(BlockData.class)) {
|
||||
data[i]++;
|
||||
}
|
||||
}
|
||||
types.add(now.getBlockType());
|
||||
}
|
||||
} catch (NullPointerException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
variety[i] = types.size();
|
||||
i++;
|
||||
}
|
||||
}
|
||||
// analyze plot
|
||||
// put in analysis obj
|
||||
|
||||
// run whenDone
|
||||
PlotAnalysis analysis = new PlotAnalysis();
|
||||
analysis.changes = (int) (MathMan.getMean(changes) * 100);
|
||||
analysis.faces = (int) (MathMan.getMean(faces) * 100);
|
||||
analysis.data = (int) (MathMan.getMean(data) * 100);
|
||||
analysis.air = (int) (MathMan.getMean(air) * 100);
|
||||
analysis.variety = (int) (MathMan.getMean(variety) * 100);
|
||||
|
||||
analysis.changes_sd = (int) (MathMan.getSD(changes, analysis.changes) * 100);
|
||||
analysis.faces_sd = (int) (MathMan.getSD(faces, analysis.faces) * 100);
|
||||
analysis.data_sd = (int) (MathMan.getSD(data, analysis.data) * 100);
|
||||
analysis.air_sd = (int) (MathMan.getSD(air, analysis.air) * 100);
|
||||
analysis.variety_sd = (int) (MathMan.getSD(variety, analysis.variety) * 100);
|
||||
System.gc();
|
||||
System.gc();
|
||||
whenDone.value = analysis;
|
||||
whenDone.run();
|
||||
}), 5);
|
||||
System.gc();
|
||||
MainUtil.initCache();
|
||||
ChunkManager.chunkTask(bot, top, new RunnableVal<int[]>() {
|
||||
@Override public void run(int[] value) {
|
||||
int X = value[0];
|
||||
int Z = value[1];
|
||||
worldObj.loadChunk(X, Z);
|
||||
int minX;
|
||||
if (X == cbx) {
|
||||
minX = bx & 15;
|
||||
} else {
|
||||
minX = 0;
|
||||
}
|
||||
int minZ;
|
||||
if (Z == cbz) {
|
||||
minZ = bz & 15;
|
||||
} else {
|
||||
minZ = 0;
|
||||
}
|
||||
int maxX;
|
||||
if (X == ctx) {
|
||||
maxX = tx & 15;
|
||||
} else {
|
||||
maxX = 16;
|
||||
}
|
||||
int maxZ;
|
||||
if (Z == ctz) {
|
||||
maxZ = tz & 15;
|
||||
} else {
|
||||
maxZ = 16;
|
||||
}
|
||||
|
||||
int cbx = X << 4;
|
||||
int cbz = Z << 4;
|
||||
|
||||
int xb = cbx - bx;
|
||||
int zb = cbz - bz;
|
||||
for (int x = minX; x <= maxX; x++) {
|
||||
int xx = cbx + x;
|
||||
for (int z = minZ; z <= maxZ; z++) {
|
||||
int zz = cbz + z;
|
||||
for (int y = 0; y < 256; y++) {
|
||||
BlockState block = queue.getBlock(xx, y, zz);
|
||||
int xr = xb + x;
|
||||
int zr = zb + z;
|
||||
newBlocks[y][xr][zr] = block;
|
||||
}
|
||||
}
|
||||
}
|
||||
worldObj.unloadChunkRequest(X, Z);
|
||||
}
|
||||
}, () -> TaskManager.runTaskAsync(run), 5);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,6 @@ package com.github.intellectualsites.plotsquared.bukkit.util;
|
||||
|
||||
import com.github.intellectualsites.plotsquared.bukkit.object.schematic.StateWrapper;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Location;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.SchematicHandler;
|
||||
|
@ -3,8 +3,6 @@ package com.github.intellectualsites.plotsquared.bukkit.util;
|
||||
import com.github.intellectualsites.plotsquared.bukkit.BukkitMain;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.TaskManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class BukkitTaskManager extends TaskManager {
|
||||
|
||||
|
@ -7,7 +7,6 @@ import com.github.intellectualsites.plotsquared.plot.object.Location;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.schematic.PlotItem;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.MathMan;
|
||||
@ -18,6 +17,8 @@ import com.github.intellectualsites.plotsquared.plot.util.WorldUtil;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.world.BlockUtil;
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import com.sk89q.worldedit.bukkit.BukkitWorld;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import lombok.NonNull;
|
||||
import org.bukkit.Bukkit;
|
||||
@ -39,7 +40,6 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
@ -279,8 +279,8 @@ import java.util.Set;
|
||||
return getWorld(worldName) != null;
|
||||
}
|
||||
|
||||
@Override public String getBiome(String world, int x, int z) {
|
||||
return getWorld(world).getBiome(x, z).name();
|
||||
@Override public BiomeType getBiome(String world, int x, int z) {
|
||||
return BukkitAdapter.adapt(getWorld(world).getBiome(x, z));
|
||||
}
|
||||
|
||||
@Override public int getHighestBlock(@NonNull final String world, final int x, final int z) {
|
||||
@ -380,20 +380,6 @@ import java.util.Set;
|
||||
}
|
||||
}
|
||||
|
||||
@Override public int getBiomeFromString(@NonNull final String biomeString) {
|
||||
try {
|
||||
final Biome biome = Biome.valueOf(biomeString.toUpperCase());
|
||||
return Arrays.asList(Biome.values()).indexOf(biome);
|
||||
} catch (IllegalArgumentException ignored) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
@Override public String[] getBiomeList() {
|
||||
final Biome[] biomes = Biome.values();
|
||||
return Arrays.stream(biomes).map(Enum::name).toArray(String[]::new);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addItems(@NonNull final String worldName, @NonNull final PlotItem items) {
|
||||
final World world = getWorld(worldName);
|
||||
@ -433,9 +419,9 @@ import java.util.Set;
|
||||
|
||||
@Override
|
||||
public void setBiomes(@NonNull final String worldName, @NonNull final CuboidRegion region,
|
||||
@NonNull final String biomeString) {
|
||||
@NonNull final BiomeType biomeType) {
|
||||
final World world = getWorld(worldName);
|
||||
final Biome biome = Biome.valueOf(biomeString.toUpperCase());
|
||||
final Biome biome = BukkitAdapter.adapt(biomeType);
|
||||
for (int x = region.getMinimumPoint().getX(); x <= region.getMaximumPoint().getX(); x++) {
|
||||
for (int z = region.getMinimumPoint().getZ(); z <= region.getMaximumPoint().getZ(); z++) {
|
||||
world.setBiome(x, z, biome);
|
||||
@ -450,7 +436,7 @@ import java.util.Set;
|
||||
@Override public BlockState getBlock(@NonNull final Location location) {
|
||||
final World world = getWorld(location.getWorld());
|
||||
final Block block = world.getBlockAt(location.getX(), location.getY(), location.getZ());
|
||||
return BlockUtil.get(block.getType().name());
|
||||
return BukkitAdapter.asBlockType(block.getType()).getDefaultState();
|
||||
}
|
||||
|
||||
@Override public String getMainWorld() {
|
||||
|
@ -8,6 +8,7 @@ import com.github.intellectualsites.plotsquared.plot.util.block.BasicLocalBlockQ
|
||||
import com.github.intellectualsites.plotsquared.plot.util.world.BlockUtil;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import io.papermc.lib.PaperLib;
|
||||
@ -130,11 +131,11 @@ public class BukkitLocalQueue extends BasicLocalBlockQueue {
|
||||
int bx = lc.getX() << 4;
|
||||
int bz = lc.getX() << 4;
|
||||
for (int x = 0; x < lc.biomes.length; x++) {
|
||||
String[] biomes2 = lc.biomes[x];
|
||||
BiomeType[] biomes2 = lc.biomes[x];
|
||||
if (biomes2 != null) {
|
||||
for (String biomeStr : biomes2) {
|
||||
for (BiomeType biomeStr : biomes2) {
|
||||
if (biomeStr != null) {
|
||||
Biome biome = Biome.valueOf(biomeStr.toUpperCase());
|
||||
Biome biome = BukkitAdapter.adapt(biomeStr);
|
||||
worldObj.setBiome(bx, bz, biome);
|
||||
}
|
||||
}
|
||||
|
@ -5,11 +5,14 @@ import com.github.intellectualsites.plotsquared.bukkit.util.BukkitUtil;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.ChunkWrapper;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Location;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.world.BlockUtil;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.block.ScopedLocalBlockQueue;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.world.PatternUtil;
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
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 com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.bukkit.Chunk;
|
||||
@ -57,11 +60,11 @@ public class GenChunk extends ScopedLocalBlockQueue {
|
||||
chunkZ = wrap.z;
|
||||
}
|
||||
|
||||
@Override public void fillBiome(String biomeName) {
|
||||
@Override public void fillBiome(BiomeType biomeType) {
|
||||
if (biomeGrid == null) {
|
||||
return;
|
||||
}
|
||||
Biome biome = Biome.valueOf(biomeName.toUpperCase());
|
||||
Biome biome = BukkitAdapter.adapt(biomeType);
|
||||
for (int x = 0; x < 16; x++) {
|
||||
for (int z = 0; z < 16; z++) {
|
||||
this.biomeGrid.setBiome(x, z, biome);
|
||||
@ -92,8 +95,8 @@ public class GenChunk extends ScopedLocalBlockQueue {
|
||||
chunkData.setRegion(minX, minY, minZ, maxX + 1, maxY + 1, maxZ + 1, BukkitAdapter.adapt(block));
|
||||
}
|
||||
|
||||
@Override public boolean setBiome(int x, int z, String biome) {
|
||||
return setBiome(x, z, Biome.valueOf(biome.toUpperCase()));
|
||||
@Override public boolean setBiome(int x, int z, BiomeType biomeType) {
|
||||
return setBiome(x, z, BukkitAdapter.adapt(biomeType));
|
||||
}
|
||||
|
||||
public boolean setBiome(int x, int z, Biome biome) {
|
||||
@ -104,6 +107,10 @@ public class GenChunk extends ScopedLocalBlockQueue {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override public boolean setBlock(int x, int y, int z, Pattern pattern) {
|
||||
return setBlock(x, y, z, PatternUtil.apply(pattern, x, y, z));
|
||||
}
|
||||
|
||||
@Override public boolean setBlock(int x, int y, int z, BlockState id) {
|
||||
if (this.result == null) {
|
||||
this.chunkData.setBlock(x, y, z, BukkitAdapter.adapt(id));
|
||||
@ -130,7 +137,7 @@ public class GenChunk extends ScopedLocalBlockQueue {
|
||||
return true;
|
||||
}
|
||||
this.chunkData.setBlock(x, y, z, BukkitAdapter.adapt(id));
|
||||
this.storeCache(x, y, z, BlockUtil.get(id.getBlockType().getId()));
|
||||
this.storeCache(x, y, z, id.toImmutableState());
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -141,7 +148,7 @@ public class GenChunk extends ScopedLocalBlockQueue {
|
||||
}
|
||||
BlockState[] array = result[i];
|
||||
if (array == null) {
|
||||
return BlockUtil.get("");
|
||||
return BlockTypes.AIR.getDefaultState();
|
||||
}
|
||||
int j = MainUtil.CACHE_J[y][x][z];
|
||||
return array[j];
|
||||
|
Reference in New Issue
Block a user