コード例 #1
0
 def gen_assign(n, g=True):
     slot = c.Var('memory_slot_%d' % n)
     self.define_objective('memory_slot_%d' % n, None)
     return c.ExecuteChain() \
             .cond('if') \
             .score_range(mar, c.ScoreRange(n, n)) \
             .run(c.OpAssign(mbr if g else slot, slot if g else mbr))
コード例 #2
0
 def apply(self, out):
     chain = c.ExecuteChain()
     for component in self.components:
         component.apply(self, chain, out)
     try:
         yield chain
     finally:
         self.close()
コード例 #3
0
def _branch_apply(out, if_true, if_false, apply):
    inverted = not if_true
    if inverted:
        if_true, if_false = if_false, if_true
    have_false = if_false is not None
    if have_false:
        # Workaround: execute store doesn't set success to 0 if failed
        # See MC-125058
        # Can't use execute store anyway because it locks the success
        # tracker. See MC-125145
        out.write(c.SetConst(c.Var('success_tracker'), 0))
    true_fn = c.Function(if_true.global_name)
    out.write(
        apply(c.ExecuteChain().cond('unless' if inverted else 'if')).run(
            true_fn))
    if have_false:
        false_fn = c.Function(if_false.global_name)
        out.write(c.ExecuteChain().cond('if').score_range(
            c.Var('success_tracker'), c.ScoreRange(0, 0)).run(false_fn))
コード例 #4
0
 def _store_from_cmd(self, cmd, out):
     out.write(c.ExecuteChain()
               .store('result')
               .score(self.ref)
               .run(cmd))
コード例 #5
0
 def _store_from_cmd(self, cmd, out):
     out.write(c.ExecuteChain()
               .store('result')
               .nbt(self.storage, self.path, self.type.nbt_type.
                       exec_store_name, 1 / self.type.scale)
               .run(cmd))
コード例 #6
0
 def _write_to_reference(self, ref, out):
     out.write(c.ExecuteChain()
               .store('result')
               .score(ref)
               .run(self.read()))
コード例 #7
0
 def gen_fn(fn, p):
     return c.ExecuteChain() \
            .cond('if') \
            .score_range(mar, c.ScoreRange(p.min, p.max)) \
            .run(c.Function(pair_name(fn, p)))