Merge branch 'master' into python3-fun-times
This commit is contained in:
@@ -16,6 +16,8 @@
|
||||
*/
|
||||
|
||||
#include "../overviewer.h"
|
||||
#include "../mc_id.h"
|
||||
#include "../block_class.h"
|
||||
#include "biomes.h"
|
||||
|
||||
typedef struct {
|
||||
@@ -75,7 +77,7 @@ base_draw(void *data, RenderState *state, PyObject *src, PyObject *mask, PyObjec
|
||||
PrimitiveBase *self = (PrimitiveBase *)data;
|
||||
|
||||
/* in order to detect top parts of doublePlant grass & ferns */
|
||||
unsigned char below_block = get_data(state, BLOCKS, state->x, state->y-1, state->z);
|
||||
unsigned short below_block = get_data(state, BLOCKS, state->x, state->y-1, state->z);
|
||||
unsigned char below_data = get_data(state, DATA, state->x, state->y-1, state->z);
|
||||
|
||||
/* draw the block! */
|
||||
@@ -93,24 +95,25 @@ base_draw(void *data, RenderState *state, PyObject *src, PyObject *mask, PyObjec
|
||||
* biome-compliant ones! The tinting is now all done here.
|
||||
*/
|
||||
if (/* grass, but not snowgrass */
|
||||
(state->block == 2 && get_data(state, BLOCKS, state->x, state->y+1, state->z) != 78) ||
|
||||
/* water */
|
||||
state->block == 8 || state->block == 9 ||
|
||||
/* leaves */
|
||||
state->block == 18 || state->block == 161 ||
|
||||
(state->block == block_grass && get_data(state, BLOCKS, state->x, state->y+1, state->z) != 78) ||
|
||||
block_class_is_subset(state->block, (mc_block_t[]){
|
||||
block_vine,
|
||||
block_waterlily,
|
||||
block_flowing_water,
|
||||
block_water,
|
||||
block_leaves,
|
||||
block_leaves2
|
||||
},
|
||||
6) ||
|
||||
/* 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
|
||||
* get constant brown color (see textures.py) */
|
||||
(((state->block == 104) || (state->block == 105)) && (state->block_data != 7)) ||
|
||||
/* vines */
|
||||
state->block == 106 ||
|
||||
/* lily pads */
|
||||
state->block == 111 ||
|
||||
(((state->block == block_pumpkin_stem) || (state->block == block_melon_stem)) && (state->block_data != 7)) ||
|
||||
/* 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 */
|
||||
(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! */
|
||||
PyObject *facemask = mask;
|
||||
@@ -118,24 +121,29 @@ base_draw(void *data, RenderState *state, PyObject *src, PyObject *mask, PyObjec
|
||||
PyObject *color_table = NULL;
|
||||
unsigned char flip_xy = 0;
|
||||
|
||||
if (state->block == 2) {
|
||||
if (state->block == block_grass) {
|
||||
/* grass needs a special facemask */
|
||||
facemask = self->grass_texture;
|
||||
}
|
||||
|
||||
switch (state->block) {
|
||||
case 2:
|
||||
/* grass */
|
||||
if(block_class_is_subset(state->block, (mc_block_t[]){
|
||||
block_grass,
|
||||
block_tallgrass,
|
||||
block_pumpkin_stem,
|
||||
block_melon_stem,
|
||||
block_vine,
|
||||
block_waterlily,
|
||||
block_double_plant
|
||||
},7)) {
|
||||
color_table = self->grasscolor;
|
||||
break;
|
||||
case 8:
|
||||
case 9:
|
||||
/* water */
|
||||
}
|
||||
else if(block_class_is_subset(state->block, (mc_block_t[]){
|
||||
block_flowing_water,block_water
|
||||
},2)) {
|
||||
color_table = self->watercolor;
|
||||
break;
|
||||
case 18:
|
||||
case 161:
|
||||
/* leaves */
|
||||
}
|
||||
else if(block_class_is_subset(state->block, (mc_block_t[]){
|
||||
block_leaves,block_leaves2
|
||||
},2)) {
|
||||
color_table = self->foliagecolor;
|
||||
if (state->block_data == 2)
|
||||
{
|
||||
@@ -143,34 +151,7 @@ base_draw(void *data, RenderState *state, PyObject *src, PyObject *mask, PyObjec
|
||||
birch foliage color is flipped XY-ways */
|
||||
flip_xy = 1;
|
||||
}
|
||||
break;
|
||||
case 31:
|
||||
/* tall grass */
|
||||
color_table = self->grasscolor;
|
||||
break;
|
||||
case 104:
|
||||
/* pumpkin stem */
|
||||
color_table = self->grasscolor;
|
||||
break;
|
||||
case 105:
|
||||
/* melon stem */
|
||||
color_table = self->grasscolor;
|
||||
break;
|
||||
case 106:
|
||||
/* vines */
|
||||
color_table = self->grasscolor;
|
||||
break;
|
||||
case 111:
|
||||
/* lily pads */
|
||||
color_table = self->grasscolor;
|
||||
break;
|
||||
case 175:
|
||||
/* doublePlant grass & ferns */
|
||||
color_table = self->grasscolor;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
};
|
||||
}
|
||||
|
||||
if (color_table) {
|
||||
unsigned char biome;
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
*/
|
||||
|
||||
#include "../overviewer.h"
|
||||
#include "../mc_id.h"
|
||||
#include "../block_class.h"
|
||||
|
||||
typedef struct {
|
||||
float opacity;
|
||||
@@ -34,16 +36,17 @@ edge_lines_draw(void *data, RenderState *state, PyObject *src, PyObject *mask, P
|
||||
PrimitiveEdgeLines *self = (PrimitiveEdgeLines *)data;
|
||||
|
||||
/* Draw some edge lines! */
|
||||
if (state->block == 44 || state->block == 78 || !is_transparent(state->block)) {
|
||||
if (block_class_is_subset(state->block, (mc_block_t[]){block_stone_slab,block_snow_layer}, 2)
|
||||
|| !is_transparent(state->block)) {
|
||||
Imaging img_i = imaging_python_to_c(state->img);
|
||||
unsigned char ink[] = {0, 0, 0, 255 * self->opacity};
|
||||
unsigned short side_block;
|
||||
int x = state->x, y = state->y, z = state->z;
|
||||
|
||||
int increment=0;
|
||||
if ((state->block == 44 || state->block == 126) && ((state->block_data & 0x8) == 0 )) // half-steps BUT no upsidown half-steps
|
||||
if (block_class_is_subset(state->block, (mc_block_t[]){block_wooden_slab,block_stone_slab}, 2) && ((state->block_data & 0x8) == 0 )) // half-steps BUT no upsidown half-steps
|
||||
increment=6;
|
||||
else if ((state->block == 78) || (state->block == 93) || (state->block == 94)) // snow, redstone repeaters (on and off)
|
||||
else if (block_class_is_subset(state->block, (mc_block_t[]){block_snow_layer,block_unpowered_repeater,block_powered_repeater}, 3)) // snow, redstone repeaters (on and off)
|
||||
increment=9;
|
||||
|
||||
/* +X side */
|
||||
@@ -51,9 +54,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)) &&
|
||||
/* 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 */
|
||||
!((state->block == 44 || state->block == 126) && ((side_block == 53) || (side_block == 67) || (side_block == 108) ||
|
||||
(side_block == 109) || (side_block == 114) || (side_block == 128) || (side_block == 134) || (side_block == 135) ||
|
||||
(side_block == 136)))) {
|
||||
!(block_class_is_subset(state->block, (mc_block_t[]){block_wooden_slab, block_stone_slab}, 2)
|
||||
&& (block_class_is_subset(side_block, block_class_stair, block_class_stair_len))
|
||||
)) {
|
||||
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);
|
||||
}
|
||||
@@ -63,9 +66,10 @@ 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)) &&
|
||||
/* 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 */
|
||||
!((state->block == 44 || state->block == 126) && ((side_block == 53) || (side_block == 67) || (side_block == 108) ||
|
||||
(side_block == 109) || (side_block == 114) || (side_block == 128) || (side_block == 134) || (side_block == 135) ||
|
||||
(side_block == 136)))) {
|
||||
!(
|
||||
block_class_is_subset(state->block, (mc_block_t[]){block_stone_slab,block_wooden_slab}, 2)
|
||||
&& (block_class_is_subset(side_block, block_class_stair, block_class_stair_len))
|
||||
)) {
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
*/
|
||||
|
||||
#include "../overviewer.h"
|
||||
#include "../mc_id.h"
|
||||
|
||||
struct HideRule {
|
||||
unsigned short blockid;
|
||||
@@ -90,7 +91,7 @@ hide_hidden(void *data, RenderState *state, int x, int y, int z) {
|
||||
return 0;
|
||||
|
||||
block = get_data(state, BLOCKS, x, y, z);
|
||||
for (i = 0; self->rules[i].blockid != 0; i++) {
|
||||
for (i = 0; self->rules[i].blockid != block_air; i++) {
|
||||
if (block == self->rules[i].blockid) {
|
||||
unsigned char data;
|
||||
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
*/
|
||||
|
||||
#include "../overviewer.h"
|
||||
#include "../mc_id.h"
|
||||
#include "../block_class.h"
|
||||
#include "lighting.h"
|
||||
#include <math.h>
|
||||
|
||||
@@ -100,7 +102,8 @@ estimate_blocklevel(RenderPrimitiveLighting *self, RenderState *state,
|
||||
int x, int y, int z, int *authoratative) {
|
||||
|
||||
/* placeholders for later data arrays, coordinates */
|
||||
unsigned char block, blocklevel;
|
||||
unsigned short block;
|
||||
unsigned char blocklevel;
|
||||
unsigned int average_count = 0, average_gather = 0, coeff = 0;
|
||||
|
||||
/* defaults to "guess" until told otherwise */
|
||||
@@ -138,7 +141,7 @@ estimate_blocklevel(RenderPrimitiveLighting *self, RenderState *state,
|
||||
blocklevel = get_data(state, BLOCKLIGHT, x, y, z);
|
||||
|
||||
/* no longer a guess */
|
||||
if (!(block == 44 || block == 53 || block == 67 || block == 108 || block == 109 || block == 180 || block == 182 || block == 205) && authoratative) {
|
||||
if (!block_class_is_subset(block, block_class_alt_height, block_class_alt_height_len) && authoratative) {
|
||||
*authoratative = 1;
|
||||
}
|
||||
|
||||
@@ -151,7 +154,8 @@ get_lighting_color(RenderPrimitiveLighting *self, RenderState *state,
|
||||
unsigned char *r, unsigned char *g, unsigned char *b) {
|
||||
|
||||
/* placeholders for later data arrays, coordinates */
|
||||
unsigned char block, skylevel, blocklevel;
|
||||
unsigned short block;
|
||||
unsigned char skylevel, blocklevel;
|
||||
|
||||
block = get_data(state, BLOCKS, x, y, z);
|
||||
skylevel = get_data(state, SKYLIGHT, x, y, z);
|
||||
@@ -159,9 +163,7 @@ get_lighting_color(RenderPrimitiveLighting *self, RenderState *state,
|
||||
|
||||
/* special half-step handling, stairs handling */
|
||||
/* Anvil also needs to be here, blockid 145 */
|
||||
if (block == 44 || block == 53 || block == 67 || block == 108 || block == 109 || block == 114 ||
|
||||
block == 128 || block == 134 || block == 135 || block == 136 || block == 145 || block == 156 ||
|
||||
block == 163 || block == 164 || block == 180 || block == 182 || block == 203 || block == 205) {
|
||||
if ( block_class_is_subset(block, block_class_alt_height, block_class_alt_height_len) || block == block_anvil) {
|
||||
unsigned int upper_block;
|
||||
|
||||
/* stairs and half-blocks take the skylevel from the upper block if it's transparent */
|
||||
@@ -170,10 +172,7 @@ get_lighting_color(RenderPrimitiveLighting *self, RenderState *state,
|
||||
do {
|
||||
upper_counter++;
|
||||
upper_block = get_data(state, BLOCKS, x, y + upper_counter, z);
|
||||
} while (upper_block == 44 || upper_block == 53 || upper_block == 67 || upper_block == 108 ||
|
||||
upper_block == 109 || upper_block == 114 || upper_block == 128 || upper_block == 134 ||
|
||||
upper_block == 135 || upper_block == 136 || upper_block == 156 || upper_block == 163 ||
|
||||
upper_block == 164 || upper_block == 180 || upper_block == 182 || upper_block == 203 || upper_block == 205);
|
||||
} while (block_class_is_subset(upper_block, block_class_alt_height, block_class_alt_height_len));
|
||||
if (is_transparent(upper_block)) {
|
||||
skylevel = get_data(state, SKYLIGHT, x, y + upper_counter, z);
|
||||
} else {
|
||||
@@ -186,7 +185,7 @@ get_lighting_color(RenderPrimitiveLighting *self, RenderState *state,
|
||||
|
||||
}
|
||||
|
||||
if (block == 10 || block == 11) {
|
||||
if (block_class_is_subset(block, (mc_block_t[]){block_flowing_lava,block_lava}, 2)) {
|
||||
/* lava blocks should always be lit! */
|
||||
*r = 255;
|
||||
*g = 255;
|
||||
@@ -305,7 +304,7 @@ lighting_draw(void *data, RenderState *state, PyObject *src, PyObject *mask, PyO
|
||||
self = (RenderPrimitiveLighting *)data;
|
||||
x = state->x, y = state->y, z = state->z;
|
||||
|
||||
if ((state->block == 8) || (state->block == 9)) { /* special case for water */
|
||||
if (block_class_is_subset(state->block, (mc_block_t[]){block_flowing_water,block_water}, 2)) { /* special case for water */
|
||||
/* looks like we need a new case for lighting, there are
|
||||
* blocks that are transparent for occlusion calculations and
|
||||
* need per-face shading if the face is drawn. */
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
*/
|
||||
|
||||
#include "../overviewer.h"
|
||||
#include "../mc_id.h"
|
||||
#include "../block_class.h"
|
||||
#include "nether.h"
|
||||
|
||||
static void
|
||||
@@ -26,16 +28,16 @@ walk_chunk(RenderState *state, RenderPrimitiveNether *data) {
|
||||
for (x = -1; x < WIDTH + 1; x++) {
|
||||
for (z = -1; z < DEPTH + 1; z++) {
|
||||
id = get_data(state, BLOCKS, x, NETHER_ROOF - (state->chunky * 16), z);
|
||||
if (id == 7) {
|
||||
if (id == block_bedrock) {
|
||||
data->remove_block[x+1][NETHER_ROOF][z+1] = 1;
|
||||
id = get_data(state, BLOCKS, x, (NETHER_ROOF + 1) - (state->chunky * 16), z);
|
||||
if (id == 39 || id == 40)
|
||||
if (id == block_brown_mushroom || id == block_red_mushroom)
|
||||
data->remove_block[x+1][NETHER_ROOF + 1][z+1] = 1;
|
||||
}
|
||||
|
||||
for (y = NETHER_ROOF-1; y>=0; y--) {
|
||||
id = get_data(state, BLOCKS, x, y - (state->chunky * 16), z);
|
||||
if (id == 7 || id == 87 || id == 153 || id == 11)
|
||||
if (block_class_is_subset(id, (mc_block_t[]){block_bedrock,block_netherrack,block_quartz_ore,block_lava}, 4))
|
||||
data->remove_block[x+1][y][z+1] = 1;
|
||||
else
|
||||
break;
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
*/
|
||||
|
||||
#include "overlay.h"
|
||||
#include "../mc_id.h"
|
||||
|
||||
typedef struct {
|
||||
/* inherits from overlay */
|
||||
@@ -31,17 +32,17 @@ struct MineralColor {
|
||||
|
||||
/* put more valuable ores first -- they take precedence */
|
||||
static struct MineralColor default_minerals[] = {
|
||||
{48 /* Mossy Stone */, 31, 153, 9},
|
||||
{block_mossy_cobblestone, 31, 153, 9},
|
||||
|
||||
{56 /* Diamond Ore */, 32, 230, 220},
|
||||
{block_diamond_ore, 32, 230, 220},
|
||||
|
||||
{21 /* Lapis Lazuli */, 0, 23, 176},
|
||||
{14 /* Gold Ore */, 255, 234, 0},
|
||||
{block_lapis_ore, 0, 23, 176},
|
||||
{block_gold_ore, 255, 234, 0},
|
||||
|
||||
{15 /* Iron Ore */, 204, 204, 204},
|
||||
{73 /* Redstone */, 186, 0, 0},
|
||||
{74 /* Lit Redstone */, 186, 0, 0},
|
||||
{16 /* Coal Ore */, 54, 54, 54},
|
||||
{block_iron_ore, 204, 204, 204},
|
||||
{block_redstone_ore, 186, 0, 0},
|
||||
{block_lit_redstone_ore, 186, 0, 0},
|
||||
{block_coal_ore, 54, 54, 54},
|
||||
|
||||
/* end of list marker */
|
||||
{0, 0, 0, 0}
|
||||
@@ -61,7 +62,7 @@ static void get_color(void *data, RenderState *state,
|
||||
int i, tmp;
|
||||
unsigned short blockid = get_data(state, BLOCKS, x, y, z);
|
||||
|
||||
for (i = 0; (max_i == -1 || i < max_i) && minerals[i].blockid != 0; i++) {
|
||||
for (i = 0; (max_i == -1 || i < max_i) && minerals[i].blockid != block_air; i++) {
|
||||
if (minerals[i].blockid == blockid) {
|
||||
*r = minerals[i].r;
|
||||
*g = minerals[i].g;
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
*/
|
||||
|
||||
#include "overlay.h"
|
||||
#include "../mc_id.h"
|
||||
|
||||
typedef enum { false, true } bool;
|
||||
|
||||
@@ -28,7 +29,7 @@ typedef struct {
|
||||
|
||||
struct Condition{
|
||||
int relx, rely, relz;
|
||||
unsigned char block;
|
||||
unsigned short block;
|
||||
};
|
||||
|
||||
struct Color {
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
*/
|
||||
|
||||
#include "overlay.h"
|
||||
#include "../mc_id.h"
|
||||
|
||||
static void get_color(void *data, RenderState *state,
|
||||
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
|
||||
int increment=0;
|
||||
if (state->block == 44) // half-step
|
||||
if (state->block == block_stone_slab) // half-step
|
||||
increment=6;
|
||||
else if (state->block == 78) // snow
|
||||
else if (state->block == block_snow_layer) // snow
|
||||
increment=9;
|
||||
|
||||
/* skip rendering the overlay if we can't see it */
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
*/
|
||||
|
||||
#include "../overviewer.h"
|
||||
#include "../mc_id.h"
|
||||
#include "../block_class.h"
|
||||
#include "lighting.h"
|
||||
#include <math.h>
|
||||
|
||||
@@ -218,7 +220,9 @@ smooth_lighting_draw(void *data, RenderState *state, PyObject *src, PyObject *ma
|
||||
|
||||
/* special case for leaves, water 8, water 9, ice 79
|
||||
-- these are also smooth-lit! */
|
||||
if (state->block != 18 && state->block != 8 && state->block != 9 && state->block != 79 && is_transparent(state->block))
|
||||
if (!block_class_is_subset(state->block, (mc_block_t[]){
|
||||
block_leaves,block_flowing_water,block_water,block_ice
|
||||
}, 4) && is_transparent(state->block))
|
||||
{
|
||||
/* transparent blocks are rendered as usual, with flat lighting */
|
||||
primitive_lighting.draw(data, state, src, mask, mask_light);
|
||||
@@ -228,7 +232,7 @@ smooth_lighting_draw(void *data, RenderState *state, PyObject *src, PyObject *ma
|
||||
/* non-transparent blocks get the special smooth treatment */
|
||||
|
||||
/* special code for water */
|
||||
if (state->block == 9)
|
||||
if (state->block == block_water)
|
||||
{
|
||||
if (!(state->block_pdata & (1 << 4)))
|
||||
light_top = 0;
|
||||
|
||||
Reference in New Issue
Block a user