Fireworks are now craftable

This commit is contained in:
the-real-herowl 2024-12-26 04:24:43 +01:00 committed by the-real-herowl
parent e69bd1412e
commit a65684e875
2 changed files with 32 additions and 18 deletions

@ -1,17 +1,28 @@
minetest.register_craft({
type = "shapeless",
output = "vl_fireworks:rocket 3",
recipe = {"mcl_core:paper", "mcl_mobitems:gunpowder"},
})
local function register_firework_crafts()
local recipe = {"mcl_core:paper"}
for i=1, 3 do
table.insert(recipe, "mcl_mobitems:gunpowder")
minetest.register_craft({
type = "shapeless",
output = "vl_fireworks:rocket 3",
recipe = recipe,
})
end
end
register_firework_crafts()
minetest.register_craft({
type = "shapeless",
output = "vl_fireworks:rocket 3",
recipe = {"mcl_core:paper", "mcl_mobitems:gunpowder", "mcl_mobitems:gunpowder"},
})
minetest.register_craft({
type = "shapeless",
output = "vl_fireworks:rocket 3",
recipe = {"mcl_core:paper", "mcl_mobitems:gunpowder", "mcl_mobitems:gunpowder", "mcl_mobitems:gunpowder"},
})
local function craft_firework(itemstack, player, old_grid)
if itemstack:get_name() ~= "vl_fireworks:rocket" then return end
local gp = 0
for _, item in pairs(old_grid) do
if item:get_name() == "mcl_mobitems:gunpowder" then gp = gp + 1 end
end
local tbl = vl_fireworks.firework_def._vl_fireworks_std_durs_forces[gp]
local meta = itemstack:get_meta()
meta:set_float("vl_fireworks:duration", tbl[1])
meta:set_int("vl_fireworks:force", tbl[2])
tt.reload_itemstack_description(itemstack)
return itemstack
end
core.register_craft_predict(craft_firework)
core.register_on_craft(craft_firework)

@ -136,7 +136,7 @@ function vl_fireworks.shoot_firework(itemstack, pos)
})
end
minetest.register_craftitem("vl_fireworks:rocket", { -- TODO use metadata
local firework_def = {
description = description,
inventory_image = "vl_fireworks_rocket.png",
stack_max = 64,
@ -162,4 +162,7 @@ minetest.register_craftitem("vl_fireworks:rocket", { -- TODO use metadata
_vl_fireworks_tt = function(duration)
return S("Duration:") .. " " .. duration
end,
})
}
vl_fireworks.firework_def = table.copy(firework_def)
minetest.register_craftitem("vl_fireworks:rocket", firework_def)