block set test

This commit is contained in:
Jesse Boyd 2019-05-02 02:01:41 +10:00
parent eec08c81ad
commit f96760b36c
No known key found for this signature in database
GPG Key ID: 59F1DE6293AF6E1F
3 changed files with 44 additions and 3 deletions

View File

@ -1,10 +1,15 @@
package com.boydti.fawe.bukkit.beta;
import com.boydti.fawe.beta.Filter;
import com.boydti.fawe.beta.IChunk;
import com.boydti.fawe.beta.IGetBlocks;
import com.boydti.fawe.beta.IQueueExtent;
import com.boydti.fawe.beta.implementation.blocks.CharSetBlocks;
import com.boydti.fawe.beta.implementation.holder.ChunkHolder;
import com.google.common.util.concurrent.Futures;
import net.minecraft.server.v1_13_R2.Chunk;
import net.minecraft.server.v1_13_R2.ChunkSection;
import org.bukkit.World;
import java.util.concurrent.Future;
@ -25,6 +30,20 @@ public class BukkitChunkHolder<T extends Future<T>> extends ChunkHolder {
BukkitQueue extent = (BukkitQueue) getExtent();
BukkitGetBlocks get = (BukkitGetBlocks) getOrCreateGet();
CharSetBlocks set = (CharSetBlocks) getOrCreateSet();
int X = getX();
int Z = getZ();
Chunk currentNmsChunk = extent.ensureLoaded(X, Z);
ChunkSection[] sections = currentNmsChunk.getSections();
World world = extent.getBukkitWorld();
boolean hasSky = world.getEnvironment() == World.Environment.NORMAL;
for (int layer = 0; layer < 16; layer++) {
if (!set.hasSection(layer)) continue;
char[] arr = set.blocks[layer];
ChunkSection newSection = extent.newChunkSection(layer, hasSky, arr);
sections[layer] = newSection;
}
@ -48,8 +67,10 @@ public class BukkitChunkHolder<T extends Future<T>> extends ChunkHolder {
*/
throw new UnsupportedOperationException("Not implemented");
// throw new UnsupportedOperationException("Not implemented");
// return true;
return null;
// return (T) (Future) Futures.immediateFuture(null);
}
@Override

View File

@ -160,8 +160,8 @@ public class BukkitQueue extends SimpleCharQueueExtent {
NMS conversion
*/
public static ChunkSection newChunkSection(final int y2, final boolean flag, final char[] blocks) {
ChunkSection section = new ChunkSection(y2 << 4, flag);
public static ChunkSection newChunkSection(final int layer, final boolean flag, final char[] blocks) {
ChunkSection section = new ChunkSection(layer << 4, flag);
if (blocks == null) {
return section;
}

View File

@ -287,6 +287,26 @@ public class RegionCommands extends MethodCommands {
System.out.println(diff);
}
@Command(
aliases = {"db2"},
usage = "",
desc = "db2",
help = "db2"
)
public void db2(Player player, @Selection Region region) throws WorldEditException {
QueueHandler queueHandler = Fawe.get().getQueueHandler();
World world = player.getWorld();
IQueueExtent queue = queueHandler.getQueue(world);
BlockState block = BlockTypes.STONE.getDefaultState();
long start = System.currentTimeMillis();
for (BlockVector3 p : region) {
queue.setBlock(p.getX(), p.getY(), p.getZ(), block);
}
queue.flush();
long diff = System.currentTimeMillis() - start;
System.out.println(diff);
}
@Command(
aliases = {"/curve", "/spline"},
usage = "<pattern> [thickness]",