Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-12-25 18:40:05 +01:00
Implement CuboidClipboard
Dieser Commit ist enthalten in:
Ursprung
50fce3147f
Commit
d85ad6e116
@ -37,6 +37,7 @@ import java.io.File;
|
|||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
|
import java.util.function.Consumer;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
|
||||||
@ -107,6 +108,10 @@ public class Schematic {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public EditSession paste(World world, Vector to, boolean allowUndo, boolean pasteAir, @Nullable Transform transform) {
|
||||||
|
return paste(world, to, allowUndo, pasteAir, true, transform);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Paste this schematic in a world
|
* Paste this schematic in a world
|
||||||
*
|
*
|
||||||
@ -117,7 +122,7 @@ public class Schematic {
|
|||||||
* @param transform
|
* @param transform
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public EditSession paste(World world, Vector to, boolean allowUndo, boolean pasteAir, @Nullable Transform transform) {
|
public EditSession paste(World world, Vector to, boolean allowUndo, boolean pasteAir, boolean copyEntities, @Nullable Transform transform) {
|
||||||
checkNotNull(world);
|
checkNotNull(world);
|
||||||
checkNotNull(to);
|
checkNotNull(to);
|
||||||
Region region = clipboard.getRegion();
|
Region region = clipboard.getRegion();
|
||||||
@ -145,6 +150,7 @@ public class Schematic {
|
|||||||
if (transform != null && !transform.isIdentity()) {
|
if (transform != null && !transform.isIdentity()) {
|
||||||
copy.setTransform(transform);
|
copy.setTransform(transform);
|
||||||
}
|
}
|
||||||
|
copy.setCopyEntities(copyEntities);
|
||||||
if (sourceMask != null) {
|
if (sourceMask != null) {
|
||||||
new MaskTraverser(sourceMask).reset(extent);
|
new MaskTraverser(sourceMask).reset(extent);
|
||||||
copy.setSourceMask(sourceMask);
|
copy.setSourceMask(sourceMask);
|
||||||
|
Datei-Diff unterdrückt, da er zu groß ist
Diff laden
@ -23,7 +23,9 @@ import com.boydti.fawe.jnbt.anvil.generator.*;
|
|||||||
import com.boydti.fawe.object.PseudoRandom;
|
import com.boydti.fawe.object.PseudoRandom;
|
||||||
import com.sk89q.worldedit.*;
|
import com.sk89q.worldedit.*;
|
||||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||||
|
import com.sk89q.worldedit.util.Countable;
|
||||||
|
import com.sk89q.worldedit.world.block.*;
|
||||||
import com.sk89q.worldedit.entity.BaseEntity;
|
import com.sk89q.worldedit.entity.BaseEntity;
|
||||||
import com.sk89q.worldedit.entity.Entity;
|
import com.sk89q.worldedit.entity.Entity;
|
||||||
import com.sk89q.worldedit.function.mask.Mask;
|
import com.sk89q.worldedit.function.mask.Mask;
|
||||||
@ -35,10 +37,9 @@ import com.sk89q.worldedit.util.Location;
|
|||||||
import com.sk89q.worldedit.regions.Region;
|
import com.sk89q.worldedit.regions.Region;
|
||||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
|
||||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.ThreadLocalRandom;
|
import java.util.concurrent.ThreadLocalRandom;
|
||||||
@ -297,6 +298,67 @@ public interface Extent extends InputExtent, OutputExtent {
|
|||||||
addOre(region, mask, BlockTypes.EMERALD_ORE.getDefaultState(), 5, 1, 100, 4, 31);
|
addOre(region, mask, BlockTypes.EMERALD_ORE.getDefaultState(), 5, 1, 100, 4, 31);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the block distribution inside a region.
|
||||||
|
*
|
||||||
|
* @param region a region
|
||||||
|
* @return the results
|
||||||
|
*/
|
||||||
|
default List<Countable<BlockType>> getBlockDistribution(final Region region) {
|
||||||
|
int[] counter = new int[BlockTypes.size()];
|
||||||
|
|
||||||
|
for (final Vector pt : region) {
|
||||||
|
BlockType type = getBlockType(pt);
|
||||||
|
counter[type.getInternalId()]++;
|
||||||
|
}
|
||||||
|
List<Countable<BlockType>> distribution = new ArrayList<>();
|
||||||
|
for (int i = 0; i < counter.length; i++) {
|
||||||
|
int count = counter[i];
|
||||||
|
if (count != 0) {
|
||||||
|
distribution.add(new Countable<>(BlockTypes.get(i), count));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Collections.sort(distribution);
|
||||||
|
return distribution;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the block distribution (with data values) inside a region.
|
||||||
|
*
|
||||||
|
* @param region a region
|
||||||
|
* @return the results
|
||||||
|
*/
|
||||||
|
default List<Countable<BlockStateHolder>> getBlockDistributionWithData(final Region region) {
|
||||||
|
int[][] counter = new int[BlockTypes.size()][];
|
||||||
|
|
||||||
|
for (final Vector pt : region) {
|
||||||
|
BlockStateHolder blk = this.getBlock(pt);
|
||||||
|
BlockType type = blk.getBlockType();
|
||||||
|
int[] stateCounter = counter[type.getInternalId()];
|
||||||
|
if (stateCounter == null) {
|
||||||
|
counter[type.getInternalId()] = stateCounter = new int[type.getMaxStateId() + 1];
|
||||||
|
}
|
||||||
|
stateCounter[blk.getInternalPropertiesId()]++;
|
||||||
|
}
|
||||||
|
List<Countable<BlockStateHolder>> distribution = new ArrayList<>();
|
||||||
|
for (int typeId = 0; typeId < counter.length; typeId++) {
|
||||||
|
BlockType type = BlockTypes.get(typeId);
|
||||||
|
int[] stateCount = counter[typeId];
|
||||||
|
if (stateCount != null) {
|
||||||
|
for (int propId = 0; propId < stateCount.length; propId++) {
|
||||||
|
int count = stateCount[propId];
|
||||||
|
if (count != 0) {
|
||||||
|
BlockStateHolder state = type.withPropertyId(propId);
|
||||||
|
distribution.add(new Countable<>(state, count));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Collections.reverse(distribution);
|
||||||
|
return distribution;
|
||||||
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
default Operation commit() {
|
default Operation commit() {
|
||||||
|
@ -132,6 +132,10 @@ public class BlockArrayClipboard implements Clipboard, LightingExtent, Closeable
|
|||||||
return region.clone();
|
return region.clone();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setRegion(Region region) {
|
||||||
|
this.region = region;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Vector getOrigin() {
|
public Vector getOrigin() {
|
||||||
return origin;
|
return origin;
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren