mirror of
https://git.minetest.land/VoxeLibre/VoxeLibre.git
synced 2024-11-25 20:11:06 +01:00
Comparator now detects jukebox as container
This commit is contained in:
parent
1ce9ab22bf
commit
e38f19b5f3
3 changed files with 11 additions and 22 deletions
|
@ -151,7 +151,7 @@ These groups are used mostly for informational purposes
|
|||
* `container=5`: Left part of a 2-part horizontal connected container. Both parts have a `"main"` inventory
|
||||
list. Both inventories are considered to belong together. This is used for large chests.
|
||||
* `container=6`: Same as above, but for the right part.
|
||||
* `container=7`: Same as `container=2`, but only music discs can be inserted
|
||||
* `container=7`: Has inventory list "`main`", no movement allowed
|
||||
* `container=1`: Other/unspecified container type
|
||||
* `spawn_egg=1`: Spawn egg
|
||||
|
||||
|
|
|
@ -211,6 +211,11 @@ function mcl_util.move_item_container(source_pos, destination_pos, source_list,
|
|||
local dctype = minetest.get_item_group(dnode.name, "container")
|
||||
local sctype = minetest.get_item_group(snode.name, "container")
|
||||
|
||||
-- Container type 7 does not allow any movement
|
||||
if sctype == 7 then
|
||||
return false
|
||||
end
|
||||
|
||||
-- Normalize double container by forcing to always use the left segment first
|
||||
local normalize_double_container = function(pos, node, ctype)
|
||||
if ctype == 6 then
|
||||
|
@ -291,13 +296,10 @@ function mcl_util.move_item_container(source_pos, destination_pos, source_list,
|
|||
return false
|
||||
end
|
||||
end
|
||||
-- Container type 7 conly allows music discs
|
||||
-- Container type 7 does not allow any placement
|
||||
if dctype == 7 then
|
||||
local stack = sinv:get_stack(source_list, source_stack_id)
|
||||
if stack and minetest.get_item_group(stack:get_name(), "music_record") == 0 then
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
-- If it's a container, put it into the container
|
||||
if dctype ~= 0 then
|
||||
|
@ -329,10 +331,6 @@ function mcl_util.move_item_container(source_pos, destination_pos, source_list,
|
|||
-- Start furnace's timer function, it will sort out whether furnace can burn or not.
|
||||
minetest.get_node_timer(dpos):start(1.0)
|
||||
end
|
||||
-- Update jukebox
|
||||
if ok and dctype == 7 then
|
||||
minetest.get_node_timer(dpos):start(0.0)
|
||||
end
|
||||
|
||||
return ok
|
||||
end
|
||||
|
|
|
@ -106,17 +106,16 @@ minetest.register_craft({
|
|||
local play_record = function(pos, itemstack, player)
|
||||
local record_id = minetest.get_item_group(itemstack:get_name(), "music_record")
|
||||
if record_id ~= 0 then
|
||||
local cname = "singleplayer" -- player:get_player_name()
|
||||
local cname = player:get_player_name()
|
||||
if active_tracks[cname] ~= nil then
|
||||
minetest.sound_stop(active_tracks[cname])
|
||||
active_tracks[cname] = nil
|
||||
end
|
||||
active_tracks[cname] = minetest.sound_play("mcl_jukebox_track_"..record_id, {
|
||||
--to_player = cname,
|
||||
max_hear_distance = 16,
|
||||
to_player = cname,
|
||||
gain = 1,
|
||||
})
|
||||
--now_playing(player, record_id)
|
||||
now_playing(player, record_id)
|
||||
return true
|
||||
end
|
||||
return false
|
||||
|
@ -192,14 +191,6 @@ minetest.register_node("mcl_jukebox:jukebox", {
|
|||
end
|
||||
meta:from_table(meta2:to_table())
|
||||
end,
|
||||
on_timer = function(pos, elapsed)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
local stack = inv:get_stack("main", 1)
|
||||
if not stack:is_empty() then
|
||||
play_record(pos, stack)
|
||||
end
|
||||
end,
|
||||
_mcl_blast_resistance = 30,
|
||||
_mcl_hardness = 2,
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue