refactor fish bucket code to not use bucket api
it was clearly not made for this
This commit is contained in:
parent
9cf910c47f
commit
dd58bed5d1
|
@ -120,37 +120,57 @@ minetest.register_craft({
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Fish Buckets
|
-- Fish Buckets
|
||||||
fish_names = {
|
local fish_names = {
|
||||||
{ techname = "cod", name = "Cod" },
|
["cod"] = "Cod",
|
||||||
{ techname = "salmon", name = "Salmon" },
|
["salmon"] = "Salmon",
|
||||||
{ techname = "axolotl", name = "Axolotl" },
|
["tropical_fish"] = "Tropical Fish",
|
||||||
--{ techname = "pufferfish", name = "Pufferfish" } FIXME: Uncomment when pufferfish mobs are added.
|
["axolotl"] = "Axolotl",
|
||||||
{ techname = "tropical_fish", name = "Tropical Fish" }
|
--["pufferfish"] = "Pufferfish", --FIXME add pufferfish
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, fish in pairs(fish_names) do
|
local fishbucket_prefix = "mcl_buckets:bucket_"
|
||||||
mcl_buckets.register_liquid({
|
|
||||||
bucketname = "mcl_buckets:bucket_" .. fish.techname,
|
local function on_place_fish(itemstack, placer, pointed_thing)
|
||||||
source_place = function(pos)
|
local pos = pointed_thing.above
|
||||||
minetest.add_entity(pos, "mobs_mc:" .. fish.techname)
|
local n = minetest.get_node_or_nil(pos)
|
||||||
return "mcl_core:water_source"
|
if n and minetest.registered_nodes[n.name].buildable_to or n.name == "mcl_portals:portal" then
|
||||||
end,
|
local fish = itemstack:get_name():gsub(fishbucket_prefix,"")
|
||||||
source_take = {"mobs_mc:" .. fish.techname},
|
if fish_names[fish] then
|
||||||
inventory_image = fish.techname .. "_bucket.png",
|
local o = minetest.add_entity(pos, "mobs_mc:" .. fish)
|
||||||
name = S("Bucket of @1", S(fish.name)),
|
minetest.set_node(pos,{name = "mcl_core:water_source"})
|
||||||
longdesc = S("This bucket is filled with water and @1.", S(fish.name)),
|
if not minetest.is_creative_enabled(placer:get_player_name()) then
|
||||||
usagehelp = S("Place it to empty the bucket and place a @1. Obtain by right clicking on a @2 with a bucket of water.", S(fish.name), S(fish.name)),
|
itemstack:set_name("mcl_buckets:bucket_empty")
|
||||||
tt_help = S("Places a water source and a @1.", S(fish.name)),
|
|
||||||
extra_check = function(pos, placer)
|
|
||||||
local dim = mcl_worlds.pos_to_dimension(pos)
|
|
||||||
if dim == "nether" then
|
|
||||||
minetest.sound_play("fire_extinguish_flame", {pos = pos, gain = 0.25, max_hear_distance = 16}, true)
|
|
||||||
return false, true
|
|
||||||
else
|
|
||||||
return true, true
|
|
||||||
end
|
end
|
||||||
end,
|
end
|
||||||
})
|
end
|
||||||
minetest.register_alias("mcl_fishing:bucket_" .. fish.techname, "mcl_buckets:bucket_" .. fish.techname)
|
return itemstack
|
||||||
end
|
end
|
||||||
|
|
||||||
|
for techname, fishname in pairs(fish_names) do
|
||||||
|
minetest.register_craftitem(fishbucket_prefix .. techname, {
|
||||||
|
description = S("Bucket of @1", S(fishname)),
|
||||||
|
_doc_items_longdesc = S("This bucket is filled with water and @1.", S(fishname)),
|
||||||
|
_doc_items_usagehelp = S("Place it to empty the bucket and place a @1. Obtain by right clicking on a @2 with a bucket of water.", S(fishname), S(fishname)),
|
||||||
|
_tt_help = S("Places a water source and a @1.", S(fishname)),
|
||||||
|
inventory_image = techname .. "_bucket.png",
|
||||||
|
stack_max = 1,
|
||||||
|
groups = {bucket = 1, fish_bucket = 1},
|
||||||
|
liquids_pointable = false,
|
||||||
|
on_place = on_place_fish,
|
||||||
|
on_secondary_use = on_place_fish,
|
||||||
|
_on_dispense = function(stack, pos, droppos, dropnode, dropdir)
|
||||||
|
local buildable = registered_nodes[dropnode.name].buildable_to or dropnode.name == "mcl_portals:portal"
|
||||||
|
if not buildable then return stack end
|
||||||
|
local result, take_bucket = get_extra_check(def.extra_check, droppos, nil)
|
||||||
|
if result then -- Fail placement of liquid if result is false
|
||||||
|
place_liquid(droppos, get_node_place(def.source_place, droppos))
|
||||||
|
end
|
||||||
|
if take_bucket then
|
||||||
|
stack:set_name("mcl_buckets:bucket_empty")
|
||||||
|
end
|
||||||
|
return stack
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
minetest.register_alias("mcl_fishing:bucket_" .. techname, "mcl_buckets:bucket_" .. techname)
|
||||||
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user