2 Commits

Author SHA1 Message Date
26a73117a9 MapGen: fix trees replace trunks 2026-10-02 21:33:07 +03:00
87e5304acd HelperLib: new getItemDefinitionOrNil function 2026-10-02 21:32:00 +03:00
2 changed files with 17 additions and 2 deletions

View File

@@ -113,7 +113,7 @@ function Tree:place(pos)
local pos1, pos2 = pos - v(16, 0, 16), pos + v(16, 80, 16) --[[@as MapVector]]
if isAreaGenerated(pos1, pos2) then
corePlaceSchematic(pos, self.path, getRotation(pos), nil, nil, 'place_center_x, place_center_z')
corePlaceSchematic(pos, self.path, getRotation(pos), nil, false, 'place_center_x, place_center_z')
else
coreEmergeArea(pos1, pos2)
end
@@ -122,7 +122,7 @@ end
---@param voxelManip VoxelManip
---@param pos MapVector
function Tree:placeOnVM(voxelManip, pos)
local result = corePlaceSchematicOnVM(voxelManip, pos, self.path, getRotation(pos), nil, nil, 'place_center_x, place_center_z')
local result = corePlaceSchematicOnVM(voxelManip, pos, self.path, getRotation(pos), nil, false, 'place_center_x, place_center_z')
if not result then
voxelManip:set_node_at(pos, {name = self.placerName, force_place = true})

View File

@@ -62,3 +62,18 @@ function Smc.getItemDefinition(itemName)
return item.itemDef
end
---@param itemName ItemStack|ItemStackString
---@return Item.ItemDefinition|Node.NodeDefinition|nil
function Smc.getItemDefinitionOrNil(itemName)
if type(itemName) ~= 'string' then
itemName = itemName:get_name()
end
local item = Smc.getRegisteredItemByName(itemName)
if item == nil then
return nil
end
return item.itemDef
end