From 7e2cb56c1b6dbce77e2eb60400c875b9bbc35353 Mon Sep 17 00:00:00 2001 From: Nicolas F Date: Mon, 15 Jul 2019 17:23:25 +0200 Subject: [PATCH] Implement some mossy blocks This adds: - mossy stone brick stairs - mossy cobblestone stairs - mossy stone brick walls We also add another block class for walls, and while we're at it, clean up the stairs texture function to not have a huge sprawling elif mess for loading textures, but instead to a cheeky dictionary lookup. In case you're wondering, yes I am just as disgusted by this code as you are. --- overviewer_core/src/block_class.c | 14 ++++++- overviewer_core/src/block_class.h | 3 ++ overviewer_core/src/iterate.c | 2 +- overviewer_core/src/mc_id.h | 3 ++ overviewer_core/src/overviewer.h | 2 +- overviewer_core/textures.py | 69 ++++++++++++++----------------- overviewer_core/world.py | 6 ++- 7 files changed, 56 insertions(+), 43 deletions(-) diff --git a/overviewer_core/src/block_class.c b/overviewer_core/src/block_class.c index fe0d86c..8b5db73 100644 --- a/overviewer_core/src/block_class.c +++ b/overviewer_core/src/block_class.c @@ -75,7 +75,9 @@ const mc_block_t block_class_stair[] = { block_purpur_stairs, block_prismarine_stairs, block_dark_prismarine_stairs, - block_prismarine_brick_stairs}; + block_prismarine_brick_stairs, + block_mossy_cobblestone_stairs, + block_mossy_stone_brick_stairs}; const size_t block_class_stair_len = COUNT_OF(block_class_stair); const mc_block_t block_class_door[] = { @@ -132,6 +134,8 @@ const mc_block_t block_class_ancil[] = { block_prismarine_stairs, block_dark_prismarine_stairs, block_prismarine_brick_stairs, + block_mossy_cobblestone_stairs, + block_mossy_stone_brick_stairs, block_grass, block_flowing_water, block_water, @@ -146,6 +150,7 @@ const mc_block_t block_class_ancil[] = { block_waterlily, block_nether_brick_fence, block_cobblestone_wall, + block_mossy_stone_brick_wall, block_double_plant, block_stained_glass_pane, block_stained_glass, @@ -175,6 +180,8 @@ const mc_block_t block_class_alt_height[] = { block_prismarine_stairs, block_dark_prismarine_stairs, block_prismarine_brick_stairs, + block_mossy_cobblestone_stairs, + block_mossy_stone_brick_stairs, block_prismarine_slab, block_dark_prismarine_slab, block_prismarine_brick_slab, @@ -199,3 +206,8 @@ const mc_block_t block_class_alt_height[] = { block_purpur_slab, block_wooden_slab}; const size_t block_class_alt_height_len = COUNT_OF(block_class_alt_height); + +const mc_block_t block_class_wall[] = { + block_cobblestone_wall, + block_mossy_stone_brick_wall}; +const size_t block_class_wall_len = COUNT_OF(block_class_wall); diff --git a/overviewer_core/src/block_class.h b/overviewer_core/src/block_class.h index 93f952e..58926fa 100644 --- a/overviewer_core/src/block_class.h +++ b/overviewer_core/src/block_class.h @@ -46,4 +46,7 @@ extern const size_t block_class_ancil_len; extern const mc_block_t block_class_alt_height[]; extern const size_t block_class_alt_height_len; +extern const mc_block_t block_class_wall[]; +extern const size_t block_class_wall_len; + #endif diff --git a/overviewer_core/src/iterate.c b/overviewer_core/src/iterate.c index fbdb30b..5fc9b5b 100644 --- a/overviewer_core/src/iterate.c +++ b/overviewer_core/src/iterate.c @@ -390,7 +390,7 @@ generate_pseudo_data(RenderState* state, uint16_t ancilData) { } } return data; - } else if (state->block == block_cobblestone_wall) { + } else if (block_class_is_subset(state->block, block_class_wall, block_class_wall_len)) { /* check for walls and add one bit with the type of wall (mossy or cobblestone)*/ if (ancilData == 0x1) { return check_adjacent_blocks(state, x, y, z, state->block) | 0x10; diff --git a/overviewer_core/src/mc_id.h b/overviewer_core/src/mc_id.h index 0ad7f48..7581aa6 100644 --- a/overviewer_core/src/mc_id.h +++ b/overviewer_core/src/mc_id.h @@ -290,6 +290,9 @@ enum mc_block_id { block_loom = 11367, block_stonecutter = 11368, block_grindstone = 11369, + block_mossy_stone_brick_stairs = 11370, + block_mossy_cobblestone_stairs = 11371, + block_mossy_stone_brick_wall = 11372, }; typedef uint16_t mc_block_t; diff --git a/overviewer_core/src/overviewer.h b/overviewer_core/src/overviewer.h index c6113d4..3cd6678 100644 --- a/overviewer_core/src/overviewer.h +++ b/overviewer_core/src/overviewer.h @@ -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 69 +#define OVERVIEWER_EXTENSION_VERSION 70 #include #include diff --git a/overviewer_core/textures.py b/overviewer_core/textures.py index 8832097..3fe4fb2 100644 --- a/overviewer_core/textures.py +++ b/overviewer_core/textures.py @@ -1891,8 +1891,9 @@ def fire(self, blockid, data): # monster spawner block(blockid=52, top_image="assets/minecraft/textures/block/spawner.png", transparent=True) -# wooden, cobblestone, red brick, stone brick, netherbrick, sandstone, spruce, birch, jungle, quartz, red sandstone and (dark) prismarine stairs. -@material(blockid=[53,67,108,109,114,128,134,135,136,156,163,164,180,203,11337,11338,11339], data=list(range(128)), transparent=True, solid=True, nospawn=True) +# wooden, cobblestone, red brick, stone brick, netherbrick, sandstone, spruce, birch, jungle, quartz, red sandstone, (dark) prismarine, mossy brick and mossy cobblestone stairs. +@material(blockid=[53,67,108,109,114,128,134,135,136,156,163,164,180,203,11337,11338,11339, + 11370, 11371], data=list(range(128)), transparent=True, solid=True, nospawn=True) def stairs(self, blockid, data): # preserve the upside-down bit upside_down = data & 0x4 @@ -1905,40 +1906,29 @@ def stairs(self, blockid, data): numpy.roll(quarters, [0,1,3,2][self.rotation]) nw,ne,se,sw = quarters - if blockid == 53: # wooden - texture = self.load_image_texture("assets/minecraft/textures/block/oak_planks.png").copy() - elif blockid == 67: # cobblestone - texture = self.load_image_texture("assets/minecraft/textures/block/cobblestone.png").copy() - elif blockid == 108: # red brick stairs - texture = self.load_image_texture("assets/minecraft/textures/block/bricks.png").copy() - elif blockid == 109: # stone brick stairs - texture = self.load_image_texture("assets/minecraft/textures/block/stone_bricks.png").copy() - elif blockid == 114: # netherbrick stairs - texture = self.load_image_texture("assets/minecraft/textures/block/nether_bricks.png").copy() - elif blockid == 128: # sandstone stairs - texture = self.load_image_texture("assets/minecraft/textures/block/sandstone.png").copy() - elif blockid == 134: # spruce wood stairs - texture = self.load_image_texture("assets/minecraft/textures/block/spruce_planks.png").copy() - elif blockid == 135: # birch wood stairs - texture = self.load_image_texture("assets/minecraft/textures/block/birch_planks.png").copy() - elif blockid == 136: # jungle good stairs - texture = self.load_image_texture("assets/minecraft/textures/block/jungle_planks.png").copy() - elif blockid == 156: # quartz block stairs - texture = self.load_image_texture("assets/minecraft/textures/block/quartz_block_side.png").copy() - elif blockid == 163: # acacia wood stairs - texture = self.load_image_texture("assets/minecraft/textures/block/acacia_planks.png").copy() - elif blockid == 164: # dark oak stairs - texture = self.load_image_texture("assets/minecraft/textures/block/dark_oak_planks.png").copy() - elif blockid == 180: # red sandstone stairs - texture = self.load_image_texture("assets/minecraft/textures/block/red_sandstone.png").copy() - elif blockid == 203: # purpur stairs - texture = self.load_image_texture("assets/minecraft/textures/block/purpur_block.png").copy() - elif blockid == 11337: # prismarine stairs - texture = self.load_image_texture("assets/minecraft/textures/block/prismarine.png").copy() - elif blockid == 11338: # dark prismarine stairs - texture = self.load_image_texture("assets/minecraft/textures/block/dark_prismarine.png").copy() - elif blockid == 11339: # prismarine brick stairs - texture = self.load_image_texture("assets/minecraft/textures/block/prismarine_bricks.png").copy() + stair_id_to_tex = { + 53: "assets/minecraft/textures/block/oak_planks.png", + 67: "assets/minecraft/textures/block/cobblestone.png", + 108: "assets/minecraft/textures/block/bricks.png", + 109: "assets/minecraft/textures/block/stone_bricks.png", + 114: "assets/minecraft/textures/block/nether_bricks.png", + 128: "assets/minecraft/textures/block/sandstone.png", + 134: "assets/minecraft/textures/block/spruce_planks.png", + 135: "assets/minecraft/textures/block/birch_planks.png", + 136: "assets/minecraft/textures/block/jungle_planks.png", + 156: "assets/minecraft/textures/block/quartz_block_side.png", + 163: "assets/minecraft/textures/block/acacia_planks.png", + 164: "assets/minecraft/textures/block/dark_oak_planks.png", + 180: "assets/minecraft/textures/block/red_sandstone.png", + 203: "assets/minecraft/textures/block/purpur_block.png", + 11337: "assets/minecraft/textures/block/prismarine.png", + 11338: "assets/minecraft/textures/block/dark_prismarine.png", + 11339: "assets/minecraft/textures/block/prismarine_bricks.png", + 11370: "assets/minecraft/textures/block/mossy_stone_bricks.png", + 11371: "assets/minecraft/textures/block/mossy_cobblestone.png", + } + + texture = self.load_image_texture(stair_id_to_tex[blockid]).copy() outside_l = texture.copy() outside_r = texture.copy() @@ -4311,13 +4301,16 @@ def beacon(self, blockid, data): return img -# cobblestone and mossy cobblestone walls, chorus plants +# cobblestone and mossy cobblestone walls, chorus plants, mossy stone brick walls # one additional bit of data value added for mossy and cobblestone -@material(blockid=[139, 199], data=list(range(32)), transparent=True, nospawn=True) +@material(blockid=[139, 199, 11372], data=list(range(32)), transparent=True, nospawn=True) def cobblestone_wall(self, blockid, data): # chorus plants if blockid == 199: t = self.load_image_texture("assets/minecraft/textures/block/chorus_plant.png").copy() + # mossy stone bricks + elif blockid == 11372: + t = self.load_image_texture("assets/minecraft/textures/block/mossy_stone_bricks.png").copy() # no rotation, uses pseudo data elif data & 0b10000 == 0: # cobblestone diff --git a/overviewer_core/world.py b/overviewer_core/world.py index 4499895..5579782 100644 --- a/overviewer_core/world.py +++ b/overviewer_core/world.py @@ -799,13 +799,15 @@ class RegionSet(object): "minecraft:fletching_table": (11359, 0), "minecraft:cartography_table": (11360, 0), "minecraft:smithing_table": (11361, 0), - "minecraft:blast_furnace": (11362, 0), "minecraft:smoker": (11364, 0), "minecraft:lectern": (11366, 0), "minecraft:loom": (11367, 0), "minecraft:stonecutter": (11368, 0), - "minecraft:grindstone": (11369, 0) + "minecraft:grindstone": (11369, 0), + "minecraft:mossy_stone_brick_stairs": (11370, 0), + "minecraft:mossy_cobblestone_stairs": (11371, 0), + "minecraft:mossy_stone_brick_wall": (11372, 0), } colors = [ 'white', 'orange', 'magenta', 'light_blue',