mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-02 11:26:42 +00:00
Merge Moo0's data flag for distr.
Also added data flag to //count. //count -d 35 will now only search for white wool. //count 35:5 will only search for green wool. //count 35 will work as normal. //count 35:-1 will also work.
This commit is contained in:
@ -20,10 +20,6 @@
|
||||
package com.sk89q.worldedit;
|
||||
|
||||
|
||||
import com.sk89q.worldedit.blocks.*;
|
||||
import com.sk89q.worldedit.data.*;
|
||||
import com.sk89q.worldedit.schematic.SchematicFormat;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
@ -32,6 +28,10 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.data.DataException;
|
||||
import com.sk89q.worldedit.schematic.SchematicFormat;
|
||||
|
||||
/**
|
||||
* The clipboard remembers the state of a cuboid region.
|
||||
*
|
||||
@ -459,4 +459,43 @@ public class CuboidClipboard {
|
||||
|
||||
return distribution;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the block distribution inside a clipboard with data values.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
// TODO reduce code duplication
|
||||
public List<Countable<BaseBlock>> getBlockDistributionWithData() {
|
||||
List<Countable<BaseBlock>> distribution = new ArrayList<Countable<BaseBlock>>();
|
||||
Map<BaseBlock, Countable<BaseBlock>> map = new HashMap<BaseBlock, Countable<BaseBlock>>();
|
||||
|
||||
int maxX = getWidth();
|
||||
int maxY = getHeight();
|
||||
int maxZ = getLength();
|
||||
|
||||
for (int x = 0; x < maxX; ++x) {
|
||||
for (int y = 0; y < maxY; ++y) {
|
||||
for (int z = 0; z < maxZ; ++z) {
|
||||
|
||||
int id = data[x][y][z].getId();
|
||||
int meta = data[x][y][z].getData();
|
||||
BaseBlock blk = new BaseBlock(id, meta);
|
||||
|
||||
if (map.containsKey(blk)) {
|
||||
map.get(blk).increment();
|
||||
} else {
|
||||
Countable<BaseBlock> c = new Countable<BaseBlock>(blk, 1);
|
||||
map.put(blk, c);
|
||||
distribution.add(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Collections.sort(distribution);
|
||||
// Collections.reverse(distribution);
|
||||
|
||||
return distribution;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user