Merge branch 'main' into animation

This commit is contained in:
MihailRis 2026-08-14 19:46:37 +03:00
commit 49e7f2c631
89 changed files with 1050 additions and 687 deletions

View file

@ -86,12 +86,27 @@ function generate_heightmap(x, y, w, h, s, inputs)
local rivermap = Heightmap(w, h)
rivermap.noiseSeed = SEED
rivermap:noise({x+21, y+12}, 0.1*s, 4)
rivermap:abs()
rivermap:mul(2.0)
rivermap:pow(0.15)
rivermap:max(0.5)
map:mul(rivermap)
rivermap:noise({ x + 21, y + 12 }, 0.1 * s, 4)
rivermap:pow(4)
rivermap:mul(3500)
rivermap:add(1)
rivermap:pow(-1)
rivermap:mul(-1)
rivermap:add(1)
local rivermap_bottom = Heightmap(w, h)
rivermap_bottom:add(0.23)
rivermap_bottom:noise({ x, y }, 2 * s, 4, 0.005)
map:sub(rivermap_bottom)
local map_multiplied = Heightmap(w, h)
map_multiplied:add(map)
map_multiplied:mul(rivermap)
map:min(map_multiplied)
map:add(rivermap_bottom)
local desertmap = Heightmap(w, h)
desertmap.noiseSeed = SEED

View file

@ -1,5 +1,44 @@
local util = {}
local DROP_FORCE = 8
local DROP_INIT_VEL = {0, 3, 0}
---@param mode integer 0 - whole stack, 1 - single item, 2 - dupe whole stack
function util.drop_from_slot(invid, slot, mode)
if invid == 0 then
return
end
local pid = hud.get_player()
if mode == 2 and not player.is_infinite_items(pid) then
return
end
local itemid, itemcount = inventory.get(invid, slot)
if itemid == 0 then
return
end
local drop_itemcount = 1
if mode == 0 then
drop_itemcount = itemcount
end
if mode == 2 then
drop_itemcount = item.stack_size(itemid)
else
inventory.set(invid, slot, itemid, itemcount - drop_itemcount)
end
local data = inventory.get_all_data(invid, slot)
local pvel = { player.get_vel(pid) }
local ppos = vec3.add({ player.get_pos(pid) }, { 0, 0.7, 0 })
local throw_force = vec3.mul(player.get_dir(pid), DROP_FORCE)
local drop = util.drop(ppos, itemid, drop_itemcount, data, 1.5)
if not drop then
return
end
local velocity = vec3.add(throw_force, vec3.add(pvel, DROP_INIT_VEL))
drop.rigidbody:set_vel(velocity)
end
function util.drop(ppos, itemid, count, data, pickup_delay)
if itemid == 0 or not itemid then
return nil

View file

@ -1,30 +1,21 @@
local base_util = require "util"
local DROP_FORCE = 8
local DROP_INIT_VEL = {0, 3, 0}
function on_hud_open()
input.add_callback("player.drop", function ()
events.on("core:drop_outside_inventory", function(mode)
local invid = hud.get_exchange_inventory()
base_util.drop_from_slot(invid, 0, mode)
end)
input.add_callback("player.drop", function()
if hud.is_paused() or hud.is_inventory_open() then
return
end
local pid = hud.get_player()
local invid, slot = player.get_inventory(pid)
local itemid, itemcount = inventory.get(invid, slot)
if itemid == 0 then
return
local mode = 1
if input.is_pressed("key:left-ctrl") or input.is_pressed("key:right-ctrl") then
mode = 0
end
local data = inventory.get_all_data(invid, slot)
inventory.set(invid, slot, itemid, itemcount-1)
local pvel = {player.get_vel(pid)}
local ppos = vec3.add({player.get_pos(pid)}, {0, 0.7, 0})
local throw_force = vec3.mul(player.get_dir(pid), DROP_FORCE)
local drop = base_util.drop(ppos, itemid, 1, data, 1.5)
if not drop then
return
end
local velocity = vec3.add(throw_force, vec3.add(pvel, DROP_INIT_VEL))
drop.rigidbody:set_vel(velocity)
base_util.drop_from_slot(invid, slot, mode)
end)
rules.create("do-loot-non-player", true)
end

View file

@ -16,6 +16,4 @@ function on_block_broken(id, x, y, z, playerid)
spawn_spread=vec3.mul(size, 0.4)
})
end
rules.create("do-loot-non-player", true)
end

View file

