mirror of
https://git.minetest.land/VoxeLibre/VoxeLibre.git
synced 2024-11-17 16:41:06 +01:00
f6f5481f30
Not using the `RecheckCartHack` on >5.9 seems to help with #4670 - not tested on older minetest; chest minecarts might still be empty there when the block is unloaded in the meantime. For <5.9, maybe it helps to decrease the time interval, 3 seconds seems to fairly long. This also makes the minecarts random: 40% minecart, 40% chest minecart, 20% tnt minecart. Reviewed-on: https://git.minetest.land/VoxeLibre/VoxeLibre/pulls/4684 Reviewed-by: the-real-herowl <the-real-herowl@noreply.git.minetest.land> Co-authored-by: kno10 <erich.schubert@gmail.com> Co-committed-by: kno10 <erich.schubert@gmail.com>
146 lines
5.3 KiB
Lua
146 lines
5.3 KiB
Lua
-- This file stores the various node types. This makes it easier to plug this mod into games
|
|
-- in which you need to change the node names.
|
|
|
|
-- Adapted for MineClone 2!
|
|
|
|
-- Node names (Don't use aliases!)
|
|
tsm_railcorridors.nodes = {
|
|
dirt = "mcl_core:dirt",
|
|
chest = "mcl_chests:chest",
|
|
rail = "mcl_minecarts:rail",
|
|
torch_floor = "mcl_torches:torch",
|
|
torch_wall = "mcl_torches:torch_wall",
|
|
cobweb = "mcl_core:cobweb",
|
|
spawner = "mcl_mobspawners:spawner",
|
|
}
|
|
|
|
local mg_name = minetest.get_mapgen_setting("mg_name")
|
|
|
|
if mg_name == "v6" then
|
|
-- In v6, wood is chosen randomly.
|
|
--[[ Wood types for the corridors. Corridors are made out of full wood blocks
|
|
and posts. For each corridor system, a random wood type is chosen with the chance
|
|
specified in per mille. ]]
|
|
tsm_railcorridors.nodes.corridor_woods = {
|
|
{ wood = "mcl_core:wood", post = "mcl_fences:fence", chance = 900},
|
|
{ wood = "mcl_core:darkwood", post = "mcl_fences:dark_oak_fence", chance = 100},
|
|
}
|
|
else
|
|
-- This generates dark oak wood in mesa biomes and oak wood everywhere else.
|
|
function tsm_railcorridors.nodes.corridor_woods_function(_, node)
|
|
if minetest.get_item_group(node.name, "hardened_clay") ~= 0 then
|
|
return "mcl_core:darkwood", "mcl_fences:dark_oak_fence"
|
|
else
|
|
return "mcl_core:wood", "mcl_fences:fence"
|
|
end
|
|
end
|
|
end
|
|
|
|
tsm_railcorridors.carts = {
|
|
"mcl_minecarts:minecart", "mcl_minecarts:minecart",
|
|
"mcl_minecarts:chest_minecart", "mcl_minecarts:chest_minecart",
|
|
"mcl_minecarts:tnt_minecart"
|
|
}
|
|
|
|
-- This is called after a spawner has been placed by the game.
|
|
-- Use this to properly set up the metadata and stuff.
|
|
-- This is needed for games if they include mob spawners.
|
|
-- All spawners spawn cave spiders
|
|
function tsm_railcorridors.on_construct_spawner(pos)
|
|
mcl_mobspawners.setup_spawner(pos, "mobs_mc:cave_spider", 0, 7)
|
|
end
|
|
|
|
|
|
-- This is called after a cart has been placed by the game.
|
|
-- Use this to properly set up entity metadata and stuff.
|
|
-- * pos: Position of cart
|
|
-- * cart: Cart entity
|
|
function tsm_railcorridors.on_construct_cart(_, cart, pr_carts)
|
|
local l = cart:get_luaentity()
|
|
local inv = mcl_entity_invs.load_inv(l,27)
|
|
if inv then -- otherwise probably not a chest minecart
|
|
local items = tsm_railcorridors.get_treasures(pr_carts)
|
|
mcl_loot.fill_inventory(inv, "main", items, pr_carts)
|
|
mcl_entity_invs.save_inv(l)
|
|
end
|
|
end
|
|
|
|
-- Fallback function. Returns a random treasure. This function is called for chests
|
|
-- only if the Treasurer mod is not found.
|
|
-- pr: A PseudoRandom object
|
|
function tsm_railcorridors.get_default_treasure(_)
|
|
-- UNUSED IN MINECLONE 2!
|
|
end
|
|
|
|
-- MineClone 2's treasure function. Gets all treasures for a single chest.
|
|
-- Based on information from Minecraft Wiki.
|
|
function tsm_railcorridors.get_treasures(pr)
|
|
local loottable = {
|
|
{
|
|
stacks_min = 1,
|
|
stacks_max = 1,
|
|
items = {
|
|
{ itemstring = "mcl_mobs:nametag", weight = 30 },
|
|
{ itemstring = "mcl_core:apple_gold", weight = 20 },
|
|
{ itemstring = "mcl_books:book", weight = 10, func = function(stack, pr)
|
|
mcl_enchanting.enchant_uniform_randomly(stack, {"soul_speed"}, pr)
|
|
end },
|
|
{ itemstring = "", weight = 5},
|
|
{ itemstring = "mcl_core:pick_iron", weight = 5 },
|
|
{ itemstring = "mcl_core:apple_gold_enchanted", weight = 1 },
|
|
}
|
|
},
|
|
{
|
|
stacks_min = 2,
|
|
stacks_max = 4,
|
|
items = {
|
|
{ itemstring = "mcl_farming:bread", weight = 15, amount_min = 1, amount_max = 3 },
|
|
{ itemstring = "mcl_core:coal_lump", weight = 10, amount_min = 3, amount_max = 8 },
|
|
{ itemstring = "mcl_farming:beetroot_seeds", weight = 10, amount_min = 2, amount_max = 4 },
|
|
{ itemstring = "mcl_farming:melon_seeds", weight = 10, amount_min = 2, amount_max = 4 },
|
|
{ itemstring = "mcl_farming:pumpkin_seeds", weight = 10, amount_min = 2, amount_max = 4 },
|
|
{ itemstring = "mcl_core:iron_ingot", weight = 10, amount_min = 1, amount_max = 5 },
|
|
{ itemstring = "mcl_core:lapis", weight = 5, amount_min = 4, amount_max = 9 },
|
|
{ itemstring = "mesecons:redstone", weight = 5, amount_min = 4, amount_max = 9 },
|
|
{ itemstring = "mcl_core:gold_ingot", weight = 5, amount_min = 1, amount_max = 3 },
|
|
{ itemstring = "mcl_core:diamond", weight = 3, amount_min = 1, amount_max = 2 },
|
|
}
|
|
},
|
|
{
|
|
stacks_min = 3,
|
|
stacks_max = 3,
|
|
items = {
|
|
{ itemstring = "mcl_minecarts:rail", weight = 20, amount_min = 4, amount_max = 8 },
|
|
{ itemstring = "mcl_torches:torch", weight = 15, amount_min = 1, amount_max = 16 },
|
|
{ itemstring = "mcl_minecarts:activator_rail", weight = 5, amount_min = 1, amount_max = 4 },
|
|
{ itemstring = "mcl_minecarts:detector_rail", weight = 5, amount_min = 1, amount_max = 4 },
|
|
{ itemstring = "mcl_minecarts:golden_rail", weight = 5, amount_min = 1, amount_max = 4 },
|
|
}
|
|
},
|
|
-- non-MC loot: 50% chance to add a minecart, offered as alternative to spawning minecarts on rails.
|
|
-- TODO: Remove this when minecarts spawn on rails.
|
|
{
|
|
stacks_min = 0,
|
|
stacks_max = 1,
|
|
items = {
|
|
{ itemstring = "mcl_minecarts:minecart", weight = 1 },
|
|
}
|
|
}
|
|
}
|
|
|
|
-- Bonus loot for v6 mapgen: Otherwise unobtainable saplings.
|
|
if mg_name == "v6" then
|
|
table.insert(loottable, {
|
|
stacks_min = 1,
|
|
stacks_max = 3,
|
|
items = {
|
|
{ itemstring = "mcl_core:darksapling", weight = 1, amount_min = 1, amount_max = 3 },
|
|
{ itemstring = "mcl_core:birchsapling", weight = 1, amount_min = 1, amount_max = 2 },
|
|
{ itemstring = "", weight = 6 },
|
|
},
|
|
})
|
|
end
|
|
local items = mcl_loot.get_multi_loot(loottable, pr)
|
|
|
|
return items
|
|
end
|