Merge PR #1957 of buscher

Fix fence connection
This commit is contained in:
Nicolas F 2021-07-10 11:18:56 +02:00
commit 352102552a
5 changed files with 36 additions and 68 deletions

View File

@ -143,29 +143,6 @@ const mc_block_t block_class_door[] = {
block_warped_door};
const size_t block_class_door_len = COUNT_OF(block_class_door);
const mc_block_t block_class_fence[] = {
block_fence,
block_nether_brick_fence,
block_spruce_fence,
block_birch_fence,
block_jungle_fence,
block_dark_oak_fence,
block_crimson_fence,
block_warped_fence,
block_acacia_fence};
const size_t block_class_fence_len = COUNT_OF(block_class_fence);
const mc_block_t block_class_fence_gate[] = {
block_fence_gate,
block_spruce_fence_gate,
block_birch_fence_gate,
block_jungle_fence_gate,
block_dark_oak_fence_gate,
block_acacia_fence_gate,
block_crimson_fence_gate,
block_warped_fence_gate};
const size_t block_class_fence_gate_len = COUNT_OF(block_class_fence_gate);
const mc_block_t block_class_ancil[] = {
block_wooden_door,
block_iron_door,
@ -229,10 +206,8 @@ const mc_block_t block_class_ancil[] = {
block_glass,
block_redstone_wire,
block_ice,
block_fence,
block_portal,
block_waterlily,
block_nether_brick_fence,
block_andesite_wall,
block_brick_wall,
block_cobblestone_wall,
@ -252,13 +227,6 @@ const mc_block_t block_class_ancil[] = {
block_polished_blackstone_brick_wall,
block_double_plant,
block_stained_glass,
block_spruce_fence,
block_birch_fence,
block_jungle_fence,
block_dark_oak_fence,
block_crimson_fence,
block_warped_fence,
block_acacia_fence,
block_cobbled_deepslate_wall,
block_polished_deepslate_wall,
block_deepslate_brick_wall,

View File

@ -36,12 +36,6 @@ extern const size_t block_class_stair_len;
extern const mc_block_t block_class_door[];
extern const size_t block_class_door_len;
extern const mc_block_t block_class_fence[];
extern const size_t block_class_fence_len;
extern const mc_block_t block_class_fence_gate[];
extern const size_t block_class_fence_gate_len;
extern const mc_block_t block_class_ancil[];
extern const size_t block_class_ancil_len;

View File

@ -276,12 +276,6 @@ generate_pseudo_data(RenderState* state, uint16_t ancilData) {
}
data = (check_adjacent_blocks(state, x, y, z, state->block) ^ 0x0f) | data;
return (data << 4) | (ancilData & 0x0f);
} else if (block_class_is_subset(state->block, block_class_fence, block_class_fence_len)) { /* fences */
/* check for fences AND fence gates */
return check_adjacent_blocks(state, x, y, z, state->block) | check_adjacent_blocks(state, x, y, z, block_fence_gate) |
check_adjacent_blocks(state, x, y, z, block_fence_gate) | check_adjacent_blocks(state, x, y, z, block_birch_fence_gate) | check_adjacent_blocks(state, x, y, z, block_jungle_fence_gate) |
check_adjacent_blocks(state, x, y, z, block_dark_oak_fence_gate) | check_adjacent_blocks(state, x, y, z, block_acacia_fence_gate)
| check_adjacent_blocks(state, x, y, z, block_crimson_fence_gate) | check_adjacent_blocks(state, x, y, z, block_warped_fence_gate);
} else if (state->block == block_redstone_wire) { /* redstone */
/* three addiotional bit are added, one for on/off state, and
@ -317,8 +311,8 @@ generate_pseudo_data(RenderState* state, uint16_t ancilData) {
}
return final_data;
} else if (block_class_is_subset(state->block, (mc_block_t[]){block_portal, block_nether_brick_fence}, 2)) {
/* portal and nether brick fences */
} else if (state->block == block_portal) {
/* portal */
return check_adjacent_blocks(state, x, y, z, state->block);
} else if (block_class_is_subset(state->block, block_class_door, block_class_door_len)) {
@ -620,7 +614,7 @@ chunk_render(PyObject* self, PyObject* args) {
state.block_data = ancilData;
/* block that need pseudo ancildata:
* grass, water, glass, chest, restone wire,
* ice, fence, portal, iron bars, glass panes,
* ice, portal, iron bars,
* trapped chests, stairs */
if (block_class_is_subset(state.block, block_class_ancil, block_class_ancil_len)) {
ancilData = generate_pseudo_data(&state, ancilData);

View File

@ -3665,10 +3665,8 @@ def jukebox(self, blockid, data):
return self.build_block(self.load_image_texture("assets/minecraft/textures/block/jukebox_top.png"), self.load_image_texture("assets/minecraft/textures/block/note_block.png"))
# nether and normal fences
# uses pseudo-ancildata found in iterate.c
@material(blockid=[85, 188, 189, 190, 191, 192, 113, 511, 512], data=list(range(16)), transparent=True, nospawn=True)
def fence(self, blockid, data):
# no need for rotations, it uses pseudo data.
# create needed images for Big stick fence
if blockid == 85: # normal fence
fence_top = self.load_image_texture("assets/minecraft/textures/block/oak_planks.png").copy()
@ -3769,24 +3767,34 @@ def fence(self, blockid, data):
pos_top_right = (10,3)
pos_bottom_right = (10,7)
pos_bottom_left = (2,7)
# +x axis points top right direction
# +y axis points bottom right direction
# First compose small sticks in the back of the image,
# then big stick and thecn small sticks in the front.
# First compose small sticks in the back of the image,
# then big stick and then small sticks in the front.
def draw_north():
alpha_over(img, fence_small_side, pos_top_left, fence_small_side)
def draw_east():
alpha_over(img, fence_small_other_side, pos_top_right, fence_small_other_side)
def draw_south():
alpha_over(img, fence_small_side, pos_bottom_right, fence_small_side)
def draw_west():
alpha_over(img, fence_small_other_side, pos_bottom_left, fence_small_other_side)
draw_funcs = [draw_north, draw_east, draw_south, draw_west]
if (data & 0b0001):
draw_funcs[(self.rotation + 0) % len(draw_funcs)]()
if (data & 0b0010):
draw_funcs[(self.rotation + 1) % len(draw_funcs)]()
alpha_over(img, fence_big, (0, 0), fence_big)
if (data & 0b0100):
draw_funcs[(self.rotation + 2) % len(draw_funcs)]()
if (data & 0b1000):
draw_funcs[(self.rotation + 3) % len(draw_funcs)]()
if (data & 0b0001) == 1:
alpha_over(img,fence_small_side, pos_top_left,fence_small_side) # top left
if (data & 0b1000) == 8:
alpha_over(img,fence_small_other_side, pos_top_right,fence_small_other_side) # top right
alpha_over(img,fence_big,(0,0),fence_big)
if (data & 0b0010) == 2:
alpha_over(img,fence_small_other_side, pos_bottom_left,fence_small_other_side) # bottom left
if (data & 0b0100) == 4:
alpha_over(img,fence_small_side, pos_bottom_right,fence_small_side) # bottom right
return img
# pumpkin

View File

@ -1303,10 +1303,14 @@ class RegionSet(object):
data = p['rotation']
elif key.endswith('_fence'):
p = palette_entry['Properties']
if p['north'] == 'true': data |= 1
if p['west'] == 'true': data |= 2
if p['south'] == 'true': data |= 4
if p['east'] == 'true': data |= 8
if p['north'] == 'true':
data |= 1
if p['east'] == 'true':
data |= 2
if p['south'] == 'true':
data |= 4
if p['west'] == 'true':
data |= 8
elif key.endswith('_stairs'):
facing = palette_entry['Properties']['facing']
if facing == 'south': data = 2