Compare commits
2 Commits
main
...
feature-sm
Author | SHA1 | Date | |
---|---|---|---|
1dd3ddd35c | |||
f926fdc493 |
136
api.lua
136
api.lua
@ -105,61 +105,103 @@ function liquid_physics.register_liquid(namespace, source_name, flowing_name)
|
||||
end
|
||||
|
||||
--Overwrite source
|
||||
source_liquid_def.liquid_range = 0
|
||||
-- source_liquid_def.liquid_range = 0
|
||||
source_liquid_def.groups.liquid_physics = 1
|
||||
|
||||
core.register_node(":" .. source_liquid_name, source_liquid_def)
|
||||
-- core.register_node(":" .. source_liquid_name, {
|
||||
-- description = source_liquid_def.description,
|
||||
-- paramtype2 = "flowingliquid",
|
||||
|
||||
-- drawtype = "flowingliquid", -- Used by drawtype = "flowingliquid"
|
||||
-- liquidtype = "", -- Flowing not needed here since condition is already met?
|
||||
|
||||
-- tiles = source_liquid_def.tiles, -- As needed by drawtype - copy from water
|
||||
-- special_tiles = source_liquid_def.tiles,
|
||||
-- use_texture_alpha = true,
|
||||
|
||||
-- liquid_renewable = false, -- Disallow any kind of spreading
|
||||
-- liquid_range = 2,
|
||||
|
||||
-- buildable_to = true, -- For liquid_alternative_source = "test_water:test",
|
||||
|
||||
-- liquid_alternative_flowing = source_liquid_name, -- As requested in documentation
|
||||
|
||||
-- liquid_move_physics = true,
|
||||
-- walkable = false,
|
||||
|
||||
-- })
|
||||
|
||||
core.override_item(source_liquid_name, {
|
||||
paramtype2 = "flowingliquid",
|
||||
drawtype = "flowingliquid",
|
||||
liquidtype = "",
|
||||
liquid_renewable = false,
|
||||
liquid_range = 2,
|
||||
liquid_alternative_source = "",
|
||||
liquid_alternative_flowing = source_liquid_name,
|
||||
liquid_move_physics = true,
|
||||
special_tiles = source_liquid_def.tiles,
|
||||
groups = source_liquid_def.groups,
|
||||
pointable = true,
|
||||
}, nil)
|
||||
|
||||
-- core.register_node(":" .. source_liquid_name, source_liquid_def)
|
||||
liquid_physics._liquid_ids[source_liquid_name] = id
|
||||
|
||||
local liquids = {}
|
||||
table.insert(liquids, "air")
|
||||
|
||||
for i = 1, 7 do
|
||||
local node_name = "liquid_physics:" .. namespace .. "_" .. source_name .. "_level_" .. i
|
||||
|
||||
local level_def = {
|
||||
name = node_name,
|
||||
description = source_liquid_def.description .. " Level " .. i,
|
||||
tiles = source_liquid_def.tiles,
|
||||
use_texture_alpha = source_liquid_def.use_texture_alpha,
|
||||
paramtype = source_liquid_def.paramtype,
|
||||
walkable = source_liquid_def.walkable,
|
||||
pointable = source_liquid_def.pointable,
|
||||
diggable = source_liquid_def.diggable,
|
||||
buildable_to = source_liquid_def.buildable_to,
|
||||
is_ground_content = source_liquid_def.is_ground_content,
|
||||
drawtype = "nodebox",
|
||||
drop = source_liquid_def.drop,
|
||||
drowning = source_liquid_def.drowning,
|
||||
liquidtype = "source",
|
||||
liquid_alternative_flowing = node_name,
|
||||
liquid_alternative_source = node_name,
|
||||
liquid_range = 0,
|
||||
liquid_viscosity = source_liquid_def.liquid_viscosity,
|
||||
liquid_renewable = false,
|
||||
waving = source_liquid_def.waving,
|
||||
color = source_liquid_def.color,
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{ -0.5, -0.5, -0.5, 0.5, -0.375 + (0.125 * (i - 1)), 0.5 },
|
||||
},
|
||||
},
|
||||
collision_box = {
|
||||
type = "fixed",
|
||||
fixed = { { -0.5, -0.5, -0.5, 0.5, -0.375 + (0.125 * (i - 1)), 0.5 }, },
|
||||
},
|
||||
post_effect_color = source_liquid_def.post_effect_color,
|
||||
groups = source_liquid_def.groups,
|
||||
sounds = source_liquid_def.sounds,
|
||||
}
|
||||
|
||||
core.register_node(":" .. node_name, level_def)
|
||||
liquid_physics._liquid_ids[node_name] = id
|
||||
|
||||
table.insert(liquids, node_name)
|
||||
liquid_physics._liquid_ids[source_liquid_name] = id
|
||||
table.insert(liquids, source_liquid_name)
|
||||
end
|
||||
|
||||
-- for i = 1, 7 do
|
||||
-- local node_name = "liquid_physics:" .. namespace .. "_" .. source_name .. "_level_" .. i
|
||||
|
||||
-- local level_def = {
|
||||
-- name = node_name,
|
||||
-- description = source_liquid_def.description .. " Level " .. i,
|
||||
-- tiles = source_liquid_def.tiles,
|
||||
-- use_texture_alpha = source_liquid_def.use_texture_alpha,
|
||||
-- paramtype = source_liquid_def.paramtype,
|
||||
-- walkable = source_liquid_def.walkable,
|
||||
-- pointable = source_liquid_def.pointable,
|
||||
-- diggable = source_liquid_def.diggable,
|
||||
-- buildable_to = source_liquid_def.buildable_to,
|
||||
-- is_ground_content = source_liquid_def.is_ground_content,
|
||||
-- drawtype = "nodebox",
|
||||
-- drop = source_liquid_def.drop,
|
||||
-- drowning = source_liquid_def.drowning,
|
||||
-- liquidtype = "source",
|
||||
-- liquid_alternative_flowing = node_name,
|
||||
-- liquid_alternative_source = node_name,
|
||||
-- liquid_range = 0,
|
||||
-- liquid_viscosity = source_liquid_def.liquid_viscosity,
|
||||
-- liquid_renewable = false,
|
||||
-- waving = source_liquid_def.waving,
|
||||
-- color = source_liquid_def.color,
|
||||
-- node_box = {
|
||||
-- type = "fixed",
|
||||
-- fixed = {
|
||||
-- { -0.5, -0.5, -0.5, 0.5, -0.375 + (0.125 * (i - 1)), 0.5 },
|
||||
-- },
|
||||
-- },
|
||||
-- collision_box = {
|
||||
-- type = "fixed",
|
||||
-- fixed = { { -0.5, -0.5, -0.5, 0.5, -0.375 + (0.125 * (i - 1)), 0.5 }, },
|
||||
-- },
|
||||
-- post_effect_color = source_liquid_def.post_effect_color,
|
||||
-- groups = source_liquid_def.groups,
|
||||
-- sounds = source_liquid_def.sounds,
|
||||
-- }
|
||||
|
||||
-- core.register_node(":" .. node_name, level_def)
|
||||
-- liquid_physics._liquid_ids[node_name] = id
|
||||
|
||||
-- table.insert(liquids, node_name)
|
||||
-- end
|
||||
|
||||
table.insert(liquids, source_liquid_name)
|
||||
|
||||
-- Finally, stop flowing
|
||||
@ -167,7 +209,9 @@ function liquid_physics.register_liquid(namespace, source_name, flowing_name)
|
||||
core.override_item(flowing_liquid_name, {
|
||||
liquid_range = 0,
|
||||
liquid_renewable = false,
|
||||
groups = flowing_liquid_def.groups
|
||||
liquid_alternative_source = "",
|
||||
liquid_alternative_flowing = "",
|
||||
groups = flowing_liquid_def.groups,
|
||||
}, nil)
|
||||
liquid_physics._liquid_ids[flowing_liquid_name] = id
|
||||
|
||||
|
@ -74,7 +74,13 @@ function internal.new_lpn(hash, pos)
|
||||
local liquid_id = internal.get_liquid_id(node.name)
|
||||
local liquid_level = -1
|
||||
if liquid_id then
|
||||
liquid_level = internal.get_liquid_level(liquid_id, node.name)
|
||||
local node_level = core.get_node_level(pos)
|
||||
if liquid_id == 0 then
|
||||
node_level = 0
|
||||
elseif node_level == 0 and node.name == liquid_physics.get_liquid_node_names(liquid_id)[8] then
|
||||
node_level = 8
|
||||
end
|
||||
liquid_level = node_level --internal.get_liquid_level(liquid_id, node.name)
|
||||
end
|
||||
return {
|
||||
hash = hash,
|
||||
@ -100,6 +106,7 @@ end
|
||||
-- @param lpn table Liquid Physics Node
|
||||
function internal.set_node(lpn)
|
||||
core.set_node(lpn.pos, { name = internal.get_liquid_node_name(lpn.liquid_id, lpn.liquid_level) })
|
||||
core.set_node_level(lpn.pos, lpn.liquid_level)
|
||||
end
|
||||
|
||||
-- This node will be checked in the next cycle
|
||||
|
@ -224,6 +224,7 @@ core.register_on_mapblocks_changed(function(modified_blocks, modified_blocks_cou
|
||||
end
|
||||
-- Update only changed nodes from buffer
|
||||
for _, lpn in pairs(b) do
|
||||
--core.chat_send_all(dump(lpn))
|
||||
if lpn.init_liquid_level ~= lpn.liquid_level then
|
||||
internal.set_node(lpn)
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user