Initial commit.

This commit is contained in:
SFENCE 2022-10-17 18:43:02 +02:00
commit 7068c46c2f
10 changed files with 234 additions and 0 deletions

33
LICENSE Normal file
View File

@ -0,0 +1,33 @@
License of source code
----------------------
The MIT License (MIT)
Copyright (c) 2022 SFENCE <sfence.software@gmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
===================================
Licenses of media
-----------------
The Creative Common License (CC BY-SA 4.0)
This work is licensed under the Creative Commons Attribution-ShareAlike 4.0 International License. To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/4.0/ or send a letter to Creative Commons, PO Box 1866, Mountain View, CA 94042, USA.

17
README.md Normal file
View File

@ -0,0 +1,17 @@
Minetest mod: `feed_buckets`
========================
Add buckets of feeds which can be used to feed up to 8 nearby animals.
Source code:
-----------------------
Copyright (c) 2022 SFENCE
MIT - check LICENSE file
License of media (textures, sounds and models):
-----------------------------------------------
CC BY-SA 4.0 - check LICENSE file
Copyright (c) 2022 Sinky (CC BY-SA 4.0):
All textures not mentioned below.

10
adaptation.lua Normal file
View File

@ -0,0 +1,10 @@
feed_buckets.adaptation = {}
adaptation = feed_buckets.adaptation
adaptation.bucket_empty = adaptation_lib.get_item("bucket_empty")
adaptation.wheat_seed = adaptation_lib.get_item("seed_wheat")
adaptation.seagrass = adaptation_lib.get_item("seagrass")

96
feed_buckets.lua Normal file
View File

@ -0,0 +1,96 @@
local adaptation = feed_buckets.adaptation
if (not adaptation.bucket_empty) then
minetest.log("error", "[feed_buckets] Feed buckets: No empty bucket definition was found.")
return
end
local bucket_empty = adaptation.bucket_empty.name
if minetest.get_modpath("hades_aquaz") then
minetest.register_craftitem("feed_buckets:bucket_algae_feed", {
description = "Bucket Of Algae Feed",
_tt_help = "Use it to feed up to 8 nearby fishes (up to 4 nodes) poitned entity or node.",
inventory_image = "feed_buckets_bucket_algae_feed.png",
groups = {
algae = 1,
},
_feed_bucket = {
max_distance = 4,
max_feeds = 8,
feed_item = "hades_aquaz:algae_feed",
empty_item = bucket_empty,
},
on_use = feed_buckets.use_bucket_of_feed_from_def,
on_place = feed_buckets.use_bucket_of_feed_from_def,
on_secondary_use = feed_bucekts.use_bucket_of_feed_from_def,
})
minetest.register_craft({
output = "feed_buckets:bucket_algae_feed",
recipe = {
{"hades_aquaz:algae_feed", "hades_aquaz:algae_feed", "hades_aquaz:algae_feed"},
{"hades_aquaz:algae_feed", "hades_aquaz:algae_feed", "hades_aquaz:algae_feed"},
{"hades_aquaz:algae_feed", bucket_empty, "hades_aquaz:algae_feed"},
},
})
end
if adaptation.seagrass then
local seagrass = adaptation.seagrass.name
minetest.register_craftitem("feed_buckets:bucket_seagrass", {
description = "Bucket Of Sea Grass",
_tt_help = "Use it to feed up to 8 nearby mobs (up to 4 nodes) poitned entity or node.",
inventory_image = "feed_buckets_bucket_seagrass.png",
groups = {
algae = 1,
},
_feed_bucket = {
max_distance = 4,
max_feeds = 8,
feed_item = seagrass,
empty_item = bucket_empty,
},
on_use = feed_buckets.use_bucket_of_feed_from_def,
on_place = feed_buckets.use_bucket_of_feed_from_def,
on_secondary_use = feed_bucekts.use_bucket_of_feed_from_def,
})
minetest.register_craft({
output = "feed_buckets:bucket_seagrass",
recipe = {
{seagrass, seagrass, seagrass},
{seagrass, seagrass, seagrass},
{seagrass, bucket_empty, seagrass},
},
})
end
if adaptation.wheat_seed then
local wheat_seed = adaptation.wheat_seed.name
minetest.register_craftitem("feed_buckets:bucket_wheat_seeds", {
description = "Bucket Of Wheat Seeds",
_tt_help = "Use it to feed up to 8 fishes nearby (up to 4 nodes) poitned entity or node.",
inventory_image = "feed_buckets_bucket_wheat_seeds.png",
groups = {
algae = 1,
},
_feed_bucket = {
max_distance = 4,
max_feeds = 8,
feed_item = wheat_seed,
empty_item = bucket_empty,
},
on_use = feed_buckets.use_bucket_of_feed_from_def,
on_place = feed_buckets.use_bucket_of_feed_from_def,
on_secondary_use = feed_buckets.use_bucket_of_feed_from_def,
})
minetest.register_craft({
output = "feed_buckets:bucket_wheat_seeds",
recipe = {
{wheat_seed, wheat_seed, wheat_seed},
{wheat_seed, wheat_seed, wheat_seed},
{wheat_seed, bucket_empty, wheat_seed},
},
})
end

