MCPcopy Index your code
hub / github.com/fogleman/Minecraft / add_block

Method add_block

main.py:233–254  ·  view source on GitHub ↗

Add a block with the given `texture` and `position` to the world. Parameters ---------- position : tuple of len 3 The (x, y, z) position of the block to add. texture : list of len 3 The coordinates of the texture squares. Use `tex_coords()` t

(self, position, texture, immediate=True)

Source from the content-addressed store, hash-verified

231 return False
232
233 def add_block(self, position, texture, immediate=True):
234 """ Add a block with the given `texture` and `position` to the world.
235
236 Parameters
237 ----------
238 position : tuple of len 3
239 The (x, y, z) position of the block to add.
240 texture : list of len 3
241 The coordinates of the texture squares. Use `tex_coords()` to
242 generate.
243 immediate : bool
244 Whether or not to draw the block immediately.
245
246 """
247 if position in self.world:
248 self.remove_block(position, immediate)
249 self.world[position] = texture
250 self.sectors.setdefault(sectorize(position), []).append(position)
251 if immediate:
252 if self.exposed(position):
253 self.show_block(position)
254 self.check_neighbors(position)
255
256 def remove_block(self, position, immediate=True):
257 """ Remove the block at the given `position`.

Callers 2

_initializeMethod · 0.95
on_mouse_pressMethod · 0.80

Calls 5

remove_blockMethod · 0.95
exposedMethod · 0.95
show_blockMethod · 0.95
check_neighborsMethod · 0.95
sectorizeFunction · 0.85

Tested by

no test coverage detected