Skip to content

Commit

Permalink
Fix trees!
Browse files Browse the repository at this point in the history
  • Loading branch information
N3RDIUM committed Dec 2, 2021
1 parent 151d30b commit 7a650a5
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 11 deletions.
7 changes: 4 additions & 3 deletions Classes/structures/structure_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ def __init__(self, structure_data, parent):
self.structure_data["structure_type"] = "tree"
self.structure_data["structure_name"] = "tree"
self.height = random.randint(7,10)
self.side = random.randint(5,6)
self.leaf_height = self.height - random.randint(6,8)
self.side = random.randint(1,2)

def generate(self, *args, **kwargs):
"""
Expand All @@ -72,10 +73,10 @@ def _generate_tree(self):
"""
for i in range(self.height):
self.util.add_block("birch_log", [self.structure_data["structure_pos"]["x"], self.structure_data["structure_pos"]["y"] + i, self.structure_data["structure_pos"]["z"]], self.chunk)
if i == self.height - 5:
if i >= self.leaf_height:
for j in range(-self.side, self.side):
for k in range(-self.side, self.side):
if not j == 0 and not k == 0:
if not [j,k] == [0,0] or i == self.height - 1:
self.util.add_block("birch_leaves", [self.structure_data["structure_pos"]["x"]+j, self.structure_data["structure_pos"]["y"] + i, self.structure_data["structure_pos"]["z"]+k], self.chunk)

all_structures["birch_tree"] = birch_tree
2 changes: 1 addition & 1 deletion Classes/terrain/block/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ def __init__(self, *args, **kwargs):

blocks_all["birch_log"] = birch_log

class birch_leaves:
class birch_leaves(BlockBase):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)

Expand Down
9 changes: 3 additions & 6 deletions Classes/terrain/chunk.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,9 @@ def add_block(self, type_, block_data, index):
:block_data: data for block
:index: index of block
"""
try:
self.blocks[index] = blocks_all[type_](block_data=block_data, parent=self)
self.parent._all_blocks[index] = self.blocks[index]
pyglet.clock.schedule_once(self.blocks[index].add_to_batch_and_save, randint(0, 1))
except:
pass
self.blocks[index] = blocks_all[type_](block_data=block_data, parent=self)
self.parent._all_blocks[index] = self.blocks[index]
pyglet.clock.schedule_once(self.blocks[index].add_to_batch_and_save, randint(0, 1))

def remove_block(self, index):
"""
Expand Down
2 changes: 1 addition & 1 deletion Classes/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def __init__(self, *args, **kwargs):
pyglet.clock.schedule(self.update)

# Player
self.player = Player((0, 100, 0), (0, 0), self)
self.player = Player((0, 50, 0), (0, 0), self)
# Model
self.model = World(self, self.player)
pyglet.clock.schedule_interval(self.model.update, 1/60)
Expand Down

0 comments on commit 7a650a5

Please sign in to comment.