0

non-oak buttons

buttons on top of blocks
This commit is contained in:
James Miller
2018-12-16 03:33:38 -08:00
parent ce78ffe008
commit 2b2ad76c81
2 changed files with 69 additions and 32 deletions

View File

@@ -2802,7 +2802,7 @@ def pressure_plate(self, blockid, data):
block(blockid=[73, 74], top_image="assets/minecraft/textures/block/redstone_ore.png")
# stone a wood buttons
@material(blockid=(77,143), data=range(16), transparent=True)
@material(blockid=(77,143,11326,11327,11328,11329,11330), data=range(16), transparent=True)
def buttons(self, blockid, data):
# 0x8 is set if the button is pressed mask this info and render
@@ -2814,6 +2814,8 @@ def buttons(self, blockid, data):
elif data == 2: data = 4
elif data == 3: data = 2
elif data == 4: data = 1
elif data == 5: data = 6
elif data == 6: data = 5
elif self.rotation == 2:
if data == 1: data = 2
elif data == 2: data = 1
@@ -2824,11 +2826,18 @@ def buttons(self, blockid, data):
elif data == 2: data = 3
elif data == 3: data = 1
elif data == 4: data = 2
elif data == 5: data = 6
elif data == 6: data = 5
if blockid == 77:
t = self.load_image_texture("assets/minecraft/textures/block/stone.png").copy()
else:
t = self.load_image_texture("assets/minecraft/textures/block/oak_planks.png").copy()
texturepath = {77:"assets/minecraft/textures/block/stone.png",
143:"assets/minecraft/textures/block/oak_planks.png",
11326:"assets/minecraft/textures/block/spruce_planks.png",
11327:"assets/minecraft/textures/block/birch_planks.png",
11328:"assets/minecraft/textures/block/jungle_planks.png",
11329:"assets/minecraft/textures/block/acacia_planks.png",
11330:"assets/minecraft/textures/block/dark_oak_planks.png"
}[blockid]
t = self.load_image_texture(texturepath).copy()
# generate the texture for the button
ImageDraw.Draw(t).rectangle((0,0,15,5),outline=(0,0,0,0),fill=(0,0,0,0))
@@ -2838,38 +2847,54 @@ def buttons(self, blockid, data):
img = Image.new("RGBA", (24,24), self.bgcolor)
button = self.transform_image_side(t)
if data == 1: # facing SOUTH
# buttons can't be placed in transparent blocks, so this
# direction can't be seen
return None
if data < 5:
button = self.transform_image_side(t)
if data == 1: # facing SOUTH
# buttons can't be placed in transparent blocks, so this
# direction can't be seen
return None
elif data == 2: # facing NORTH
# paste it twice with different brightness to make a 3D effect
alpha_over(img, button, (12,-1), button)
alpha = button.split()[3]
button = ImageEnhance.Brightness(button).enhance(0.9)
button.putalpha(alpha)
alpha_over(img, button, (11,0), button)
elif data == 3: # facing WEST
# paste it twice with different brightness to make a 3D effect
button = button.transpose(Image.FLIP_LEFT_RIGHT)
alpha_over(img, button, (0,-1), button)
alpha = button.split()[3]
button = ImageEnhance.Brightness(button).enhance(0.9)
button.putalpha(alpha)
alpha_over(img, button, (1,0), button)
elif data == 4: # facing EAST
# buttons can't be placed in transparent blocks, so this
# direction can't be seen
return None
else:
if data == 5: # long axis east-west
button = self.transform_image_top(t)
else: # long axis north-south
button = self.transform_image_top(t.rotate(90))
elif data == 2: # facing NORTH
# paste it twice with different brightness to make a 3D effect
alpha_over(img, button, (12,-1), button)
alpha_over(img, button, (0,12), button)
alpha = button.split()[3]
button = ImageEnhance.Brightness(button).enhance(0.9)
button.putalpha(alpha)
alpha_over(img, button, (11,0), button)
elif data == 3: # facing WEST
# paste it twice with different brightness to make a 3D effect
button = button.transpose(Image.FLIP_LEFT_RIGHT)
alpha_over(img, button, (0,-1), button)
alpha = button.split()[3]
button = ImageEnhance.Brightness(button).enhance(0.9)
button.putalpha(alpha)
alpha_over(img, button, (1,0), button)
elif data == 4: # facing EAST
# buttons can't be placed in transparent blocks, so this
# direction can't be seen
return None
alpha_over(img, button, (0,11), button)
return img

View File

@@ -761,6 +761,11 @@ class RegionSet(object):
'minecraft:dead_fire_coral_block': (11323, 0),
'minecraft:dead_horn_coral_block': (11324, 0),
'minecraft:dead_tube_coral_block': (11325, 0),
'minecraft:spruce_button': (11326,0),
'minecraft:birch_button': (11327,0),
'minecraft:jungle_button': (11328,0),
'minecraft:acacia_button': (11329,0),
'minecraft:dark_oak_button': (11330,0),
}
colors = [ 'white', 'orange', 'magenta', 'light_blue',
@@ -825,9 +830,16 @@ class RegionSet(object):
elif key in ['minecraft:ladder', 'minecraft:chest', 'minecraft:ender_chest', 'minecraft:trapped_chest', 'minecraft:furnace']:
facing = palette_entry['Properties']['facing']
data = {'north': 2, 'south': 3, 'west': 4, 'east': 5}[facing]
elif key in ['minecraft:stone_button', 'minecraft:oak_button']:
elif key.endswith('_button'):
facing = palette_entry['Properties']['facing']
data = {'east': 1, 'west': 2, 'south': 3, 'north': 4}[facing]
face = palette_entry['Properties']['face']
if face == 'ceiling':
block = 0
data = 0
elif face == 'wall':
data = {'east': 1, 'west': 2, 'south': 3, 'north': 4}[facing]
elif face == 'floor':
data = {'east': 6, 'west': 6, 'south': 5, 'north': 5}[facing]
elif key == 'minecraft:nether_wart':
data = int(palette_entry['Properties']['age'])
elif key.endswith('shulker_box') or key.endswith('piston') or key in ['minecraft:observer', 'minecraft:dropper', 'minecraft:dispenser']: