Lazy tags + get / set tiles

Lazy tags means tiles/ents are not translated into the nms NBTBase until it is needed. Should be faster in cases where getFullBlock is called, but nbt is not always needed.
Commands like Copy and Paste, where the input/output are both nms worlds, can entirely bypass WorldEdit translating to and from the WorldEdit JNBT classes.
This commit is contained in:
Jesse Boyd
2019-11-20 03:40:52 +00:00
parent 60759934a3
commit 144ea2ef34
40 changed files with 298 additions and 172 deletions

View File

@ -31,7 +31,7 @@ import java.util.OptionalInt;
import static com.google.common.base.Preconditions.checkState;
public final class BlockStateIdAccess {
/*
private static final BiMap<BlockState, Integer> ASSIGNED_IDS = HashBiMap.create(2 << 13);
public static OptionalInt getBlockStateId(BlockState holder) {
@ -49,7 +49,7 @@ public final class BlockStateIdAccess {
* {@link OptionalInt#empty()}. In those cases, we will use our own ID system,
* since it's useful for other entries as well.
* @return an unused ID in WorldEdit's ID tracker
*/
/
private static int provideUnusedWorldEditId() {
return usedIds.nextClearBit(0);
}
@ -73,5 +73,12 @@ public final class BlockStateIdAccess {
private BlockStateIdAccess() {
}
*/
public static OptionalInt getBlockStateId(BlockState holder) {
return OptionalInt.of(holder.getOrdinal());
}
public static @Nullable BlockState getBlockStateById(int id) {
return BlockState.getFromOrdinal(id);
}
}