aboutsummaryrefslogtreecommitdiff
path: root/games/minimal/mods/default/textures/default_rail_curved.png
blob: f87e826c9d652e7daacd1431ad99c7c9a1236f61 (plain)
ofshex dumpascii
0000 89 50 4e 47 0d 0a 1a 0a 00 00 00 0d 49 48 44 52 00 00 00 10 00 00 00 10 08 03 00 00 00 28 2d 0f .PNG........IHDR.............(-.
0020 53 00 00 00 a5 50 4c 54 45 00 00 00 55 57 53 68 4a 1c 6b 4c 1c 6c 4d 1c 6c 4d 1d 6d 4d 1c 6e 4e S....PLTE...UWShJ.kL.lM.lM.mM.nN
0040 1d 6f 4f 1d 70 50 1d 70 50 1e 71 51 1d 72 50 1e 72 51 1e 73 52 1f 74 53 1f 75 53 1e 76 54 1f 78 .oO.pP.pP.qQ.rP.rQ.sR.tS.uS.vT.x
0060 55 1f 78 55 20 7b 59 24 7d 59 21 7e 5c 25 7e 5c 26 83 5d 23 83 5f 27 84 60 27 84 61 2b 87 62 28 U.xU.{Y$}Y!~\%~\&.]#._'.`'.a+.b(
0080 89 64 29 8d 67 29 8d 69 2e 90 6b 2f 91 6b 2f 92 6c 2f 92 6c 30 95 6f 30 98 71 32 9a 72 32 9b 73 .d).g).i..k/.k/.l/.l0.o0.q2.r2.s
00a0 33 9c 74 33 9d 74 33 9f 75 34 9f 76 33 a1 77 35 a2 77 34 a2 78 35 a4 78 35 a4 79 36 a7 7c 37 a8 3.t3.t3.u4.v3.w5.w4.x5.x5.y6.|7.
00c0 7c 37 ab 7e 37 ac 7e 38 ac 80 38 ba bd b6 41 d8 8a 21 00 00 00 01 74 52 4e 53 00 40 e6 d8 66 00 |7.~7.~8..8...A..!....tRNS.@..f.
00e0 00 00 80 49 44 41 54 18 19 05 c1 07 22 03 01 00 04 c0 59 2d 51 8e 28 d1 85 20 6a 74 f6 ff 4f 33 ...IDAT.....".....Y-Q.(...jt..O3
0100 03 00 00 00 2e df 00 00 e3 b6 05 40 9b 24 00 da 64 b8 03 38 fa 68 c2 ea 27 c0 a4 81 e9 0d 40 73 ...........@.$..d..8.h..'.....@s
0120 fe 0b a7 0f 40 63 6b 36 c7 e6 3d d0 b0 77 f6 cc ce 1c 34 70 70 bc 60 b8 e6 e4 a2 01 bb b3 77 eb ....@ck6..=..w....4pp.`.......w.
0140 0b f6 9b bf e5 2b 0c 57 b7 09 9a 61 ba f6 fd f2 c5 61 5a 34 d8 58 19 fd 3c a6 db 4b 34 c0 78 48 .....+.W...a.....aZ4.X..<..K4.xH
0160 9f fc 03 d4 79 0b 69 69 52 f2 1c 00 00 00 00 49 45 4e 44 ae 42 60 82 ....y.iiR......IEND.B`.
>112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310
-- Minetest: builtin/item.lua

local builtin_shared = ...

--
-- Falling stuff
--

core.register_entity(":__builtin:falling_node", {
	initial_properties = {
		visual = "wielditem",
		visual_size = {x = 0.667, y = 0.667},
		textures = {},
		physical = true,
		is_visible = false,
		collide_with_objects = false,
		collisionbox = {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
	},

	node = {},
	meta = {},

	set_node = function(self, node, meta)
		self.node = node
		self.meta = meta or {}
		self.object:set_properties({
			is_visible = true,
			textures = {node.name},
		})
	end,

	get_staticdata = function(self)
		local ds = {
			node = self.node,
			meta = self.meta,
		}
		return core.serialize(ds)
	end,

	on_activate = function(self, staticdata)
		self.object:set_armor_groups({immortal = 1})
		
		local ds = core.deserialize(staticdata)
		if ds and ds.node then
			self:set_node(ds.node, ds.meta)
		elseif ds then
			self:set_node(ds)
		elseif staticdata ~= "" then
			self:set_node({name = staticdata})
		end
	end,

	on_step = function(self, dtime)
		-- Set gravity
		local acceleration = self.object:getacceleration()
		if not vector.equals(acceleration, {x = 0, y = -10, z = 0}) then
			self.object:setacceleration({x = 0, y = -10, z = 0})
		end
		-- Turn to actual node when colliding with ground, or continue to move
		local pos = self.object:getpos()
		-- Position of bottom center point
		local bcp = {x = pos.x, y = pos.y - 0.7, z = pos.z}
		-- Avoid bugs caused by an unloaded node below
		local bcn = core.get_node_or_nil(bcp)
		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
			if core.registered_nodes[self.node.name] then
				core.add_node(np, self.node)
				if self.meta then
					local meta = core.get_meta(np)
					meta:from_table(self.meta)
				end
			end
			self.object:remove()
			core.check_for_falling(np)
			return
		end
		local vel = self.object:getvelocity()
		if vector.equals(vel, {x = 0, y = 0, z = 0}) then
			local npos = self.object:getpos()
			self.object:setpos(vector.round(npos))
		end
	end
})

local function spawn_falling_node(p, node, meta)
	local obj = core.add_entity(p, "__builtin:falling_node")
	if obj then
		obj:get_luaentity():set_node(node, meta)
	end
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
	local obj = core.add_entity(pos, "__builtin:falling_node")
	if obj then
		obj:get_luaentity():set_node(node)
		core.remove_node(pos)
		return true
	end
	return false
end

local function drop_attached_node(p)
	local n = core.get_node(p)
	core.remove_node(p)
	for _, item in pairs(core.get_node_drops(n, "")) 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
			n.level = core.get_node_level(p)
			local meta = core.get_meta(p)
			local metatable = {}
			if meta ~= nil then
				metatable = meta:to_table()
			end
			core.remove_node(p)
			spawn_falling_node(p, n, metatable)
			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},