Skip to content

Commit

Permalink
Improve Chest appearance - opening chests.
Browse files Browse the repository at this point in the history
Adds a mesh model that appears when a chest is opened. The chest
stays visibly open as long as the player keeps it open. When the
player closes the formspec, the chest returns back to the closed
shape. While opening and closing, a sound plays.

A second person inspecting the chest will trigger a second sound
open. However, only after the last player closes the chest, does the
chest actually visually close and is the sound close played. This
keeps mesh updates to a minimum.

While it's possible that a server shutting down may cause chests
to remain open, this does not affect the chests' working matter,
and opening or closing them should fix them.

Old chests are converted to the new style by LBM. I previously
had them converted on open but this was unreliable, and LBMs
don't have that problem.

Open chests cannot be dug up. This prevents people from keeping
a chest open and digging it out as well, since closing a chest
would place a chest back (swap) at the spot. We could protect
against this, but it still messes up the client and causes a lot
of "missing node inventory" error messages otherwise. It's
unlikely but possible that a player lagging out causes a chest
to stay "open" and thus unremovable by digging, but there are
other ways of dealing with that - a server restart fixes that
issue.

If the lid of the chest is obstructed, the sounds continue to play,
but the lid isn't opened. Obstructed means that a node is present
above the chest lid, however, we ignore several node types like signs,
torches (not 3d) and wallmounted nodeboxes (typically signs) since
they don't pose any major obstruction in almost any case, and are
typically found above chests. Additionally, the selection box of the
opened chest does not include the lid, and so one can still interact
with e.g. a sign behind an open lid.

Due to the fact that chests now have 7+ textures, we can no longer
use materials (limit: 6) to texture the chest, and so there is now
a single UV mapped image that applies both to open and closed chests.
While this does mean texture pack makers need to create it, this
is extremely simple and consists of a simple cut'n'paste over the
template and should be really easy to do. Only one texture file is
now then used for both open and closed chests.
  • Loading branch information
sofar authored and paramat committed May 1, 2017
1 parent 4ec0fd9 commit 011ad78
Show file tree
Hide file tree
Showing 12 changed files with 367 additions and 146 deletions.
13 changes: 13 additions & 0 deletions mods/default/README.txt
Expand Up @@ -154,6 +154,9 @@ sofar (CC BY-SA 3.0):
default_aspen_tree
default_aspen_tree_top, derived from default_pine_tree_top (by paramat)
default_aspen_wood, derived from default_pine_wood (by paramat)
default_chest_wood, default_chest_wood_locked derived from default_chest_* textures by BlockMen

sofar (WTFPL):
default_gravel.png -- Derived from Gambit's PixelBOX texture pack light gravel

Neuromancer (CC BY-SA 2.0):
Expand Down Expand Up @@ -285,3 +288,13 @@ https://www.freesound.org/people/AGFX/packs/1253/
blukotek (CC0 1.0)
https://www.freesound.org/people/blukotek/sounds/251660/
default_dig_snappy.ogg

Chests sounds added by sofar, derived of several files mixed together:
default_chest_open.ogg
default_chest_close.ogg
- http://www.freesound.org/people/Sevin7/sounds/269722/ CC0
- http://www.freesound.org/people/Percy%20Duke/sounds/23448/ CC-BY-3.0
- http://www.freesound.org/people/kingsamas/sounds/135576/ CC-BY-3.0
- http://www.freesound.org/people/bulbastre/sounds/126887/ CC-BY-3.0
- http://www.freesound.org/people/Yoyodaman234/sounds/183541/ CC0

