Move to BinaryTags where appropriate in adapters

This commit is contained in:
dordsor21
2021-12-29 16:00:49 +00:00
parent 48e2953910
commit f38859237a
9 changed files with 111 additions and 102 deletions

View File

@ -4,6 +4,7 @@ import com.fastasyncworldedit.core.Fawe;
import com.fastasyncworldedit.core.util.TaskManager;
import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.entity.BaseEntity;
import com.sk89q.worldedit.util.nbt.CompoundBinaryTag;
import com.sk89q.worldedit.world.entity.EntityType;
import javax.annotation.Nullable;
@ -11,26 +12,26 @@ import java.util.function.Supplier;
public class LazyBaseEntity extends BaseEntity {
private Supplier<CompoundTag> saveTag;
private Supplier<CompoundBinaryTag> saveTag;
public LazyBaseEntity(EntityType type, Supplier<CompoundTag> saveTag) {
public LazyBaseEntity(EntityType type, Supplier<CompoundBinaryTag> saveTag) {
super(type);
this.saveTag = saveTag;
}
@Nullable
@Override
public CompoundTag getNbtData() {
Supplier<CompoundTag> tmp = saveTag;
public CompoundBinaryTag getNbt() {
Supplier<CompoundBinaryTag> tmp = saveTag;
if (tmp != null) {
saveTag = null;
if (Fawe.isMainThread()) {
setNbtData(tmp.get());
setNbt(tmp.get());
} else {
setNbtData(TaskManager.taskManager().sync(tmp));
setNbt(TaskManager.taskManager().sync(tmp));
}
}
return super.getNbtData();
return super.getNbt();
}
}