From 7590fea329299f009197911497aa7eab16ddb299 Mon Sep 17 00:00:00 2001 From: mckaygerhard Date: Wed, 24 Apr 2024 16:18:26 -0400 Subject: [PATCH] Fix Warning spam about use_texture_alpha * Previously the alpha value in the nodedef indicated the transparency the water was actually rendered with. Now only the alpha in the texture is respected. * Closes and fixes https://github.com/minetest/minetest_game/issues/2819 * Backported https://github.com/minetest/minetest_game/pull/2822 * this is the same as https://github.com/minetest/minetest_game/pull/2729 --- mods/beds/api.lua | 3 +++ mods/beds/beds.lua | 5 +++++ mods/default/legacy.lua | 4 +++- mods/default/nodes.lua | 17 +++++++++++++---- mods/default/torch.lua | 5 +++++ mods/doors/init.lua | 5 +++++ mods/floatland/init.lua | 3 ++- mods/flowers/init.lua | 2 ++ mods/mobs_jam/balrog.lua | 2 +- mods/stairs/init.lua | 3 +++ mods/xdecor/src/workbench.lua | 3 ++- mods/xpanes/init.lua | 4 ++++ 12 files changed, 48 insertions(+), 8 deletions(-) diff --git a/mods/beds/api.lua b/mods/beds/api.lua index 9349545..ddcc2ec 100644 --- a/mods/beds/api.lua +++ b/mods/beds/api.lua @@ -1,5 +1,6 @@ local reverse = true +local is_54 = minetest.has_feature("direct_velocity_on_players") or false local function destruct_bed(pos, n) local node = minetest.get_node(pos) @@ -29,6 +30,7 @@ function beds.register_bed(name, def) wield_image = def.wield_image, drawtype = "nodebox", tiles = def.tiles.bottom, + use_texture_alpha = (is_54 and "clip" or true), paramtype = "light", paramtype2 = "facedir", is_ground_content = false, @@ -149,6 +151,7 @@ function beds.register_bed(name, def) paramtype = "light", paramtype2 = "facedir", is_ground_content = false, + use_texture_alpha = (is_54 and "clip" or true), pointable = false, groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 3, bed = 2}, sounds = def.sounds or default.node_sound_wood_defaults(), diff --git a/mods/beds/beds.lua b/mods/beds/beds.lua index bb2fd5d..a5f6460 100644 --- a/mods/beds/beds.lua +++ b/mods/beds/beds.lua @@ -1,4 +1,7 @@ -- Fancy shaped bed +local is_54 = minetest.has_feature("direct_velocity_on_players") or false + +print("is 54 "..(is_54 and 'x' or 'nil')) beds.register_bed("beds:fancy_bed", { description = "Fancy Bed", @@ -22,6 +25,7 @@ beds.register_bed("beds:fancy_bed", { "default_wood.png", } }, + use_texture_alpha = (is_54 and "clip" or true), nodebox = { bottom = { {-0.5, -0.5, -0.5, -0.375, -0.065, -0.4375}, @@ -73,6 +77,7 @@ beds.register_bed("beds:bed", { "beds_transparent.png", } }, + use_texture_alpha = (is_54 and "clip" or true), nodebox = { bottom = {-0.5, -0.5, -0.5, 0.5, 0.06, 0.5}, top = {-0.5, -0.5, -0.5, 0.5, 0.06, 0.5}, diff --git a/mods/default/legacy.lua b/mods/default/legacy.lua index cb7918b..ef2f999 100644 --- a/mods/default/legacy.lua +++ b/mods/default/legacy.lua @@ -1,4 +1,5 @@ -- mods/default/legacy.lua +local is_54 = minetest.has_feature("direct_velocity_on_players") or false -- Horrible stuff to support old code registering falling nodes -- Don't use this and never do what this does, it's completely wrong! @@ -16,10 +17,11 @@ function default.spawn_falling_node(p, nodename) end -- Liquids -WATER_ALPHA = minetest.registered_nodes["default:water_source"].alpha +WATER_ALPHA = minetest.registered_nodes["default:water_source"].alpha or true WATER_VISC = minetest.registered_nodes["default:water_source"].liquid_viscosity LAVA_VISC = minetest.registered_nodes["default:lava_source"].liquid_viscosity LIGHT_MAX = default.LIGHT_MAX +if is_54 then WATER_ALPHA = minetest.registered_nodes["default:water_source"].use_texture_alpha or "opaque" end -- Formspecs default.gui_suvival_form = default.gui_survival_form diff --git a/mods/default/nodes.lua b/mods/default/nodes.lua index 0cf8f4f..b437ae9 100644 --- a/mods/default/nodes.lua +++ b/mods/default/nodes.lua @@ -208,6 +208,11 @@ default:cloud -- Stone -- +local is_54 = minetest.has_feature("direct_velocity_on_players") or false +local alpha_use_texture_alpha = true + +if is_54 then alpha_use_texture_alpha = "blend" end + minetest.register_node("default:stone", { description = "Stone", tiles = {"default_stone.png"}, @@ -1507,7 +1512,7 @@ minetest.register_node("default:water_source", { backface_culling = false, }, }, - alpha = 160, + use_texture_alpha = alpha_use_texture_alpha, paramtype = "light", walkable = false, pointable = false, @@ -1551,7 +1556,7 @@ minetest.register_node("default:water_flowing", { }, }, }, - alpha = 160, + use_texture_alpha = alpha_use_texture_alpha, paramtype = "light", paramtype2 = "flowingliquid", walkable = false, @@ -1598,7 +1603,7 @@ minetest.register_node("default:river_water_source", { backface_culling = false, }, }, - alpha = 160, + use_texture_alpha = alpha_use_texture_alpha, paramtype = "light", walkable = false, pointable = false, @@ -1644,7 +1649,7 @@ minetest.register_node("default:river_water_flowing", { }, }, }, - alpha = 160, + use_texture_alpha = alpha_use_texture_alpha, paramtype = "light", paramtype2 = "flowingliquid", walkable = false, @@ -2175,6 +2180,7 @@ local function register_sign(material, desc, def) sunlight_propagates = true, is_ground_content = false, walkable = false, + use_texture_alpha = (is_54 and "opaque" or true), node_box = { type = "wallmounted", wall_top = {-0.4375, 0.4375, -0.3125, 0.4375, 0.5, 0.3125}, @@ -2316,6 +2322,7 @@ minetest.register_node("default:glass", { description = "Glass", drawtype = "glasslike_framed_optional", tiles = {"default_glass.png", "default_glass_detail.png"}, + use_texture_alpha = (is_54 and "clip" or true), paramtype = "light", paramtype2 = "glasslikeliquidlevel", sunlight_propagates = true, @@ -2328,6 +2335,7 @@ minetest.register_node("default:obsidian_glass", { description = "Obsidian Glass", drawtype = "glasslike_framed_optional", tiles = {"default_obsidian_glass.png", "default_obsidian_glass_detail.png"}, + use_texture_alpha = (is_54 and "clip" or true), paramtype = "light", paramtype2 = "glasslikeliquidlevel", is_ground_content = false, @@ -2365,6 +2373,7 @@ minetest.register_node("default:mese_post_light", { tiles = {"default_mese_post_light_top.png", "default_mese_post_light_top.png", "default_mese_post_light_side_dark.png", "default_mese_post_light_side_dark.png", "default_mese_post_light_side.png", "default_mese_post_light_side.png"}, + use_texture_alpha = (is_54 and "clip" or true), wield_image = "default_mese_post_light_side.png", drawtype = "nodebox", node_box = { diff --git a/mods/default/torch.lua b/mods/default/torch.lua index a7b83cf..10fc922 100644 --- a/mods/default/torch.lua +++ b/mods/default/torch.lua @@ -35,6 +35,8 @@ See LICENSE.txt and http://www.gnu.org/licenses/lgpl-2.1.txt --]] +local is_54 = minetest.has_feature("direct_velocity_on_players") or false + minetest.register_node("default:torch", { description = "Torch", drawtype = "mesh", @@ -45,6 +47,7 @@ minetest.register_node("default:torch", { name = "default_torch_on_floor_animated.png", animation = {type = "vertical_frames", aspect_w = 16, aspect_h = 16, length = 3.3} }}, + use_texture_alpha = (is_54 and "clip" or true), paramtype = "light", paramtype2 = "wallmounted", sunlight_propagates = true, @@ -94,6 +97,7 @@ minetest.register_node("default:torch_wall", { name = "default_torch_on_floor_animated.png", animation = {type = "vertical_frames", aspect_w = 16, aspect_h = 16, length = 3.3} }}, + use_texture_alpha = (is_54 and "clip" or true), paramtype = "light", paramtype2 = "wallmounted", sunlight_propagates = true, @@ -115,6 +119,7 @@ minetest.register_node("default:torch_ceiling", { name = "default_torch_on_floor_animated.png", animation = {type = "vertical_frames", aspect_w = 16, aspect_h = 16, length = 3.3} }}, + use_texture_alpha = (is_54 and "clip" or true), paramtype = "light", paramtype2 = "wallmounted", sunlight_propagates = true, diff --git a/mods/doors/init.lua b/mods/doors/init.lua index 5945cc0..f80c753 100644 --- a/mods/doors/init.lua +++ b/mods/doors/init.lua @@ -1,3 +1,5 @@ +local is_54 = minetest.has_feature("direct_velocity_on_players") or false + -- our API object doors = {} @@ -87,6 +89,7 @@ minetest.register_node("doors:hidden", { buildable_to = false, floodable = false, drop = "", + use_texture_alpha = (is_54 and "clip" or true), groups = {not_in_creative_inventory = 1}, on_blast = function() end, tiles = {"doors_blank.png"}, @@ -423,6 +426,7 @@ function doors.register(name, def) def.paramtype = "light" def.paramtype2 = "facedir" def.sunlight_propagates = true + def.use_texture_alpha = def.use_texture_alpha or (is_54 and "clip" or true) def.walkable = true def.is_ground_content = false def.buildable_to = false @@ -564,6 +568,7 @@ function doors.register_trapdoor(name, def) def.drawtype = "nodebox" def.paramtype = "light" def.paramtype2 = "facedir" + def.use_texture_alpha = def.use_texture_alpha or (is_54 and "clip" or true) def.is_ground_content = false if def.protected then diff --git a/mods/floatland/init.lua b/mods/floatland/init.lua index 6451391..a0ce0f4 100644 --- a/mods/floatland/init.lua +++ b/mods/floatland/init.lua @@ -1,6 +1,7 @@ -- minetest.clear_registered_biomes() -- do not regenerate, we want to combine it! -- Get setting or default +local is_54 = minetest.has_feature("direct_velocity_on_players") or false local mgv7 = minetest.get_mapgen_setting("mg_name") or nil local mgv7_spflags = minetest.get_mapgen_setting("mgv7_spflags") or "mountains, ridges, floatlands, caverns" local captures_float = string.match(mgv7_spflags, "floatlands") @@ -70,7 +71,7 @@ minetest.register_node("floatland:sand_crystal_block", { paramtype = "light", paramtype2 = "glasslikeliquidlevel", param2 = 255, - use_texture_alpha = "blend", + use_texture_alpha = (is_54 and "blend" or true), sunlight_propagates = false, groups = {cracky = 2}, sounds = default.node_sound_glass_defaults(), diff --git a/mods/flowers/init.lua b/mods/flowers/init.lua index 00a82ee..aff37ce 100644 --- a/mods/flowers/init.lua +++ b/mods/flowers/init.lua @@ -6,6 +6,7 @@ flowers = {} +local is_54 = minetest.has_feature("direct_velocity_on_players") or false -- Map Generation @@ -271,6 +272,7 @@ minetest.register_node("flowers:waterlily", { tiles = {"flowers_waterlily.png", "flowers_waterlily_bottom.png"}, inventory_image = "flowers_waterlily.png", wield_image = "flowers_waterlily.png", + use_texture_alpha = (is_54 and "clip" or true), liquids_pointable = true, walkable = false, buildable_to = true, diff --git a/mods/mobs_jam/balrog.lua b/mods/mobs_jam/balrog.lua index c7418b5..0cadc45 100644 --- a/mods/mobs_jam/balrog.lua +++ b/mods/mobs_jam/balrog.lua @@ -376,4 +376,4 @@ mobs:register_egg("mobs_jam:balrog", mobs:alias_mob("mobs_balrog:balrog", "mobs_jam:balrog") -print("[Mod] Mobs Balrog (from mobs_jam) loaded.") +print("[Mod] Mobs JAM (Balrog) loaded.") diff --git a/mods/stairs/init.lua b/mods/stairs/init.lua index 788fa50..b027928 100644 --- a/mods/stairs/init.lua +++ b/mods/stairs/init.lua @@ -1,6 +1,7 @@ -- Minetest 0.4 mod: stairs -- See README.txt for licensing and other information. +local is_54 = minetest.has_feature("direct_velocity_on_players") or false -- Global namespace for functions @@ -70,6 +71,7 @@ function stairs.register_stair(subname, recipeitem, groups, images, description, paramtype = "light", paramtype2 = "facedir", is_ground_content = false, + use_texture_alpha = (is_54 and "clip" or true), groups = new_groups, sounds = sounds, selection_box = { @@ -147,6 +149,7 @@ function stairs.register_slab(subname, recipeitem, groups, images, description, paramtype = "light", paramtype2 = "facedir", is_ground_content = false, + use_texture_alpha = (is_54 and "clip" or true), groups = new_groups, sounds = sounds, node_box = { diff --git a/mods/xdecor/src/workbench.lua b/mods/xdecor/src/workbench.lua index 2f7ca25..083e9af 100644 --- a/mods/xdecor/src/workbench.lua +++ b/mods/xdecor/src/workbench.lua @@ -1,6 +1,7 @@ local workbench = {} local nodes = {} +local is_54 = minetest.has_feature("direct_velocity_on_players") or false screwdriver = screwdriver or {} local min, ceil = math.min, math.ceil local S = xdecor.S @@ -343,7 +344,7 @@ for i = 1, #nodes do drawtype = "nodebox", sounds = def.sounds, tiles = tiles, - use_texture_alpha = def.use_texture_alpha, + use_texture_alpha = def.use_texture_alpha or (is_54 and "clip" or true), groups = groups, -- `unpack` has been changed to `table.unpack` in newest Lua versions node_box = xdecor.pixelbox(16, {unpack(d, 3)}), diff --git a/mods/xpanes/init.lua b/mods/xpanes/init.lua index 40fddba..6b790bb 100644 --- a/mods/xpanes/init.lua +++ b/mods/xpanes/init.lua @@ -1,4 +1,6 @@ +local is_54 = minetest.has_feature("direct_velocity_on_players") or false + local function is_pane(pos) return minetest.get_item_group(minetest.get_node(pos).name, "pane") > 0 end @@ -104,6 +106,7 @@ function xpanes.register_pane(name, def) groups = flatgroups, drop = "xpanes:" .. name .. "_flat", sounds = def.sounds, + use_texture_alpha = def.use_texture_alpha or (is_54 and "opaque" or false), node_box = { type = "fixed", fixed = {{-1/2, -1/2, -1/32, 1/2, 1/2, 1/32}}, @@ -128,6 +131,7 @@ function xpanes.register_pane(name, def) groups = groups, drop = "xpanes:" .. name .. "_flat", sounds = def.sounds, + use_texture_alpha = def.use_texture_alpha or (is_54 and "opaque" or false), node_box = { type = "connected", fixed = {{-1/32, -1/2, -1/32, 1/32, 1/2, 1/32}},