forked from VoxeLibre/VoxeLibre
new buckets fixes
This commit is contained in:
parent
f70dbb8cfa
commit
40f4287ff2
|
@ -18,7 +18,8 @@ local string = string
|
||||||
local raycast = minetest.raycast
|
local raycast = minetest.raycast
|
||||||
local get_node = minetest.get_node
|
local get_node = minetest.get_node
|
||||||
local add_node = minetest.add_node
|
local add_node = minetest.add_node
|
||||||
local get_node_group = minetest.get_node_group
|
local add_item = minetest.add_item
|
||||||
|
|
||||||
|
|
||||||
if mod_mcl_core then
|
if mod_mcl_core then
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
|
@ -26,7 +27,7 @@ if mod_mcl_core then
|
||||||
recipe = {
|
recipe = {
|
||||||
{"mcl_core:iron_ingot", "", "mcl_core:iron_ingot"},
|
{"mcl_core:iron_ingot", "", "mcl_core:iron_ingot"},
|
||||||
{"", "mcl_core:iron_ingot", ""},
|
{"", "mcl_core:iron_ingot", ""},
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -34,41 +35,46 @@ mcl_buckets = {}
|
||||||
mcl_buckets.liquids = {}
|
mcl_buckets.liquids = {}
|
||||||
|
|
||||||
-- Sound helper functions for placing and taking liquids
|
-- Sound helper functions for placing and taking liquids
|
||||||
local sound_place = function(itemname, pos)
|
local function sound_place(itemname, pos)
|
||||||
local def = minetest.registered_nodes[itemname]
|
local def = minetest.registered_nodes[itemname]
|
||||||
if def and def.sounds and def.sounds.place then
|
if def and def.sounds and def.sounds.place then
|
||||||
minetest.sound_play(def.sounds.place, {gain=1.0, pos = pos, pitch = 1 + math.random(-10, 10)*0.005}, true)
|
minetest.sound_play(def.sounds.place, {gain=1.0, pos = pos, pitch = 1 + math.random(-10, 10)*0.005}, true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local sound_take = function(itemname, pos)
|
local function sound_take(itemname, pos)
|
||||||
local def = minetest.registered_nodes[itemname]
|
local def = minetest.registered_nodes[itemname]
|
||||||
if def and def.sounds and def.sounds.dug then
|
if def and def.sounds and def.sounds.dug then
|
||||||
minetest.sound_play(def.sounds.dug, {gain=1.0, pos = pos, pitch = 1 + math.random(-10, 10)*0.005}, true)
|
minetest.sound_play(def.sounds.dug, {gain=1.0, pos = pos, pitch = 1 + math.random(-10, 10)*0.005}, true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local place_liquid = function(pos, itemstring)
|
local function place_liquid(pos, itemstring)
|
||||||
local fullness = minetest.registered_nodes[itemstring].liquid_range
|
local fullness = minetest.registered_nodes[itemstring].liquid_range
|
||||||
sound_place(itemstring, pos)
|
sound_place(itemstring, pos)
|
||||||
minetest.add_node(pos, {name=itemstring, param2=fullness})
|
minetest.add_node(pos, {name=itemstring, param2=fullness})
|
||||||
end
|
end
|
||||||
local function give_bucket(new_bucket, itemstack, user)
|
local function give_bucket(new_bucket, itemstack, user)
|
||||||
|
local inv = user:get_inventory()
|
||||||
|
if minetest.is_creative_enabled(user:get_player_name()) then
|
||||||
|
--TODO: is a full bucket added if inv doesn't contain one?
|
||||||
|
return itemstack
|
||||||
|
else
|
||||||
if itemstack:get_count() == 1 then
|
if itemstack:get_count() == 1 then
|
||||||
return new_bucket
|
return new_bucket
|
||||||
else
|
else
|
||||||
local inv = user:get_inventory()
|
|
||||||
if inv:room_for_item("main", new_bucket) then
|
if inv:room_for_item("main", new_bucket) then
|
||||||
inv:add_item("main", new_bucket)
|
inv:add_item("main", new_bucket)
|
||||||
else
|
else
|
||||||
minetest.add_item(user:get_pos(), new_bucket)
|
add_item(user:get_pos(), new_bucket)
|
||||||
end
|
end
|
||||||
if not minetest.is_creative_enabled(user:get_player_name()) then
|
|
||||||
itemstack:take_item()
|
itemstack:take_item()
|
||||||
end
|
|
||||||
return itemstack
|
return itemstack
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local pointable_sources = {}
|
||||||
|
|
||||||
local function bucket_raycast(user)
|
local function bucket_raycast(user)
|
||||||
local pos = user:get_pos()
|
local pos = user:get_pos()
|
||||||
|
@ -80,7 +86,7 @@ local function bucket_raycast(user)
|
||||||
local ray = raycast(pos, pos2, false, true)
|
local ray = raycast(pos, pos2, false, true)
|
||||||
if ray then
|
if ray then
|
||||||
for pointed_thing in ray do
|
for pointed_thing in ray do
|
||||||
if pointed_thing and get_node_group(get_node(pointed_thing.above).name, "_mcl_bucket_pointable") == 1 then
|
if pointed_thing and pointable_sources[get_node(pointed_thing.above).name] then
|
||||||
--minetest.chat_send_all("found!")
|
--minetest.chat_send_all("found!")
|
||||||
return {under=pointed_thing.under,above=pointed_thing.above}
|
return {under=pointed_thing.under,above=pointed_thing.above}
|
||||||
end
|
end
|
||||||
|
@ -97,6 +103,7 @@ function mcl_buckets.register_liquid(def)
|
||||||
on_take = def.on_take,
|
on_take = def.on_take,
|
||||||
itemname = def.itemname,
|
itemname = def.itemname,
|
||||||
}
|
}
|
||||||
|
pointable_sources[source] = true
|
||||||
if type(def.source_place) == "string" then
|
if type(def.source_place) == "string" then
|
||||||
mcl_buckets.liquids[def.source_place] = mcl_buckets.liquids[source]
|
mcl_buckets.liquids[def.source_place] = mcl_buckets.liquids[source]
|
||||||
end
|
end
|
||||||
|
@ -137,7 +144,7 @@ function mcl_buckets.register_liquid(def)
|
||||||
node_place = def.source_place
|
node_place = def.source_place
|
||||||
end
|
end
|
||||||
-- Check if pointing to a buildable node
|
-- Check if pointing to a buildable node
|
||||||
local item = itemstack:get_name()
|
--local item = itemstack:get_name()
|
||||||
|
|
||||||
if def.extra_check and def.extra_check(place_pos, user) == false then
|
if def.extra_check and def.extra_check(place_pos, user) == false then
|
||||||
-- Fail placement of liquid
|
-- Fail placement of liquid
|
||||||
|
@ -308,7 +315,7 @@ minetest.register_craftitem("mcl_buckets:bucket_empty", {
|
||||||
return minetest.registered_nodes[nn].on_rightclick(pointed_thing.under, node, user, itemstack) or itemstack
|
return minetest.registered_nodes[nn].on_rightclick(pointed_thing.under, node, user, itemstack) or itemstack
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
local new_bucket
|
||||||
local liquid_node = bucket_raycast(user)
|
local liquid_node = bucket_raycast(user)
|
||||||
if liquid_node then
|
if liquid_node then
|
||||||
if minetest.is_protected(liquid_node.above, user:get_player_name()) then
|
if minetest.is_protected(liquid_node.above, user:get_player_name()) then
|
||||||
|
@ -318,7 +325,6 @@ minetest.register_craftitem("mcl_buckets:bucket_empty", {
|
||||||
if liquid_name then
|
if liquid_name then
|
||||||
local liquid_def = mcl_buckets.liquids[liquid_name]
|
local liquid_def = mcl_buckets.liquids[liquid_name]
|
||||||
if liquid_def then
|
if liquid_def then
|
||||||
local new_bucket
|
|
||||||
--minetest.chat_send_all("test")
|
--minetest.chat_send_all("test")
|
||||||
-- Fill bucket, but not in Creative Mode
|
-- Fill bucket, but not in Creative Mode
|
||||||
-- FIXME: remove this line
|
-- FIXME: remove this line
|
||||||
|
|
|
@ -3,7 +3,7 @@ local mod_mcl_core = minetest.get_modpath("mcl_core")
|
||||||
local mod_mclx_core = minetest.get_modpath("mclx_core")
|
local mod_mclx_core = minetest.get_modpath("mclx_core")
|
||||||
local has_awards = minetest.get_modpath("awards")
|
local has_awards = minetest.get_modpath("awards")
|
||||||
|
|
||||||
local sound_place = function(itemname, pos)
|
local function sound_place(itemname, pos)
|
||||||
local def = minetest.registered_nodes[itemname]
|
local def = minetest.registered_nodes[itemname]
|
||||||
if def and def.sounds and def.sounds.place then
|
if def and def.sounds and def.sounds.place then
|
||||||
minetest.sound_play(def.sounds.place, {gain=1.0, pos = pos, pitch = 1 + math.random(-10, 10)*0.005}, true)
|
minetest.sound_play(def.sounds.place, {gain=1.0, pos = pos, pitch = 1 + math.random(-10, 10)*0.005}, true)
|
||||||
|
|
|
@ -95,7 +95,7 @@ S("• When water is directly below lava, the water turns into stone."),
|
||||||
liquid_range = 7,
|
liquid_range = 7,
|
||||||
post_effect_color = {a=209, r=0x03, g=0x3C, b=0x5C},
|
post_effect_color = {a=209, r=0x03, g=0x3C, b=0x5C},
|
||||||
stack_max = 64,
|
stack_max = 64,
|
||||||
groups = { water=3, liquid=3, puts_out_fire=1, freezes=1, not_in_creative_inventory=1, dig_by_piston=1, _mcl_bucket_pointable=1},
|
groups = { water=3, liquid=3, puts_out_fire=1, freezes=1, not_in_creative_inventory=1, dig_by_piston=1},
|
||||||
_mcl_blast_resistance = 100,
|
_mcl_blast_resistance = 100,
|
||||||
-- Hardness intentionally set to infinite instead of 100 (Minecraft value) to avoid problems in creative mode
|
-- Hardness intentionally set to infinite instead of 100 (Minecraft value) to avoid problems in creative mode
|
||||||
_mcl_hardness = -1,
|
_mcl_hardness = -1,
|
||||||
|
@ -196,7 +196,7 @@ S("• When lava is directly above water, the water turns into stone."),
|
||||||
damage_per_second = 4*2,
|
damage_per_second = 4*2,
|
||||||
post_effect_color = {a=245, r=208, g=73, b=10},
|
post_effect_color = {a=245, r=208, g=73, b=10},
|
||||||
stack_max = 64,
|
stack_max = 64,
|
||||||
groups = { lava=3, lava_source=1, liquid=2, destroys_items=1, not_in_creative_inventory=1, dig_by_piston=1, set_on_fire=15, fire_damage=1, _mcl_bucket_pointable=1},
|
groups = { lava=3, lava_source=1, liquid=2, destroys_items=1, not_in_creative_inventory=1, dig_by_piston=1, set_on_fire=15, fire_damage=1},
|
||||||
_mcl_blast_resistance = 100,
|
_mcl_blast_resistance = 100,
|
||||||
-- Hardness intentionally set to infinite instead of 100 (Minecraft value) to avoid problems in creative mode
|
-- Hardness intentionally set to infinite instead of 100 (Minecraft value) to avoid problems in creative mode
|
||||||
_mcl_hardness = -1,
|
_mcl_hardness = -1,
|
||||||
|
|
Loading…
Reference in New Issue