2018-03-25 22:20:32 +02:00
|
|
|
-- This file stores the various node types. This makes it easier to plug this mod into games
|
2017-05-13 21:50:41 +02:00
|
|
|
-- in which you need to change the node names.
|
|
|
|
|
|
|
|
-- Adapted for MineClone 2!
|
|
|
|
|
2024-04-12 11:11:46 +02:00
|
|
|
-- Imports
|
|
|
|
local create_minecart = mcl_minecarts.create_minecart
|
|
|
|
local get_cart_data = mcl_minecarts.get_cart_data
|
|
|
|
local save_cart_data = mcl_minecarts.save_cart_data
|
|
|
|
|
2017-05-13 21:50:41 +02:00
|
|
|
-- Node names (Don't use aliases!)
|
|
|
|
tsm_railcorridors.nodes = {
|
|
|
|
dirt = "mcl_core:dirt",
|
|
|
|
chest = "mcl_chests:chest",
|
2024-04-12 11:11:46 +02:00
|
|
|
rail = "mcl_minecarts:rail_v2",
|
2017-05-13 21:50:41 +02:00
|
|
|
torch_floor = "mcl_torches:torch",
|
|
|
|
torch_wall = "mcl_torches:torch_wall",
|
2017-08-14 05:35:32 +02:00
|
|
|
cobweb = "mcl_core:cobweb",
|
|
|
|
spawner = "mcl_mobspawners:spawner",
|
2017-12-08 16:12:31 +01:00
|
|
|
}
|
|
|
|
|
2024-04-12 11:11:46 +02:00
|
|
|
local update_rail_connections = mcl_minecarts.update_rail_connections
|
|
|
|
local rails_to_update = {}
|
|
|
|
tsm_railcorridors.on_place_node = {
|
|
|
|
[tsm_railcorridors.nodes.rail] = function(pos, node)
|
|
|
|
rails_to_update[#rails_to_update + 1] = pos
|
|
|
|
end,
|
|
|
|
}
|
|
|
|
tsm_railcorridors.on_start = function()
|
|
|
|
rails_to_update = {}
|
|
|
|
end
|
|
|
|
tsm_railcorridors.on_finish = function()
|
|
|
|
for _,pos in pairs(rails_to_update) do
|
|
|
|
update_rail_connections(pos, {legacy = true, ignore_neighbor_connections = true})
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-12-08 16:12:31 +01:00
|
|
|
local mg_name = minetest.get_mapgen_setting("mg_name")
|
2017-05-13 21:50:41 +02:00
|
|
|
|
2017-12-08 16:12:31 +01:00
|
|
|
if mg_name == "v6" then
|
|
|
|
-- In v6, wood is chosen randomly.
|
2017-05-13 21:50:41 +02:00
|
|
|
--[[ 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. ]]
|
2017-12-08 16:12:31 +01:00
|
|
|
tsm_railcorridors.nodes.corridor_woods = {
|
2017-05-13 21:50:41 +02:00
|
|
|
{ wood = "mcl_core:wood", post = "mcl_fences:fence", chance = 900},
|
|
|
|
{ wood = "mcl_core:darkwood", post = "mcl_fences:dark_oak_fence", chance = 100},
|
2017-12-08 16:12:31 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
-- This generates dark oak wood in mesa biomes and oak wood everywhere else.
|
2021-05-25 12:52:25 +02:00
|
|
|
function tsm_railcorridors.nodes.corridor_woods_function(pos, node)
|
2017-12-08 16:12:31 +01:00
|
|
|
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
|
2021-01-22 19:45:18 +01:00
|
|
|
|
2017-05-13 21:50:41 +02:00
|
|
|
|
2024-04-12 11:11:46 +02:00
|
|
|
tsm_railcorridors.carts = { "mcl_minecarts:chest_minecart", "mcl_minecarts:hopper_minecart", "mcl_minecarts:minecart" }
|
|
|
|
local has_loot = {
|
|
|
|
["mcl_minecarts:chest_minecart"] = true,
|
|
|
|
["mcl_minecarts:hopper_minceart"] = true,
|
|
|
|
}
|
|
|
|
|
|
|
|
function tsm_railcorridors.create_cart_staticdata(entity_id,pos, pr)
|
|
|
|
local uuid = create_minecart(entity_id, pos, vector.new(1,0,0))
|
2017-08-14 20:01:04 +02:00
|
|
|
|
2024-04-12 11:11:46 +02:00
|
|
|
-- Fill the cart with loot
|
|
|
|
local cartdata = get_cart_data(uuid)
|
|
|
|
if cartdata and has_loot[entity_id] then
|
|
|
|
local items = tsm_railcorridors.get_treasures(pr)
|
2022-07-02 00:27:09 +02:00
|
|
|
|
2024-04-12 11:11:46 +02:00
|
|
|
-- Convert from ItemStack to itemstrings
|
|
|
|
for k,item in pairs(items) do
|
|
|
|
items[k] = item:to_string()
|
|
|
|
end
|
|
|
|
cartdata.inventory = items
|
|
|
|
|
|
|
|
print("cartdata = "..dump(cartdata))
|
|
|
|
save_cart_data(uuid)
|
|
|
|
end
|
2022-07-02 00:27:09 +02:00
|
|
|
|
2024-04-12 11:11:46 +02:00
|
|
|
return minetest.serialize({ uuid=uuid, seq=1 })
|
2017-08-14 20:01:04 +02:00
|
|
|
end
|
|
|
|
|
2017-05-13 21:50:41 +02:00
|
|
|
-- 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(pr)
|
2017-05-13 22:47:43 +02:00
|
|
|
-- UNUSED IN MINECLONE 2!
|
|
|
|
end
|
|
|
|
|
2017-08-14 05:35:32 +02:00
|
|
|
-- All spawners spawn cave spiders
|
|
|
|
function tsm_railcorridors.on_construct_spawner(pos)
|
2018-01-08 00:41:57 +01:00
|
|
|
mcl_mobspawners.setup_spawner(pos, "mobs_mc:cave_spider", 0, 7)
|
2017-08-14 05:35:32 +02:00
|
|
|
end
|
|
|
|
|
2017-05-13 22:47:43 +02:00
|
|
|
-- MineClone 2's treasure function. Gets all treasures for a single chest.
|
|
|
|
-- Based on information from Minecraft Wiki.
|
|
|
|
function tsm_railcorridors.get_treasures(pr)
|
2017-09-07 04:38:50 +02:00
|
|
|
local loottable = {
|
2017-05-19 16:46:03 +02:00
|
|
|
{
|
|
|
|
stacks_min = 1,
|
|
|
|
stacks_max = 1,
|
|
|
|
items = {
|
2018-05-31 18:32:26 +02:00
|
|
|
{ itemstring = "mcl_mobs:nametag", weight = 30 },
|
2017-05-19 16:46:03 +02:00
|
|
|
{ itemstring = "mcl_core:apple_gold", weight = 20 },
|
2021-12-07 17:57:18 +01:00
|
|
|
{ itemstring = "mcl_books:book", weight = 10, func = function(stack, pr)
|
2021-12-07 18:19:41 +01:00
|
|
|
mcl_enchanting.enchant_uniform_randomly(stack, {"soul_speed"}, pr)
|
2021-12-07 17:57:18 +01:00
|
|
|
end },
|
2017-05-19 16:46:03 +02:00
|
|
|
{ itemstring = "", weight = 5},
|
|
|
|
{ itemstring = "mcl_core:pick_iron", weight = 5 },
|
2021-01-22 19:45:18 +01:00
|
|
|
{ itemstring = "mcl_core:apple_gold_enchanted", weight = 1 },
|
2017-05-19 16:46:03 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
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 },
|
2022-12-22 18:10:59 +01:00
|
|
|
{ itemstring = "mcl_core:lapis", weight = 5, amount_min = 4, amount_max = 9 },
|
2017-05-19 16:46:03 +02:00
|
|
|
{ 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 = {
|
2024-04-12 11:11:46 +02:00
|
|
|
{ itemstring = "mcl_minecarts:rail_v2", weight = 20, amount_min = 4, amount_max = 8 },
|
2017-05-19 16:46:03 +02:00
|
|
|
{ itemstring = "mcl_torches:torch", weight = 15, amount_min = 1, amount_max = 16 },
|
2024-04-12 11:11:46 +02:00
|
|
|
{ itemstring = "mcl_minecarts:activator_rail_v2", weight = 5, amount_min = 1, amount_max = 4 },
|
|
|
|
{ itemstring = "mcl_minecarts:detector_rail_v2", weight = 5, amount_min = 1, amount_max = 4 },
|
|
|
|
{ itemstring = "mcl_minecarts:golden_rail_v2", weight = 5, amount_min = 1, amount_max = 4 },
|
2017-05-19 16:46:03 +02:00
|
|
|
}
|
2019-02-06 03:00:45 +01:00
|
|
|
},
|
|
|
|
-- 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 },
|
|
|
|
}
|
2017-09-07 04:38:50 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
-- Bonus loot for v6 mapgen: Otherwise unobtainable saplings.
|
|
|
|
if mg_name == "v6" then
|
|
|
|
table.insert(loottable, {
|
|
|
|
stacks_min = 1,
|
2018-01-12 19:02:06 +01:00
|
|
|
stacks_max = 3,
|
2017-09-07 04:38:50 +02:00
|
|
|
items = {
|
2018-01-12 19:02:06 +01:00
|
|
|
{ itemstring = "mcl_core:darksapling", weight = 1, amount_min = 1, amount_max = 3 },
|
2017-09-07 04:38:50 +02:00
|
|
|
{ itemstring = "mcl_core:birchsapling", weight = 1, amount_min = 1, amount_max = 2 },
|
2018-01-12 19:02:06 +01:00
|
|
|
{ itemstring = "", weight = 6 },
|
2017-09-07 04:38:50 +02:00
|
|
|
},
|
|
|
|
})
|
|
|
|
end
|
|
|
|
local items = mcl_loot.get_multi_loot(loottable, pr)
|
2017-05-13 22:47:43 +02:00
|
|
|
|
|
|
|
return items
|
2017-05-13 21:50:41 +02:00
|
|
|
end
|