61
functions.lua Normal file
View File

@ -0,0 +1,61 @@
local function check_follow(follow, feed_item)
for _,follow_item in pairs(follow) do
if (follow_item==feed_item) then
return true
elseif (follow_item:sub(1, 6)=="group:") then
if (minetest.get_item_group(feed_item, follow_item:sub(7))>0) then
return true
end
end
end
return false
end
function feed_buckets.use_bucket_of_feed(itemstack, user, pointed_thing, feed_data)
local feed_pos = user:get_pos()
if (pointed_thing.type=="node") then
feed_pos = pointed_thing.under
elseif (pointed_thing.type=="object") then
feed_pos = pointed_thing.ref:get_pos()
end
local objects = minetest.get_objects_inside_radius(feed_pos, feed_data.max_distance)
local feeds = 0
for _,object in pairs(objects) do
local luaentity = object:get_luaentity()
if luaentity and (luaentity.follow) then
local follow = luaentity.follow
if (type(follow)=="string") then
follow = string.split(follow, ",")
end
if check_follow(follow, feed_data.feed_item) then
user:set_wielded_item(ItemStack(feed_data.feed_item))
luaentity:on_rightclick(user)
feeds = feeds + 1
end
end
if feeds>=feed_data.max_feeds then
break
end
end
if (feeds>0) then
itemstack:take_item(1)
local inv = user:get_inventory()
local empty = inv:add_item("main", ItemStack(feed_data.empty_item))
if (empty:get_count()>0) then
minetest.add_item(user:get_pos(), empty)
end
end
return itemstack
end
function feed_buckets.use_bucket_of_feed_from_def(itemstack, user, pointed_thing, feed_data)
local def = itemstack:get_definition()
return feed_buckets.use_bucket_of_feed(itemstack, user, pointed_thing, def._feed_bucket)
end

13
init.lua Normal file
View File

@ -0,0 +1,13 @@
feed_buckets = {
translator = minetest.get_translator("feed_bucket")
}
local modpath = minetest.get_modpath(minetest.get_current_modname())
dofile(modpath.."/adaptation.lua")
dofile(modpath.."/functions.lua")
dofile(modpath.."/feed_buckets.lua")

4
mod.conf Normal file
View File

@ -0,0 +1,4 @@
name = feed_buckets
title = Bucket of feeds for easier feeding.
depends = adaptation_lib, adaptation_minetest_game, adaptation_hades_revisited, adaptation_mineclone, adaptation_hades_extensionmods, adaptation_farming_redo, adaptation_xocean
optional_depends = hades_aquaz, farming, hades_farming, mcl_farming

Binary file not shown.

After

Width:  |  Height:  |  Size: 297 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 287 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 305 B