From 7afbceb78216e9d5b83e67f94fe1c4510d241872 Mon Sep 17 00:00:00 2001 From: Andrea Plati Date: Mon, 9 Mar 2015 18:52:56 +0100 Subject: [PATCH] First commit, as of 0.9 --- README.txt | 35 +++ bows.lua | 114 +++++++++ build_arrow.lua | 92 +++++++ depends.txt | 5 + diamond_arrow.lua | 80 ++++++ dig_arrow.lua | 77 ++++++ fire_arrow.lua | 114 +++++++++ init.lua | 28 +++ obsidian_arrow.lua | 80 ++++++ sounds/throwing_sound.ogg | Bin 0 -> 11011 bytes steel_arrow.lua | 80 ++++++ stone_arrow.lua | 80 ++++++ teleport_arrow.lua | 82 ++++++ textures/throwing_arrow_build.png | Bin 0 -> 203 bytes textures/throwing_arrow_build_2.png | Bin 0 -> 201 bytes textures/throwing_arrow_build_back.png | Bin 0 -> 213 bytes textures/throwing_arrow_build_front.png | Bin 0 -> 178 bytes textures/throwing_arrow_diamond.png | Bin 0 -> 196 bytes textures/throwing_arrow_diamond_2.png | Bin 0 -> 201 bytes textures/throwing_arrow_diamond_back.png | Bin 0 -> 210 bytes textures/throwing_arrow_diamond_front.png | Bin 0 -> 176 bytes textures/throwing_arrow_dig.png | Bin 0 -> 200 bytes textures/throwing_arrow_dig_2.png | Bin 0 -> 208 bytes textures/throwing_arrow_dig_back.png | Bin 0 -> 215 bytes textures/throwing_arrow_dig_front.png | Bin 0 -> 178 bytes textures/throwing_arrow_fire.png | Bin 0 -> 266 bytes textures/throwing_arrow_fire_2.png | Bin 0 -> 266 bytes textures/throwing_arrow_fire_back.png | Bin 0 -> 268 bytes textures/throwing_arrow_fire_front.png | Bin 0 -> 306 bytes textures/throwing_arrow_obsidian.png | Bin 0 -> 192 bytes textures/throwing_arrow_obsidian_2.png | Bin 0 -> 191 bytes textures/throwing_arrow_obsidian_back.png | Bin 0 -> 204 bytes textures/throwing_arrow_obsidian_front.png | Bin 0 -> 170 bytes textures/throwing_arrow_steel.png | Bin 0 -> 195 bytes textures/throwing_arrow_steel_2.png | Bin 0 -> 193 bytes textures/throwing_arrow_steel_back.png | Bin 0 -> 209 bytes textures/throwing_arrow_steel_front.png | Bin 0 -> 177 bytes textures/throwing_arrow_stone.png | Bin 0 -> 201 bytes textures/throwing_arrow_stone_2.png | Bin 0 -> 195 bytes textures/throwing_arrow_stone_back.png | Bin 0 -> 213 bytes textures/throwing_arrow_stone_front.png | Bin 0 -> 178 bytes textures/throwing_arrow_teleport.png | Bin 0 -> 196 bytes textures/throwing_arrow_teleport_2.png | Bin 0 -> 201 bytes textures/throwing_arrow_teleport_back.png | Bin 0 -> 207 bytes textures/throwing_arrow_teleport_front.png | Bin 0 -> 176 bytes textures/throwing_arrow_tnt.png | Bin 0 -> 200 bytes textures/throwing_arrow_tnt_2.png | Bin 0 -> 200 bytes textures/throwing_arrow_tnt_back.png | Bin 0 -> 211 bytes textures/throwing_arrow_tnt_front.png | Bin 0 -> 177 bytes textures/throwing_arrow_torch.png | Bin 0 -> 200 bytes textures/throwing_arrow_torch_2.png | Bin 0 -> 200 bytes textures/throwing_arrow_torch_back.png | Bin 0 -> 212 bytes textures/throwing_arrow_torch_front.png | Bin 0 -> 178 bytes textures/throwing_bow_composite.png | Bin 0 -> 579 bytes textures/throwing_bow_steel.png | Bin 0 -> 576 bytes textures/throwing_bow_wood.png | Bin 0 -> 484 bytes textures/throwing_empty.png | Bin 0 -> 178 bytes tnt_arrow.lua | 279 +++++++++++++++++++++ torch_arrow.lua | 80 ++++++ 59 files changed, 1226 insertions(+) create mode 100644 README.txt create mode 100644 bows.lua create mode 100644 build_arrow.lua create mode 100644 depends.txt create mode 100644 diamond_arrow.lua create mode 100644 dig_arrow.lua create mode 100644 fire_arrow.lua create mode 100644 init.lua create mode 100644 obsidian_arrow.lua create mode 100644 sounds/throwing_sound.ogg create mode 100644 steel_arrow.lua create mode 100644 stone_arrow.lua create mode 100644 teleport_arrow.lua create mode 100644 textures/throwing_arrow_build.png create mode 100644 textures/throwing_arrow_build_2.png create mode 100644 textures/throwing_arrow_build_back.png create mode 100644 textures/throwing_arrow_build_front.png create mode 100644 textures/throwing_arrow_diamond.png create mode 100644 textures/throwing_arrow_diamond_2.png create mode 100644 textures/throwing_arrow_diamond_back.png create mode 100644 textures/throwing_arrow_diamond_front.png create mode 100644 textures/throwing_arrow_dig.png create mode 100644 textures/throwing_arrow_dig_2.png create mode 100644 textures/throwing_arrow_dig_back.png create mode 100644 textures/throwing_arrow_dig_front.png create mode 100644 textures/throwing_arrow_fire.png create mode 100644 textures/throwing_arrow_fire_2.png create mode 100644 textures/throwing_arrow_fire_back.png create mode 100644 textures/throwing_arrow_fire_front.png create mode 100644 textures/throwing_arrow_obsidian.png create mode 100644 textures/throwing_arrow_obsidian_2.png create mode 100644 textures/throwing_arrow_obsidian_back.png create mode 100644 textures/throwing_arrow_obsidian_front.png create mode 100644 textures/throwing_arrow_steel.png create mode 100644 textures/throwing_arrow_steel_2.png create mode 100644 textures/throwing_arrow_steel_back.png create mode 100644 textures/throwing_arrow_steel_front.png create mode 100644 textures/throwing_arrow_stone.png create mode 100644 textures/throwing_arrow_stone_2.png create mode 100644 textures/throwing_arrow_stone_back.png create mode 100644 textures/throwing_arrow_stone_front.png create mode 100644 textures/throwing_arrow_teleport.png create mode 100644 textures/throwing_arrow_teleport_2.png create mode 100644 textures/throwing_arrow_teleport_back.png create mode 100644 textures/throwing_arrow_teleport_front.png create mode 100644 textures/throwing_arrow_tnt.png create mode 100644 textures/throwing_arrow_tnt_2.png create mode 100644 textures/throwing_arrow_tnt_back.png create mode 100644 textures/throwing_arrow_tnt_front.png create mode 100644 textures/throwing_arrow_torch.png create mode 100644 textures/throwing_arrow_torch_2.png create mode 100644 textures/throwing_arrow_torch_back.png create mode 100644 textures/throwing_arrow_torch_front.png create mode 100644 textures/throwing_bow_composite.png create mode 100644 textures/throwing_bow_steel.png create mode 100644 textures/throwing_bow_wood.png create mode 100644 textures/throwing_empty.png create mode 100644 tnt_arrow.lua create mode 100644 torch_arrow.lua diff --git a/README.txt b/README.txt new file mode 100644 index 0000000..b4b9d44 --- /dev/null +++ b/README.txt @@ -0,0 +1,35 @@ +=== THROWING ENHANCED for MINETEST === + +Inroduction: +This mod adds many bows and arrows to Minetest. +It began as a fork of PilzAdam's throwing mod with some enhancements from me. Enjoy! +Echoes91 + +How to install: +http://wiki.minetest.com/wiki/Installing_Mods + +How to use the mod: +Select the bow and place the arrows into the slot next to it; shoot with left mouse click. +Every shoot will take 1 arrow from your inventory and wears out the bow. + +License: +This mod was originally published by Jeija and reworked by PilzAdam +Sourcecode: WTFPL (see below) +Grahpics & sounds: WTFPL (see below) + +See also: +http://minetest.net/ + + DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + Version 2, December 2004 + + Copyright (C) 2004 Sam Hocevar + + Everyone is permitted to copy and distribute verbatim or modified + copies of this license document, and changing it is allowed as long + as the name is changed. + + DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. You just DO WHAT THE FUCK YOU WANT TO. \ No newline at end of file diff --git a/bows.lua b/bows.lua new file mode 100644 index 0000000..5bcfec5 --- /dev/null +++ b/bows.lua @@ -0,0 +1,114 @@ +local stiffness=0 +local bow_idle=false +local reload=0 + +local throwing_shoot_arrow = function(itemstack, player) + if not bow_idle then + bow_idle=true + for _,arrow in ipairs(arrows) do + if player:get_inventory():get_stack("main", player:get_wield_index()+1):get_name() == arrow[1] then + if not minetest.setting_getbool("creative_mode") then + player:get_inventory():remove_item("main", arrow[1]) + end + local playerpos = player:getpos() + local obj = minetest.add_entity({x=playerpos.x,y=playerpos.y+1.5,z=playerpos.z}, arrow[2]) + local dir = player:get_look_dir() + obj:setvelocity({x=dir.x*stiffness, y=dir.y*stiffness, z=dir.z*stiffness}) + obj:setacceleration({x=dir.x*-3, y=-10, z=dir.z*-3}) + obj:setyaw(player:get_look_yaw()+math.pi) + minetest.sound_play("throwing_sound", {pos=playerpos}) + if obj:get_luaentity().player == "" then + obj:get_luaentity().player = player + end + obj:get_luaentity().stack = player:get_inventory():get_stack("main", player:get_wield_index()+2) + obj:get_luaentity().inventory = player:get_inventory() + return true + end + end + end + return false +end + +local function reloading () + minetest.after(reload, function() + bow_idle=false + end) +end + +minetest.register_tool("throwing:bow_wood", { + description = "Wood Bow", + inventory_image = "throwing_bow_wood.png", + stack_max = 1, + on_use = function(itemstack, user, pointed_thing) + stiffness = 15 + reload = 1.1 + if throwing_shoot_arrow(itemstack, user, pointed_thing) then + reloading() + if not minetest.setting_getbool("creative_mode") then + itemstack:add_wear(65535/100) + end + end + return itemstack + end, +}) + +minetest.register_craft({ + output = 'throwing:bow_wood', + recipe = { + {'farming:string', 'group:wood', ''}, + {'farming:string', '', 'group:wood'}, + {'farming:string', 'group:wood', ''}, + } +}) + +minetest.register_tool("throwing:bow_steel", { + description = "Steel Bow", + inventory_image = "throwing_bow_steel.png", + stack_max = 1, + on_use = function(itemstack, user, pointed_thing) + stiffness = 20 + reload = 1.4 + if throwing_shoot_arrow(itemstack, user, pointed_thing) then + reloading() + if not minetest.setting_getbool("creative_mode") then + itemstack:add_wear(65535/200) + end + end + return itemstack + end, +}) + +minetest.register_craft({ + output = 'throwing:bow_steel', + recipe = { + {'farming:string', 'default:steel_ingot', ''}, + {'farming:string', '', 'default:steel_ingot'}, + {'farming:string', 'default:steel_ingot', ''}, + } +}) + +minetest.register_tool("throwing:bow_composite", { + description = "Composite Bow", + inventory_image = "throwing_bow_composite.png", + stack_max = 1, + on_use = function(itemstack, user, pointed_thing) + stiffness = 25 + reload = 1.3 + if throwing_shoot_arrow(itemstack, user, pointed_thing) then + reloading() + if not minetest.setting_getbool("creative_mode") then + itemstack:add_wear(65535/300) + end + end + return itemstack + end, +}) + +minetest.register_craft({ + output = 'throwing:bow_composite', + recipe = { + {'farming:string', 'default:steel_ingot', 'group:wood'}, + {'farming:string', 'group:wood', 'default:steel_ingot'}, + {'farming:string', 'default:steel_ingot', 'group:wood'}, + } +}) diff --git a/build_arrow.lua b/build_arrow.lua new file mode 100644 index 0000000..6d159ec --- /dev/null +++ b/build_arrow.lua @@ -0,0 +1,92 @@ +minetest.register_craftitem("throwing:arrow_build", { + description = "Build Arrow", + inventory_image = "throwing_arrow_build.png", +}) + +minetest.register_node("throwing:arrow_build_box", { + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = { + -- Shaft + {-6.5/17, -1.5/17, -1.5/17, 6.5/17, 1.5/17, 1.5/17}, + --Spitze + {-4.5/17, 2.5/17, 2.5/17, -3.5/17, -2.5/17, -2.5/17}, + {-8.5/17, 0.5/17, 0.5/17, -6.5/17, -0.5/17, -0.5/17}, + --Federn + {6.5/17, 1.5/17, 1.5/17, 7.5/17, 2.5/17, 2.5/17}, + {7.5/17, -2.5/17, 2.5/17, 6.5/17, -1.5/17, 1.5/17}, + {7.5/17, 2.5/17, -2.5/17, 6.5/17, 1.5/17, -1.5/17}, + {6.5/17, -1.5/17, -1.5/17, 7.5/17, -2.5/17, -2.5/17}, + + {7.5/17, 2.5/17, 2.5/17, 8.5/17, 3.5/17, 3.5/17}, + {8.5/17, -3.5/17, 3.5/17, 7.5/17, -2.5/17, 2.5/17}, + {8.5/17, 3.5/17, -3.5/17, 7.5/17, 2.5/17, -2.5/17}, + {7.5/17, -2.5/17, -2.5/17, 8.5/17, -3.5/17, -3.5/17}, + } + }, + tiles = {"throwing_arrow_build.png", "throwing_arrow_build.png", "throwing_arrow_build_back.png", "throwing_arrow_build_front.png", "throwing_arrow_build_2.png", "throwing_arrow_build.png"}, + groups = {not_in_creative_inventory=1}, +}) + +local THROWING_ARROW_ENTITY={ + physical = false, + timer=0, + visual = "wielditem", + visual_size = {x=0.1, y=0.1}, + textures = {"throwing:arrow_build_box"}, + lastpos={}, + collisionbox = {0,0,0,0,0,0}, + node = "", +} + +THROWING_ARROW_ENTITY.on_step = function(self, dtime) + self.timer=self.timer+dtime + local pos = self.object:getpos() + local node = minetest.get_node(pos) + + if self.timer>0.2 then + local objs = minetest.env:get_objects_inside_radius({x=pos.x,y=pos.y,z=pos.z}, 1) + for k, obj in pairs(objs) do + if obj:get_luaentity() ~= nil then + if obj:get_luaentity().name ~= "throwing:arrow_build_entity" and obj:get_luaentity().name ~= "__builtin:item" then + self.object:remove() + if not minetest.setting_getbool("creative_mode") then + self.inventory:remove_item("main", {name=self.stack:get_name()}) + end + if self.stack:get_definition().type == "node" and self.stack:get_name() ~= "default:torch" then + minetest.place_node(self.lastpos, {name=self.stack:get_name()}) + else + minetest.add_item(self.lastpos, {name=self.stack:get_name()}) + end + minetest.add_item(self.lastpos, 'throwing:arrow_build') + end + end + end + end + + if self.lastpos.x~=nil then + if node.name ~= "air" then + self.object:remove() + if not minetest.setting_getbool("creative_mode") then + self.inventory:remove_item("main", {name=self.stack:get_name()}) + end + if self.stack:get_definition().type == "node" and self.stack:get_name() ~= "default:torch" then + minetest.place_node(self.lastpos, {name=self.stack:get_name()}) + else + minetest.add_item(self.lastpos, {name=self.stack:get_name()}) + end + minetest.add_item(self.lastpos, 'throwing:arrow_build') + end + end + self.lastpos={x=pos.x, y=pos.y, z=pos.z} +end + +minetest.register_entity("throwing:arrow_build_entity", THROWING_ARROW_ENTITY) + +minetest.register_craft({ + output = 'throwing:arrow_build', + recipe = { + {'default:stick', 'default:stick', 'default:shovel_steel'}, + } +}) diff --git a/depends.txt b/depends.txt new file mode 100644 index 0000000..cfbdb21 --- /dev/null +++ b/depends.txt @@ -0,0 +1,5 @@ +default +bucket +fire +farming +tnt diff --git a/diamond_arrow.lua b/diamond_arrow.lua new file mode 100644 index 0000000..a545e2d --- /dev/null +++ b/diamond_arrow.lua @@ -0,0 +1,80 @@ +minetest.register_craftitem("throwing:arrow_diamond", { + description = "Diamond arrow", + inventory_image = "throwing_arrow_diamond.png", +}) + +minetest.register_node("throwing:arrow_diamond_box", { + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = { + -- Shaft + {-6.5/17, -1.5/17, -1.5/17, 6.5/17, 1.5/17, 1.5/17}, + --Spitze + {-4.5/17, 2.5/17, 2.5/17, -3.5/17, -2.5/17, -2.5/17}, + {-8.5/17, 0.5/17, 0.5/17, -6.5/17, -0.5/17, -0.5/17}, + --Federn + {6.5/17, 1.5/17, 1.5/17, 7.5/17, 2.5/17, 2.5/17}, + {7.5/17, -2.5/17, 2.5/17, 6.5/17, -1.5/17, 1.5/17}, + {7.5/17, 2.5/17, -2.5/17, 6.5/17, 1.5/17, -1.5/17}, + {6.5/17, -1.5/17, -1.5/17, 7.5/17, -2.5/17, -2.5/17}, + + {7.5/17, 2.5/17, 2.5/17, 8.5/17, 3.5/17, 3.5/17}, + {8.5/17, -3.5/17, 3.5/17, 7.5/17, -2.5/17, 2.5/17}, + {8.5/17, 3.5/17, -3.5/17, 7.5/17, 2.5/17, -2.5/17}, + {7.5/17, -2.5/17, -2.5/17, 8.5/17, -3.5/17, -3.5/17}, + } + }, + tiles = {"throwing_arrow_diamond.png", "throwing_arrow_diamond.png", "throwing_arrow_diamond_back.png", "throwing_arrow_diamond_front.png", "throwing_arrow_diamond_2.png", "throwing_arrow_diamond.png"}, + groups = {not_in_creative_inventory=1}, +}) + +local THROWING_ARROW_ENTITY={ + physical = false, + timer=0, + visual = "wielditem", + visual_size = {x=0.1, y=0.1}, + textures = {"throwing:arrow_diamond_box"}, + lastpos={}, + collisionbox = {0,0,0,0,0,0}, +} + +THROWING_ARROW_ENTITY.on_step = function(self, dtime) + self.timer=self.timer+dtime + local pos = self.object:getpos() + local node = minetest.get_node(pos) + + if self.timer>0.2 then + local objs = minetest.env:get_objects_inside_radius({x=pos.x,y=pos.y,z=pos.z}, 2) + for k, obj in pairs(objs) do + if obj:get_luaentity() ~= nil then + if obj:get_luaentity().name ~= "throwing:arrow_diamond_entity" and obj:get_luaentity().name ~= "__builtin:item" then + local damage = 6 + obj:punch(self.object, 1.0, { + full_punch_interval=1.0, + damage_groups={fleshy=damage}, + }, nil) + self.object:remove() + minetest.add_item(self.lastpos, 'throwing:arrow_diamond') + end + end + end + end + + if self.lastpos.x~=nil then + if node.name ~= "air" then + self.object:remove() + minetest.add_item(self.lastpos, 'throwing:arrow_diamond') + end + end + self.lastpos={x=pos.x, y=pos.y, z=pos.z} +end + +minetest.register_entity("throwing:arrow_diamond_entity", THROWING_ARROW_ENTITY) + +minetest.register_craft({ + output = 'throwing:arrow_diamond 9', + recipe = { + {'default:stick', 'default:stick', 'default:diamond'}, + } +}) diff --git a/dig_arrow.lua b/dig_arrow.lua new file mode 100644 index 0000000..d3c7361 --- /dev/null +++ b/dig_arrow.lua @@ -0,0 +1,77 @@ +minetest.register_craftitem("throwing:arrow_dig", { + description = "Dig Arrow", + inventory_image = "throwing_arrow_dig.png", +}) + +minetest.register_node("throwing:arrow_dig_box", { + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = { + -- Shaft + {-6.5/17, -1.5/17, -1.5/17, 6.5/17, 1.5/17, 1.5/17}, + --Spitze + {-4.5/17, 2.5/17, 2.5/17, -3.5/17, -2.5/17, -2.5/17}, + {-8.5/17, 0.5/17, 0.5/17, -6.5/17, -0.5/17, -0.5/17}, + --Federn + {6.5/17, 1.5/17, 1.5/17, 7.5/17, 2.5/17, 2.5/17}, + {7.5/17, -2.5/17, 2.5/17, 6.5/17, -1.5/17, 1.5/17}, + {7.5/17, 2.5/17, -2.5/17, 6.5/17, 1.5/17, -1.5/17}, + {6.5/17, -1.5/17, -1.5/17, 7.5/17, -2.5/17, -2.5/17}, + + {7.5/17, 2.5/17, 2.5/17, 8.5/17, 3.5/17, 3.5/17}, + {8.5/17, -3.5/17, 3.5/17, 7.5/17, -2.5/17, 2.5/17}, + {8.5/17, 3.5/17, -3.5/17, 7.5/17, 2.5/17, -2.5/17}, + {7.5/17, -2.5/17, -2.5/17, 8.5/17, -3.5/17, -3.5/17}, + } + }, + tiles = {"throwing_arrow_dig.png", "throwing_arrow_dig.png", "throwing_arrow_dig_back.png", "throwing_arrow_dig_front.png", "throwing_arrow_dig_2.png", "throwing_arrow_dig.png"}, + groups = {not_in_creative_inventory=1}, +}) + +local THROWING_ARROW_ENTITY={ + physical = false, + timer=0, + visual = "wielditem", + visual_size = {x=0.1, y=0.1}, + textures = {"throwing:arrow_dig_box"}, + lastpos={}, + collisionbox = {0,0,0,0,0,0}, +} + +THROWING_ARROW_ENTITY.on_step = function(self, dtime) + self.timer=self.timer+dtime + local pos = self.object:getpos() + local node = minetest.get_node(pos) + + if self.timer>0.2 then + local objs = minetest.get_objects_inside_radius({x=pos.x,y=pos.y,z=pos.z}, 1) + for k, obj in pairs(objs) do + if obj:get_luaentity() ~= nil then + if obj:get_luaentity().name ~= "throwing:arrow_dig_entity" and obj:get_luaentity().name ~= "__builtin:item" then + self.object:remove() + minetest.add_item(pos, 'throwing:arrow_dig') + minetest.dig_node(pos) + end + end + end + end + + if self.lastpos.x~=nil then + if node.name ~= "air" then + self.object:remove() + minetest.add_item(self.lastpos, 'throwing:arrow_dig') + minetest.dig_node(pos) + end + end + self.lastpos={x=pos.x, y=pos.y, z=pos.z} +end + +minetest.register_entity("throwing:arrow_dig_entity", THROWING_ARROW_ENTITY) + +minetest.register_craft({ + output = 'throwing:arrow_dig', + recipe = { + {'default:stick', 'default:stick', 'default:pick_steel'}, + } +}) diff --git a/fire_arrow.lua b/fire_arrow.lua new file mode 100644 index 0000000..62d0d79 --- /dev/null +++ b/fire_arrow.lua @@ -0,0 +1,114 @@ +minetest.register_craftitem("throwing:arrow_fire", { + description = "Fire Arrow", + inventory_image = "throwing_arrow_fire.png", +}) + +minetest.register_node("throwing:arrow_fire_box", { + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = { + -- Shaft + {-6.5/17, -1.5/17, -1.5/17, 6.5/17, 1.5/17, 1.5/17}, + --Spitze + {-4.5/17, 2.5/17, 2.5/17, -3.5/17, -2.5/17, -2.5/17}, + {-8.5/17, 0.5/17, 0.5/17, -6.5/17, -0.5/17, -0.5/17}, + --Federn + {6.5/17, 1.5/17, 1.5/17, 7.5/17, 2.5/17, 2.5/17}, + {7.5/17, -2.5/17, 2.5/17, 6.5/17, -1.5/17, 1.5/17}, + {7.5/17, 2.5/17, -2.5/17, 6.5/17, 1.5/17, -1.5/17}, + {6.5/17, -1.5/17, -1.5/17, 7.5/17, -2.5/17, -2.5/17}, + + {7.5/17, 2.5/17, 2.5/17, 8.5/17, 3.5/17, 3.5/17}, + {8.5/17, -3.5/17, 3.5/17, 7.5/17, -2.5/17, 2.5/17}, + {8.5/17, 3.5/17, -3.5/17, 7.5/17, 2.5/17, -2.5/17}, + {7.5/17, -2.5/17, -2.5/17, 8.5/17, -3.5/17, -3.5/17}, + } + }, + tiles = {"throwing_arrow_fire.png", "throwing_arrow_fire.png", "throwing_arrow_fire_back.png", "throwing_arrow_fire_front.png", "throwing_arrow_fire_2.png", "throwing_arrow_fire.png"}, + groups = {not_in_creative_inventory=1}, +}) + +local THROWING_ARROW_ENTITY={ + physical = false, + timer=0, + visual = "wielditem", + visual_size = {x=0.1, y=0.1}, + textures = {"throwing:arrow_fire_box"}, + lastpos={}, + collisionbox = {0,0,0,0,0,0}, +} + +THROWING_ARROW_ENTITY.on_step = function(self, dtime) + self.timer=self.timer+dtime + local pos = self.object:getpos() + local node = minetest.get_node(pos) + + if self.timer>0.2 then + local objs = minetest.get_objects_inside_radius({x=pos.x,y=pos.y,z=pos.z}, 2) + for k, obj in pairs(objs) do + if obj:get_luaentity() ~= nil then + if obj:get_luaentity().name ~= "throwing:arrow_fire_entity" and obj:get_luaentity().name ~= "__builtin:item" then + local damage = 5 + obj:punch(self.object, 1.0, { + full_punch_interval=1.0, + damage_groups={fleshy=damage}, + }, nil) + self.object:remove() + end + end + end + end + + if self.lastpos.x~=nil then + if node.name ~= "air" and node.name ~= "throwing:light" then + minetest.set_node(self.lastpos, {name="fire:basic_flame"}) + self.object:remove() + end + if math.floor(self.lastpos.x+0.5) ~= math.floor(pos.x+0.5) or math.floor(self.lastpos.y+0.5) ~= math.floor(pos.y+0.5) or math.floor(self.lastpos.z+0.5) ~= math.floor(pos.z+0.5) then + if minetest.get_node(self.lastpos).name == "throwing:light" then + minetest.remove_node(self.lastpos) + end + if minetest.get_node(pos).name == "air" then + minetest.set_node(pos, {name="throwing:light"}) + end + end + end + self.lastpos={x=pos.x, y=pos.y, z=pos.z} +end + +minetest.register_entity("throwing:arrow_fire_entity", THROWING_ARROW_ENTITY) + +minetest.register_craft({ + output = 'throwing:arrow_fire 4', + recipe = { + {'default:stick', 'default:stick', 'bucket:bucket_lava'}, + }, + replacements = { + {"bucket:bucket_lava", "bucket:bucket_empty"} + } +}) + +minetest.register_node("throwing:light", { + drawtype = "airlike", + paramtype = "light", + sunlight_propagates = true, + tiles = {"throwing_empty.png"}, + light_source = LIGHT_MAX-4, + selection_box = { + type = "fixed", + fixed = { + {0,0,0,0,0,0} + } + }, + groups = {not_in_creative_inventory=1} +}) + +minetest.register_abm({ + nodenames = {"throwing:light"}, + interval = 10, + chance = 1, + action = function(pos, node) + minetest.remove_node(pos) + end +}) diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..250fdb3 --- /dev/null +++ b/init.lua @@ -0,0 +1,28 @@ +arrows = { + {"throwing:arrow_steel", "throwing:arrow_steel_entity"}, + {"throwing:arrow_stone", "throwing:arrow_stone_entity"}, + {"throwing:arrow_obsidian", "throwing:arrow_obsidian_entity"}, + {"throwing:arrow_fire", "throwing:arrow_fire_entity"}, + {"throwing:arrow_teleport", "throwing:arrow_teleport_entity"}, + {"throwing:arrow_dig", "throwing:arrow_dig_entity"}, + {"throwing:arrow_build", "throwing:arrow_build_entity"}, + {"throwing:arrow_tnt", "throwing:arrow_tnt_entity"}, + {"throwing:arrow_torch", "throwing:arrow_torch_entity"}, + {"throwing:arrow_diamond", "throwing:arrow_diamond_entity"}, +} + +dofile(minetest.get_modpath("throwing").."/bows.lua") +dofile(minetest.get_modpath("throwing").."/steel_arrow.lua") +dofile(minetest.get_modpath("throwing").."/stone_arrow.lua") +dofile(minetest.get_modpath("throwing").."/obsidian_arrow.lua") +dofile(minetest.get_modpath("throwing").."/fire_arrow.lua") +dofile(minetest.get_modpath("throwing").."/teleport_arrow.lua") +dofile(minetest.get_modpath("throwing").."/dig_arrow.lua") +dofile(minetest.get_modpath("throwing").."/build_arrow.lua") +dofile(minetest.get_modpath("throwing").."/tnt_arrow.lua") +dofile(minetest.get_modpath("throwing").."/torch_arrow.lua") +dofile(minetest.get_modpath("throwing").."/diamond_arrow.lua") + +if minetest.setting_get("log_mods") then + minetest.log("action", "throwing loaded") +end diff --git a/obsidian_arrow.lua b/obsidian_arrow.lua new file mode 100644 index 0000000..7c2e4c6 --- /dev/null +++ b/obsidian_arrow.lua @@ -0,0 +1,80 @@ +minetest.register_craftitem("throwing:arrow_obsidian", { + description = "Obsidian arrow", + inventory_image = "throwing_arrow_obsidian.png", +}) + +minetest.register_node("throwing:arrow_obsidian_box", { + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = { + -- Shaft + {-6.5/17, -1.5/17, -1.5/17, 6.5/17, 1.5/17, 1.5/17}, + --Spitze + {-4.5/17, 2.5/17, 2.5/17, -3.5/17, -2.5/17, -2.5/17}, + {-8.5/17, 0.5/17, 0.5/17, -6.5/17, -0.5/17, -0.5/17}, + --Federn + {6.5/17, 1.5/17, 1.5/17, 7.5/17, 2.5/17, 2.5/17}, + {7.5/17, -2.5/17, 2.5/17, 6.5/17, -1.5/17, 1.5/17}, + {7.5/17, 2.5/17, -2.5/17, 6.5/17, 1.5/17, -1.5/17}, + {6.5/17, -1.5/17, -1.5/17, 7.5/17, -2.5/17, -2.5/17}, + + {7.5/17, 2.5/17, 2.5/17, 8.5/17, 3.5/17, 3.5/17}, + {8.5/17, -3.5/17, 3.5/17, 7.5/17, -2.5/17, 2.5/17}, + {8.5/17, 3.5/17, -3.5/17, 7.5/17, 2.5/17, -2.5/17}, + {7.5/17, -2.5/17, -2.5/17, 8.5/17, -3.5/17, -3.5/17}, + } + }, + tiles = {"throwing_arrow_obsidian.png", "throwing_arrow_obsidian.png", "throwing_arrow_obsidian_back.png", "throwing_arrow_obsidian_front.png", "throwing_arrow_obsidian_2.png", "throwing_arrow_obsidian.png"}, + groups = {not_in_creative_inventory=1}, +}) + +local THROWING_ARROW_ENTITY={ + physical = false, + timer=0, + visual = "wielditem", + visual_size = {x=0.1, y=0.1}, + textures = {"throwing:arrow_obsidian_box"}, + lastpos={}, + collisionbox = {0,0,0,0,0,0}, +} + +THROWING_ARROW_ENTITY.on_step = function(self, dtime) + self.timer=self.timer+dtime + local pos = self.object:getpos() + local node = minetest.get_node(pos) + + if self.timer>0.2 then + local objs = minetest.get_objects_inside_radius({x=pos.x,y=pos.y,z=pos.z}, 2) + for k, obj in pairs(objs) do + if obj:get_luaentity() ~= nil then + if obj:get_luaentity().name ~= "throwing:arrow_obsidian_entity" and obj:get_luaentity().name ~= "__builtin:item" then + local damage = 4 + obj:punch(self.object, 1.0, { + full_punch_interval=1.0, + damage_groups={fleshy=damage}, + }, nil) + self.object:remove() + minetest.add_item(self.lastpos, 'throwing:arrow_obsidian') + end + end + end + end + + if self.lastpos.x~=nil then + if node.name ~= "air" then + self.object:remove() + minetest.add_item(self.lastpos, 'throwing:arrow_obsidian') + end + end + self.lastpos={x=pos.x, y=pos.y, z=pos.z} +end + +minetest.register_entity("throwing:arrow_obsidian_entity", THROWING_ARROW_ENTITY) + +minetest.register_craft({ + output = 'throwing:arrow_obsidian', + recipe = { + {'default:stick', 'default:stick', 'default:obsidian_shard'}, + } +}) diff --git a/sounds/throwing_sound.ogg b/sounds/throwing_sound.ogg new file mode 100644 index 0000000000000000000000000000000000000000..c8911e5fed64d61e1a0007b98847b27d8044e3cc GIT binary patch literal 11011 zcmb7q1z1$u*Y_D3L_kVVkO8S7l%ZP$6d2Nhp}V_NK)KQ(IUp(BC9NQcK}dIpNP~cs zlrZlB@BM%GdB5j--{;%xvuB^#XRoza{PtRVII31w>Hrq-cd@eTHofecxIXHK+<|yH zxtiLzU48+PEdu}ySbzh_)#qD?>gCM;l*^eA@NPl}XO2|o^2z^{HS9lhxWQp<8)xf# zs;*X0dmB^DE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Mud6QZL!Y+3bkq^-EMt5TJBldJ>|LR6!v+VFd+-gqF z>Jy97ujlyIjZ?}m9F$=XISo=+viC=c50Ok=y`IH|r#X?cwx0R1$$o=1*=#gJuTI8D zikk%BL0+szNdk(`F|TAuO|zxdElmhGJWD!EA6V1%d>z;7S`Q#MUBA~WKDl~0Ofsi; zAWsYn@lO<*xT$HxWczHva`&J!XK+`!Tp&t2CeYpTM5#2G8t1dFu%vlA{HxWVUDEWv zuPPYhjQytBr|Y!ZcFV0$stZ3z!Q|TNH{)n-{NPk>m+)admG6$)WDEBuHT^``u%1Qq3XNYLD zypzYo)P9@uoOVmpkvH9o{@9F`&thjg8zm%)g{wlh<1j}EW{$D_4O=DQe5;SK{I11d zqw%3;BL;FTIBo~E8t-rLZQsr|xudHua35M@#*eB&nx&uYZl(vHp7$Kgl5-Vf`EdPD%8!HjSIQ5*&j+mYmdZeY{{nEm98mxO literal 0 HcmV?d00001 diff --git a/steel_arrow.lua b/steel_arrow.lua new file mode 100644 index 0000000..57dc92f --- /dev/null +++ b/steel_arrow.lua @@ -0,0 +1,80 @@ +minetest.register_craftitem("throwing:arrow_steel", { + description = "Steel arrow", + inventory_image = "throwing_arrow_steel.png", +}) + +minetest.register_node("throwing:arrow_steel_box", { + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = { + -- Shaft + {-6.5/17, -1.5/17, -1.5/17, 6.5/17, 1.5/17, 1.5/17}, + --Spitze + {-4.5/17, 2.5/17, 2.5/17, -3.5/17, -2.5/17, -2.5/17}, + {-8.5/17, 0.5/17, 0.5/17, -6.5/17, -0.5/17, -0.5/17}, + --Federn + {6.5/17, 1.5/17, 1.5/17, 7.5/17, 2.5/17, 2.5/17}, + {7.5/17, -2.5/17, 2.5/17, 6.5/17, -1.5/17, 1.5/17}, + {7.5/17, 2.5/17, -2.5/17, 6.5/17, 1.5/17, -1.5/17}, + {6.5/17, -1.5/17, -1.5/17, 7.5/17, -2.5/17, -2.5/17}, + + {7.5/17, 2.5/17, 2.5/17, 8.5/17, 3.5/17, 3.5/17}, + {8.5/17, -3.5/17, 3.5/17, 7.5/17, -2.5/17, 2.5/17}, + {8.5/17, 3.5/17, -3.5/17, 7.5/17, 2.5/17, -2.5/17}, + {7.5/17, -2.5/17, -2.5/17, 8.5/17, -3.5/17, -3.5/17}, + } + }, + tiles = {"throwing_arrow_steel.png", "throwing_arrow_steel.png", "throwing_arrow_steel_back.png", "throwing_arrow_steel_front.png", "throwing_arrow_steel_2.png", "throwing_arrow_steel.png"}, + groups = {not_in_creative_inventory=1}, +}) + +local THROWING_ARROW_ENTITY={ + physical = false, + timer=0, + visual = "wielditem", + visual_size = {x=0.1, y=0.1}, + textures = {"throwing:arrow_steel_box"}, + lastpos={}, + collisionbox = {0,0,0,0,0,0}, +} + +THROWING_ARROW_ENTITY.on_step = function(self, dtime) + self.timer=self.timer+dtime + local pos = self.object:getpos() + local node = minetest.get_node(pos) + + if self.timer>0.2 then + local objs = minetest.get_objects_inside_radius({x=pos.x,y=pos.y,z=pos.z}, 2) + for k, obj in pairs(objs) do + if obj:get_luaentity() ~= nil then + if obj:get_luaentity().name ~= "throwing:arrow_steel_entity" and obj:get_luaentity().name ~= "__builtin:item" then + local damage = 3 + obj:punch(self.object, 1.0, { + full_punch_interval=1.0, + damage_groups={fleshy=damage}, + }, nil) + self.object:remove() + minetest.add_item(self.lastpos, 'throwing:arrow_steel') + end + end + end + end + + if self.lastpos.x~=nil then + if node.name ~= "air" then + self.object:remove() + minetest.add_item(self.lastpos, 'throwing:arrow_steel') + end + end + self.lastpos={x=pos.x, y=pos.y, z=pos.z} +end + +minetest.register_entity("throwing:arrow_steel_entity", THROWING_ARROW_ENTITY) + +minetest.register_craft({ + output = 'throwing:arrow_steel 16', + recipe = { + {'default:stick', 'default:stick', 'default:steel_ingot'}, + } +}) diff --git a/stone_arrow.lua b/stone_arrow.lua new file mode 100644 index 0000000..e277b74 --- /dev/null +++ b/stone_arrow.lua @@ -0,0 +1,80 @@ +minetest.register_craftitem("throwing:arrow_stone", { + description = "Stone arrow", + inventory_image = "throwing_arrow_stone.png", +}) + +minetest.register_node("throwing:arrow_stone_box", { + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = { + -- Shaft + {-6.5/17, -1.5/17, -1.5/17, 6.5/17, 1.5/17, 1.5/17}, + --Spitze + {-4.5/17, 2.5/17, 2.5/17, -3.5/17, -2.5/17, -2.5/17}, + {-8.5/17, 0.5/17, 0.5/17, -6.5/17, -0.5/17, -0.5/17}, + --Federn + {6.5/17, 1.5/17, 1.5/17, 7.5/17, 2.5/17, 2.5/17}, + {7.5/17, -2.5/17, 2.5/17, 6.5/17, -1.5/17, 1.5/17}, + {7.5/17, 2.5/17, -2.5/17, 6.5/17, 1.5/17, -1.5/17}, + {6.5/17, -1.5/17, -1.5/17, 7.5/17, -2.5/17, -2.5/17}, + + {7.5/17, 2.5/17, 2.5/17, 8.5/17, 3.5/17, 3.5/17}, + {8.5/17, -3.5/17, 3.5/17, 7.5/17, -2.5/17, 2.5/17}, + {8.5/17, 3.5/17, -3.5/17, 7.5/17, 2.5/17, -2.5/17}, + {7.5/17, -2.5/17, -2.5/17, 8.5/17, -3.5/17, -3.5/17}, + } + }, + tiles = {"throwing_arrow_stone.png", "throwing_arrow_stone.png", "throwing_arrow_stone_back.png", "throwing_arrow_stone_front.png", "throwing_arrow_stone_2.png", "throwing_arrow_stone.png"}, + groups = {not_in_creative_inventory=1}, +}) + +local THROWING_ARROW_ENTITY={ + physical = false, + timer=0, + visual = "wielditem", + visual_size = {x=0.1, y=0.1}, + textures = {"throwing:arrow_stone_box"}, + lastpos={}, + collisionbox = {0,0,0,0,0,0}, +} + +THROWING_ARROW_ENTITY.on_step = function(self, dtime) + self.timer=self.timer+dtime + local pos = self.object:getpos() + local node = minetest.get_node(pos) + + if self.timer>0.2 then + local objs = minetest.get_objects_inside_radius({x=pos.x,y=pos.y,z=pos.z}, 2) + for k, obj in pairs(objs) do + if obj:get_luaentity() ~= nil then + if obj:get_luaentity().name ~= "throwing:arrow_stone_entity" and obj:get_luaentity().name ~= "__builtin:item" then + local damage = 1.5 + obj:punch(self.object, 1.0, { + full_punch_interval=1.0, + damage_groups={fleshy=damage}, + }, nil) + self.object:remove() + minetest.add_item(self.lastpos, 'throwing:arrow_stone') + end + end + end + end + + if self.lastpos.x~=nil then + if node.name ~= "air" then + self.object:remove() + minetest.add_item(self.lastpos, 'throwing:arrow_stone') + end + end + self.lastpos={x=pos.x, y=pos.y, z=pos.z} +end + +minetest.register_entity("throwing:arrow_stone_entity", THROWING_ARROW_ENTITY) + +minetest.register_craft({ + output = 'throwing:arrow_stone 16', + recipe = { + {'default:stick', 'default:stick', 'default:cobble'}, + } +}) diff --git a/teleport_arrow.lua b/teleport_arrow.lua new file mode 100644 index 0000000..ca4c494 --- /dev/null +++ b/teleport_arrow.lua @@ -0,0 +1,82 @@ +minetest.register_craftitem("throwing:arrow_teleport", { + description = "Teleport Arrow", + inventory_image = "throwing_arrow_teleport.png", +}) + +minetest.register_node("throwing:arrow_teleport_box", { + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = { + -- Shaft + {-6.5/17, -1.5/17, -1.5/17, 6.5/17, 1.5/17, 1.5/17}, + --Spitze + {-4.5/17, 2.5/17, 2.5/17, -3.5/17, -2.5/17, -2.5/17}, + {-8.5/17, 0.5/17, 0.5/17, -6.5/17, -0.5/17, -0.5/17}, + --Federn + {6.5/17, 1.5/17, 1.5/17, 7.5/17, 2.5/17, 2.5/17}, + {7.5/17, -2.5/17, 2.5/17, 6.5/17, -1.5/17, 1.5/17}, + {7.5/17, 2.5/17, -2.5/17, 6.5/17, 1.5/17, -1.5/17}, + {6.5/17, -1.5/17, -1.5/17, 7.5/17, -2.5/17, -2.5/17}, + + {7.5/17, 2.5/17, 2.5/17, 8.5/17, 3.5/17, 3.5/17}, + {8.5/17, -3.5/17, 3.5/17, 7.5/17, -2.5/17, 2.5/17}, + {8.5/17, 3.5/17, -3.5/17, 7.5/17, 2.5/17, -2.5/17}, + {7.5/17, -2.5/17, -2.5/17, 8.5/17, -3.5/17, -3.5/17}, + } + }, + tiles = {"throwing_arrow_teleport.png", "throwing_arrow_teleport.png", "throwing_arrow_teleport_back.png", "throwing_arrow_teleport_front.png", "throwing_arrow_teleport_2.png", "throwing_arrow_teleport.png"}, + groups = {not_in_creative_inventory=1}, +}) + +local THROWING_ARROW_ENTITY={ + physical = false, + timer=0, + visual = "wielditem", + visual_size = {x=0.1, y=0.1}, + textures = {"throwing:arrow_teleport_box"}, + lastpos={}, + collisionbox = {0,0,0,0,0,0}, + player = "", +} + +THROWING_ARROW_ENTITY.on_step = function(self, dtime) + self.timer=self.timer+dtime + local pos = self.object:getpos() + local node = minetest.get_node(pos) + + if self.timer>0.2 then + local objs = minetest.get_objects_inside_radius({x=pos.x,y=pos.y,z=pos.z}, 2) + for k, obj in pairs(objs) do + if obj:get_luaentity() ~= nil then + if obj:get_luaentity().name ~= "throwing:arrow_teleport_entity" and obj:get_luaentity().name ~= "__builtin:item" then + self.object:remove() + if self.player ~= "" then + self.player:setpos(pos) + self.player:get_inventory():add_item("main", ItemStack("throwing:arrow_teleport")) + end + end + end + end + end + + if self.lastpos.x~=nil then + if node.name ~= "air" then + self.object:remove() + if self.player ~= "" then + self.player:setpos(self.lastpos) + self.player:get_inventory():add_item("main", ItemStack("throwing:arrow_teleport")) + end + end + end + self.lastpos={x=pos.x, y=pos.y, z=pos.z} +end + +minetest.register_entity("throwing:arrow_teleport_entity", THROWING_ARROW_ENTITY) + +minetest.register_craft({ + output = 'throwing:arrow_teleport', + recipe = { + {'default:stick', 'default:stick', 'default:mese'}, + } +}) diff --git a/textures/throwing_arrow_build.png b/textures/throwing_arrow_build.png new file mode 100644 index 0000000000000000000000000000000000000000..09d01ec381da099f4e118af854b33b4880e4c98f GIT binary patch literal 203 zcmeAS@N?(olHy`uVBq!ia0vp^f*{Pn1|+R>-G2cowj^(N7l!{JxM1({$v_d#0*}aI z1_o|n5N2eUHAey{$X?><>&kwgnS)D6<82-HETB+?r;B5V#p&b(3D#!eoO^qI+P6J8 zQqlH*iPV86-{M_n+>XsPR@aPkR&t~yfWVQo&s&XkT&mNbUA6D=`N=IQ@mbu+V3L%W oo$TvE?@7XHTRP_kI><6G{0UOX@8{dv2(*L2)78&qol`;+0JA$j_5c6? literal 0 HcmV?d00001 diff --git a/textures/throwing_arrow_build_2.png b/textures/throwing_arrow_build_2.png new file mode 100644 index 0000000000000000000000000000000000000000..4fdbd9216bc83682c31fea70ab0092439bb0228d GIT binary patch literal 201 zcmeAS@N?(olHy`uVBq!ia0vp^f*{Pn1|+R>-G2cowj^(N7l!{JxM1({$v_d#0*}aI z1_o|n5N2eUHAey{$X?><>&kwgnS)EnNI>S(1E5ftr;B5V#p&b(3Dzx)v(5AW`Ik4V z9Wzc?k(!c_kl=AW?dSW;8|Ni@yDB(3Z}Ite;O0+m#a|EG1YQfJI43l49{cbz!oSGi piGE5#%g(k(1`Fff^f0|*X4p1e_Ik(;EfJs%44$rjF6*2UngFT!LU8~9 literal 0 HcmV?d00001 diff --git a/textures/throwing_arrow_build_back.png b/textures/throwing_arrow_build_back.png new file mode 100644 index 0000000000000000000000000000000000000000..621f258d2a3224544f84b3523aeaa294b2ecba2f GIT binary patch literal 213 zcmeAS@N?(olHy`uVBq!ia0vp^f*{Pn1|+R>-G2cowj^(N7l!{JxM1({$v_d#0*}aI z1_mK8X6#Yg$qp1`FY)wsWxvnN!6nSPaaYEwh3G6qJ5Jxq%ZJUcu4 zzw+nh=Q9s#@o`7E)v(=-e$4$`yEP~6!`H7zm(82VI$iPmwI4-G2cowj^(N7l!{JxM1({$v_d#0*}aI z1_mK8X6#Yg$qp1`FY)wsWxvnN!6htmo69W*C}i*H;uvCaIyqs1jDeA157VLp&(6;N zKUv}2iH_3?IzRGANPQAFGPtBu#@4I&e4kHC+M!RbouHp;~e`^JcOyVRu QfkrWSy85}Sb4q9e0ITyd?*IS* literal 0 HcmV?d00001 diff --git a/textures/throwing_arrow_diamond.png b/textures/throwing_arrow_diamond.png new file mode 100644 index 0000000000000000000000000000000000000000..ae34eb07bf9e7bcdf01bc43471398b6896ef5d63 GIT binary patch literal 196 zcmeAS@N?(olHy`uVBq!ia0vp^f*{Pn1|+R>-G2cowj^(N7l!{JxM1({$v_d#0*}aI z1_o|n5N2eUHAey{$X?><>&kwgnO#UncUn8!H=t0Ur;B5V#p&b(3D#!eoO^qI+An+Y z-~PX+X#?x*XC=8}O>93))}-GE5t g41CkWw2Fb@S&RG^yNQd-G2cowj^(N7l!{JxM1({$v_d#0*}aI z1_o|n5N2eUHAey{$X?><>&kwgnO#UnalWC~U7%2yr;B5V#p&b(3Dzx)v(5AW`PVo9 z`+qRt^oaup4op~g_S604$+m~5bvZPpo!Rq=+0&d`nHdPUd;EJCcf=fJdHlO%jrv^y oH!-&v*&2Mpua2J6SYXG%ut7;aY5i=&0H6&Fp00i_>zopr0NNKoMgRZ+ literal 0 HcmV?d00001 diff --git a/textures/throwing_arrow_diamond_back.png b/textures/throwing_arrow_diamond_back.png new file mode 100644 index 0000000000000000000000000000000000000000..0c92fba4377999cbc69b0ad55972132e895623a3 GIT binary patch literal 210 zcmeAS@N?(olHy`uVBq!ia0vp^f*{Pn1|+R>-G2cowj^(N7l!{JxM1({$v_d#0*}aI z1_mK8X6#Yg$qp1`FY)wsWxvnNE~F!Iz~sEwh3G6qJ5Jxq%ZJUcu4 zzw+nh=Q9s#@o`7|Vf*`^`M3p70tg(*J@w!I|K(DP2X|(M*BKZXY%;i{)3s5GiJMvJ vV0~5#XW>R?kD3b&j#C&VJN*t-ED~Y(AZjMrboualpj8Z>u6{1-oD!M<<~>GI literal 0 HcmV?d00001 diff --git a/textures/throwing_arrow_diamond_front.png b/textures/throwing_arrow_diamond_front.png new file mode 100644 index 0000000000000000000000000000000000000000..791c88d3c07386f665b97e60d56fb8cb09c100a2 GIT binary patch literal 176 zcmeAS@N?(olHy`uVBq!ia0vp^f*{Pn1|+R>-G2cowj^(N7l!{JxM1({$v_d#0*}aI z1_mK8X6#Yg$qp1`FY)wsWxvnNE~LY9#dO{*ppdPni(`nz>Ewh3G6qJ5Jxq%ZJUcu4 z|73-8Cps=K`Co5fYOu-Rl1>?0uj2oiY~F8p-G2cowj^(N7l!{JxM1({$v_d#0*}aI z1_o|n5N2eUHAey{$X?><>&kwgnS)DA_WnYyy+EN*PZ!4!i_^&o60FU_IrsMbv~PRR zDXji)aux%(+1Z!3bXa&ly^J`&VX4xDMi6KfnLUy53-G2cowj^(N7l!{JxM1({$v_d#0*}aI z1_o|n5N2eUHAey{$X?><>&kwgnS)DAqf_YIJfKjlr;B5V#p&b(3Dzx)v(5AW`Ik5Q z&9P`)IIXp@u`$uxRpIcnv$Ox_ujEiUsld(6?ZyTKAfl}#S8P%2B#ZAHZ4$yg4=-<= s_atG%h7AcVJKG)^ER1{8!}N-o!Szopr07|AnZvX%Q literal 0 HcmV?d00001 diff --git a/textures/throwing_arrow_dig_back.png b/textures/throwing_arrow_dig_back.png new file mode 100644 index 0000000000000000000000000000000000000000..3bc4a60798522186545374507984362ca8d9d217 GIT binary patch literal 215 zcmeAS@N?(olHy`uVBq!ia0vp^f*{Pn1|+R>-G2cowj^(N7l!{JxM1({$v_d#0*}aI z1_mK8X6#Yg$qp1`FY)wsWxvnN!6nY*y~&IdD3s#q;uvCaIyqs1jDeA157VLp&(6;N zul#xW`OJe_eB2RkHEf+-U59?IkKdp6;p^9<%jQjFovyfO(ITGDlXD;ZIkMBeVAmY2 zz@DoD5fTEN|ALi$I=W?@9yPP^EaExg(a>+|b&-`}O}?_i3Yl9Ufc7zXy85}Sb4q9e E09(XKivR!s literal 0 HcmV?d00001 diff --git a/textures/throwing_arrow_dig_front.png b/textures/throwing_arrow_dig_front.png new file mode 100644 index 0000000000000000000000000000000000000000..7a29499604340f0ae8302cdf422947d7092ae25b GIT binary patch literal 178 zcmeAS@N?(olHy`uVBq!ia0vp^f*{Pn1|+R>-G2cowj^(N7l!{JxM1({$v_d#0*}aI z1_mK8X6#Yg$qp1`FY)wsWxvnN!6nYKhD(|cC}i*H;uvCaIyqs1jDeA157VLp&(6;N zKUv}2iH_3?gw_2LGB#}3kgz234Ud%bKV#l$HzaKm1X3N`m}=GpcIh!NJUk^-G_zv< QVxUnBp00i_>zopr0Jn-YCIA2c literal 0 HcmV?d00001 diff --git a/textures/throwing_arrow_fire.png b/textures/throwing_arrow_fire.png new file mode 100644 index 0000000000000000000000000000000000000000..8f5075a32bbd59c7462620023181181c687fd138 GIT binary patch literal 266 zcmeAS@N?(olHy`uVBq!ia0vp^f*{Pn1|+R>-G2co#^NA%Cx&(BWL^R}Y)RhkE(~88 zW-;h19ZJy!if|TqL>4nJa0`PlBg3pY5H=O_B$Mc{EE7pA2O!^g}OXl978Nl zCnrd-HVfz6+w;@D?ZM-Ui~pBM9r$GIKCRKwvE$*dW!3*hpSnm|lvGMy+InBudc3S z|MlCp*V_xEcK9E!x--eX`pf@dkrg4`a|0b@85pi>={{b^@M;gxRScf4elF{r5}E*j CU|@>? literal 0 HcmV?d00001 diff --git a/textures/throwing_arrow_fire_2.png b/textures/throwing_arrow_fire_2.png new file mode 100644 index 0000000000000000000000000000000000000000..ed0aa5fb9e16e14d29185050e97fd6efa046a182 GIT binary patch literal 266 zcmeAS@N?(olHy`uVBq!ia0vp^f*{Pn1|+R>-G2co#^NA%Cx&(BWL^R}Y)RhkE(~88 zW-;h19ZJy!if|TqL>4nJa0`PlBg3pY5H=O_B$Mc{EB9lEvGtwLS3FNjv*GO zlM^IZw=m8&&;RFN-Yj>#J84B~VnRZ~jUd4j8!A6P`yZ{v#3`k;O#A2u!?y4L|GKZ2 zH2FJ4LQ-x|azc}*P%;BEGxK44UpY3lY4drQn&$9)FSq@9{=liP@_8Np$Ez0cRQ~?X ze7ODpeu*c(Qzf5#HkG)^)FSE0H+jD8um73i){7f}UMiF_=syvs5ArR8r>mdKI;Vst E0Pg8n`~Uy| literal 0 HcmV?d00001 diff --git a/textures/throwing_arrow_fire_back.png b/textures/throwing_arrow_fire_back.png new file mode 100644 index 0000000000000000000000000000000000000000..8a7d99306fee4e38782e07eebb99f431d6fc500e GIT binary patch literal 268 zcmeAS@N?(olHy`uVBq!ia0vp^f*{Pn1|+R>-G2co#^NA%Cx&(BWL^R}Y)RhkE(~88 zW-;h19ZJy!if|TqL>4nJ2!SzUkJ3(dpdfpRr>`sf9S%W$W%j6?6$U_|9#0p?5R22v z2@7Nlj0}6279DtYcJ_be&&$te9@OIFj@ZNYcmCsl|I_>4{GV_8>wlrd0TAf8JcYY# z&;RB7|MERI_YFuBDBpY1BS?gsqiE5GqiaG6c1f*Py!?EN!HL;gi#z^SsWqMM`CoDP zN&3QH|E2Q|{r@kX^@v;eQBwPa9}5_pHJFWr=C*uv(PWsdVZQm_niZ))cQJUn`njxg HN@xNAjoD_% literal 0 HcmV?d00001 diff --git a/textures/throwing_arrow_fire_front.png b/textures/throwing_arrow_fire_front.png new file mode 100644 index 0000000000000000000000000000000000000000..3994257d15c3e6b7026d44e765ad54e7909382be GIT binary patch literal 306 zcmeAS@N?(olHy`uVBq!ia0vp^f*{Pn1|+R>-G2co#^NA%Cx&(BWL^R}Y)RhkE(~88 zW-;h19ZJy!if|TqL>4nJ2!SzUkJ3(dpdfpRr>`sf9S%W$B_)nxUo)W4CQlc~5R22v z2@7Nlj0}6279DtYcJ}|t3g=FAoL<0Pw&%a-Qx{1Kmq^KX@wJB+tkXSq;6}ad>?$|0 zm^KcMA|r#1e^L@APfnZg^kLGEb$SO594L@o9W^IVCx6wM4-fzAv$4$!=ZSx_&+t#( zHFVdQ&MBb@01jDi#sB~S literal 0 HcmV?d00001 diff --git a/textures/throwing_arrow_obsidian.png b/textures/throwing_arrow_obsidian.png new file mode 100644 index 0000000000000000000000000000000000000000..86e5ef24c62404da8ffe8f48023fad54dc771f24 GIT binary patch literal 192 zcmeAS@N?(olHy`uVBq!ia0vp^f*{Pn1|+R>-G2cowj^(N7l!{JxM1({$v_d#0*}aI z1_o|n5N2eUHAey{$X?><>&kwgnVpZ5Gu%7l3Q)+`)5S5w;&gI?1Z%T!&b>W9?ae;^ zUm|s&$+viy8Mk9|jny^doRu6Y4U(Vc%j6&6NdSQ)AZ|&T)Zl--YR{+tn!F*aj-Jz4 bz{J2%^hErhevc{8QU(T3S3j3^P6-G2cowj^(N7l!{JxM1({$v_d#0*}aI z1_o|n5N2eUHAey{$X?><>&kwgnVpYQe)0Uftw13kPZ!4!i_^&o60BPoXPf8$vln1X zT#=fRkdWYUJ?-cF%NyqWZC*H^^_cQ8hM09pO&@Elu1!wnP(EWS($4uc eDP1H$o`Iq4fMj~Lrvx|9Tn0~9KbLh*2~7ZTayYsG literal 0 HcmV?d00001 diff --git a/textures/throwing_arrow_obsidian_back.png b/textures/throwing_arrow_obsidian_back.png new file mode 100644 index 0000000000000000000000000000000000000000..bd1232fe8891b328e32a4b5a7ab0a67f68101bbb GIT binary patch literal 204 zcmeAS@N?(olHy`uVBq!ia0vp^f*{Pn1|+R>-G2cowj^(N7l!{JxM1({$v_d#0*}aI z1_mK8X6#Yg$qp1`FY)wsWxvnN&c|t5p&}9t6pHk8aSX9Iot&^h#=yw1hiTD)XJ=>s zSN^>GeC9zdKJEx7wu6Rz%n~3V`O)G<{Vp@^ImVw~$;WI9Qt#R*#l+35bg(|Fg|l#@ ovq#N^2FEFklAV5sDi(<_wDD`0UoH3@0JMa`)78&qol`;+02kRjq5uE@ literal 0 HcmV?d00001 diff --git a/textures/throwing_arrow_obsidian_front.png b/textures/throwing_arrow_obsidian_front.png new file mode 100644 index 0000000000000000000000000000000000000000..f74c13e4f1a9fa722a87541d4b06818f44a258f3 GIT binary patch literal 170 zcmeAS@N?(olHy`uVBq!ia0vp^f*{Pn1|+R>-G2cowj^(N7l!{JxM1({$v_d#0*}aI z1_mK8X6#Yg$qp1`FY)wsWxvnN&d0^~h-uvxppdzzi(`nz>Ewh3G6qJ5Jxq%ZJUcu4 z|73-8CpwPntdYtPvu-{%;lEF_Y8e~9gp1^ai5()I2CB>q;YIvKyi26LfkrTRy85}S Ib4q9e04J+2>;M1& literal 0 HcmV?d00001 diff --git a/textures/throwing_arrow_steel.png b/textures/throwing_arrow_steel.png new file mode 100644 index 0000000000000000000000000000000000000000..3d706101b4c32a9fc9d6c770d4df0961bb40cbb3 GIT binary patch literal 195 zcmeAS@N?(olHy`uVBq!ia0vp^f*{Pn1|+R>-G2cowj^(N7a$D;Kb?2i11Zh|kH}&M z25w;xW@MN(M*=9wUgGKN%6^}jT}Y9we`@1zpiqFPi(`nz>Er|n)@I?HdwYJ`w>|g| z1e3EExXsSKyrsj!`{`xG`3*~zCNzRTtH|t$jAt0wfI!VnL*c5x{JyU{R8MjW-#T(m dV*wun!+sIvA3{q6HUrIO@O1TaS?83{1OR_bI>-P3 literal 0 HcmV?d00001 diff --git a/textures/throwing_arrow_steel_2.png b/textures/throwing_arrow_steel_2.png new file mode 100644 index 0000000000000000000000000000000000000000..b989983a5f0f9b59cf85ecb2598340ffd6a75e4d GIT binary patch literal 193 zcmeAS@N?(olHy`uVBq!ia0vp^f*{Pn1|+R>-G2cowj^(N7a$D;Kb?2i11Zh|kH}&M z25w;xW@MN(M*=9wUgGKN%6^}jT}V-+M(4w3ppc)Zi(`nz>Er|n)-8;)&GY~HmpA|W z|G$6XwARMP#zb#dg~QLz&i-G2cowj^(N7a$D;Kb?2i11Zh|kH}&M z1|cwJ>`~gu4iscB@$_|Nzt7Arq^P$`L6Z?E6zA#U7-DfcIbnf}fstVk)1m{<&d&a? z{CWBL%!68d+!1@&6q#k%3_#$K$Es!lm#ftNBXAnc~1Y6Zty9_o0ZDR0r^>bP0l+XkK?Pfh3 literal 0 HcmV?d00001 diff --git a/textures/throwing_arrow_steel_front.png b/textures/throwing_arrow_steel_front.png new file mode 100644 index 0000000000000000000000000000000000000000..38ccec459843cf971657756064b542c632780dec GIT binary patch literal 177 zcmeAS@N?(olHy`uVBq!ia0vp^f*{Pn1|+R>-G2cowj^(N7a$D;Kb?2i11Zh|kH}&M z1|cwJ>`~gu4iscB@$_|Nzt7Arq{M$WC2I~)$j;NnF~s6@a>4=`10%y8rbP#yot^!E zvckC&9j6!k2ZG}vy`i?HN$D3PKF!bEaOB(r#%2v>BcTV$y+I|64DZ$n71iu=O9h(5 N;OXk;vd$@?2>>;rH)H?+ literal 0 HcmV?d00001 diff --git a/textures/throwing_arrow_stone.png b/textures/throwing_arrow_stone.png new file mode 100644 index 0000000000000000000000000000000000000000..c7a14e9c1074b6f3be6e141295a01c5336cd8361 GIT binary patch literal 201 zcmeAS@N?(olHy`uVBq!ia0vp^f*{Pn1|+R>-G2cowj^(N7l!{JxM1({$v_d#0*}aI z1_o|n5N2eUHAey{$X?><>&kwgnO#W9P=>YK94Hj#>Eak-aXL9cg0)#V=iZ*5_H7AO zRln+kcoPmTvy7eHy1>y+_O;};5Edf?AlNV=$=Ikt@&E{!6hHGhHq$uWXi`>(|M99j klb*D2<|d_!1h6wOeAuRtu`cb^XP^xXp00i_>zopr0Fy^Q0ssI2 literal 0 HcmV?d00001 diff --git a/textures/throwing_arrow_stone_2.png b/textures/throwing_arrow_stone_2.png new file mode 100644 index 0000000000000000000000000000000000000000..23617ef040561ac9d91159a22890deed4310862d GIT binary patch literal 195 zcmeAS@N?(olHy`uVBq!ia0vp^f*{Pn1|+R>-G2cowj^(N7l!{JxM1({$v_d#0*}aI z1_o|n5N2eUHAey{$X?><>&kwgnO#U(#7}CHAy6p5)5S5w;&gI?1nU;Y+2;BG{L7m! zUA}C1#mLCOz+g%C=0D$GMx5WURB6HnO|z2)&(6#=mJH-kymix~?EnLJkK-2a2@Gdc kLpX(B9X+S9z>b08h>G0#`=7t}0nKLcboFyt=akR{0I>%?aR2}S literal 0 HcmV?d00001 diff --git a/textures/throwing_arrow_stone_back.png b/textures/throwing_arrow_stone_back.png new file mode 100644 index 0000000000000000000000000000000000000000..293334e9e9bc7e64928547a58bbd32fbae4f7532 GIT binary patch literal 213 zcmeAS@N?(olHy`uVBq!ia0vp^f*{Pn1|+R>-G2cowj^(N7l!{JxM1({$v_d#0*}aI z1_mK8X6#Yg$qp1`FY)wsWxvnNE~KoIad^>Opiq*hi(`nz>Ewh3G6qJ5Jxq%ZJUcu4 zzw+nh=Q9s#@o`7E)v)Qt?~^&#-_w)w;p^9<%jQjFovwI#x_6OL5GooGNau!4Oejn1`9J4)}V`0TY-G2cowj^(N7l!{JxM1({$v_d#0*}aI z1_mK8X6#Yg$qp1`FY)wsWxvnNE~KpgU$9yfC}i*H;uvCaIyqs1jDeA157VLp&(6;N zKUv}2iH_3?R;mdKI;Vst0P6)bJ^%m! literal 0 HcmV?d00001 diff --git a/textures/throwing_arrow_teleport.png b/textures/throwing_arrow_teleport.png new file mode 100644 index 0000000000000000000000000000000000000000..536bea260a34bf79cd88dbe3f88a1cb98f8b263a GIT binary patch literal 196 zcmeAS@N?(olHy`uVBq!ia0vp^f*{Pn1|+R>-G2cowj^(N7l!{JxM1({$v_d#0*}aI z1_o|n5N2eUHAey{$X?><>&kwgnO#Ur_8H5>J3yg8PZ!4!i_^&o60FU_IrsMbv|sk3 ze*ga^QU{uRi+7oEJ2ux?T{F&E$&u0^;nZ~Y1Vb7FGY|+fKUQ;NJLcQ7MC#GyjdJ}u il8H`>Z%DF+FfwSd%FQ@&!C(o{a0X9TKbLh*2~7Zs06F3S literal 0 HcmV?d00001 diff --git a/textures/throwing_arrow_teleport_2.png b/textures/throwing_arrow_teleport_2.png new file mode 100644 index 0000000000000000000000000000000000000000..85311d0ce7d8d93d07b06086b48581e72e43d4d0 GIT binary patch literal 201 zcmeAS@N?(olHy`uVBq!ia0vp^f*{Pn1|+R>-G2cowj^(N7l!{JxM1({$v_d#0*}aI z1_o|n5N2eUHAey{$X?><>&kwgnO#WBVDasm~}}_A8W0yP0r(Z otmZZ&TZ2#d)zNbr3+xyeb{~=3Vpi$90cZn*r>mdKI;Vst07AM$1ONa4 literal 0 HcmV?d00001 diff --git a/textures/throwing_arrow_teleport_back.png b/textures/throwing_arrow_teleport_back.png new file mode 100644 index 0000000000000000000000000000000000000000..ec85fcbeed9b6da52f4ec77ed67b97370b16300a GIT binary patch literal 207 zcmeAS@N?(olHy`uVBq!ia0vp^f*{Pn1|+R>-G2cowj^(N7l!{JxM1({$v_d#0*}aI z1_mK8X6#Yg$qp1`FY)wsWxvnNE~G8^ZRMM7K%p2<7sn8b)5!@7WDJZ9dzcm-cy@O7 zf9221&u1Rg;^U6^!}j-kbFvJZ0SIh*V07eqx|#E?b7n06x$>q5t9EUaV&Z02I#{38 s!dbY{*`ww{gX0uN$xgpR6^ld|TBqnQwa{?b2egO5)78&qol`;+0IX(0WB>pF literal 0 HcmV?d00001 diff --git a/textures/throwing_arrow_teleport_front.png b/textures/throwing_arrow_teleport_front.png new file mode 100644 index 0000000000000000000000000000000000000000..4423c51742ab757c1a8b311edd55de014c5b812d GIT binary patch literal 176 zcmeAS@N?(olHy`uVBq!ia0vp^f*{Pn1|+R>-G2cowj^(N7l!{JxM1({$v_d#0*}aI z1_mK8X6#Yg$qp1`FY)wsWxvnNE~G8fAu)j)C}ivD;uvCaIyqs1jDeA157VLp&(6;N zKUv}2iH^%l{@2Zrk}x;Cq*KP$tN4E=oA(-G2cowj^(N7l!{JxM1({$v_d#0*}aI z1_o|n5N2eUHAey{$X?><>&kwgnVrv6{zA@@DxgrPr;B5V#p&b(3D#!eoO^qI+P6KZ zXKVYvMCw43Z}BcOZpY>tt82zND>+gUKtSi_@% literal 0 HcmV?d00001 diff --git a/textures/throwing_arrow_tnt_2.png b/textures/throwing_arrow_tnt_2.png new file mode 100644 index 0000000000000000000000000000000000000000..5c9b978a6fe442400fa75c80ca5476dd62bc38cb GIT binary patch literal 200 zcmeAS@N?(olHy`uVBq!ia0vp^f*{Pn1|+R>-G2cowj^(N7l!{JxM1({$v_d#0*}aI z1_o|n5N2eUHAey{$X?><>&kwgnVrv6`{Rv(^FX0cPZ!4!i_^&o60BPoXPf8$^Dl4y zXKawLA~i7~A>l@l;E4^DpP&7Y)?(tEUG$azj)EH-o7)aWgJus_gTpftnCxU-G2cowj^(N7l!{JxM1({$v_d#0*}aI z1_mK8X6#Yg$qp1`FY)wsWxvnN&S%ER=y&QCP$DO>Xh@b}GXQ}{CQt2|5C7-M6|<;6cGaGz=SJ>QKapfp7BM!L vrvFzsgdZifPx!Hbu~~!JNN8@$M;A?oTl)Hj^V~~8)-!mz`njxgN@xNA(*{9( literal 0 HcmV?d00001 diff --git a/textures/throwing_arrow_tnt_front.png b/textures/throwing_arrow_tnt_front.png new file mode 100644 index 0000000000000000000000000000000000000000..d15904f799da37d5750d4d8283405cc51bb4193d GIT binary patch literal 177 zcmeAS@N?(olHy`uVBq!ia0vp^f*{Pn1|+R>-G2cowj^(N7l!{JxM1({$v_d#0*}aI z1_mK8X6#Yg$qp1`FY)wsWxvnN&Sxf&{qL0qP{_{H#WBR-G2cowj^(N7l!{JxM1({$v_d#0*}aI z1_o|n5N2eUHAey{$X?><>&kwgnO#VibMySmX+WV+PZ!4!i_^&o60FU_IrsMbv~PRx zKb+^kr)dN0>}MspVohv6OV*^{2ogMT00f-6&YoaMV_*gX;l&cn${@V5?MKO)j$)e!PC{xWt~$(695yIJ^%m! literal 0 HcmV?d00001 diff --git a/textures/throwing_arrow_torch_2.png b/textures/throwing_arrow_torch_2.png new file mode 100644 index 0000000000000000000000000000000000000000..01643e0d917f833121ca8f70aad13ce16c3fa747 GIT binary patch literal 200 zcmeAS@N?(olHy`uVBq!ia0vp^f*{Pn1|+R>-G2cowj^(N7l!{JxM1({$v_d#0*}aI z1_o|n5N2eUHAey{$X?><>&kwgnO#U%*zd2F3{WW4)5S5w;&gI?1nU;Y+2;BG{L7pF z?N2%oaQe`J0|z!NRhp3a`Pte3+e27{63@u*aO_Fq=_zndV4KL5&}Mj$rN-*oFVdQ&MBb@026jSod5s; literal 0 HcmV?d00001 diff --git a/textures/throwing_arrow_torch_back.png b/textures/throwing_arrow_torch_back.png new file mode 100644 index 0000000000000000000000000000000000000000..a012b9024b56ef3b56fe0726a1c585c47caaaeed GIT binary patch literal 212 zcmeAS@N?(olHy`uVBq!ia0vp^f*{Pn1|+R>-G2cowj^(N7l!{JxM1({$v_d#0*}aI z1_mK8X6#Yg$qp1`FY)wsWxvnNE~Kj^_+ya>P$<#U#WBRGw+%5dC*CjkVGWS;sT&hy_`Ci1}_$>0AC47w7xPPGc`xhfDL xA;9@BSlOqeTh{4OGaJt$o)aD=LdS%cGO!*tU0Xlr`c9x_44$rjF6*2UngH^{MhpM| literal 0 HcmV?d00001 diff --git a/textures/throwing_arrow_torch_front.png b/textures/throwing_arrow_torch_front.png new file mode 100644 index 0000000000000000000000000000000000000000..1ca6f0f8943acf9eb14461fc982c62d438839161 GIT binary patch literal 178 zcmeAS@N?(olHy`uVBq!ia0vp^f*{Pn1|+R>-G2cowj^(N7l!{JxM1({$v_d#0*}aI z1_mK8X6#Yg$qp1`FY)wsWxvnNE~LlApAe}F6teepaSX9Iot&^h#=yw1hiTD)XJ=>s zpR921M91j`|JO?xm>6^!8eGyTW9wD?KaL}000McNliru-vb8@0TW{I8>RpN0nkZA zK~y-)ZBxN&8!-@lGrKZ2{fZEpHrJkP@S&IDuLz-OLvKA7dh{Cn4Jq`{euRw;W(|e@ zK?*(eJIrb{F9%!OwH<-b%t-U}=8XiB=+0^wSl2bPZ)Qj-fn>XO=aFM(XCUqll87-P zrPTUo06F=TNnO{hhJoGvY8YCEiq4o$r<~1Z1c32;jbC5hA=~rufZOes+wGR!oa0-o zig#Dw%>`K3HO&mwFt8d1HcivoDJ7a2%rK zIG(SM*!}$U77vd}RQHvd8B`S{8Do@wzkkdii{tM2_*(e>C3t&@Hr6x^+#O~{cZa(} zTQyZNp06<*^(Z3v_Q$0x6(I=juazPK0O+nF0u>RsJ7%Nak-BDvhsPvl#9%PM=Ql4{ zmgTAxPx#24YJ`L;&sp?f~wJY48*P000SaNLh0L01|Wn01|Wo-ewBL_t(I%Y9Q#iW5N;{@$zVA;DFSAcLZ~^8#_#r;tHWX6FTFnVez- z1-(QFBy>n}g%K3ILS_|0_pA5KBB`1r4i*&E^?vJn-`7GC|63^~hzL{_?haKw@#}do z0JuBceIK9-RfU-W0L~lgadHTuBrTUqni)g{i^YQZ75Sd?;&HXnXhc=T&CQJfziUVS0K21>3ng40wsh15kZU* zRaF%jB=N2bPDNB8 zb~7$DE-^4L^m3s900Cf0L_t(IPkoYIPK7WKg$vOacj3Q2nQJt<8UOXs6&Q^odx8g8 z7lgl&Z(y2o?~P3k)6&kFGpCJ2#Qit=zIRa+xj2s9FborFei!FwyplN zwdHIi+s43fP?G!xsHXs4FY8zlb=tV-0eF( zL{)(7rfC#&dw$O=u%01!Id$@V6-n6d+T6FN6-+W!!RKlML`EDMIp#=JRZ9;zXy#Du z^(>O7V*5dtF6kI4(&CF$)v7Ki|AJRm}_Fp)OQZEMM{@bSpW`)W^N#UL;; zZ(?}ABpU($xfT3C(X2$WEK|a*1oj&38d>891osDey^`m-!aq~kLKCe=q?#H?XlXnv zWm&2kui*D)M*w3?&?>Xr8X4nFX@p?wOEd$i%G``XT~QQXwk0nVgg;5H>w4i2`}7>1 aWBv#3=%ksXVTCgQ0000Er?+O75NtU=qlsM<- z=BDPAFgO>bCYGe8D3oWGWGJ|M`UZqI@`(c#@p`&AhHzX@P5=TRmz9Ar?z5H^kj3EX L>gTe~DWM4fuVE-u literal 0 HcmV?d00001 diff --git a/tnt_arrow.lua b/tnt_arrow.lua new file mode 100644 index 0000000..83d1b3d --- /dev/null +++ b/tnt_arrow.lua @@ -0,0 +1,279 @@ +minetest.register_craftitem("throwing:arrow_tnt", { + description = "TNT arrow", + inventory_image = "throwing_arrow_tnt.png", +}) + +minetest.register_node("throwing:arrow_tnt_box", { + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = { + -- Shaft + {-6.5/17, -1.5/17, -1.5/17, 6.5/17, 1.5/17, 1.5/17}, + --Spitze + {-4.5/17, 2.5/17, 2.5/17, -3.5/17, -2.5/17, -2.5/17}, + {-8.5/17, 0.5/17, 0.5/17, -6.5/17, -0.5/17, -0.5/17}, + --Federn + {6.5/17, 1.5/17, 1.5/17, 7.5/17, 2.5/17, 2.5/17}, + {7.5/17, -2.5/17, 2.5/17, 6.5/17, -1.5/17, 1.5/17}, + {7.5/17, 2.5/17, -2.5/17, 6.5/17, 1.5/17, -1.5/17}, + {6.5/17, -1.5/17, -1.5/17, 7.5/17, -2.5/17, -2.5/17}, + + {7.5/17, 2.5/17, 2.5/17, 8.5/17, 3.5/17, 3.5/17}, + {8.5/17, -3.5/17, 3.5/17, 7.5/17, -2.5/17, 2.5/17}, + {8.5/17, 3.5/17, -3.5/17, 7.5/17, 2.5/17, -2.5/17}, + {7.5/17, -2.5/17, -2.5/17, 8.5/17, -3.5/17, -3.5/17}, + } + }, + tiles = {"throwing_arrow_tnt.png", "throwing_arrow_tnt.png", "throwing_arrow_tnt_back.png", "throwing_arrow_tnt_front.png", "throwing_arrow_tnt_2.png", "throwing_arrow_tnt.png"}, + groups = {not_in_creative_inventory=1}, +}) + +local THROWING_ARROW_ENTITY={ + physical = false, + timer=0, + visual = "wielditem", + visual_size = {x=0.1, y=0.1}, + textures = {"throwing:arrow_tnt_box"}, + lastpos={}, + collisionbox = {0,0,0,0,0,0}, +} + +-- TNT functions copied, would be nice to directly call them through an API... + +-- loss probabilities array (one in X will be lost) +local loss_prob = {} + +loss_prob["default:cobble"] = 3 +loss_prob["default:dirt"] = 4 + +local radius = tonumber(minetest.setting_get("tnt_radius") or 3) + +-- Fill a list with data for content IDs, after all nodes are registered +local cid_data = {} +minetest.after(0, function() + for name, def in pairs(minetest.registered_nodes) do + cid_data[minetest.get_content_id(name)] = { + name = name, + drops = def.drops, + flammable = def.groups.flammable, + } + end +end) + +local function rand_pos(center, pos, radius) + pos.x = center.x + math.random(-radius, radius) + pos.z = center.z + math.random(-radius, radius) +end + +local function eject_drops(drops, pos, radius) + local drop_pos = vector.new(pos) + for _, item in pairs(drops) do + local count = item:get_count() + local max = item:get_stack_max() + if count > max then + item:set_count(max) + end + while count > 0 do + if count < max then + item:set_count(count) + end + rand_pos(pos, drop_pos, radius) + local obj = minetest.add_item(drop_pos, item) + if obj then + obj:get_luaentity().collect = true + obj:setacceleration({x=0, y=-10, z=0}) + obj:setvelocity({x=math.random(-3, 3), y=10, + z=math.random(-3, 3)}) + end + count = count - max + end + end +end + +local function add_drop(drops, item) + item = ItemStack(item) + local name = item:get_name() + if loss_prob[name] ~= nil and math.random(1, loss_prob[name]) == 1 then + return + end + + local drop = drops[name] + if drop == nil then + drops[name] = item + else + drop:set_count(drop:get_count() + item:get_count()) + end +end + +local fire_node = {name="fire:basic_flame"} + +local function destroy(drops, pos, cid) + if minetest.is_protected(pos, "") then + return + end + local def = cid_data[cid] + if def and def.flammable then + minetest.set_node(pos, fire_node) + else + minetest.remove_node(pos) + if def then + local node_drops = minetest.get_node_drops(def.name, "") + for _, item in ipairs(node_drops) do + add_drop(drops, item) + end + end + end +end + + +local function calc_velocity(pos1, pos2, old_vel, power) + local vel = vector.direction(pos1, pos2) + vel = vector.normalize(vel) + vel = vector.multiply(vel, power) + + -- Divide by distance + local dist = vector.distance(pos1, pos2) + dist = math.max(dist, 1) + vel = vector.divide(vel, dist) + + -- Add old velocity + vel = vector.add(vel, old_vel) + return vel +end + +local function entity_physics(pos, radius) + -- Make the damage radius larger than the destruction radius + radius = radius * 2 + local objs = minetest.get_objects_inside_radius(pos, radius) + for _, obj in pairs(objs) do + local obj_pos = obj:getpos() + local obj_vel = obj:getvelocity() + local dist = math.max(1, vector.distance(pos, obj_pos)) + + if obj_vel ~= nil then + obj:setvelocity(calc_velocity(pos, obj_pos, + obj_vel, radius * 10)) + end + + local damage = (4 / dist) * radius + obj:set_hp(obj:get_hp() - damage) + end +end + +local function add_effects(pos, radius) + minetest.add_particlespawner({ + amount = 128, + time = 1, + minpos = vector.subtract(pos, radius / 2), + maxpos = vector.add(pos, radius / 2), + minvel = {x=-20, y=-20, z=-20}, + maxvel = {x=20, y=20, z=20}, + minacc = vector.new(), + maxacc = vector.new(), + minexptime = 1, + maxexptime = 3, + minsize = 8, + maxsize = 16, + texture = "tnt_smoke.png", + }) +end + + +local function explode(pos, radius) + local pos = vector.round(pos) + local vm = VoxelManip() + local pr = PseudoRandom(os.time()) + local p1 = vector.subtract(pos, radius) + local p2 = vector.add(pos, radius) + local minp, maxp = vm:read_from_map(p1, p2) + local a = VoxelArea:new({MinEdge = minp, MaxEdge = maxp}) + local data = vm:get_data() + + local drops = {} + local p = {} + + local c_air = minetest.get_content_id("air") + local c_tnt = minetest.get_content_id("tnt:tnt") + local c_tnt_burning = minetest.get_content_id("tnt:tnt_burning") + local c_gunpowder = minetest.get_content_id("tnt:gunpowder") + local c_gunpowder_burning = minetest.get_content_id("tnt:gunpowder_burning") + local c_boom = minetest.get_content_id("tnt:boom") + local c_fire = minetest.get_content_id("fire:basic_flame") + + for z = -radius, radius do + for y = -radius, radius do + local vi = a:index(pos.x + (-radius), pos.y + y, pos.z + z) + for x = -radius, radius do + if (x * x) + (y * y) + (z * z) <= + (radius * radius) + pr:next(-radius, radius) then + local cid = data[vi] + p.x = pos.x + x + p.y = pos.y + y + p.z = pos.z + z + if cid == c_tnt or cid == c_gunpowder then + burn(p) + elseif cid ~= c_tnt_burning and + cid ~= c_gunpowder_burning and + cid ~= c_air and + cid ~= c_fire and + cid ~= c_boom then + destroy(drops, p, cid) + end + end + vi = vi + 1 + end + end + end + + return drops +end + + +local function boom(pos) + minetest.sound_play("tnt_explode", {pos=pos, gain=1.5, max_hear_distance=2*64}) + minetest.set_node(pos, {name="tnt:boom"}) + minetest.get_node_timer(pos):start(0.5) + + local drops = explode(pos, radius) + entity_physics(pos, radius) + eject_drops(drops, pos, radius) + add_effects(pos, radius) +end + +-- Back to the arrow + +THROWING_ARROW_ENTITY.on_step = function(self, dtime) + self.timer=self.timer+dtime + local pos = self.object:getpos() + local node = minetest.get_node(pos) + + if self.timer>0.2 then + local objs = minetest.get_objects_inside_radius({x=pos.x,y=pos.y,z=pos.z}, 2) + for k, obj in pairs(objs) do + if obj:get_luaentity() ~= nil then + if obj:get_luaentity().name ~= "throwing:arrow_tnt_entity" and obj:get_luaentity().name ~= "__builtin:item" then + self.object:remove() + boom(self.lastpos) + end + end + end + end + + if self.lastpos.x~=nil then + if node.name ~= "air" then + self.object:remove() + boom(self.lastpos) + end + end + self.lastpos={x=pos.x, y=pos.y, z=pos.z} +end + +minetest.register_entity("throwing:arrow_tnt_entity", THROWING_ARROW_ENTITY) + +minetest.register_craft({ + output = 'throwing:arrow_tnt', + recipe = { + {'default:stick', 'default:stick', 'tnt:tnt'}, + } +}) diff --git a/torch_arrow.lua b/torch_arrow.lua new file mode 100644 index 0000000..6a12140 --- /dev/null +++ b/torch_arrow.lua @@ -0,0 +1,80 @@ +minetest.register_craftitem("throwing:arrow_torch", { + description = "Torch Arrow", + inventory_image = "throwing_arrow_torch.png", +}) + +minetest.register_node("throwing:arrow_torch_box", { + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = { + -- Shaft + {-6.5/17, -1.5/17, -1.5/17, 6.5/17, 1.5/17, 1.5/17}, + --Spitze + {-4.5/17, 2.5/17, 2.5/17, -3.5/17, -2.5/17, -2.5/17}, + {-8.5/17, 0.5/17, 0.5/17, -6.5/17, -0.5/17, -0.5/17}, + --Federn + {6.5/17, 1.5/17, 1.5/17, 7.5/17, 2.5/17, 2.5/17}, + {7.5/17, -2.5/17, 2.5/17, 6.5/17, -1.5/17, 1.5/17}, + {7.5/17, 2.5/17, -2.5/17, 6.5/17, 1.5/17, -1.5/17}, + {6.5/17, -1.5/17, -1.5/17, 7.5/17, -2.5/17, -2.5/17}, + + {7.5/17, 2.5/17, 2.5/17, 8.5/17, 3.5/17, 3.5/17}, + {8.5/17, -3.5/17, 3.5/17, 7.5/17, -2.5/17, 2.5/17}, + {8.5/17, 3.5/17, -3.5/17, 7.5/17, 2.5/17, -2.5/17}, + {7.5/17, -2.5/17, -2.5/17, 8.5/17, -3.5/17, -3.5/17}, + } + }, + tiles = {"throwing_arrow_torch.png", "throwing_arrow_torch.png", "throwing_arrow_torch_back.png", "throwing_arrow_torch_front.png", "throwing_arrow_torch_2.png", "throwing_arrow_torch.png"}, + groups = {not_in_creative_inventory=1}, +}) + +local THROWING_ARROW_ENTITY={ + physical = false, + timer=0, + visual = "wielditem", + visual_size = {x=0.1, y=0.1}, + textures = {"throwing:arrow_torch_box"}, + lastpos={}, + collisionbox = {0,0,0,0,0,0}, + node = "", +} + +THROWING_ARROW_ENTITY.on_step = function(self, dtime) + self.timer=self.timer+dtime + local pos = self.object:getpos() + local node = minetest.get_node(pos) + + if self.timer>0.2 then + local objs = minetest.get_objects_inside_radius({x=pos.x,y=pos.y,z=pos.z}, 1) + for k, obj in pairs(objs) do + if obj:get_luaentity() ~= nil then + if obj:get_luaentity().name ~= "throwing:arrow_torch_entity" and obj:get_luaentity().name ~= "__builtin:item" then + local damage = 0.5 + obj:punch(self.object, 1.0, { + full_punch_interval=1.0, + damage_groups={fleshy=damage}, + }, nil) + self.object:remove() + end + end + end + end + + if self.lastpos.x~=nil then + if node.name ~= "air" then + self.object:remove() + minetest.place_node(self.lastpos, {name="default:torch"}) + end + end + self.lastpos={x=pos.x, y=pos.y, z=pos.z} +end + +minetest.register_entity("throwing:arrow_torch_entity", THROWING_ARROW_ENTITY) + +minetest.register_craft({ + output = 'throwing:arrow_torch 4', + recipe = { + {'default:stick', 'default:stick', 'default:coal'}, + } +})