@ -1,6 +1,6 @@
<container id='pack_%{id}' onclick='%{callback}' size='0,80' color='#00000040' hover-color='#00000080' position-func="%{position_func}" z-index="%{index}">
<label color='#FFFFFF80' size='300,25' align='right' gravity='top-right'>
[%{id_verbose}]
<label color='#FFFFFF80' size='340,25' align='right' gravity='top-right'>
[%{id_verbose} %{version}]
</label>
<label pos='78,6'>%{title}</label>
<label if='%{creator}' color='#CCFFE5B2' size='300,20' align='right'

View file

@ -192,13 +192,15 @@ function gui.ask(text, on_yes, on_no, yes_text, no_text)
<container id='%s' color='#00000080' size-func='-1,-1' z-index='10'>
<panel color='#507090E0' size='600' padding='16'
gravity='center-center' interval='4'>
<label margin='4'>%s</label>
<label margin='4' markup='md'>%s</label>
<button onclick='DATA.on_yes()'>@%s</button>
<button onclick='DATA.on_no()'>@%s</button>
</panel>
</container>
]], id, string.escape_xml(text)), {on_yes=yes_callback, on_no=no_callback},
string.escape_xml(yes_text), string.escape_xml(no_text))
]], id,
string.escape_xml(text),
string.escape_xml(yes_text),
string.escape_xml(no_text)), {on_yes=yes_callback, on_no=no_callback})
input.add_callback("key:escape", no_callback, gui.root[id])
end

View file

@ -1,6 +1,9 @@
#include <shadows>
#include <fog>
#define CLOUDS_FOG_FACTOR_MUL 0.3f
#define CLOUDS_FOG_CURVE_MUL 0.4f
vec4 effect() {
vec4 pos = texture(u_position, v_uv);
float light = 1.0;
@ -32,6 +35,10 @@ vec4 effect() {
light = pow(light, u_gamma);
vec3 fogColor = texture(u_skybox, dir).rgb;
float fog = calc_fog(length(u_view * vec4((modelpos.xyz - u_cameraPos) * FOG_POS_SCALE, 0.0)) / 256.0);
float fog = calc_fog(
length(u_view * vec4((modelpos.xyz - u_cameraPos) * FOG_POS_SCALE, 0.0)) / 256.0,
mix(1.0, CLOUDS_FOG_FACTOR_MUL, emission),
mix(1.0, CLOUDS_FOG_CURVE_MUL, emission)
);
return vec4(mix(texture(u_screen, v_uv).rgb * mix(1.0, light, 1.0), fogColor, fog), 1.0);
}

View file

@ -15,11 +15,33 @@ uniform float u_fogCurve;
uniform bool u_alphaClip;
uniform vec3 u_sunDir;
const float BAYER_MATRIX[64] = float[](
0.0, 32.0, 8.0, 40.0, 2.0, 34.0, 10.0, 42.0,
48.0, 16.0, 56.0, 24.0, 50.0, 18.0, 58.0, 26.0,
12.0, 44.0, 4.0, 36.0, 14.0, 46.0, 6.0, 38.0,
60.0, 28.0, 52.0, 20.0, 62.0, 30.0, 54.0, 22.0,
3.0, 35.0, 11.0, 43.0, 1.0, 33.0, 9.0, 41.0,
51.0, 19.0, 59.0, 27.0, 49.0, 17.0, 57.0, 25.0,
15.0, 47.0, 7.0, 39.0, 13.0, 45.0, 5.0, 37.0,
63.0, 31.0, 55.0, 23.0, 61.0, 29.0, 53.0, 21.0
);
float calc_bayer(vec2 pos){
ivec2 p = ivec2(mod(pos, 8.0));
return BAYER_MATRIX[p.y * 8 + p.x] / 64.0;
}
void main() {
vec4 texColor = texture(u_texture0, a_texCoord);
float alpha = a_color.a * texColor.a;
// anyway it's any alpha-test alternative required
if (alpha < (u_alphaClip ? 0.5f : 0.15f)) {
if (u_alphaClip) {
float bayer = calc_bayer(gl_FragCoord.xy);
if (alpha - bayer < 0.01f) {
discard;
}
alpha = 1.0;
} else if (alpha < 0.05f) {
discard;
}
f_color = a_color * texColor;

View file

@ -7,13 +7,17 @@ uniform float u_weatherFogOpacity;
uniform float u_weatherFogDencity;
uniform float u_weatherFogCurve;
float calc_fog(float depth) {
float calc_fog(float depth, float fogFactor, float fogCurve) {
return min(
1.0,
max(pow(depth * u_fogFactor, u_fogCurve),
max(pow(depth * u_fogFactor * fogFactor, u_fogCurve * fogCurve),
min(pow(depth * u_weatherFogDencity, u_weatherFogCurve),
u_weatherFogOpacity))
);
}
float calc_fog(float depth) {
return calc_fog(depth, 1.0, 1.0);
}
#endif // FOG_GLSL_