82 changes: 82 additions & 0 deletions mods/default/models/chest_open.obj
@@ -0,0 +1,82 @@
# Blender v2.76 (sub 0) OBJ File: 'chest_open.blend'
# www.blender.org
mtllib chest_open.mtl
o Bottom_Cube.001
v -0.500000 -0.500000 0.500000
v -0.500000 0.187500 0.500000
v -0.500000 -0.500000 -0.500000
v -0.500000 0.187500 -0.500000
v 0.500000 -0.500000 0.500000
v 0.500000 0.187500 0.500000
v 0.500000 -0.500000 -0.500000
v 0.500000 0.187500 -0.500000
vt 0.750000 0.343750
vt 0.500000 0.343750
vt 0.500000 0.000000
vt 0.750000 0.000000
vt 0.250000 0.343750
vt 0.250000 0.000000
vt 0.000000 0.343750
vt 0.000000 0.000000
vt 0.750000 0.875000
vt 0.500000 0.875000
vt 0.500000 0.500000
vt 0.750000 0.500000
vt 0.250000 0.500000
vt 0.250000 1.000000
vt 0.000000 1.000000
vt 0.000000 0.500000
vt 1.000000 0.500000
vt 1.000000 0.000000
vn -1.000000 0.000000 0.000000
vn 0.000000 0.000000 -1.000000
vn 1.000000 0.000000 0.000000
vn 0.000000 0.000000 1.000000
vn 0.000000 -1.000000 0.000000
vn 0.000000 1.000000 0.000000
usemtl None
s off
f 2/1/1 4/2/1 3/3/1 1/4/1
f 4/2/2 8/5/2 7/6/2 3/3/2
f 8/5/3 6/7/3 5/8/3 7/6/3
f 6/9/4 2/10/4 1/11/4 5/12/4
f 1/13/5 3/14/5 7/15/5 5/16/5
f 6/4/6 8/12/6 4/17/6 2/18/6
o Top_Cube.002
v -0.499900 0.187501 0.499900
v -0.499900 0.408471 0.720970
v -0.499900 0.894607 -0.207108
v -0.499900 1.115578 0.013863
v 0.499900 0.187501 0.499900
v 0.499900 0.408471 0.720970
v 0.499900 0.894607 -0.207108
v 0.499900 1.115578 0.013863
vt 0.750000 0.500000
vt 0.500000 0.500000
vt 0.500000 0.343750
vt 0.750000 0.343750
vt 0.250000 0.500000
vt 0.250000 0.343750
vt 0.000000 0.500000
vt 0.000000 0.343750
vt 0.750000 1.000000
vt 0.500000 1.000000
vt 0.500000 0.843750
vt 0.750000 0.843750
vt 1.000000 0.500000
vt 1.000000 1.000000
vt 0.250000 1.000000
vn -1.000000 0.000000 0.000000
vn 0.000000 0.707100 -0.707100
vn 1.000000 0.000000 0.000000
vn 0.000000 -0.707100 0.707100
vn 0.000000 -0.707100 -0.707100
vn 0.000000 0.707100 0.707100
usemtl None
s off
f 10/19/7 12/20/7 11/21/7 9/22/7
f 12/20/8 16/23/8 15/24/8 11/21/8
f 16/23/9 14/25/9 13/26/9 15/24/9
f 14/27/10 10/28/10 9/29/10 13/30/10
f 9/31/11 11/32/11 15/27/11 13/19/11
f 14/33/12 16/23/12 12/20/12 10/28/12
38 changes: 38 additions & 0 deletions mods/default/models/cube.obj
@@ -0,0 +1,38 @@
# Blender v2.76 (sub 0) OBJ File: 'chest_close.blend'
# www.blender.org
mtllib chest_close.mtl
o Cube_Cube.001
v -0.500000 -0.500000 0.500000
v -0.500000 0.500000 0.500000
v -0.500000 -0.500000 -0.500000
v -0.500000 0.500000 -0.500000
v 0.500000 -0.500000 0.500000
v 0.500000 0.500000 0.500000
v 0.500000 -0.500000 -0.500000
v 0.500000 0.500000 -0.500000
vt 0.750000 0.500000
vt 0.500000 0.500000
vt 0.500000 -0.000000
vt 0.750000 0.000000
vt 0.250000 0.500000
vt 0.250000 0.000000
vt 0.000000 0.500000
vt -0.000000 0.000000
vt 0.750000 1.000000
vt 0.500000 1.000000
vt 0.250000 1.000000
vt -0.000000 1.000000
vn -1.000000 0.000000 0.000000
vn 0.000000 0.000000 -1.000000
vn 1.000000 0.000000 0.000000
vn 0.000000 0.000000 1.000000
vn 0.000000 -1.000000 0.000000
vn 0.000000 1.000000 0.000000
usemtl None
s off
f 2/1/1 4/2/1 3/3/1 1/4/1
f 4/2/2 8/5/2 7/6/2 3/3/2
f 8/5/3 6/7/3 5/8/3 7/6/3
f 6/9/4 2/10/4 1/2/4 5/1/4
f 1/5/5 3/11/5 7/12/5 5/7/5
f 6/11/6 8/5/6 4/2/6 2/10/6

0 comments on commit 011ad78

Please sign in to comment.