Example #1
0
    def dig_hook(self, chunk, x, y, z, block):
        """
        Check for neighboring water that might want to spread.

        Also check to see whether we are, for example, dug ice that has turned
        back into water.
        """

        x += chunk.x * 16
        z += chunk.z * 16

        # Check for sponges first, since they will mark the entirety of the
        # area.
        if block == self.sponge:
            for coords in itercube(x, y, z, 3):
                self.tracked.add(coords)

        else:
            for coords in iterneighbors(x, y, z):
                test_block = yield self.factory.world.get_block(coords)
                if test_block in (self.spring, self.fluid):
                    self.tracked.add(coords)

        self.schedule()
Example #2
0
    def test_above(self):
        x, y, z = 0, 0, 0

        self.assertTrue((0, 1, 0) in iterneighbors(x, y, z))
Example #3
0
    def test_no_neighbors(self):
        x, y, z = 0, -2, 0

        self.assertEqual(list(iterneighbors(x, y, z)), [])