Fix fence connection
- use ingame data
This commit is contained in:
@@ -143,29 +143,6 @@ const mc_block_t block_class_door[] = {
|
|||||||
block_warped_door};
|
block_warped_door};
|
||||||
const size_t block_class_door_len = COUNT_OF(block_class_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[] = {
|
const mc_block_t block_class_ancil[] = {
|
||||||
block_wooden_door,
|
block_wooden_door,
|
||||||
block_iron_door,
|
block_iron_door,
|
||||||
@@ -229,10 +206,8 @@ const mc_block_t block_class_ancil[] = {
|
|||||||
block_glass,
|
block_glass,
|
||||||
block_redstone_wire,
|
block_redstone_wire,
|
||||||
block_ice,
|
block_ice,
|
||||||
block_fence,
|
|
||||||
block_portal,
|
block_portal,
|
||||||
block_waterlily,
|
block_waterlily,
|
||||||
block_nether_brick_fence,
|
|
||||||
block_andesite_wall,
|
block_andesite_wall,
|
||||||
block_brick_wall,
|
block_brick_wall,
|
||||||
block_cobblestone_wall,
|
block_cobblestone_wall,
|
||||||
@@ -252,13 +227,6 @@ const mc_block_t block_class_ancil[] = {
|
|||||||
block_polished_blackstone_brick_wall,
|
block_polished_blackstone_brick_wall,
|
||||||
block_double_plant,
|
block_double_plant,
|
||||||
block_stained_glass,
|
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_cobbled_deepslate_wall,
|
||||||
block_polished_deepslate_wall,
|
block_polished_deepslate_wall,
|
||||||
block_deepslate_brick_wall,
|
block_deepslate_brick_wall,
|
||||||
|
|||||||
@@ -36,12 +36,6 @@ extern const size_t block_class_stair_len;
|
|||||||
extern const mc_block_t block_class_door[];
|
extern const mc_block_t block_class_door[];
|
||||||
extern const size_t block_class_door_len;
|
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 mc_block_t block_class_ancil[];
|
||||||
extern const size_t block_class_ancil_len;
|
extern const size_t block_class_ancil_len;
|
||||||
|
|
||||||
|
|||||||
@@ -276,12 +276,6 @@ generate_pseudo_data(RenderState* state, uint16_t ancilData) {
|
|||||||
}
|
}
|
||||||
data = (check_adjacent_blocks(state, x, y, z, state->block) ^ 0x0f) | data;
|
data = (check_adjacent_blocks(state, x, y, z, state->block) ^ 0x0f) | data;
|
||||||
return (data << 4) | (ancilData & 0x0f);
|
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 */
|
} else if (state->block == block_redstone_wire) { /* redstone */
|
||||||
/* three addiotional bit are added, one for on/off state, and
|
/* 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;
|
return final_data;
|
||||||
|
|
||||||
} else if (block_class_is_subset(state->block, (mc_block_t[]){block_portal, block_nether_brick_fence}, 2)) {
|
} else if (state->block == block_portal) {
|
||||||
/* portal and nether brick fences */
|
/* portal */
|
||||||
return check_adjacent_blocks(state, x, y, z, state->block);
|
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)) {
|
} 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;
|
state.block_data = ancilData;
|
||||||
/* block that need pseudo ancildata:
|
/* block that need pseudo ancildata:
|
||||||
* grass, water, glass, chest, restone wire,
|
* grass, water, glass, chest, restone wire,
|
||||||
* ice, fence, portal, iron bars, glass panes,
|
* ice, portal, iron bars,
|
||||||
* trapped chests, stairs */
|
* trapped chests, stairs */
|
||||||
if (block_class_is_subset(state.block, block_class_ancil, block_class_ancil_len)) {
|
if (block_class_is_subset(state.block, block_class_ancil, block_class_ancil_len)) {
|
||||||
ancilData = generate_pseudo_data(&state, ancilData);
|
ancilData = generate_pseudo_data(&state, ancilData);
|
||||||
|
|||||||
@@ -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"))
|
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
|
# 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)
|
@material(blockid=[85, 188, 189, 190, 191, 192, 113, 511, 512], data=list(range(16)), transparent=True, nospawn=True)
|
||||||
def fence(self, blockid, data):
|
def fence(self, blockid, data):
|
||||||
# no need for rotations, it uses pseudo data.
|
|
||||||
# create needed images for Big stick fence
|
# create needed images for Big stick fence
|
||||||
if blockid == 85: # normal fence
|
if blockid == 85: # normal fence
|
||||||
fence_top = self.load_image_texture("assets/minecraft/textures/block/oak_planks.png").copy()
|
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_top_right = (10,3)
|
||||||
pos_bottom_right = (10,7)
|
pos_bottom_right = (10,7)
|
||||||
pos_bottom_left = (2,7)
|
pos_bottom_left = (2,7)
|
||||||
|
|
||||||
# +x axis points top right direction
|
# +x axis points top right direction
|
||||||
# +y axis points bottom right direction
|
# +y axis points bottom right direction
|
||||||
# First compose small sticks in the back of the image,
|
# First compose small sticks in the back of the image,
|
||||||
# then big stick and thecn small sticks in the front.
|
# 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
|
return img
|
||||||
|
|
||||||
# pumpkin
|
# pumpkin
|
||||||
|
|||||||
@@ -1303,10 +1303,14 @@ class RegionSet(object):
|
|||||||
data = p['rotation']
|
data = p['rotation']
|
||||||
elif key.endswith('_fence'):
|
elif key.endswith('_fence'):
|
||||||
p = palette_entry['Properties']
|
p = palette_entry['Properties']
|
||||||
if p['north'] == 'true': data |= 1
|
if p['north'] == 'true':
|
||||||
if p['west'] == 'true': data |= 2
|
data |= 1
|
||||||
if p['south'] == 'true': data |= 4
|
if p['east'] == 'true':
|
||||||
if p['east'] == 'true': data |= 8
|
data |= 2
|
||||||
|
if p['south'] == 'true':
|
||||||
|
data |= 4
|
||||||
|
if p['west'] == 'true':
|
||||||
|
data |= 8
|
||||||
elif key.endswith('_stairs'):
|
elif key.endswith('_stairs'):
|
||||||
facing = palette_entry['Properties']['facing']
|
facing = palette_entry['Properties']['facing']
|
||||||
if facing == 'south': data = 2
|
if facing == 'south': data = 2
|
||||||
|
|||||||
Reference in New Issue
Block a user