Skip to content

Commit

Permalink
Merge pull request #1668 from IncredibleHolg/addblocks-nov19-01
Browse files Browse the repository at this point in the history
Adds composter and bamboo
  • Loading branch information
CounterPillow committed Dec 5, 2019
2 parents 7d9feb3 + 9e27e6a commit 6dccdaa
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 2 deletions.
4 changes: 3 additions & 1 deletion overviewer_core/src/mc_id.h
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,8 @@ enum mc_block_id {
block_dark_oak_wall_sign = 11412,
block_bamboo_sapling = 11413,
block_scaffolding = 11414,
block_bamboo = 11416,
block_composter = 11417,
// adding a gap in the numbering of walls to keep them all
// in one numbering block starting at 21000
block_andesite_wall = 21000,
Expand All @@ -339,7 +341,7 @@ enum mc_block_id {
block_red_nether_brick_wall = 21010,
block_red_sandstone_wall = 21011,
block_sandstone_wall = 21012,
block_stone_brick_wall = 21013
block_stone_brick_wall = 21013
};

typedef uint16_t mc_block_t;
Expand Down
2 changes: 1 addition & 1 deletion overviewer_core/src/overviewer.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

// increment this value if you've made a change to the c extesion
// and want to force users to rebuild
#define OVERVIEWER_EXTENSION_VERSION 76
#define OVERVIEWER_EXTENSION_VERSION 77

#include <stdbool.h>
#include <stdint.h>
Expand Down
84 changes: 84 additions & 0 deletions overviewer_core/textures.py
Original file line number Diff line number Diff line change
Expand Up @@ -1935,6 +1935,90 @@ def lantern(self, blockid, data):
alpha_over(img, top, (0, 8-hangoff), top)
return img

# bamboo
@material(blockid=11416, transparent=True)
def bamboo(self, blockid, data):
# get the multipart texture of the lantern
inputtexture = self.load_image_texture("assets/minecraft/textures/block/bamboo_stalk.png")

# # now create a textures, using the parts defined in bamboo1_age0.json
# { "from": [ 7, 0, 7 ],
# "to": [ 9, 16, 9 ],
# "faces": {
# "down": { "uv": [ 13, 4, 15, 6 ], "texture": "#all", "cullface": "down" },
# "up": { "uv": [ 13, 0, 15, 2], "texture": "#all", "cullface": "up" },
# "north": { "uv": [ 0, 0, 2, 16 ], "texture": "#all" },
# "south": { "uv": [ 0, 0, 2, 16 ], "texture": "#all" },
# "west": { "uv": [ 0, 0, 2, 16 ], "texture": "#all" },
# "east": { "uv": [ 0, 0, 2, 16 ], "texture": "#all" }
# }
# }

side_crop = inputtexture.crop((0, 0, 3, 16))
side_slice = side_crop.copy()
side_texture = Image.new("RGBA", (16, 16), self.bgcolor)
side_texture.paste(side_slice,(0, 0))

# JSON data for top
# "up": { "uv": [ 13, 0, 15, 2], "texture": "#all", "cullface": "up" },
top_crop = inputtexture.crop((13, 0, 16, 3))
top_slice = top_crop.copy()
top_texture = Image.new("RGBA", (16, 16), self.bgcolor)
top_texture.paste(top_slice,(5, 5))

# mimic parts of build_full_block, to get an object smaller than a block
# build_full_block(self, top, side1, side2, side3, side4, bottom=None):
# a non transparent block uses top, side 3 and side 4.
img = Image.new("RGBA", (24, 24), self.bgcolor)
# prepare the side textures
# side3
side3 = self.transform_image_side(side_texture)
# Darken this side
sidealpha = side3.split()[3]
side3 = ImageEnhance.Brightness(side3).enhance(0.9)
side3.putalpha(sidealpha)
# place the transformed texture
xoff = 3
yoff = 0
alpha_over(img, side3, (4+xoff, yoff), side3)
# side4
side4 = self.transform_image_side(side_texture)
side4 = side4.transpose(Image.FLIP_LEFT_RIGHT)
# Darken this side
sidealpha = side4.split()[3]
side4 = ImageEnhance.Brightness(side4).enhance(0.8)
side4.putalpha(sidealpha)
alpha_over(img, side4, (-4+xoff, yoff), side4)
# top
top = self.transform_image_top(top_texture)
alpha_over(img, top, (-4+xoff, -5), top)
return img

# composter
@material(blockid=11417, data=list(range(9)), transparent=True)
def composter(self, blockid, data):
side = self.load_image_texture("assets/minecraft/textures/block/composter_side.png")
top = self.load_image_texture("assets/minecraft/textures/block/composter_top.png")
# bottom = self.load_image_texture("assets/minecraft/textures/block/composter_bottom.png")

if data == 0: # empty
return self.build_full_block(top, side, side, side, side)

if data == 8:
compost = self.transform_image_top(
self.load_image_texture("assets/minecraft/textures/block/composter_ready.png"))
else:
compost = self.transform_image_top(
self.load_image_texture("assets/minecraft/textures/block/composter_compost.png"))

nudge = {1: (0, 9), 2: (0, 8), 3: (0, 7), 4: (0, 6), 5: (0, 4), 6: (0, 2), 7: (0, 0), 8: (0, 0)}

img = self.build_full_block(None, side, side, None, None)
alpha_over(img, compost, nudge[data], compost)
img2 = self.build_full_block(top, None, None, side, side)
alpha_over(img, img2, (0, 0), img2)
return img

# fire
@material(blockid=51, data=list(range(16)), transparent=True)
def fire(self, blockid, data):
Expand Down
4 changes: 4 additions & 0 deletions overviewer_core/world.py
Original file line number Diff line number Diff line change
Expand Up @@ -832,6 +832,8 @@ def __init__(self, regiondir, rel):
'minecraft:bamboo_sapling': (11413, 0),
'minecraft:scaffolding': (11414, 0),
"minecraft:smooth_red_sandstone_stairs": (11415, 0),
'minecraft:bamboo': (11416, 0),
"minecraft:composter": (11417, 0),
# adding a gap in the numbering of walls to keep them all
# in one numbering block starting at 21000
'minecraft:andesite_wall': (21000, 0),
Expand Down Expand Up @@ -1127,6 +1129,8 @@ def _get_block(self, palette_entry):
data = 1
else:
data = 0
elif key == "minecraft:composter":
data = palette_entry['Properties']['level']
return (block, data)

def get_type(self):
Expand Down

0 comments on commit 6dccdaa

Please sign in to comment.