Merge 5.1.5 and a fix into master

This commit is contained in:
kay27 2022-02-06 05:37:32 +04:00
commit 07e000d077
15 changed files with 465 additions and 35 deletions

View File

@ -30,6 +30,7 @@ mcl_mapgen.LAST_BLOCK = mcl_mapgen.CS - 1
mcl_mapgen.LAST_NODE_IN_BLOCK = mcl_mapgen.BS - 1
mcl_mapgen.LAST_NODE_IN_CHUNK = mcl_mapgen.CS_NODES - 1
mcl_mapgen.HALF_CS_NODES = math_floor(mcl_mapgen.CS_NODES / 2)
mcl_mapgen.HALF_BS = math_floor(mcl_mapgen.BS / 2)
mcl_mapgen.CS_3D = mcl_mapgen.CS^3
mcl_mapgen.CHUNK_WITH_SHELL = mcl_mapgen.CS + 2
mcl_mapgen.CHUNK_WITH_SHELL_3D = mcl_mapgen.CHUNK_WITH_SHELL^3
@ -166,40 +167,38 @@ local function is_chunk_finished(minp)
return true
end
local function unsigned(v)
if v < 0 then
v = 0x100000000 - (math.abs(v) % 0x100000000)
end
local function uint32_t(v)
if v >= 0 then
return v % 0x100000000
end
return 0x100000000 - (math.abs(v) % 0x100000000)
end
local function bitwise_xor_32(a, b)
local a = unsigned(a)
local b = unsigned(b)
local c = 0
for n = 31, 0, -1 do
local mask = math.floor(2^n)
if (a >= mask) ~= (b >= mask) then
c = c + mask
end
a = a % mask
b = b % mask
end
return c
local function get_block_seed(pos, current_seed)
local current_seed = current_seed or uint32_t(tonumber(seed))
return uint32_t(uint32_t(23 * pos.x) + uint32_t(42123 * pos.y) + uint32_t(38134234 * pos.z) + current_seed)
end
local function getBlockSeed2(pos, seed)
local seed = seed or mcl_mapgen.seed
local n = unsigned(unsigned(1619 * pos.x) + unsigned(31337 * pos.y) + unsigned(52591 * pos.z) + unsigned(1013 * seed))
n = bitwise_xor_32(math.floor(n / 0x2000), n)
return unsigned((n * unsigned(n * n * 60493 + 19990303) + 1376312589))
local function get_block_seed2(pos, current_seed)
local current_seed = current_seed or uint32_t(tonumber(seed))
local n = uint32_t(uint32_t(1619 * pos.x) + uint32_t(31337 * pos.y) + uint32_t(52591 * pos.z) + uint32_t(1013 * current_seed))
n = bit.bxor(bit.rshift(n, 13), n)
local seed = uint32_t((n * uint32_t(n * n * 60493 + 19990303) + 1376312589))
return seed
end
local function get_block_seed3(pos, current_seed)
local current_seed = uint32_t(current_seed or uint32_t(tonumber(seed)))
local x = uint32_t((pos.x + 32768) * 13)
local y = uint32_t((pos.y + 32767) * 13873)
local z = uint32_t((pos.z + 76705) * 115249)
local seed = uint32_t(bit.bxor(current_seed, x, y, z))
return seed
end
minetest.register_on_generated(function(minp, maxp, chunkseed)
local minp, maxp, chunkseed = minp, maxp, chunkseed
local vm, emin, emax = minetest.get_mapgen_object("voxelmanip")
minetest_log("action", "[mcl_mapgen] New_chunk=" .. minetest_pos_to_string(minp) .. "..." .. minetest_pos_to_string(maxp) .. ", shell=" .. minetest_pos_to_string(emin) .. "..." .. minetest_pos_to_string(emax) .. ", chunkseed=" .. tostring(chunkseed))
data = vm:get_data(lvm_buffer)
area = VoxelArea:new({MinEdge=emin, MaxEdge=emax})
vm_context = {
@ -256,10 +255,10 @@ minetest.register_on_generated(function(minp, maxp, chunkseed)
end
local number_of_blocks = 0
for k, offset in pairs(ready_blocks) do
if queue_blocks_lvm_counter > 0 then
if queue_blocks_lvm_counter > 0 or nodes_block > 0 then
local block_minp = p0 + vector.multiply(offset, BS)
local block_maxp = vector.add(block_minp, LAST_NODE_IN_BLOCK)
local blockseed = getBlockSeed2(block_minp)
local blockseed = get_block_seed3(block_minp)
vm_context.minp, vm_context.maxp, vm_context.blockseed = block_minp, block_maxp, blockseed
-- --
-- mcl_mapgen.register_mapgen_block_lvm(function(vm_context), order_number) --
@ -268,7 +267,7 @@ minetest.register_on_generated(function(minp, maxp, chunkseed)
v.callback_function(vm_context)
end
if nodes_block > 0 then
current_blocks[#current_blocks + 1] = { minp = block_minp, maxp = block_maxp, seed = blockseed }
current_blocks[#current_blocks + 1] = { minp = block_minp, maxp = block_maxp, blockseed = blockseed }
end
end
number_of_blocks = number_of_blocks + 1
@ -306,7 +305,7 @@ minetest.register_on_generated(function(minp, maxp, chunkseed)
for i, chunk_minp in pairs(current_chunks) do
local chunk_maxp = vector.add(chunk_minp, LAST_NODE_IN_CHUNK)
local chunkseed = getBlockSeed2(chunk_minp)
local current_chunk_seed = get_block_seed3(vector.subtract(chunk_minp, BS))
area = VoxelArea:new({MinEdge=minp, MaxEdge=maxp})
vm_context = {
data = data,
@ -320,7 +319,7 @@ minetest.register_on_generated(function(minp, maxp, chunkseed)
emax = chunk_maxp,
minp = chunk_minp,
maxp = chunk_maxp,
chunkseed = chunkseedseed,
chunkseed = current_chunk_seed,
}
-- --
-- mcl_mapgen.register_mapgen_lvm(function(vm_context), order_number) --
@ -332,7 +331,7 @@ minetest.register_on_generated(function(minp, maxp, chunkseed)
-- mcl_mapgen.register_mapgen(function(minp, maxp, chunkseed, vm_context), order_number) --
-- --
for _, v in pairs(queue_chunks_nodes) do
v.f(chunk_minp, chunk_maxp, chunkseed, vm_context)
v.f(chunk_minp, chunk_maxp, current_chunk_seed, vm_context)
end
if vm_context.write or vm_context.write_param2 or vm_context.write_light then
if vm_context.write then
@ -353,12 +352,12 @@ minetest.register_on_generated(function(minp, maxp, chunkseed)
end
end
for i, b in pairs(current_blocks) do
for _, b in pairs(current_blocks) do
-- --
-- mcl_mapgen.register_mapgen_block(function(minp, maxp, blockseed), order_number) --
-- --
for _, v in pairs(queue_blocks_nodes) do
v.f(b.minp, b.maxp, b.seed)
v.f(b.minp, b.maxp, b.blockseed)
end
end
end)

View File

@ -89,10 +89,13 @@ mobs:register_mob("mobs_mc:blaze", {
end,
do_custom = function(self)
if self.attacking and self.state == "attack" and vector.distance(self.object:get_pos(), self.attacking:get_pos()) < 1.2 then
local pos = self.object:get_pos()
if self.attacking and self.state == "attack" then
local attacking_pos = self.attacking:get_pos()
if attacking_pos and vector.distance(pos, attacking_pos) < 1.2 then
mcl_burning.set_on_fire(self.attacking, 5)
end
local pos = self.object:get_pos()
end
minetest.add_particle({
pos = {x=pos.x+math.random(-0.7,0.7)*math.random()/2,y=pos.y+math.random(0.7,1.2),z=pos.z+math.random(-0.7,0.7)*math.random()/2},
velocity = {x=0, y=math.random(1,1), z=0},

View File

@ -0,0 +1,93 @@
local radius_min = 3
local radius_max = mcl_mapgen.HALF_BS
local layers = {
{
[8] = "mcl_blackstone:basalt_polished",
[92] = "mcl_deepslate:deepslate",
},
{
[100] = "mcl_amethyst:calcite",
},
{
[85] = "mcl_amethyst:amethyst_block",
[15] = "mcl_amethyst:budding_amethyst_block",
},
{
[98] = "mcl_amethyst:amethyst_block",
[2] = "mcl_amethyst:budding_amethyst_block",
},
{
[100] = "air",
}
}
local function round(v)
if v < 0 then
return math.ceil(v - 0.5)
end
return math.floor(v + 0.5)
end
local function place(pos, rotation, pr)
local radius1 = vector.new(
-pr:next(radius_min, radius_max),
-pr:next(radius_min, radius_max),
-pr:next(radius_min, radius_max)
)
local radius2 = vector.new(
pr:next(radius_min, radius_max),
pr:next(radius_min, radius_max),
pr:next(radius_min, radius_max)
)
local layer_radius = pr:next(radius_min, radius_max)
local radius1_normalized = vector.normalize(radius1)
local radius2_normalized = vector.normalize(radius2)
local pos = vector.subtract(pos, radius1)
for x = radius1.x, radius2.x do
local max_x = (x < 0) and radius1.x or radius2.x
for y = radius1.y, radius2.y do
local max_y = (y < 0) and radius1.y or radius2.y
for z = radius1.z, radius2.z do
local max_z = (z < 0) and radius1.z or radius2.z
local normal_abs = vector.new(x / max_x, y / max_y, z / max_z)
local inverted_layer = round(vector.length(normal_abs) * layer_radius)
if inverted_layer <= layer_radius then
local layer = math.min(math.max(1, layer_radius - inverted_layer + 1), #layers)
local offset = vector.new(x, y, z)
local node_pos = pos + offset
local node_candidates = layers[layer]
local node_name
local chance_index = pr:next(1, 100)
local current_weight = 0
for chance, node_name_iterated in pairs(node_candidates) do
if chance_index <= current_weight + chance then
node_name = node_name_iterated
break
end
current_weight = current_weight + chance
end
minetest.swap_node(node_pos, {name = node_name})
end
end
end
end
end
mcl_structures.register_structure({
name = "amethyst_geode",
place_function = place,
})
local decrease_scan_area = 1
local mapblock_opacity_placement_threshold = 0.98
local threshold = math.floor(((mcl_mapgen.BS - 2 * decrease_scan_area)^3) * mapblock_opacity_placement_threshold)
local upper_than = mcl_mapgen.overworld.bedrock_max
mcl_mapgen.register_mapgen_block(function(minp, maxp, blockseed)
local y = minp.y
if y <= upper_than then return end
local pr = PseudoRandom(blockseed + 143)
if pr:next(1, 120) ~= 54 then return end
local opacity_counter = #minetest.find_nodes_in_area(vector.add(minp, decrease_scan_area), vector.subtract(maxp, decrease_scan_area), "group:opaque")
if opacity_counter < threshold then return end
place(minp, nil, pr)
end)

View File

@ -0,0 +1,54 @@
local S = minetest.get_translator(minetest.get_current_modname())
local interval = 10
local chance = 5
local function grow(pos, node)
local def = minetest.registered_nodes[node.name]
local next_gen = def._mcl_amethyst_next_grade
if not next_gen then return end
local dir = minetest.wallmounted_to_dir(node.param2)
local ba_pos = vector.add(pos, dir)
local ba_node = minetest.get_node(ba_pos)
if ba_node.name ~= "mcl_amethyst:budding_amethyst_block" then return end
local swap_result = table.copy(node)
swap_result.name = next_gen
minetest.swap_node(pos, swap_result)
end
minetest.register_abm({
label = "Amethyst Bud Growth",
nodenames = {"group:amethyst_buds"},
neighbors = {"mcl_amethyst:budding_amethyst_block"},
interval = interval,
chance = chance,
action = grow,
})
local all_directions = {
vector.new(1,0,0),
vector.new(0,1,0),
vector.new(0,0,1),
vector.new(-1,0,0),
vector.new(0,-1,0),
vector.new(0,0,-1),
}
minetest.register_abm({
label = "Spawn Amethyst Bud",
nodenames = {"mcl_amethyst:budding_amethyst_block"},
neighbors = {"air", "group:water"},
interval = 20,
chance = 2,
action = function(pos)
local check_pos = vector.add(all_directions[math.random(1, #all_directions)], pos)
local check_node = minetest.get_node(check_pos)
local check_node_name = check_node.name
if check_node_name ~= "air" and minetest.get_item_group(check_node_name, "water") == 0 then return end
local param2 = minetest.dir_to_wallmounted(vector.subtract(pos, check_pos))
local new_node = {name = "mcl_amethyst:small_amethyst_bud", param2 = param2}
minetest.swap_node(check_pos, new_node)
end,
})

View File

@ -0,0 +1,238 @@
local S = minetest.get_translator(minetest.get_current_modname())
local modname = minetest.get_current_modname()
local modpath = minetest.get_modpath(modname)
mcl_amethyst = {}
local sounds = mcl_sounds.node_sound_glass_defaults({
footstep = {name="amethyst_walk", gain=0.4},
dug = {name="amethyst_break", gain=0.44},
})
-- Amethyst block
minetest.register_node("mcl_amethyst:amethyst_block",{
description = S("Block of Amethyst"),
tiles = {"amethyst_block.png"},
_mcl_hardness = 1.5,
_mcl_blast_resistance = 1.5,
groups = {
pickaxey = 1,
building_block = 1,
},
sounds = sounds,
is_ground_content = true,
stack_max = 64,
_doc_items_longdesc = S("The Block of Amethyst is a decoration block crafted from amethyst shards."),
})
-- Budding Amethyst block
minetest.register_node("mcl_amethyst:budding_amethyst_block",{
description = S("Budding Amethyst"),
tiles = {"budding_amethyst.png"},
drop = "",
_mcl_hardness = 1.5,
_mcl_blast_resistance = 1.5,
groups = {
pickaxey = 1,
building_block = 1,
dig_by_piston = 1,
},
sounds = sounds,
is_ground_content = true,
stack_max = 64,
_doc_items_longdesc = S("The Budding Amethyst can grow amethyst"),
})
-- Amethyst Shard
minetest.register_craftitem("mcl_amethyst:amethyst_shard",{
description = S("Amethyst Shard"),
inventory_image = "amethyst_shard.png",
stack_max = 64,
groups = {
craftitem = 1,
},
_doc_items_longdesc = S("An amethyst shard is a crystalline mineral."),
})
-- Calcite
minetest.register_node("mcl_amethyst:calcite",{
description = S("Calcite"),
tiles = {"calcite.png"},
_mcl_hardness = 0.75,
_mcl_blast_resistance = 0.75,
groups = {
pickaxey = 1,
building_block = 1,
},
sounds = mcl_sounds.node_sound_stone_defaults(),
is_ground_content = true,
stack_max = 64,
_doc_items_longdesc = S("Calcite can be found as part of amethyst geodes."),
})
-- Tinied Glass
minetest.register_node("mcl_amethyst:tinted_glass",{
description = S("Tinted Glass"),
tiles = {"tinted_glass.png"},
_mcl_hardness = 0.3,
_mcl_blast_resistance = 0.3,
drawtype = "glasslike",
use_texture_alpha = "clip",
sunlight_propagates = false,
groups = {
handy = 1,
building_block = 1,
deco_block = 1,
},
sounds = mcl_sounds.node_sound_glass_defaults(),
is_ground_content = false,
stack_max = 64,
_doc_items_longdesc = S("Tinted Glass is a type of glass which blocks lights while it is visually transparent."),
})
-- Amethyst Cluster
local bud_def = {
{
size = "small",
description = S("Small Amethyst Bud"),
long_desc = S("Small Amethyst Bud is the first growth of amethyst bud."),
light_source = 3,
next_stage = "mcl_amethyst:medium_amethyst_bud",
selection_box = { -4/16, -7/16, -4/16, 4/16, -3/16, 4/16 },
},
{
size = "medium",
description = S("Medium Amethyst Bud"),
long_desc = S("Medium Amethyst Bud is the second growth of amethyst bud."),
light_source = 4,
next_stage = "mcl_amethyst:large_amethyst_bud",
selection_box = { -4.5/16, -8/16, -4.5/16, 4.5/16, -2/16, 4.5/16 },
},
{
size = "large",
description = S("Large Amethyst Bud"),
long_desc = S("Large Amethyst Bud is the third growth of amethyst bud."),
light_source = 5,
next_stage = "mcl_amethyst:amethyst_cluster",
selection_box = { -4.5/16, -8/16, -4.5/16, 4.5/16, -1/16, 4.5/16 },
},
}
for _, def in pairs(bud_def) do
local size = def.size
local name = "mcl_amethyst:" .. size .. "_amethyst_bud"
local tile = size .. "_amethyst_bud.png"
local inventory_image = size .. "_amethyst_bud.png"
minetest.register_node(name, {
description = def.description,
_mcl_hardness = 1.5,
_mcl_blast_resistance = 1.5,
drop = "",
tiles = {tile},
inventory_image = inventory_image,
paramtype1 = "light",
paramtype2 = "wallmounted",
drawtype = "plantlike",
use_texture_alpha = "clip",
sunlight_propagates = true,
walkable = false,
light_source = def.light_source,
groups = {
dig_by_water = 1,
destroy_by_lava_flow = 1,
dig_by_piston = 1,
pickaxey = 1,
deco_block = 1,
amethyst_buds = 1,
attached_node = 1,
},
sounds = sounds,
selection_box = {
type = "fixed",
fixed = def.selection_box
},
_mcl_silk_touch_drop = true,
_mcl_amethyst_next_grade = def.next_stage,
_doc_items_longdesc = def.longdesc,
})
end
minetest.register_node("mcl_amethyst:amethyst_cluster",{
description = "Amethyst Cluster",
_mcl_hardness = 1.5,
_mcl_blast_resistance = 1.5,
_doc_items_longdesc = S("Amethyst Cluster is the final growth of amethyst bud."),
drop = {
max_items = 1,
items = {
{
tools = {"~mcl_tools:pick_"},
items = {"mcl_amethyst:amethyst_shard 4"},
},
{
items = {"mcl_amethyst:amethyst_shard 2"},
},
}
},
tiles = {"amethyst_cluster.png",},
inventory_image = "amethyst_cluster.png",
paramtype2 = "wallmounted",
drawtype = "plantlike",
paramtype1 = "light",
use_texture_alpha = "clip",
sunlight_propagates = true,
walkable = false,
light_source = 7,
groups = {
dig_by_water = 1,
destroy_by_lava_flow = 1,
dig_by_piston = 1,
pickaxey = 1,
deco_block = 1,
attached_node = 1,
},
sounds = sounds,
selection_box = {
type = "fixed",
fixed = { -4.8/16, -8/16, -4.8/16, 4.8/16, 3.9/16, 4.8/16 },
},
_mcl_silk_touch_drop = true,
})
-- Register Crafts
minetest.register_craft({
output = "mcl_amethyst:amethyst_block",
recipe = {
{"mcl_amethyst:amethyst_shard","mcl_amethyst:amethyst_shard",},
{"mcl_amethyst:amethyst_shard","mcl_amethyst:amethyst_shard",},
},
})
minetest.register_craft({
output = "mcl_amethyst:tinted_glass 2",
recipe = {
{"","mcl_amethyst:amethyst_shard",""},
{"mcl_amethyst:amethyst_shard","mcl_core:glass","mcl_amethyst:amethyst_shard",},
{"","mcl_amethyst:amethyst_shard",""},
},
})
if minetest.get_modpath("mcl_spyglass") then
minetest.clear_craft({output = "mcl_spyglass:spyglass",})
local function craft_spyglass(ingot)
minetest.register_craft({
output = "mcl_spyglass:spyglass",
recipe = {
{"mcl_amethyst:amethyst_shard"},
{ingot},
{ingot},
}
})
end
if minetest.get_modpath("mcl_copper") then
craft_spyglass("mcl_copper:copper_ingot")
else
craft_spyglass("mcl_core:iron_ingot")
end
end
dofile(modpath .. "/grow.lua")
dofile(modpath .. "/geode.lua")

View File

@ -0,0 +1,19 @@
# textdomain: mcl_amethyst
Amethyst Cluster=Аметистовая друза
Amethyst Cluster is the final growth of amethyst bud.=Аметистовая друза - это последняя 4-я стадия роста аметистового бутона.
Amethyst Shard=Осколок аметиста
An amethyst shard is a crystalline mineral.=Осколок аметиста - это кристаллический минерал, получаемый в результате разрушения кластеров аметиста.
Block of Amethyst=Аметистовый блок
Budding Amethyst=Растущий аметист
Calcite=Кальцит
Calcite can be found as part of amethyst geodes.=Кальцит можно найти в составе аметистовых жеод.
Large Amethyst Bud=Большой росток аметиста
Large Amethyst Bud is the third growth of amethyst bud.=Большой росток - третья стадия роста аметиста.
Medium Amethyst Bud=Средний росток аметиста
Medium Amethyst Bud is the second growth of amethyst bud.=Средний росток - вторая стадия роста аметиста.
Small Amethyst Bud=Маленький росток аметиста
Small Amethyst Bud is the first growth of amethyst bud.=Маленький росток - первая стадия роста аметиста.
The Block of Amethyst is a decoration block crafted from amethyst shards.=Блок аметиста - декоративный блок, скрафченный из осколков аметиста.
The Budding Amethyst can grow amethyst=Растущий аметист может вырастить аметист
Tinted Glass=Тонированное стекло
Tinted Glass is a type of glass which blocks lights while it is visually transparent.=Тонированное стекло блокирует свет, но визуально прозрачно.

View File

@ -0,0 +1,19 @@
# textdomain: mcl_amethyst
Amethyst Cluster=
Amethyst Cluster is the final growth of amethyst bud.=
Amethyst Shard=
An amethyst shard is a crystalline mineral.=
Block of Amethyst=
Budding Amethyst=
Calcite=
Calcite can be found as part of amethyst geodes.=
Large Amethyst Bud=
Large Amethyst Bud is the third growth of amethyst bud.=
Medium Amethyst Bud=
Medium Amethyst Bud is the second growth of amethyst bud.=
Small Amethyst Bud=
Small Amethyst Bud is the first growth of amethyst bud.=
The Block of Amethyst is a decoration block crafted from amethyst shards.=
The Budding Amethyst can grow amethyst=
Tinted Glass=
Tinted Glass is a type of glass which blocks lights while it is visually transparent.=

View File

@ -0,0 +1,5 @@
name = mcl_amethyst
author = Emojiminetest, kay27
description = Amethyst related stuff for MCL5
depends = mcl_init, mcl_core, mcl_wip, mcl_mapgen, mcl_structures, mcl_blackstone, mcl_deepslate
optional_depends = mcl_spyglass, mcl_copper

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.