mirror of
				https://github.com/mt-mods/plantlife_modpack.git
				synced 2025-11-04 07:25:30 +01:00 
			
		
		
		
	fix rare edge-case where unknown nodes cause a crash
When a new mapblock is generated and the mod checks the neighbors around a target to place a fallen twig, if it finds an unknown node (because it's in a neighboring, old mapblock from a previous session -- perhaps an old moss node that hadn't converted-over to wallmounted yet), trying to check its buildable_to state will fail, since that requires that there be a node def to look at, which an unknown node wouldn't have. This substitutes a known not-buildable_to node for those cases, so that the code won't try to overwrite what it found.
This commit is contained in:
		@@ -4,6 +4,12 @@
 | 
			
		||||
-- TWiGS
 | 
			
		||||
-----------------------------------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
local fakenode = {
 | 
			
		||||
	name = "default:stone", -- could be anything that's guaranteed to exist at mapgen time, and isn't buildable_to
 | 
			
		||||
	param1 = 0,
 | 
			
		||||
	param2 = 0
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
abstract_trunks.place_twig = function(pos)
 | 
			
		||||
	local twig_size     = math.random(1,27)
 | 
			
		||||
 | 
			
		||||
@@ -26,6 +32,16 @@ abstract_trunks.place_twig = function(pos)
 | 
			
		||||
	local node_s_w      = minetest.get_node(south_west)
 | 
			
		||||
	local node_west     = minetest.get_node(west)
 | 
			
		||||
	local node_n_w      = minetest.get_node(north_west)
 | 
			
		||||
 | 
			
		||||
	node_north = minetest.registered_nodes[node_north.name] and node_north or fakenode
 | 
			
		||||
	node_n_e   = minetest.registered_nodes[node_n_e.name]   and node_n_e   or fakenode
 | 
			
		||||
	node_east  = minetest.registered_nodes[node_east.name]  and node_east  or fakenode
 | 
			
		||||
	node_s_e   = minetest.registered_nodes[node_s_e.name]   and node_s_e   or fakenode
 | 
			
		||||
	node_south = minetest.registered_nodes[node_south.name] and node_south or fakenode
 | 
			
		||||
	node_s_w   = minetest.registered_nodes[node_s_w.name]   and node_s_w   or fakenode
 | 
			
		||||
	node_west  = minetest.registered_nodes[node_west.name]  and node_west  or fakenode
 | 
			
		||||
	node_n_w   = minetest.registered_nodes[node_n_w.name]   and node_n_w   or fakenode
 | 
			
		||||
 | 
			
		||||
--	small twigs
 | 
			
		||||
	if twig_size <= 16 then
 | 
			
		||||
		minetest.swap_node(right_here, {name="trunks:twig_"..math.random(1,4), param2=math.random(0,3)})
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user