ofs | hex dump | ascii |
---|
0000 | 89 50 4e 47 0d 0a 1a 0a 00 00 00 0d 49 48 44 52 00 00 02 00 00 00 02 00 08 06 00 00 00 f4 78 d4 | .PNG........IHDR..............x. |
0020 | fa 00 00 00 06 62 4b 47 44 00 ff 00 ff 00 ff a0 bd a7 93 00 00 00 09 70 48 59 73 00 00 0b 13 00 | .....bKGD..............pHYs..... |
0040 | 00 0b 13 01 00 9a 9c 18 00 00 00 07 74 49 4d 45 07 e0 04 0a 12 01 3a 80 18 68 6b 00 00 20 00 49 | ............tIME......:..hk....I |
0060 | 44 41 54 78 da ec dd db 6f 9c f7 75 ff fb cf fa 3e 73 e0 90 22 25 51 a2 ac f3 21 4e 14 c5 8e 63 | DATx....o..u....>s.."%Q...!N...c |
0080 | 27 45 ed 66 ff 50 34 bd eb 5d 81 02 ce 6f ef 7f 40 01 5a a0 0d d0 3f 40 a3 3f a0 40 9a 8b 00 f6 | 'E.f.P4..]...o..@.Z...?@.?.@.... |
00a0 | 6d 2f f6 de f5 a5 83 f6 26 40 04 04 3b 75 92 ba b6 23 9f a2 c4 96 64 9d 4d 91 12 4f 22 67 e6 79 | m/......&@..;u...#....d.M..O"g.y |
00c0 | be 6b 5f cc 33 f4 90 e2 61 86 e2 61 86 7c bf 00 c1 b6 24 eb 30 24 67 ad ef fa ae b5 1e 13 80 9e | .k_.3...a..a.|....$.0$g......... |
00e0 | e7 ee f6 d6 5b 6f 85 b1 b1 31 bb 76 ed 9a 6d c6 af f9 a3 1f fd a8 2e 49 6f bc f1 46 69 33 ff ac | ....[o...1.v..m........Io..Fi3.. |
0100 | f7 ee dd 73 49 b1 5a ad ba 24 e7 a3 07 f4 26 e3 25 00 7a 3b b0 d7 6a b5 90 24 49 71 7e 7e 7e 20 | ...sI.Z..$....&.%.z;..j..$Iq~~~. |
0120 | 49 92 e2 c0 c0 40 68 34 1a cf fc b5 fb 8f ff f8 8f b7 24 e9 a7 3f fd e9 a9 cd fa fb 64 4d 8d 4a | I....@h4..........$..?......dM.J |
0140 | a5 b2 90 65 59 a3 5c 2e 47 12 05 80 04 00 20 c8 b7 05 f9 4e 02 7b 92 24 56 af d7 8b 92 46 0a 85 | ...eY.\.G..........N.{.$V....F.. |
0160 | c2 68 9a a6 23 66 56 34 b3 67 fa da fd a7 7f fa a7 ff b7 fd bf ff f5 5f ff f5 7f 6f c2 df d3 93 | .h..#fV4.g............._...o.... |
0180 | 24 69 48 9a 4e d3 74 b2 5c 2e 4f bb 7b 23 cb 32 ef 36 51 20 39 00 48 00 80 5d 19 e4 bb 08 ec 41 | $iH.N.t.\.O.{#.2.6Q.9.H..].....A |
01a0 | 52 59 d2 21 77 3f 2e 69 34 ff ef f0 2c 7f de 1f ff f8 c7 ff 67 fb 7f ff e4 27 3f f9 7f 36 e1 65 | RY.!w?.i4...,.......g....'?..6.e |
01c0 | 88 66 56 73 f7 49 33 bb 2b 69 42 52 4d 52 ec 26 51 20 39 00 48 00 80 be 08 f6 1b 0c f2 9d 06 76 | .fVs.I3.+iBRMR.&Q.9.H..........v |
01e0 | 93 54 32 b3 e1 fc e7 8e 48 2a 3e cb d7 ee 8f 7f fc e3 15 4b fe 3f f9 c9 4f 6e 3d eb 4b 63 66 0d | .T2.....H*>........K.?..On=.Kcf. |
0200 | 49 d3 ee 3e 29 69 5a 52 7d 85 20 bd 6a a2 b0 d1 e4 80 a4 00 20 01 00 b6 35 d8 27 49 92 64 59 56 | I..>)iZR}...j...........5.'I.dYV |
0220 | da 40 90 ef 26 b0 27 92 8a ee 3e 90 ff da 72 f7 0d 07 ba 1f ff f8 c7 83 ab 24 00 4f 9e e5 bd c4 | .@..&.'...>...r..........$.O.... |
0240 | cc cc dd e5 ee 0d 33 5b 90 d4 c8 4f ff de 45 a2 d0 55 72 90 a6 69 9d a4 00 20 01 00 36 2d e0 3f | ......3[...O..E..Ur..i......6-.? |
0260 | 7a f4 28 74 18 ec cb 66 36 b0 c1 20 df 4d 60 b7 d6 f5 80 bb 37 24 d5 f2 7f 46 33 eb 38 b8 fd f8 | z.(t...f6....M`.....7$...F3.8... |
0280 | c7 3f 3e 29 49 bf fc e5 2f f5 d7 7f fd d7 ad bf b3 5a 37 0f 3f f9 c9 4f 6e 6f e0 65 0b 92 4a 92 | .?>)I.../........Z7.?..Ono.e..J. |
02a0 | ca 66 56 cc 7f cd 35 ff 1e 6b 24 0a 5d 25 07 ee be 90 24 49 ad 93 a4 80 84 00 58 aa c0 4b 00 02 | .fV...5..k$.]%....$I......X..K.. |
02c0 | fe 57 01 ff 67 3f fb 59 71 7e 7e 7e a0 5c 2e 97 cc ac 9c 65 d9 48 b9 5c 3e 94 a6 e9 48 8c b1 1c | .W..g?.Yq~~~.\.....e.H.\>...H... |
02e0 | 42 18 90 74 28 cb b2 e3 66 36 2a 69 c0 dd cb 66 36 62 66 2b 06 79 77 5f 2b c8 5b 08 a1 a3 c0 1e | B..t(...f6*i...f6bf+.yw_+.[..... |
0300 | 63 5c 12 1c cd 6c 5a 52 23 ff f5 3a f5 c3 75 5e 8f 5f 77 7b ec 77 f7 a2 a4 11 33 1b 8d 31 8e 48 | c\...lZR#..:..u^._w{.w....3..1.H |
0320 | 5a ad 49 31 48 2a e5 af 57 d1 cc 8a ee 5e 68 7f 2d da 92 83 23 2b 25 07 92 1a 66 d6 9e 1c d4 62 | Z.I1H*..W....^h.-...#+%...f....b |
0340 | 8c f3 ee 3e 19 42 b8 db 68 34 26 dc 7d a1 50 28 d4 0a 85 c2 74 bd 5e 9f 2c 14 0a 53 f5 7a bd b6 | ...>.B..h4&.}.P(....t.^.,..S.z.. |
0360 | 6f df be 7a a5 52 59 f8 e9 4f 7f 4a 42 00 50 01 00 27 fc 64 31 e0 4b 2a bb fb 88 99 1d 4a d3 f4 | o..z.RY..O.JB.P..'.d1.K*.....J.. |
0380 | 80 99 ed 33 b3 c3 6d 27 fb 81 fc 94 3b b2 ec 44 5f 58 e7 24 bf e6 e9 dd dd 3b 0a ec 66 16 dd bd | ...3..m'....;..D_X.$.....;..f... |
03a0 | 26 69 c2 cc ee 9a d9 a4 56 68 b2 5b cd 3f fd d3 3f fd df 92 74 f1 e2 45 49 d2 9b 6f be b9 58 01 | &i......Vh.[.?..?...t..EI..o..X. |
03c0 | c8 7f 7d 49 d2 bf fe eb bf fe 5f dd 9c fe b3 2c 2b 87 10 46 f3 d7 e9 90 99 95 dd 3d ac 95 28 b4 | ..}I......_....,+..F.......=..(. |
03e0 | 5e bb b6 44 61 bd 2a c2 8a 95 03 33 4b f3 24 61 49 52 60 66 f3 ad 4a 81 bb 3f 74 f7 d9 10 c2 54 | ^..Da.*....3K.$aIR`f..J..?t....T |
0400 | 8c 71 a2 50 28 4c 49 aa d5 6a b5 3a 15 02 50 01 00 f6 40 d0 97 94 fc ec 67 3f 2b ad 72 c2 5f 0c | .q.P(LI..j.:..P...@.....g?+.r._. |
0420 | f8 31 c6 e3 66 76 48 d2 b0 a4 fd cb 4e f6 85 15 4e f4 5f 45 a8 66 40 7f 2a c8 af 75 7a 5f 2d b0 | .1..fvH.....N...N._E.f@.*..uz_-. |
0440 | 9b d9 53 dd f3 21 84 7a 8c 71 26 cb b2 89 62 b1 38 ed ee 8d 34 4d 37 35 58 a5 69 fa ff 75 fc 06 | ..S..!.z.q&...b.8...4M75X.i..u.. |
0460 | 52 28 58 9a a6 c5 24 49 46 0a 85 c2 a8 a4 11 77 2f b5 aa 1a ed 89 42 5e 41 79 2a 51 e8 a0 8a b0 | R(X...$IF......w/.....B^Ay*Q.... |
0480 | 52 e5 a0 95 24 58 fe d2 1c 59 9e 14 e4 af f1 84 a4 29 33 9b 71 f7 89 10 c2 dd 2c cb 1e ba fb 6c | R...$X...Y.......)3.q.....,....l |
04a0 | b1 58 9c aa d7 eb 13 2b 55 08 26 27 27 33 92 01 50 01 00 76 c1 29 3f cb b2 4a 08 61 30 c6 78 60 | .X.....+U.&''3..P..v.)?..J.a0.x` |
04c0 | 95 13 fe 21 49 c3 66 b6 3f ff f7 91 18 e3 80 99 95 56 0a f6 5f 1d 6a bf 0a f6 66 96 a9 79 5f dd | ...!I.f.?........V.._.j...f..y_. |
04e0 | 71 90 57 de dc 66 66 f5 18 e3 4c 8c 71 cd c0 5e 2a 95 32 77 6f 0c 0d 0d 2d dc ba 75 ab 21 29 1e | q.W..ff...L.q..^*.2wo...-..u.!). |
0500 | 3b 76 6c dd 00 d5 da fa 57 ad 56 f5 57 7f f5 57 92 b4 a4 07 a0 ed 2f 25 a9 bb ed 80 f7 ee dd 4b | ;vl.....W.V.W..W....../%.......K |
0520 | 4e 9d 3a 55 9c 9b 9b 1b c8 83 f3 53 fb 0c 0a 85 82 d5 6a b5 a7 12 85 56 b3 e4 6a 55 84 95 2a 07 | N.:U.......S......j....V..jU..*. |
0540 | 66 56 5a a5 62 d0 fe be e6 6d 95 82 7a fe cf 69 35 fb 06 a6 24 cd b4 3e 16 ed 15 02 33 7b 98 65 | fVZ.b....m..z..i5...$..>....3{.e |
0560 | d9 54 92 24 73 49 92 cc 53 1d 00 09 00 d0 47 a7 fc f1 f1 f1 52 7b 59 3f 4d d3 fd 92 0e 4b 1a 33 | .T.$sI..S.....G.....R{Y?M....K.3 |
0580 | b3 a3 92 4e 74 12 f0 db bf 3e 3a 0c f6 35 77 5f d8 48 90 ef 26 b0 6f 30 18 79 37 09 40 97 ef 0d | ...Nt....>:..5w_.H..&.o0.y7.@... |
05a0 | 56 ad 56 4d 52 38 76 ec 98 75 9b 28 6c 20 39 18 70 f7 f2 7a 49 41 5e 1d 68 2f a0 ac 9b 10 48 ba | V.VMR8v..u.(l.9.p..zIA^.h/....H. |
05c0 | e3 ee f7 93 24 19 cf b2 ec e1 4a d7 05 54 07 40 02 00 f4 58 d0 5f eb 94 2f e9 84 bb 1f cd 93 80 | ....$.....J..T.@...X._../....... |
05e0 | c3 dd 04 fc 3c d0 d7 dc 7d 3a 0f ee 2b 06 fb 18 e3 42 fe f3 a7 37 12 e4 b7 f0 94 e9 f9 a9 5e 92 | ....<...}:..+....B...7........^. |
0600 | f4 ee bb ef 4a 7a ba 07 e0 da b5 6b 92 a4 6f 7e f3 9b 5b f5 fe b0 6a a2 d0 4d 72 20 a9 9c 7f ac | ....Jz.....k..o~..[...j..Mr..... |
0620 | 57 4d 0a 24 ed 6f 4b 04 06 3a 4d 08 dc fd a1 a4 71 33 bb 9f 27 03 6b 56 07 48 06 40 02 00 f4 40 | WM.$.oK..:M.....q3..'.kV.H.@...@ |
0640 | d0 cf b2 6c 6c b5 53 be bb 1f 36 b3 fd 31 c6 21 49 95 2e 03 fe 63 49 b3 ee fe 70 bd 60 1f 42 48 | ...ll.S...6..1.!I....cI...p.`.BH |
0660 | 77 28 c8 f7 43 02 b0 29 c9 c1 dc dc 5c 21 84 b0 66 52 90 27 79 fb f2 44 e0 50 a7 09 81 a4 79 33 | w(..C..)....\!..fR.'y..D.P....y3 |
0680 | 7b 22 e9 b1 99 3d 5c ad 3a 20 69 9c 64 00 24 00 40 8f 04 7d 33 3b d9 c1 29 3f b4 05 c5 7a 27 01 | {"...=\.:.i.d.$.@..}3;..)?...z'. |
06a0 | df dd 27 f2 26 b2 a9 b5 82 fd b1 63 c7 b2 1d 0c f2 6b 06 ff 6a b5 ba f8 1d 6b 5d 01 48 d2 95 2b | ..'.&......c.....k..j....k].H..+ |
06c0 | 57 16 7f ac 47 de 23 9e 4a 0e d6 4a 0a 42 08 87 f2 a4 6f 38 6f e0 ec 34 21 68 7d 6e c4 f5 aa 03 | W...G.#.J..J.B....o8o..4!h}n.... |
06e0 | ee 7e 9b 64 00 24 00 40 6f 05 fd 03 1d 9c f2 17 dc fd 89 a4 c7 9d 04 fc 2c cb a6 87 87 87 17 1a | .~.d.$.@o...............,....... |
0700 | 8d 46 bd c7 83 fd 6e 4d 00 ba 4e 0a d2 34 2d a5 69 3a d0 49 42 d0 aa 0e 49 1a 6c 7d de ac 57 1d | .F....nM..N..4-.i:.IB...I.l}..W. |
0720 | 90 34 4e 32 00 12 00 60 13 55 ab d5 70 ec d8 b1 24 4d d3 f2 33 04 fd 55 4f f9 6a 8e 84 3d 74 f7 | .4N2...`.U..p...$M..3..UO.j..=t. |
0740 | 71 49 ad 7b de 8e 02 7e 1f 76 82 bb f4 d5 dc ff 9f fd d9 9f 49 5a ff 0a e0 fc f9 f3 ad 84 a9 df | qI.{...~.v..........IZ.......... |
0760 | de 27 96 24 05 9d 26 04 6a 5e 17 1d 75 f7 d6 e7 d3 ba d5 81 8d 24 03 e3 e3 e3 75 49 29 89 00 7a | .'.$..&.j^..u........$....uI)..z |
0780 | 05 7b 00 d0 53 a7 fd eb d7 af 97 eb f5 fa 70 a3 d1 38 94 24 c9 91 46 a3 71 c4 cc 8e 86 10 16 83 | .{..S.........p..8.$..F.q....... |
07a0 | be a4 c3 66 76 20 c6 38 e4 ee 95 7c 44 af 3d e8 d7 d6 3a e5 bb fb 9d 10 c2 7d 77 1f cf b2 ec 61 | ...fv..8...|D.=...:......}w....a |
07c0 | 7b c0 1f 19 19 59 b8 75 eb 56 63 ff fe fd d9 e4 e4 a4 4f 4e 4e 72 72 eb a3 4f a5 fc 63 d5 da 9f | {....Y.u.Vc.......ONNrr..O..c... |
07e0 | 90 56 ab d5 ba a4 f9 b6 84 e0 cb b9 b9 b9 db ed 09 41 92 24 87 cd 6c cc dd 8f ba fb 89 56 75 c0 | .V...............A.$..l......Vu. |
0800 | dd f7 bb 7b 2b 21 18 6c 4b 30 cb f9 b7 11 77 3f 24 e9 b8 99 3d 71 f7 c7 79 22 30 ee ee f7 dd fd | ...{+!.lK0....w?$...=q..y"0..... |
0820 | b6 a4 fb ee fe 65 8c f1 cb 91 91 91 c9 42 a1 30 f3 d3 9f fe b4 46 55 00 54 00 c0 69 bf ed b4 9f | .....e.......B.0.....FU.T..i.... |
0840 | 65 d9 50 8c f1 60 08 e1 78 08 e1 ac a4 b3 79 97 77 a7 27 fd c5 a0 1f 42 18 5f ed 94 2f e9 61 9a | e.P..`..x.....y.w.'....B._../.a. |
0860 | a6 53 fb f6 ed 9b 2b 95 4a f3 7d 7c c2 ef e8 f4 7f fc f8 f1 25 3f d0 c9 15 80 24 1d 3f 7e 7c a7 | .S....+.J.}|........%?....$.?~|. |
0880 | 1a 02 b7 b5 42 50 af d7 2b 0b 0b 0b 83 92 0e e4 c9 e5 5a d5 81 03 5a 7a 55 b0 6e 65 40 d2 3d 49 | ....BP..+.........Z...ZzU.ne@.=I |
08a0 | 37 24 dd 08 21 dc c9 b2 ec 11 55 01 50 01 00 a7 fd b6 d3 be a4
| 7$..!.....U.P........#.B.X.....1 |
08c0 | c6 13 66 76 d0 dd 3b 3a e9 87 10 5a 6f b8 f7 63 8c b7 57 3b e5 0f 0d 0d 2d cc cd cd d5 1f 3c 78 | ..fv..;:...Zo..c..W;....-.....<x |
08e0 | c0 29 8c 0a 41 5d d2 fc e8 e8 e8 d4 d0 d0 d0 c4 dc dc dc 9d d5 aa 03 92 4e b6 27 03 ee 7e 60 bd | .)..A]..................N.'..~`. |
0900 | ca 40 08 61 ce dd 1f 49 ba 6b 66 d7 dd fd 86 a4 7b 54 05 40 05 00 9c f6 57 3e ed 1f 71 f7 43 f9 | .@.a...I.kf.....{T.@....W>..q.C. |
0920 | 29 ac dc e9 49 df dd 97 04 fd 18 e3 e3 5d 7e ca 5f f3 f4 ff 83 1f fc 40 d2 57 77 fa dd f6 00 b4 | )...I........]~._......@.Ww..... |
0940 | 2a 01 7d d0 10 b8 2d d5 01 33 1b 33 b3 b1 18 e3 51 33 3b d9 69 65 40 52 dd dd 67 cc 6c c2 dd bf | *.}...-..3.3....Q3;.ie@R..g.l... |
0960 | 34 b3 2f a9 0a 80 0a 00 f6 44 e0 97 54 a8 54 2a dd 9e f6 4b f9 69 3f e6 41 7f 7e bd 93 7e 8c f1 | 4./......D..T.T*...K.i?.A.~..~.. |
0980 | 61 9a a6 8b 41 9f 53 3e 36 b3 3a 50 af d7 ef b6 5d 15 8c 75 52 19 50 73 33 61 25 5f 6d 3c 22 e9 | a...A.S>6.:P....]..uR.Ps3a%_m<". |
09a0 | a8 99 ad 5b 15 68 34 1a d3 d5 6a b5 46 22 00 2a 00 e8 eb c0 3f 38 38 38 9c 65 d9 e1 fc d4 74 ae | ...[.h4...j.F".*....?888.e....t. |
09c0 | 93 d3 7e be 3b bf 2e 69 b6 75 72 92 f4 e5 7a 27 fd b9 b9 b9 fa 1e 2f a5 2e 9e fe 5b 27 f9 67 e9 | ..~.;..i.ur...z'....../....['.g. |
09e0 | 01 90 a4 bb 77 ef ee 95 2a c0 ba d5 81 d1 d1 d1 64 68 68 a8 b4 5e 65 40 d2 91 fc 01 45 a3 6a 2e | ....w...*.......dhh..^e@....E.j. |
0a00 | a3 2a 75 5a 15 08 21 5c 97 74 3b 4d d3 87 8d 46 63 7a 7e 7e 9e 44 00 54 00 d0 e3 91 67 d9 fd 7e | .*uZ..!\.t;M...Fcz~~.D.T....g..~ |
0a20 | 2b f0 c7 18 4f 4a fa 9a a4 af 4b fa 5a 87 a7 fd 39 33 7b 24 e9 6e 8c f1 46 fe c6 78 97 93 3e 76 | +...OJ....K.Z...93{$.n..F..x..>v |
0a40 | b8 3a 90 55 ab d5 46 07 95 81 63 66 76 56 d2 59 35 d7 50 1f ec b4 2a 10 63 fc dc cc fe 14 42 b8 | .:.U..F...cfvV.Y5.P...*.c.....B. |
0a60 | 5e a9 54 6e 15 8b c5 87 f4 09 80 0a 00 7a f6 b4 bf da fd be 99 9d 33 b3 af e7 09 c0 49 77 1f eb | ^.Tn.........z........3.....Iw.. |
0a80 | f4 b4 ef ee f7 42 08 37 b2 2c bb 51 2a 95 ee b8 fb a3 42 a1 c0 49 7f 9d d3 7f 6b ee 7f f9 9d 7e | .....B.7.,.Q
local bcn = core.get_node_or_nil(bcp)
-- Delete on contact with ignore at world edges
if bcn and bcn.name == "ignore" then
self.object:remove()
return
end
local bcd = bcn and core.registered_nodes[bcn.name]
if bcn and
(not bcd or bcd.walkable or
(core.get_item_group(self.node.name, "float") ~= 0 and
bcd.liquidtype ~= "none")) then
if bcd and bcd.leveled and
bcn.name == self.node.name then
local addlevel = self.node.level
if not addlevel or addlevel <= 0 then
addlevel = bcd.leveled
end
if core.add_node_level(bcp, addlevel) == 0 then
self.object:remove()
return
end
elseif bcd and bcd.buildable_to and
(core.get_item_group(self.node.name, "float") == 0 or
bcd.liquidtype == "none") then
core.remove_node(bcp)
return
end
local np = {x = bcp.x, y = bcp.y + 1, z = bcp.z}
-- Check what's here
local n2 = core.get_node(np)
local nd = core.registered_nodes[n2.name]
-- If it's not air or liquid, remove node and replace it with
-- it's drops
if n2.name ~= "air" and (not nd or nd.liquidtype == "none") then
core.remove_node(np)
if nd and nd.buildable_to == false then
-- Add dropped items
local drops = core.get_node_drops(n2, "")
for _, dropped_item in pairs(drops) do
core.add_item(np, dropped_item)
end
end
-- Run script hook
for _, callback in pairs(core.registered_on_dignodes) do
callback(np, n2)
end
end
-- Create node and remove entity
local def = core.registered_nodes[self.node.name]
if def then
core.add_node(np, self.node)
if self.meta then
local meta = core.get_meta(np)
meta:from_table(self.meta)
end
if def.sounds and def.sounds.place then
core.sound_play(def.sounds.place, {pos = np})
end
end
self.object:remove()
core.check_for_falling(np)
return
end
local vel = self.object:get_velocity()
if vector.equals(vel, {x = 0, y = 0, z = 0}) then
local npos = self.object:get_pos()
self.object:set_pos(vector.round(npos))
end
end
})
local function convert_to_falling_node(pos, node)
local obj = core.add_entity(pos, "__builtin:falling_node")
if not obj then
return false
end
node.level = core.get_node_level(pos)
local meta = core.get_meta(pos)
local metatable = meta and meta:to_table() or {}
local def = core.registered_nodes[node.name]
if def and def.sounds and def.sounds.fall then
core.sound_play(def.sounds.fall, {pos = pos})
end
obj:get_luaentity():set_node(node, metatable)
core.remove_node(pos)
return true
end
function core.spawn_falling_node(pos)
local node = core.get_node(pos)
if node.name == "air" or node.name == "ignore" then
return false
end
return convert_to_falling_node(pos, node)
end
local function drop_attached_node(p)
local n = core.get_node(p)
local drops = core.get_node_drops(n, "")
local def = core.registered_items[n.name]
if def and def.preserve_metadata then
local oldmeta = core.get_meta(p):to_table().fields
-- Copy pos and node because the callback can modify them.
local pos_copy = {x=p.x, y=p.y, z=p.z}
local node_copy = {name=n.name, param1=n.param1, param2=n.param2}
local drop_stacks = {}
for k, v in pairs(drops) do
drop_stacks[k] = ItemStack(v)
end
drops = drop_stacks
def.preserve_metadata(pos_copy, node_copy, oldmeta, drops)
end
if def and def.sounds and def.sounds.fall then
core.sound_play(def.sounds.fall, {pos = p})
end
core.remove_node(p)
for _, item in pairs(drops) do
local pos = {
x = p.x + math.random()/2 - 0.25,
y = p.y + math.random()/2 - 0.25,
z = p.z + math.random()/2 - 0.25,
}
core.add_item(pos, item)
end
end
function builtin_shared.check_attached_node(p, n)
local def = core.registered_nodes[n.name]
local d = {x = 0, y = 0, z = 0}
if def.paramtype2 == "wallmounted" or
def.paramtype2 == "colorwallmounted" then
-- The fallback vector here is in case 'wallmounted to dir' is nil due
-- to voxelmanip placing a wallmounted node without resetting a
-- pre-existing param2 value that is out-of-range for wallmounted.
-- The fallback vector corresponds to param2 = 0.
d = core.wallmounted_to_dir(n.param2) or {x = 0, y = 1, z = 0}
else
d.y = -1
end
local p2 = vector.add(p, d)
local nn = core.get_node(p2).name
local def2 = core.registered_nodes[nn]
if def2 and not def2.walkable then
return false
end
return true
end
--
-- Some common functions
--
function core.check_single_for_falling(p)
local n = core.get_node(p)
if core.get_item_group(n.name, "falling_node") ~= 0 then
local p_bottom = {x = p.x, y = p.y - 1, z = p.z}
-- Only spawn falling node if node below is loaded
local n_bottom = core.get_node_or_nil(p_bottom)
local d_bottom = n_bottom and core.registered_nodes[n_bottom.name]
if d_bottom and
(core.get_item_group(n.name, "float") == 0 or
d_bottom.liquidtype == "none") and
(n.name ~= n_bottom.name or (d_bottom.leveled and
core.get_node_level(p_bottom) <
core.get_node_max_level(p_bottom))) and
(not d_bottom.walkable or d_bottom.buildable_to) then
convert_to_falling_node(p, n)
return true
end
end
if core.get_item_group(n.name, "attached_node") ~= 0 then
if not builtin_shared.check_attached_node(p, n) then
drop_attached_node(p)
return true
end
end
return false
end
-- This table is specifically ordered.
-- We don't walk diagonals, only our direct neighbors, and self.
-- Down first as likely case, but always before self. The same with sides.
-- Up must come last, so that things above self will also fall all at once.
local check_for_falling_neighbors = {
{x = -1, y = -1, z = 0},
{x = 1, y = -1, z = 0},
{x = 0, y = -1, z = -1},
{x = 0, y = -1, z = 1},
{x = 0, y = -1, z = 0},
{x = -1, y = 0, z = 0},
{x = 1, y = 0, z = 0},
{x = 0, y = 0, z = 1},
{x = 0, y = 0, z = -1},
{x = 0, y = 0, z = 0},
{x = 0, y = 1, z = 0},
}
function core.check_for_falling(p)
-- Round p to prevent falling entities to get stuck.
p = vector.round(p)
-- We make a stack, and manually maintain size for performance.
-- Stored in the stack, we will maintain tables with pos, and
-- last neighbor visited. This way, when we get back to each
-- node, we know which directions we have already walked, and
-- which direction is the next to walk.
local s = {}
local n = 0
-- The neighbor order we will visit from our table.
local v = 1
while true do
-- Push current pos onto the stack.
n = n + 1
s[n] = {p = p, v = v}
-- Select next node from neighbor list.
p = vector.add(p, check_for_falling_neighbors[v])
-- Now we check out the node. If it is in need of an update,
-- it will let us know in the return value (true = updated).
if not core.check_single_for_falling(p) then
-- If we don't need to "recurse" (walk) to it then pop
-- our previous pos off the stack and continue from there,
-- with the v value we were at when we last were at that
-- node
repeat
local pop = s[n]
p = pop.p
v = pop.v
s[n] = nil
n = n - 1
-- If there's nothing left on the stack, and no
-- more sides to walk to, we're done and can exit
if n == 0 and v == 11 then
return
end
until v < 11
-- The next round walk the next neighbor in list.
v = v + 1
else
-- If we did need to walk the neighbor, then
-- start walking it from the walk order start (1),
-- and not the order we just pushed up the stack.
v = 1
end
end
end
--
-- Global callbacks
--
local function on_placenode(p, node)
core.check_for_falling(p)
end
core.register_on_placenode(on_placenode)
local function on_dignode(p, node)
core.check_for_falling(p)
end
core.register_on_dignode(on_dignode)
local function on_punchnode(p, node)
core.check_for_falling(p)
end
core.register_on_punchnode(on_punchnode)
|