0

Block ID to mc_id replacement pass

This commit is contained in:
Wunkolo
2019-03-16 21:15:08 -07:00
parent 7e97544f4d
commit 4d4df31ece
8 changed files with 40 additions and 33 deletions

View File

@@ -666,7 +666,7 @@ chunk_render(PyObject *self, PyObject *args) {
state.imgy -= 12; state.imgy -= 12;
/* get blockid */ /* get blockid */
state.block = getArrayShort3D(blocks_py, state.x, state.y, state.z); state.block = getArrayShort3D(blocks_py, state.x, state.y, state.z);
if (state.block == 0 || render_mode_hidden(rendermode, state.x, state.y, state.z)) { if (state.block == block_air || render_mode_hidden(rendermode, state.x, state.y, state.z)) {
continue; continue;
} }

View File

@@ -16,6 +16,7 @@
*/ */
#include "../overviewer.h" #include "../overviewer.h"
#include "../mc_id.h"
#include "biomes.h" #include "biomes.h"
typedef struct { typedef struct {
@@ -93,24 +94,24 @@ base_draw(void *data, RenderState *state, PyObject *src, PyObject *mask, PyObjec
* biome-compliant ones! The tinting is now all done here. * biome-compliant ones! The tinting is now all done here.
*/ */
if (/* grass, but not snowgrass */ if (/* grass, but not snowgrass */
(state->block == 2 && get_data(state, BLOCKS, state->x, state->y+1, state->z) != 78) || (state->block == block_grass && get_data(state, BLOCKS, state->x, state->y+1, state->z) != 78) ||
/* water */ /* water */
state->block == 8 || state->block == 9 || state->block == block_flowing_water || state->block == block_water ||
/* leaves */ /* leaves */
state->block == 18 || state->block == 161 || state->block == block_leaves || state->block == block_leaves2 ||
/* tallgrass, but not dead shrubs */ /* tallgrass, but not dead shrubs */
(state->block == 31 && state->block_data != 0) || (state->block == block_tallgrass && state->block_data != 0) ||
/* pumpkin/melon stem, not fully grown. Fully grown stems /* pumpkin/melon stem, not fully grown. Fully grown stems
* get constant brown color (see textures.py) */ * get constant brown color (see textures.py) */
(((state->block == 104) || (state->block == 105)) && (state->block_data != 7)) || (((state->block == block_pumpkin_stem) || (state->block == block_melon_stem)) && (state->block_data != 7)) ||
/* vines */ /* vines */
state->block == 106 || state->block == block_vine ||
/* lily pads */ /* lily pads */
state->block == 111 || state->block == block_waterlily ||
/* doublePlant grass & ferns */ /* doublePlant grass & ferns */
(state->block == 175 && (state->block_data == 2 || state->block_data == 3)) || (state->block == block_double_plant && (state->block_data == 2 || state->block_data == 3)) ||
/* doublePlant grass & ferns tops */ /* doublePlant grass & ferns tops */
(state->block == 175 && below_block == 175 && (below_data == 2 || below_data == 3)) ) (state->block == block_double_plant && below_block == block_double_plant && (below_data == 2 || below_data == 3)) )
{ {
/* do the biome stuff! */ /* do the biome stuff! */
PyObject *facemask = mask; PyObject *facemask = mask;
@@ -118,7 +119,7 @@ base_draw(void *data, RenderState *state, PyObject *src, PyObject *mask, PyObjec
PyObject *color_table = NULL; PyObject *color_table = NULL;
unsigned char flip_xy = 0; unsigned char flip_xy = 0;
if (state->block == 2) { if (state->block == block_grass) {
/* grass needs a special facemask */ /* grass needs a special facemask */
facemask = self->grass_texture; facemask = self->grass_texture;
} }

View File

@@ -16,6 +16,7 @@
*/ */
#include "../overviewer.h" #include "../overviewer.h"
#include "../mc_id.h"
typedef struct { typedef struct {
float opacity; float opacity;
@@ -34,16 +35,16 @@ edge_lines_draw(void *data, RenderState *state, PyObject *src, PyObject *mask, P
PrimitiveEdgeLines *self = (PrimitiveEdgeLines *)data; PrimitiveEdgeLines *self = (PrimitiveEdgeLines *)data;
/* Draw some edge lines! */ /* Draw some edge lines! */
if (state->block == 44 || state->block == 78 || !is_transparent(state->block)) { if (state->block == block_stone_slab || state->block == block_snow_layer || !is_transparent(state->block)) {
Imaging img_i = imaging_python_to_c(state->img); Imaging img_i = imaging_python_to_c(state->img);
unsigned char ink[] = {0, 0, 0, 255 * self->opacity}; unsigned char ink[] = {0, 0, 0, 255 * self->opacity};
unsigned short side_block; unsigned short side_block;
int x = state->x, y = state->y, z = state->z; int x = state->x, y = state->y, z = state->z;
int increment=0; int increment=0;
if ((state->block == 44 || state->block == 126) && ((state->block_data & 0x8) == 0 )) // half-steps BUT no upsidown half-steps if ((state->block == block_stone_slab || state->block == block_wooden_slab) && ((state->block_data & 0x8) == 0 )) // half-steps BUT no upsidown half-steps
increment=6; increment=6;
else if ((state->block == 78) || (state->block == 93) || (state->block == 94)) // snow, redstone repeaters (on and off) else if ((state->block == block_snow_layer) || (state->block == block_unpowered_repeater) || (state->block == block_powered_repeater)) // snow, redstone repeaters (on and off)
increment=9; increment=9;
/* +X side */ /* +X side */
@@ -51,9 +52,9 @@ edge_lines_draw(void *data, RenderState *state, PyObject *src, PyObject *mask, P
if (side_block != state->block && (is_transparent(side_block) || render_mode_hidden(state->rendermode, x+1, y, z)) && if (side_block != state->block && (is_transparent(side_block) || render_mode_hidden(state->rendermode, x+1, y, z)) &&
/* WARNING: ugly special case approaching */ /* WARNING: ugly special case approaching */
/* if the block is a slab and the side block is a stair don't draw anything, it can give very ugly results */ /* if the block is a slab and the side block is a stair don't draw anything, it can give very ugly results */
!((state->block == 44 || state->block == 126) && ((side_block == 53) || (side_block == 67) || (side_block == 108) || !((state->block == block_stone_slab || state->block == block_wooden_slab) && ((side_block == block_oak_stairs) || (side_block == block_stone_stairs) || (side_block == block_brick_stairs) ||
(side_block == 109) || (side_block == 114) || (side_block == 128) || (side_block == 134) || (side_block == 135) || (side_block == block_stone_brick_stairs) || (side_block == block_nether_brick_stairs) || (side_block == block_sandstone_stairs) || (side_block == block_spruce_stairs) || (side_block == block_birch_stairs) ||
(side_block == 136)))) { (side_block == block_jungle_stairs)))) {
ImagingDrawLine(img_i, state->imgx+12, state->imgy+1+increment, state->imgx+22+1, state->imgy+5+1+increment, &ink, 1); ImagingDrawLine(img_i, state->imgx+12, state->imgy+1+increment, state->imgx+22+1, state->imgy+5+1+increment, &ink, 1);
ImagingDrawLine(img_i, state->imgx+12, state->imgy+increment, state->imgx+22+1, state->imgy+5+increment, &ink, 1); ImagingDrawLine(img_i, state->imgx+12, state->imgy+increment, state->imgx+22+1, state->imgy+5+increment, &ink, 1);
} }
@@ -63,9 +64,9 @@ edge_lines_draw(void *data, RenderState *state, PyObject *src, PyObject *mask, P
if (side_block != state->block && (is_transparent(side_block) || render_mode_hidden(state->rendermode, x, y, z-1)) && if (side_block != state->block && (is_transparent(side_block) || render_mode_hidden(state->rendermode, x, y, z-1)) &&
/* WARNING: ugly special case approaching */ /* WARNING: ugly special case approaching */
/* if the block is a slab and the side block is a stair don't draw anything, it can give very ugly results */ /* if the block is a slab and the side block is a stair don't draw anything, it can give very ugly results */
!((state->block == 44 || state->block == 126) && ((side_block == 53) || (side_block == 67) || (side_block == 108) || !((state->block == block_stone_slab || state->block == block_wooden_slab) && ((side_block == block_oak_stairs) || (side_block == block_stone_stairs) || (side_block == block_brick_stairs) ||
(side_block == 109) || (side_block == 114) || (side_block == 128) || (side_block == 134) || (side_block == 135) || (side_block == block_stone_brick_stairs) || (side_block == block_nether_brick_stairs) || (side_block == block_sandstone_stairs) || (side_block == block_spruce_stairs) || (side_block == block_birch_stairs) ||
(side_block == 136)))) { (side_block == block_jungle_stairs)))) {
ImagingDrawLine(img_i, state->imgx, state->imgy+6+1+increment, state->imgx+12+1, state->imgy+1+increment, &ink, 1); ImagingDrawLine(img_i, state->imgx, state->imgy+6+1+increment, state->imgx+12+1, state->imgy+1+increment, &ink, 1);
ImagingDrawLine(img_i, state->imgx, state->imgy+6+increment, state->imgx+12+1, state->imgy+increment, &ink, 1); ImagingDrawLine(img_i, state->imgx, state->imgy+6+increment, state->imgx+12+1, state->imgy+increment, &ink, 1);
} }

View File

@@ -16,6 +16,7 @@
*/ */
#include "../overviewer.h" #include "../overviewer.h"
#include "../mc_id.h"
struct HideRule { struct HideRule {
unsigned short blockid; unsigned short blockid;

View File

@@ -16,6 +16,7 @@
*/ */
#include "../overviewer.h" #include "../overviewer.h"
#include "../mc_id.h"
#include "lighting.h" #include "lighting.h"
#include <math.h> #include <math.h>
@@ -138,7 +139,7 @@ estimate_blocklevel(RenderPrimitiveLighting *self, RenderState *state,
blocklevel = get_data(state, BLOCKLIGHT, x, y, z); blocklevel = get_data(state, BLOCKLIGHT, x, y, z);
/* no longer a guess */ /* no longer a guess */
if (!(block == 44 || block == 53 || block == 67 || block == 108 || block == 109 || block == 180 || block == 182 || block == 205) && authoratative) { if (!(block == block_stone_slab || block == block_oak_stairs || block == block_stone_stairs || block == block_brick_stairs || block == block_stone_brick_stairs || block == block_red_sandstone_stairs || block == block_stone_slab2 || block == block_purpur_slab ) && authoratative) {
*authoratative = 1; *authoratative = 1;
} }
@@ -159,9 +160,9 @@ get_lighting_color(RenderPrimitiveLighting *self, RenderState *state,
/* special half-step handling, stairs handling */ /* special half-step handling, stairs handling */
/* Anvil also needs to be here, blockid 145 */ /* Anvil also needs to be here, blockid 145 */
if (block == 44 || block == 53 || block == 67 || block == 108 || block == 109 || block == 114 || if (block == block_stone_slab || block == block_oak_stairs || block == block_stone_stairs || block == block_brick_stairs || block == block_stone_brick_stairs || block == block_nether_brick_stairs ||
block == 128 || block == 134 || block == 135 || block == 136 || block == 145 || block == 156 || block == block_sandstone_stairs || block == block_spruce_stairs || block == block_birch_stairs || block == block_jungle_stairs || block == block_anvil || block == block_quartz_stairs ||
block == 163 || block == 164 || block == 180 || block == 182 || block == 203 || block == 205) { block == block_acacia_stairs || block == block_dark_oak_stairs || block == block_red_sandstone_stairs || block == block_stone_slab2 || block == block_purpur_stairs || block == block_purpur_slab ) {
unsigned int upper_block; unsigned int upper_block;
/* stairs and half-blocks take the skylevel from the upper block if it's transparent */ /* stairs and half-blocks take the skylevel from the upper block if it's transparent */
@@ -170,10 +171,10 @@ get_lighting_color(RenderPrimitiveLighting *self, RenderState *state,
do { do {
upper_counter++; upper_counter++;
upper_block = get_data(state, BLOCKS, x, y + upper_counter, z); upper_block = get_data(state, BLOCKS, x, y + upper_counter, z);
} while (upper_block == 44 || upper_block == 53 || upper_block == 67 || upper_block == 108 || } while (upper_block == block_stone_slab || upper_block == block_oak_stairs || upper_block == block_stone_stairs || upper_block == block_brick_stairs ||
upper_block == 109 || upper_block == 114 || upper_block == 128 || upper_block == 134 || upper_block == block_stone_brick_stairs || upper_block == block_nether_brick_stairs || upper_block == block_sandstone_stairs || upper_block == block_spruce_stairs ||
upper_block == 135 || upper_block == 136 || upper_block == 156 || upper_block == 163 || upper_block == block_birch_stairs || upper_block == block_jungle_stairs || upper_block == block_quartz_stairs || upper_block == block_acacia_stairs ||
upper_block == 164 || upper_block == 180 || upper_block == 182 || upper_block == 203 || upper_block == 205); upper_block == block_dark_oak_stairs || upper_block == block_red_sandstone_stairs || upper_block == block_stone_slab2 || upper_block == block_purpur_stairs || upper_block == block_purpur_slab );
if (is_transparent(upper_block)) { if (is_transparent(upper_block)) {
skylevel = get_data(state, SKYLIGHT, x, y + upper_counter, z); skylevel = get_data(state, SKYLIGHT, x, y + upper_counter, z);
} else { } else {
@@ -186,7 +187,7 @@ get_lighting_color(RenderPrimitiveLighting *self, RenderState *state,
} }
if (block == 10 || block == 11) { if (block == block_flowing_lava || block == block_lava) {
/* lava blocks should always be lit! */ /* lava blocks should always be lit! */
*r = 255; *r = 255;
*g = 255; *g = 255;
@@ -305,7 +306,7 @@ lighting_draw(void *data, RenderState *state, PyObject *src, PyObject *mask, PyO
self = (RenderPrimitiveLighting *)data; self = (RenderPrimitiveLighting *)data;
x = state->x, y = state->y, z = state->z; x = state->x, y = state->y, z = state->z;
if ((state->block == 8) || (state->block == 9)) { /* special case for water */ if ((state->block == block_flowing_water) || (state->block == block_water)) { /* special case for water */
/* looks like we need a new case for lighting, there are /* looks like we need a new case for lighting, there are
* blocks that are transparent for occlusion calculations and * blocks that are transparent for occlusion calculations and
* need per-face shading if the face is drawn. */ * need per-face shading if the face is drawn. */

View File

@@ -16,6 +16,7 @@
*/ */
#include "overlay.h" #include "overlay.h"
#include "../mc_id.h"
typedef enum { false, true } bool; typedef enum { false, true } bool;

View File

@@ -16,6 +16,7 @@
*/ */
#include "overlay.h" #include "overlay.h"
#include "../mc_id.h"
static void get_color(void *data, RenderState *state, static void get_color(void *data, RenderState *state,
unsigned char *r, unsigned char *g, unsigned char *b, unsigned char *a) { unsigned char *r, unsigned char *g, unsigned char *b, unsigned char *a) {
@@ -85,9 +86,9 @@ overlay_draw(void *data, RenderState *state, PyObject *src, PyObject *mask, PyOb
// exactly analogous to edge-line code for these special blocks // exactly analogous to edge-line code for these special blocks
int increment=0; int increment=0;
if (state->block == 44) // half-step if (state->block == block_stone_slab) // half-step
increment=6; increment=6;
else if (state->block == 78) // snow else if (state->block == block_snow_layer) // snow
increment=9; increment=9;
/* skip rendering the overlay if we can't see it */ /* skip rendering the overlay if we can't see it */

View File

@@ -16,6 +16,7 @@
*/ */
#include "../overviewer.h" #include "../overviewer.h"
#include "../mc_id.h"
#include "lighting.h" #include "lighting.h"
#include <math.h> #include <math.h>
@@ -228,7 +229,7 @@ smooth_lighting_draw(void *data, RenderState *state, PyObject *src, PyObject *ma
/* non-transparent blocks get the special smooth treatment */ /* non-transparent blocks get the special smooth treatment */
/* special code for water */ /* special code for water */
if (state->block == 9) if (state->block == block_water)
{ {
if (!(state->block_pdata & (1 << 4))) if (!(state->block_pdata & (1 << 4)))
light_top = 0; light_top = 0;