From 854e10f087783ba12a6d9c6c780230c24c45862a Mon Sep 17 00:00:00 2001 From: sys4-fr Date: Tue, 20 Nov 2018 19:38:26 +0100 Subject: [PATCH] Plusieurs modifications MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Suppression du biome snow_sand - Suppression de plusieurs ABMS pour gagner en performance - Suppression de code obsolète - Suppression de la mapgen V6 - Génération des sapins à base de schematics --- schematics/pine.mts | Bin 172 -> 0 bytes schematics/pine_from_sapling.mts | Bin 170 -> 0 bytes schematics/snow_pine.mts | Bin 0 -> 170 bytes schematics/snow_pine_from_sapling.mts | Bin 0 -> 167 bytes schematics/snow_xmas_from_sapling.mts | Bin 0 -> 197 bytes schematics/snowy_snow_pine_from_sapling.mts | Bin 0 -> 201 bytes schematics/snowy_snow_xmas_from_sapling.mts | Bin 0 -> 230 bytes src/abms.lua | 14 +- src/crafting.lua | 4 +- src/mapgen.lua | 10 +- src/mapgen_v7.lua | 10 +- src/nodes.lua | 159 ++++++++++++++------ src/snowball.lua | 8 +- 13 files changed, 137 insertions(+), 68 deletions(-) delete mode 100644 schematics/pine.mts delete mode 100644 schematics/pine_from_sapling.mts create mode 100644 schematics/snow_pine.mts create mode 100644 schematics/snow_pine_from_sapling.mts create mode 100644 schematics/snow_xmas_from_sapling.mts create mode 100644 schematics/snowy_snow_pine_from_sapling.mts create mode 100644 schematics/snowy_snow_xmas_from_sapling.mts diff --git a/schematics/pine.mts b/schematics/pine.mts deleted file mode 100644 index 0f966ffb08a71199cac1d1cbda631e43e5d94559..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 172 zcmV;d08{@>R8vg=1ONp94gduV3=9Gcb7l-?41a%re*gmj17T@$01R_(Z+ALwWo2Y+ zWpe-#WMyVyb!>DxaA|I3UvzS1Wq6#;QUMA8AqaDR{GNVCAm&{Q?1E~7jD=%pA_VYi z)zx5G^7(jX5XPV%R=m_5`DxaA|I3UvzS1Wq6$JQqc+kAqaE+`2BhW;#n=Qj_Y1-f{cY@Xd(pg z8r9QaS@QXKW)Q}p9jjjIj&n^+lLallX7YWxmrRxe|KDxaA|I3UvzS1Wq6$Jl2Ho4APhsJ7w^&C%A|8^gpLmPvnNQ55<(Fm z6kFb14eJu`$2%9I81<$!t6JjRL-+8&8*d~1zMM;>%hLZMiphKm%^Q-%wv*O3k){tX Y3cCVT$I<8Iy7-jLTz=kX1E#ev4MQqNw*UYD literal 0 HcmV?d00001 diff --git a/schematics/snow_pine_from_sapling.mts b/schematics/snow_pine_from_sapling.mts new file mode 100644 index 0000000000000000000000000000000000000000..9b74de96f7b6e27d12f18ed40781d18a3d646310 GIT binary patch literal 167 zcmV;Y09gM`R8vg=1ONp94gdvze?J000&@a$26=yfe*gmj17T@$01R_(Z+ALwWo2Y+ zWpe-#WMyVyb!>DxaA|I3UvzS1Wq6$JQb7v9APlR1yieaKNY>2=l@7fap~Of+D2fmi zoL*fG)+OGLcP@l6)DN?)io~%dO_K@Dzef7)+)Jd((*L3c(0mHbbIFR~+%_(F)wAX$ V?76=4a$WkA%w7)u#|=x6DUBf&MsffE literal 0 HcmV?d00001 diff --git a/schematics/snow_xmas_from_sapling.mts b/schematics/snow_xmas_from_sapling.mts new file mode 100644 index 0000000000000000000000000000000000000000..eb305390e4ad0a08359c522faf2be2bd002b7f79 GIT binary patch literal 197 zcmeYb3HD`RVPIw8XJDkCpfGb{W)Xu}abAA8RbFapN=|BVd`fC^ zeomznQG8BjNyVJElLEO8DDXJ1wyx-3 zC!(S))t+qh*TAV$P;Q}ylSsj>lDQG9KQ7x-tMD#zW06~L!gpiMnR`zB(ax?ajefUr v^~A95e^X~As4vvG@=$cK+YJwf73HiBcWPCiaITHI@;p}d?+TvRR$BZ3K4VSQ literal 0 HcmV?d00001 diff --git a/schematics/snowy_snow_pine_from_sapling.mts b/schematics/snowy_snow_pine_from_sapling.mts new file mode 100644 index 0000000000000000000000000000000000000000..11d0842e91e3b333f8cd6f4b876a84b7cdf63647 GIT binary patch literal 201 zcmeYb3HD`RVPIw8V_>bXw`a0vDrPEXtE{iD2Z}N$W)?B<6zAoaTjiyursSj+Gw`IO zrX`l!X3)QUN8Cq3jkpuo{mYIj5Kto!|fv))c_2AzLza3+e^ z#0mu}x#en<`@UNfFfG+Ce%?&xyHoeNx1Eb(5(X$Qn6sPsJ(EOZsP1)lOgf wzi8Rr6y1rY`5Kz~6QkCpdfQ%W)Xu}abAA8RbFapN=|BVd`fC^ zeo;~1_2#{`4w?a6Qiou=4E6J^VgQ5aU%3DP literal 0 HcmV?d00001 diff --git a/src/abms.lua b/src/abms.lua index 1e763c0..c92c870 100644 --- a/src/abms.lua +++ b/src/abms.lua @@ -1,6 +1,6 @@ -- Added to change dirt_with_snow to dirt if covered with blocks that don't let light through (sunlight_propagates) or have a light paramtype and liquidtype combination. ~ LazyJ, 2014_03_08 -minetest.register_abm({ +--[[minetest.register_abm({ nodenames = {"default:dirt_with_snow"}, interval = 2, chance = 20, @@ -17,7 +17,7 @@ minetest.register_abm({ end end }) - +]]-- --Melting @@ -76,6 +76,7 @@ minetest.register_abm({ --Freezing --Water freezes when in contact with snow. +--[[ minetest.register_abm({ nodenames = {"default:water_source"}, -- Added "group:icemaker" and snowbrick. ~ LazyJ @@ -120,7 +121,7 @@ minetest.register_abm({ end end, }) - +]]-- --Spread moss to cobble. @@ -138,7 +139,7 @@ minetest.register_abm({ - +--[[ --Grow Pine Saplings minetest.register_abm({ nodenames = {"snow:sapling_pine"}, @@ -171,7 +172,6 @@ minetest.register_abm({ - --Grow Christmas Tree Saplings minetest.register_abm({ nodenames = {"snow:xmas_tree"}, @@ -196,10 +196,11 @@ minetest.register_abm({ end }) - +]]-- --Backwards Compatability. +--[[ minetest.register_abm({ nodenames = {"snow:snow1","snow:snow2","snow:snow3","gsnow4","snow:snow5","snow:snow6","snow:snow7","snow:snow8"}, interval = 1, @@ -209,3 +210,4 @@ minetest.register_abm({ minetest.set_node_level(pos, 7*(tonumber(node.name:sub(-1)))) end, }) +]]-- diff --git a/src/crafting.lua b/src/crafting.lua index 8a8068a..2600170 100644 --- a/src/crafting.lua +++ b/src/crafting.lua @@ -57,7 +57,7 @@ of snowblocks (and then use them to water-grief by melting the snow blocks). ~ LazyJ -]] +]]-- minetest.register_craft({ type = "shapeless", @@ -77,7 +77,7 @@ minetest.register_craft({ "default:snowblock", "default:snowblock" } -})]] +})]]-- diff --git a/src/mapgen.lua b/src/mapgen.lua index 951b786..f6fc7ea 100644 --- a/src/mapgen.lua +++ b/src/mapgen.lua @@ -12,7 +12,7 @@ saplings grow into trees. --]] -- Part 1: To disable the mapgen, add the *starting* comment under this line. -local perlin_scale, nosmooth_rarity +--[[local perlin_scale, nosmooth_rarity if not snow.disable_mapgen then print("[snow] Mapgen enabled!") @@ -68,10 +68,10 @@ if not snow.disable_mapgen then if mgname == "v6" then --Load mapgen_v6 compatibility. dofile(path.."/src/mapgen_v6.lua") - else + else]]-- --Load mapgen_v7 compatibility. - dofile(path.."/src/mapgen_v7.lua") - end +dofile(minetest.get_modpath("snow").."/src/mapgen_v7.lua") +--[[ end end -- To complete the commenting-out add the *closing* comment under this line. @@ -200,7 +200,7 @@ function snow.voxelmanip_pine(pos,a,data) data[a:index(pos.x,pos.y+7,pos.z)] = c_snow end end - +]]-- -- treecapitator support if minetest.global_exists("treecapitator") then treecapitator.register_tree{ diff --git a/src/mapgen_v7.lua b/src/mapgen_v7.lua index 22705e2..8489a39 100644 --- a/src/mapgen_v7.lua +++ b/src/mapgen_v7.lua @@ -70,7 +70,7 @@ minetest.register_biome({ humidity_point = 40.0, }) -minetest.register_biome({ +--[[minetest.register_biome({ name = "snow_biome_sand", node_top = "default:sand", @@ -83,7 +83,7 @@ minetest.register_biome({ heat_point = 10.0, humidity_point = 40.0, }) - +]]-- --Pine tree. minetest.register_decoration({ @@ -101,7 +101,7 @@ minetest.register_decoration({ y_max = 31000, y_min = 4, biomes = {"snowy_grassland", "coniferous_forest", "taiga", "snow_biome_alpine"}, - schematic = minetest.get_modpath("snow").."/schematics/pine.mts", + schematic = minetest.get_modpath("snow").."/schematics/snow_pine.mts", flags = "place_center_x, place_center_z", }) @@ -121,7 +121,7 @@ minetest.register_decoration({ y_max = 31000, y_min = 4, biomes = {"snow_biome_forest", "pine_forest"}, - schematic = minetest.get_modpath("snow").."/schematics/pine.mts", + schematic = minetest.get_modpath("snow").."/schematics/snow_pine.mts", flags = "place_center_x, place_center_z", }) @@ -133,7 +133,7 @@ minetest.register_decoration({ y_max = 31000, y_min = 4, biomes = {"snow_biome_lush"}, - schematic = minetest.get_modpath("snow").."/schematics/pine.mts", + schematic = minetest.get_modpath("snow").."/schematics/snow_pine.mts", flags = "place_center_x, place_center_z", }) diff --git a/src/nodes.lua b/src/nodes.lua index acbc2df..8d87b4a 100644 --- a/src/nodes.lua +++ b/src/nodes.lua @@ -1,29 +1,81 @@ -- NODES +-- Grow sapling + +local function grow_pine_tree(pos) + local path = minetest.get_modpath("snow").."/schematics/snow_pine_from_sapling.mts" + minetest.place_schematic({x= pos.x -2, y = pos.y - 1, z = pos.z - 2}, path, "0", nil, false) +end + +local function grow_snowy_pine_tree(pos) + local path = minetest.get_modpath("snow").."/schematics/snowy_snow_pine_from_sapling.mts" + minetest.place_schematic({x= pos.x -2, y = pos.y - 1, z = pos.z - 2}, path, "random", nil, false) +end + +local function grow_xmas_tree(pos) + local path = minetest.get_modpath("snow").."/schematics/snow_xmas_from_sapling.mts" + minetest.place_schematic({x= pos.x -2, y = pos.y - 1, z = pos.z - 2}, path, "0", nil, false) +end + +local function grow_snowy_xmas_tree(pos) + local path = minetest.get_modpath("snow").."/schematics/snowy_snow_xmas_from_sapling.mts" + minetest.place_schematic({x= pos.x -2, y = pos.y - 1, z = pos.z - 2}, path, "random", nil, false) +end + +local function is_snow_nearby(pos) + return minetest.find_node_near(pos, 1, {"group:snowy"}) +end + +local function grow_sapling(pos) + if not default.can_grow(pos) then + -- try again 5 min later + minetest.get_node_timer(pos):start(300) + return + end + + local node = minetest.get_node(pos) + if node.name == "snow:sapling_pine" then + minetest.log("action", "A Snow Pine sapling grows into a tree at "..minetest.pos_to_string(pos)) + if is_snow_nearby(pos) then + grow_snowy_pine_tree(pos) + else + grow_pine_tree(pos) + end + elseif node.name == "snow:xmas_tree" then + minetest.log("action", "A Christmas sapling grows into a tree at "..minetest.pos_to_string(pos)) + if is_snow_nearby(pos) then + grow_snowy_xmas_tree(pos) + else + grow_xmas_tree(pos) + end + end +end + +minetest.register_lbm({ + name = "snow:convert_saplings_to_node_timer", + nodenames = {"snow:sapling_pine", "snow:xmas_tree"}, + action = function(pos) + minetest.get_node_timer(pos):start(math.random(300, 1500)) + end +}) + -- Pine Needles -local nodedef = { - description = "Snow Pine Needles", - drawtype = "allfaces_optional", - visual_scale = 1.3, - tiles = {"snow_needles.png"}, - waving = 1, - paramtype = "light", - groups = {snappy = 3, leafdecay = 3, flammable = 2, leaves = 1}, - drop = { - max_items = 1, - items = { - { - -- player will get sapling with 1/20 chance - items = {'snow:sapling_pine'}, - rarity = 20, - }, - { - items = {'snow:needles'}, - } +local nodedef = table.copy(minetest.registered_nodes["default:pine_needles"]) +nodedef.description = "Snow Pine Needles" +nodedef.tiles = {"snow_needles.png"} +nodedef.visual_scale = 1.3 +nodedef.drop = { + max_items = 1, + items = { + { + -- player will get sapling with 1/20 chance + items = {'snow:sapling_pine'}, + rarity = 20, + }, + { + items = {'snow:needles'}, } - }, - sounds = default.node_sound_leaves_defaults(), - after_place_node = default.after_place_leaves, + } } --[[ @@ -43,12 +95,6 @@ end minetest.register_node("snow:needles", table.copy(nodedef)) -default.register_leafdecay{ - trunks = {"default:pine_tree"}, - leaves = {"snow:needles", "default:pine_needles"}, - radius = 2, -} - snow.register_on_configuring(function(name, v) if name == "christmas_content" then local drop = minetest.registered_nodes["snow:needles"].drop @@ -86,25 +132,35 @@ else end nodedef.drop.items[#nodedef.drop.items] = {items = {'snow:needles_decorated'}} -minetest.register_node("snow:needles_decorated", nodedef) +minetest.register_node("snow:needles_decorated", table.copy(nodedef)) +-- Leaf decay + +default.register_leafdecay{ + trunks = {"default:pine_tree"}, + leaves = {"snow:needles", "default:pine_needles", "snow:needles_decorated"}, + radius = 2, +} -- Saplings -nodedef = { - description = "Snow Pine Sapling", - drawtype = "plantlike", - visual_scale = 1.0, - tiles = {"snow_sapling_pine.png"}, - inventory_image = "snow_sapling_pine.png", - wield_image = "snow_sapling_pine.png", - paramtype = "light", - sunlight_propagates = true, - walkable = false, - groups = {snappy=2,dig_immediate=3, flammable = 3, - attached_node = 1, sapling = 1}, - sounds = default.node_sound_leaves_defaults(), -} +nodedef = table.copy(minetest.registered_nodes["default:pine_sapling"]) +nodedef.description = "Snow Pine Sapling" +nodedef.tiles = {"snow_sapling_pine.png"} +nodedef.inventory_image = "snow_sapling_pine.png" +nodedef.wield_image = "snow_sapling_pine.png" +nodedef.on_timer = grow_sapling +nodedef.on_place = function(itemstack, placer, pointed_thing) + itemstack = default.sapling_on_place( + itemstack, + placer, + pointed_thing, + "snow:sapling_pine", + {x = -2, y = 1, z = -2}, + {x = 2, y = 13, z = 2}, + 4) + return itemstack +end -- Pine Sapling minetest.register_node("snow:sapling_pine", table.copy(nodedef)) @@ -114,10 +170,21 @@ nodedef.description = "Christmas Tree" nodedef.tiles = {"snow_xmas_tree.png"} nodedef.inventory_image = "snow_xmas_tree.png" nodedef.wield_image = "snow_xmas_tree.png" +nodedef.on_place = function(itemstack, placer, pointed_thing) + itemstack = default.sapling_on_place( + itemstack, + placer, + pointed_thing, + "snow:xmas_tree", + {x= -2, y = 1, z = -2}, + {x = 2, y = 14, z = 2}, + 4) + return itemstack +end minetest.register_node("snow:xmas_tree", nodedef) - +-- Star nodedef = { description = "Star", drawtype = "plantlike", @@ -229,7 +296,7 @@ if rawget(_G, "flowers") then end -- Leaves -local leaves = minetest.registered_nodes["default:leaves"] +--[[local leaves = minetest.registered_nodes["default:leaves"] nodedef = { description = "Snow Leaves", tiles = {"snow_leaves.png"}, @@ -265,7 +332,7 @@ nodedef.groups.flammable = 1 minetest.register_node("snow:apple", nodedef) snow.known_plants[minetest.get_content_id("default:apple")] = minetest.get_content_id("snow:apple") ---[[if not snow.disable_mapgen then +if not snow.disable_mapgen then -- decay from default/nodes.lua:2537 default.register_leafdecay{ trunks = {"default:tree"}, diff --git a/src/snowball.lua b/src/snowball.lua index e0afd34..164dd96 100644 --- a/src/snowball.lua +++ b/src/snowball.lua @@ -31,7 +31,7 @@ local function get_gravity() return grav*snowball_gravity end -local someone_throwing, just_acitvated +local someone_throwing, just_activated --Shoot snowball function snow.shoot_snowball(item, player) @@ -48,7 +48,7 @@ function snow.shoot_snowball(item, player) if creative_mode then if not someone_throwing then someone_throwing = true - just_acitvated = true + just_activated = true end return end @@ -82,12 +82,12 @@ if creative_mode then local timer -- only if one holds left click if someone_throwing - and not just_acitvated then + and not just_activated then update_step() timer = 0.006 else timer = 0.5 - just_acitvated = false + just_activated = false end minetest.after(timer, do_step) end