1
0
Fork 0

Comparator now detects jukebox as container

This commit is contained in:
Wuzzy 2018-05-12 22:48:49 +02:00
parent 1ce9ab22bf
commit e38f19b5f3
3 changed files with 11 additions and 22 deletions

View File

@ -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 * `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. 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=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 * `container=1`: Other/unspecified container type
* `spawn_egg=1`: Spawn egg * `spawn_egg=1`: Spawn egg

View File

@ -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 dctype = minetest.get_item_group(dnode.name, "container")
local sctype = minetest.get_item_group(snode.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 -- Normalize double container by forcing to always use the left segment first
local normalize_double_container = function(pos, node, ctype) local normalize_double_container = function(pos, node, ctype)
if ctype == 6 then if ctype == 6 then
@ -291,13 +296,10 @@ function mcl_util.move_item_container(source_pos, destination_pos, source_list,
return false return false
end end
end end
-- Container type 7 conly allows music discs -- Container type 7 does not allow any placement
if dctype == 7 then 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 return false
end end
end
-- If it's a container, put it into the container -- If it's a container, put it into the container
if dctype ~= 0 then 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. -- Start furnace's timer function, it will sort out whether furnace can burn or not.
minetest.get_node_timer(dpos):start(1.0) minetest.get_node_timer(dpos):start(1.0)
end end
-- Update jukebox
if ok and dctype == 7 then
minetest.get_node_timer(dpos):start(0.0)
end
return ok return ok
end end

View File

@ -106,17 +106,16 @@ minetest.register_craft({
local play_record = function(pos, itemstack, player) local play_record = function(pos, itemstack, player)
local record_id = minetest.get_item_group(itemstack:get_name(), "music_record") local record_id = minetest.get_item_group(itemstack:get_name(), "music_record")
if record_id ~= 0 then if record_id ~= 0 then
local cname = "singleplayer" -- player:get_player_name() local cname = player:get_player_name()
if active_tracks[cname] ~= nil then if active_tracks[cname] ~= nil then
minetest.sound_stop(active_tracks[cname]) minetest.sound_stop(active_tracks[cname])
active_tracks[cname] = nil active_tracks[cname] = nil
end end
active_tracks[cname] = minetest.sound_play("mcl_jukebox_track_"..record_id, { active_tracks[cname] = minetest.sound_play("mcl_jukebox_track_"..record_id, {
--to_player = cname, to_player = cname,
max_hear_distance = 16,
gain = 1, gain = 1,
}) })
--now_playing(player, record_id) now_playing(player, record_id)
return true return true
end end
return false return false
@ -192,14 +191,6 @@ minetest.register_node("mcl_jukebox:jukebox", {
end end
meta:from_table(meta2:to_table()) meta:from_table(meta2:to_table())
end, 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_blast_resistance = 30,
_mcl_hardness = 2, _mcl_hardness = 2,
}) })