Mehr Mods hinzugefügt

This commit is contained in:
N-Nachtigal 2025-05-10 23:49:11 +02:00
parent 92a55732cf
commit 9e345a25fb
2805 changed files with 2096013 additions and 0 deletions

49
mods/bows/api.txt Normal file
View file

@ -0,0 +1,49 @@
Here is an example of how to register a bow:
bows.register_bow("bow_wood",{
description = "Wooden bow",
texture = "bows_bow.png",
texture_loaded = "bows_bow_loaded.png",
uses = 50, -- How many time you can use a bow to shoot
level = 1, -- Higher levels mean faster arrows
-- Crafting recipe to make bow, can be left nil
craft = {
{"", "group:stick", "farming:string"},
{"group:stick", "", "farming:string"},
{"", "group:stick", "farming:string"}
},
})
Here is an example of how to register an arrow:
bows.register_arrow("arrow_steel",{
description = "Steel arrow",
-- Arrow texture, the ^[colorize section changes the default arrows colour
texture = "bows_arrow_wood.png^[colorize:#FFFFFFcc",
damage = 8, -- How many 1/2 hearts damage it can do
craft_count = 4, -- How many arrows are made from recipe below
craft = {
{"default:steel_ingot", "group:stick", bows.feather}
},
-- Special function when an entity or mob is hit
on_hit_object = function(self, target, hp, user, lastpos)
if target:get_luaentity().name == "mob_horse:horse" then
print ("--- aww da horsey!!! " .. hp .. " damage points!")
end
end,
-- Special function when arrow hits a node
on_hit_node = function(self, pos, user, arrow_pos)
if self.node.name == "default:glass" then
minetest.sound_play("default_break_glass", {
pos = pos, gain = 1.0, max_hear_distance = 10})
minetest.remove_node(pos)
minetest.add_item(pos, "vessels:glass_fragments")
end
end,
})

157
mods/bows/arrow.lua Normal file
View file

@ -0,0 +1,157 @@
local math_random = math.random
-- helper to remove or maybe drop arrow item
local function on_hit_remove(self)
core.sound_play(
bows.registered_arrows[self.name].on_hit_sound, {
pos = self.object:get_pos(),
gain = 1.0,
max_hear_distance = 12
}, true)
-- chance of dropping arrow
local chance = core.registered_items[self.name].drop_chance or 10
local pos = self.object:get_pos()
if pos and math_random(chance) == 1 then
pos.y = pos.y + 0.5
core.add_item(pos, self.name)
end
self.object:remove()
return self
end
-- when arrow hits an entity
local function on_hit_object(self, target, hp, user, lastpos)
target:punch(user, 1.0, {
--full_punch_interval = 1.0,
damage_groups = {fleshy = hp},
}, nil)
if bows.registered_arrows[self.name].on_hit_object then
bows.registered_arrows[self.name].on_hit_object(
self, target, hp, user, lastpos)
end
on_hit_remove(self)
return self
end
-- arrow entity
core.register_entity("bows:arrow",{
initial_properties = {
hp_max = 10,
visual = "wielditem",
visual_size = {x = .20, y = .20},
collisionbox = {-0.1, -0.1, -0.1, 0.1, 0.1, 0.1},
physical = false,
textures = {"air"}
},
_is_arrow = true,
timer = 10,
on_activate = function(self, staticdata)
if not self then
self.object:remove() ; return
end
if bows.tmp and bows.tmp.arrow ~= nil then
self.arrow = bows.tmp.arrow
self.user = bows.tmp.user
self.name = bows.tmp.name
self.dmg = bows.registered_arrows[self.name].damage
bows.tmp = nil
self.object:set_properties({textures = {self.arrow}})
else
self.object:remove()
end
end,
on_step = function(self, dtime, ...)
self.timer = self.timer - dtime
if self.timer < 0 then
self.object:remove() ; return
end
local pos = self.object:get_pos() ; self.oldpos = self.oldpos or pos
local cast = core.raycast(self.oldpos, pos, true, true)
local thing = cast:next()
local ok = true
-- loop through things
while thing do
-- ignore the object that is the arrow
if thing.type == "object" and thing.ref ~= self.object then
-- add entity name to thing table (if not player)
if not thing.ref:is_player() then
thing.name = thing.ref:get_luaentity() and thing.ref:get_luaentity().name
end
-- check if dropped item or yourself
if thing.name == "__builtin:item"
or (not thing.name
and thing.ref:get_player_name() == self.user:get_player_name()) then
ok = false
end
-- can we hit entity ?
if ok then
--print("-- hit entity", thing.name)
on_hit_object(self, thing.ref, self.dmg, self.user, pos)
return self
end
-- are we inside a node ?
elseif thing.type == "node" then
self.node = core.get_node(pos)
local def = core.registered_nodes[self.node.name]
if def and def.walkable then
--print("-- hit node", self.node.name)
if bows.registered_arrows[self.name].on_hit_node then
bows.registered_arrows[self.name].on_hit_node(
self, pos, self.user, self.oldpos)
end
on_hit_remove(self)
return self
end
end
thing = cast:next()
end
self.oldpos = pos
end
})

185
mods/bows/init.lua Normal file
View file

@ -0,0 +1,185 @@
-- Bows Mod by UjEdwin (edited by TenPlus1)
bows = {
pvp = core.settings:get_bool("enable_pvp"),
registered_arrows = {},
registered_bows = {}
}
-- creative check
local creative_mode_cache = core.settings:get_bool("creative_mode")
function bows.is_creative(name)
return creative_mode_cache or core.check_player_privs(name, {creative = true})
end
-- register arrow
function bows.register_arrow(name, def)
if name == nil or name == "" then
return false
end
def.damage = def.damage or 0
def.name = "bows:" .. name
def.level = def.level or 1
def.on_hit_object = def.on_hit_object
def.on_hit_node = def.on_hit_node
def.on_hit_sound = def.on_hit_sound or "default_dig_dig_immediate"
bows.registered_arrows[def.name] = def
core.register_craftitem(":bows:" .. name, {
description = def.description or name,
inventory_image = def.texture or "bows_arrow_wooden.png",
groups = {arrow = 1},
drop_chance = def.drop_chance
})
if def.craft then
core.register_craft({
output = def.name .." " .. (def.craft_count or 4),
recipe = def.craft
})
end
end
-- register bow
function bows.register_bow(name, def)
if name == nil or name == "" then
return false
end
def.replace = "bows:" .. name .. "_loaded"
def.name = "bows:" .. name
def.uses = def.uses - 1 or 49
bows.registered_bows[def.replace] = def
core.register_tool(":" .. def.name, {
description = def.description or name,
inventory_image = def.texture or "bows_bow.png",
on_use = bows.load,
groups = {bow = 1}
})
core.register_tool(":" .. def.replace, {
description = def.description or name,
inventory_image = def.texture_loaded or "bows_bow_loaded.png",
on_use = bows.shoot,
groups = {bow = 1, not_in_creative_inventory = 1}
})
if def.craft then
core.register_craft({output = def.name,recipe = def.craft})
end
end
-- load bow
function bows.load(itemstack, user, pointed_thing)
local inv = user:get_inventory()
local index = user:get_wield_index() - 1
local arrow = inv:get_stack("main", index)
if core.get_item_group(arrow:get_name(), "arrow") == 0 then
return itemstack
end
local item = itemstack:to_table()
local meta = core.deserialize(item.metadata)
meta = {arrow = arrow:get_name()}
item.metadata = core.serialize(meta)
item.name = item.name .. "_loaded"
itemstack:replace(item)
if not bows.is_creative(user:get_player_name()) then
inv:set_stack("main", index,
ItemStack(arrow:get_name() .. " " .. (arrow:get_count() - 1)))
end
return itemstack
end
-- shoot bow
function bows.shoot(itemstack, user, pointed_thing)
local item = itemstack:to_table()
local meta = core.deserialize(item.metadata)
if (not (meta and meta.arrow))
or (not bows.registered_arrows[meta.arrow]) then
return itemstack
end
local name = itemstack:get_name()
local replace = bows.registered_bows[name].name
local ar = bows.registered_bows[name].uses
local wear = bows.registered_bows[name].uses
local level = 19 + bows.registered_bows[name].level
bows.tmp = {}
bows.tmp.arrow = meta.arrow
bows.tmp.user = user
bows.tmp.name = meta.arrow
item.arrow = ""
item.metadata = core.serialize(meta)
item.name = replace
itemstack:replace(item)
local prop = user:get_properties()
local pos = user:get_pos() ; pos.y = pos.y + (prop.eye_height or 1.23)
local dir = user:get_look_dir()
local is_attached = user:get_attach()
-- if player riding a mob then increase arrow height so you dont hit mob
if is_attached then
local prop = is_attached:get_properties()
local height = prop and (-prop.collisionbox[2] + prop.collisionbox[5]) or 1
pos.y = pos.y + height
end
local e = core.add_entity({x = pos.x, y = pos.y, z = pos.z}, "bows:arrow")
e:set_velocity({x = dir.x * level, y = dir.y * level, z = dir.z * level})
e:set_acceleration({x = dir.x * -3, y = -10, z = dir.z * -3})
e:set_yaw(user:get_look_horizontal() - math.pi/2)
if not bows.is_creative(user:get_player_name()) then
itemstack:add_wear(65535 / wear)
end
core.sound_play("bows_shoot", {pos = pos, max_hear_distance = 10}, true)
return itemstack
end
-- register items
local path = core.get_modpath("bows")
dofile(path .. "/arrow.lua")
dofile(path .. "/items.lua")
-- add lucky blocks
if core.get_modpath("lucky_block") then
dofile(path .. "/lucky_block.lua")
end
print ("[MOD] Bows loaded")

196
mods/bows/items.lua Normal file
View file

@ -0,0 +1,196 @@
local S = core.get_translator("bows")
-- detect feather item to use
local feather = "default:leaves"
if core.get_modpath("animalia") then
feather = "animalia:feather"
elseif core.get_modpath("mobs_animal") then
feather = "mobs:chicken_feather"
elseif core.get_modpath("xanadu") then
feather = "mobs:chicken_feather"
end
-- helpful recipes
core.register_craft({
output = "default:flint",
recipe = {{"default:gravel"}}
})
core.register_craft({
output = "farming:cotton 4",
recipe = {{"group:wool"}}
})
-- wooden bow
bows.register_bow("bow_wood",{
description = S("Wooden bow"),
texture = "bows_bow.png",
texture_loaded = "bows_bow_loaded.png",
uses = 50,
level = 1,
craft = {
{"", "group:stick", "farming:string"},
{"group:stick", "", "farming:string"},
{"", "group:stick", "farming:string"}
}
})
core.register_craft({
type = "fuel",
recipe = "bows:bow_wood",
burntime = 3
})
-- steel bow
bows.register_bow("bow_steel",{
description = S("Steel bow"),
texture = "bows_bow_steel.png",
texture_loaded = "bows_bow_loaded_steel.png",
uses = 280,
level = 5,
craft = {
{"", "default:steel_ingot", "farming:string"},
{"default:steel_ingot", "", "farming:string"},
{"", "default:steel_ingot", "farming:string"}
}
})
-- bronze bow
bows.register_bow("bow_bronze",{
description = S("Bronze bow"),
texture = "bows_bow_bronze.png",
texture_loaded = "bows_bow_loaded_bronze.png",
uses = 140,
level = 3,
craft = {
{"", "default:bronze_ingot", "farming:string"},
{"default:bronze_ingot", "", "farming:string"},
{"", "default:bronze_ingot", "farming:string"}
}
})
-- special David BOWie (lucky block drop)
bows.register_bow("bow_bowie",{
description = S("David BOWie"),
texture = "bows_bow_bowie.png",
texture_loaded = "bows_bow_loaded_bowie.png",
uses = 500,
level = 7
})
-- wooden arrow
bows.register_arrow("arrow",{
description = S("Wooden arrow"),
texture = "bows_arrow_wood.png",
damage = 2,
craft_count = 4,
drop_chance = 10,
craft = {
{"default:flint", "group:stick", feather}
},
on_hit_sound = "bows_arrow_hit",
--[[
on_hit_node = function(self, pos, user, arrow_pos)
core.add_particle({
pos = pos,
velocity = {x=0, y=0, z=0},
acceleration = {x=0, y=0, z=0},
expirationtime = 1,
size = 4,
collisiondetection = false,
vertical = false,
texture = "heart.png",
})
end]]
})
core.register_craft({
type = "fuel",
recipe = "bows:arrow",
burntime = 1
})
-- steel arrow
bows.register_arrow("arrow_steel",{
description = S("Steel arrow"),
texture = "bows_arrow_wood.png^[colorize:#FFFFFFcc",
damage = 6,
craft_count = 4,
drop_chance = 9,
craft = {
{"default:steel_ingot", "group:stick", feather}
},
on_hit_sound = "bows_arrow_hit",
--[[
on_hit_object = function(self, target, hp, user, lastpos)
if target
and target:get_luaentity()
and target:get_luaentity().name
and target:get_luaentity().name == "mob_horse:horse" then
print ("--- aww da horsey!!!")
end
end,]]
on_hit_node = function(self, pos, user, arrow_pos)
end
})
-- mese arrow (enables node mesecons when hit)
bows.register_arrow("arrow_mese",{
description = S("Mese arrow"),
texture = "bows_arrow_wood.png^[colorize:#e3ff00cc",
damage = 7,
craft_count = 4,
drop_chance = 8,
craft = {
{"default:mese_crystal", "group:stick", feather}
},
on_hit_sound = "bows_arrow_hit",
on_hit_node = function(self, pos, user, arrow_pos)
if self.node.name == "mesecons_switch:mesecon_switch_on"
or self.node.name == "mesecons_switch:mesecon_switch_off" then
local def = core.registered_nodes[self.node.name]
-- This toggles the mesecons switch on/off
if def and def.on_rightclick then
def.on_rightclick(vector.round(pos), self.node, user)
end
end
end
})
-- diamond arrow (breaks glass node when hit)
bows.register_arrow("arrow_diamond",{
description = S("Diamond arrow"),
texture = "bows_arrow_wood.png^[colorize:#15d7c2cc",
damage = 8,
craft_count = 4,
drop_chance = 7,
craft = {
{"default:diamond", "group:stick", feather}
},
on_hit_sound = "bows_arrow_hit",
on_hit_node = function(self, pos, user, arrow_pos)
if self.node.name == "default:glass"
and not core.is_protected(pos, user:get_player_name()) then
core.sound_play("default_break_glass", {
pos = pos, gain = 1.0, max_hear_distance = 10}, true)
core.remove_node(pos)
core.add_item(pos, "vessels:glass_fragments")
end
end
})

21
mods/bows/license.txt Normal file
View file

@ -0,0 +1,21 @@
Code by AiTechEye and edited by TenPlus1 (LGPL-2.1-only)
Textures by AiTechEye (CC0)
bows_arrow_wood.png
bows_bow.png
bows_bow_bronze.png
bows_bow_loaded.png
bows_bow_loaded_bronze.png
bows_bow_loaded_steel.png
bows_bow_steel.png
Textures by TenPlus1 (CC0)
bows_bow_bowie.png
bows_bow_loaded_bowie.png
Sound by cmusounddesign (Attribution 3.0 license):
bows_shoot.ogg
Sound by robinhoot76 https://freesound.org (Creative Common License):
bows_arrow_hit.ogg

View file

@ -0,0 +1,11 @@
# textdomain: bows
Wooden bow=
Steel bow=
Bronze bow=
David BOWie=
Wooden arrow=
Steel arrow=
Mese arrow=
Diamond arrow=
You took an arrow to the knee!

45
mods/bows/lucky_block.lua Normal file
View file

@ -0,0 +1,45 @@
local S = core.get_translator("bows")
-- custom lb function
local function arrow_to_knee(pos, player)
local ppos = player:get_pos()
player:punch(player, 1.0, {
full_punch_interval = 1.0,
damage_groups = {fleshy = 6}
}, nil)
core.sound_play("player_damage",
{pos = ppos, gain = 1.0, max_hear_distance = 10}, true)
core.chat_send_player(player:get_player_name(),
lucky_block.green .. S("You took an arrow to the knee!"))
core.add_item(ppos, "bows:arrow_steel")
end
-- add lucky blocks
lucky_block:add_blocks({
{"cus", arrow_to_knee},
{"dro", {"bows:bow_wood"}},
{"dro", {"bows:bow_steel"}},
{"dro", {"bows:bow_bronze"}},
{"dro", {"bows:arrow"}, 10},
{"dro", {"bows:arrow_steel"}, 8},
{"dro", {"bows:arrow_mese"}, 7},
{"dro", {"bows:arrow_diamond"}, 6},
{"nod", "default:chest", 0, {
{name = "default:stick", max = 5},
{name = "default:flint", max = 5},
{name = "default:steel_ingot", max = 5},
{name = "default:bronze_ingot", max = 5},
{name = "default:mese_crystal_fragment", max = 5},
{name = "farming:string", max = 5},
{name = bows.feather, max = 5},
{name = "bows:bow_bowie", max = 1, chance = 5}
}}
})

8
mods/bows/mod.conf Normal file
View file

@ -0,0 +1,8 @@
name = bows
description = Adds a selection of bows and arrows for players to use.
depends = default
optional_depends = lucky_block
min_minetest_version = 5.0
release = 30928
author = TenPlus1
title = Bows

14
mods/bows/readme.MD Normal file
View file

@ -0,0 +1,14 @@
# Bows Mod for Minetest
### Originally by AiTechEye
### Forked and tweaked by TenPlus1
This mod allows the player to craft bows and arrows to be used in game that can hurt players and mobs as well as affect nodes hit when using special functions included in the arrow definition.
Stack arrows you wish to use on the left side of the bow.
License: CC0
Lucky blocks: 9

BIN
mods/bows/screenshot.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 197 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 322 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 179 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 307 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 375 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 202 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 360 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 391 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 296 B