Fix some bugs and increase the size by to much
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
Ursprung
42f8a044a4
Commit
b17cd9acda
@ -75,21 +75,59 @@ public class TSchemWriter implements ClipboardWriter {
|
|||||||
}
|
}
|
||||||
out.writeNamedTag("SizeMinOffset", new ByteArrayTag(bsArray));
|
out.writeNamedTag("SizeMinOffset", new ByteArrayTag(bsArray));
|
||||||
|
|
||||||
Map<BlockState, BitSet> blockMap = new HashMap<>();
|
Map<BlockState, byte[]> blocks = new HashMap<>();
|
||||||
typedClipboard.getBlocks().forEach((blockState, blockVector3s) -> {
|
for (Map.Entry<BlockState, Set<BlockVector3>> entry : typedClipboard.getBlocks().entrySet()) {
|
||||||
blockMap.put(blockState, new BitSet(volume));
|
BitSet bitSet = new BitSet(volume);
|
||||||
});
|
for (BlockVector3 blockVector3 : entry.getValue()) {
|
||||||
clipboard.getRegion().forEach(blockVector3 -> {
|
int index = blockVector3.getBlockX() + blockVector3.getBlockY() * region.getWidth() + blockVector3.getBlockZ() * region.getWidth() * region.getHeight();
|
||||||
int index = blockVector3.getBlockX() + blockVector3.getBlockY() * region.getWidth() + blockVector3.getBlockZ() * region.getWidth() * region.getHeight();
|
bitSet.set(index);
|
||||||
for (Map.Entry<BlockState, Set<BlockVector3>> entry : typedClipboard.getBlocks().entrySet()) {
|
}
|
||||||
if (entry.getValue().contains(blockVector3)) {
|
byte[] bytes = bitSet.toByteArray();
|
||||||
blockMap.get(entry.getKey()).set(index);
|
// RunLengthEncoding
|
||||||
|
List<Byte> bytes2 = new ArrayList<>();
|
||||||
|
int last = -1;
|
||||||
|
int count = 0;
|
||||||
|
for (int i = 0; i < bytes.length; i++) {
|
||||||
|
byte b = bytes[i];
|
||||||
|
if (b == last) {
|
||||||
|
count++;
|
||||||
|
} else {
|
||||||
|
if (count > 0) {
|
||||||
|
writeVarInt((count - 1), bytes2);
|
||||||
|
bytes2.add((byte) last);
|
||||||
|
}
|
||||||
|
last = b;
|
||||||
|
count = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
if (count > 0) {
|
||||||
|
writeVarInt((count - 1), bytes2);
|
||||||
|
bytes2.add((byte) last);
|
||||||
|
}
|
||||||
|
// Convert to byte array
|
||||||
|
bytes = new byte[bytes2.size()];
|
||||||
|
for (int i = 0; i < bytes.length; i++) {
|
||||||
|
bytes[i] = bytes2.get(i);
|
||||||
|
}
|
||||||
|
System.out.println(entry.getKey().getAsString() + " " + bitSet.toByteArray().length + " -> " + bytes2.size());
|
||||||
|
blocks.put(entry.getKey(), bytes);
|
||||||
|
}
|
||||||
|
|
||||||
|
BlockState biggest = null;
|
||||||
|
int biggestSize = 0;
|
||||||
|
for (Map.Entry<BlockState, byte[]> entry : blocks.entrySet()) {
|
||||||
|
if (entry.getValue().length > biggestSize) {
|
||||||
|
biggest = entry.getKey();
|
||||||
|
biggestSize = entry.getValue().length;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
System.out.println("Biggest: " + biggest.getAsString() + " " + biggestSize);
|
||||||
|
blocks.remove(biggest);
|
||||||
|
out.writeNamedTag("BaseBlock", biggest.getAsString());
|
||||||
|
|
||||||
out.writeLazyCompoundTag("Blocks", out2 -> {
|
out.writeLazyCompoundTag("Blocks", out2 -> {
|
||||||
for (Map.Entry<BlockState, BitSet> entry : blockMap.entrySet()) {
|
for (Map.Entry<BlockState, byte[]> entry : blocks.entrySet()) {
|
||||||
out2.writeNamedTag(entry.getKey().getAsString(), entry.getValue().toByteArray());
|
out2.writeNamedTag(entry.getKey().getAsString(), entry.getValue());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren