def clone_to(self, other, out): other_direct = other._direct_nbt() if other_direct is not None: other_path, other_storage = other_direct # Optimize here - can copy NBT directly out.write(c.DataModifyFrom(other_storage, other_path, 'set', self.storage, self.path)) else: super().clone_to(other, out)
def apply(self, out, func): direct = self.var._direct_nbt() assert direct is not None, self.var dest_path, dest_storage = direct if isinstance(self.nbt, Variable): src_path, src_storage = self.nbt.as_nbt_variable(out)._direct_nbt() out.write(c.DataModifyFrom(dest_storage, dest_path, self.action, src_storage, src_path)) else: out.write(c.DataModifyValue(dest_storage, dest_path, self.action, self.nbt))
def get_cmd(self, func): direct = self.var._direct_nbt() assert direct is not None, self.var dest_path, dest_storage = direct if isinstance(self.source, BlockRef): source = self.source.as_cmdref() elif isinstance(self.source, EntitySelection): source = c.EntityReference(self.source.as_resolve()) else: assert False return c.DataModifyFrom(dest_storage, dest_path, self.action, source, c.NbtPath(str(self.source_path)))
def get_cmd(self, func): if isinstance(self.target, BlockRef): target = self.target.as_cmdref() elif isinstance(self.target, EntitySelection): target = c.EntityReference(self.target.as_resolve()) else: assert False if isinstance(self.source, BlockRef): source = self.source.as_cmdref() elif isinstance(self.source, EntitySelection): source = c.EntityReference(self.source.as_resolve()) else: assert False return c.DataModifyFrom(target, c.NbtPath(str(self.target_path)), self.action, source, c.NbtPath(str(self.source_path)))
def push_to_stack(self, out): # out-of-bounds stack path out.write(c.DataModifyFrom(c.GlobalNBT(self.namespace), c.StackPath(None), 'append', self.storage, self.root_path))
def cmd_set_from(self, path, storage): return c.DataModifyFrom(self.block, c.NbtPath('Command'), 'set', storage, path.subpath('.cmd'))
def push_to_stack(self, out): # out-of-bounds stack path out.write( c.DataModifyFrom(c.GlobalEntity.ref, c.StackPath(None), 'append', self.entity.ref, self.root_path))
def get_cmd(self): return c.DataModifyFrom(c.UtilBlockPos.ref, c.NbtPath('Command'), 'set', c.GlobalEntity.ref, c.StackPath(STACK_HEAD, 'cmd'))
def cmd_set_from(self, path, entity): return c.DataModifyFrom(self.block, c.NbtPath('Command'), 'set', entity.ref, path.subpath('.cmd'))