From b6575ab19297db672dcfac13921ec9c0c24e5058 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Mon, 16 Jan 2017 23:11:04 +0100 Subject: [PATCH] Rework throwing code, add egg --- mods/default/crafting.lua | 4 +- mods/default/functions.lua | 44 ---------- mods/default/nodes.lua | 4 +- mods/default/textures/default_snowball.png | Bin 320 -> 0 bytes mods/default/tools.lua | 15 +--- mods/mcl_cake/init.lua | 2 +- mods/mcl_mobitems/init.lua | 8 ++ mods/{throwing => mcl_throwing}/README.txt | 0 mods/{throwing => mcl_throwing}/arrow.lua | 18 ++-- mods/{throwing => mcl_throwing}/depends.txt | 0 mods/{throwing => mcl_throwing}/init.lua | 51 ++++++------ mods/mcl_throwing/mod.conf | 1 + .../sounds/mcl_throwing_bow_shoot.ogg} | Bin .../textures/mcl_throwing_arrow.png} | Bin .../textures/mcl_throwing_arrow_2.png} | Bin .../textures/mcl_throwing_arrow_back.png} | Bin .../textures/mcl_throwing_arrow_front.png} | Bin .../textures/mcl_throwing_arrow_inv.png} | Bin .../textures/mcl_throwing_bow.png} | Bin .../textures/mcl_throwing_bow_0.png} | Bin .../textures/mcl_throwing_bow_1.png} | Bin .../textures/mcl_throwing_bow_2.png} | Bin .../textures/mcl_throwing_egg.png | Bin 0 -> 254 bytes .../textures/mcl_throwing_snowball.png | Bin 0 -> 365 bytes mods/mcl_throwing/throwable.lua | 78 ++++++++++++++++++ mods/mobs_mc/chicken.lua | 28 +------ mods/mobs_mc/skeleton.lua | 28 +++---- mods/throwing/textures/throwing_arrow_tnt.png | Bin 240 -> 0 bytes mods/throwing/textures/throwing_empty.png | Bin 68 -> 0 bytes mods/throwing/textures/throwing_string.png | Bin 382 -> 0 bytes 30 files changed, 142 insertions(+), 139 deletions(-) delete mode 100644 mods/default/textures/default_snowball.png rename mods/{throwing => mcl_throwing}/README.txt (100%) rename mods/{throwing => mcl_throwing}/arrow.lua (74%) rename mods/{throwing => mcl_throwing}/depends.txt (100%) rename mods/{throwing => mcl_throwing}/init.lua (68%) create mode 100644 mods/mcl_throwing/mod.conf rename mods/{throwing/sounds/throwing_sound.ogg => mcl_throwing/sounds/mcl_throwing_bow_shoot.ogg} (100%) rename mods/{throwing/textures/throwing_arrow.png => mcl_throwing/textures/mcl_throwing_arrow.png} (100%) rename mods/{throwing/textures/throwing_arrow_2.png => mcl_throwing/textures/mcl_throwing_arrow_2.png} (100%) rename mods/{throwing/textures/throwing_arrow_back.png => mcl_throwing/textures/mcl_throwing_arrow_back.png} (100%) rename mods/{throwing/textures/throwing_arrow_front.png => mcl_throwing/textures/mcl_throwing_arrow_front.png} (100%) rename mods/{throwing/textures/throwing_arrow_inv.png => mcl_throwing/textures/mcl_throwing_arrow_inv.png} (100%) rename mods/{throwing/textures/throwing_bow.png => mcl_throwing/textures/mcl_throwing_bow.png} (100%) rename mods/{throwing/textures/throwing_bow_0.png => mcl_throwing/textures/mcl_throwing_bow_0.png} (100%) rename mods/{throwing/textures/throwing_bow_1.png => mcl_throwing/textures/mcl_throwing_bow_1.png} (100%) rename mods/{throwing/textures/throwing_bow_2.png => mcl_throwing/textures/mcl_throwing_bow_2.png} (100%) create mode 100644 mods/mcl_throwing/textures/mcl_throwing_egg.png create mode 100644 mods/mcl_throwing/textures/mcl_throwing_snowball.png create mode 100644 mods/mcl_throwing/throwable.lua delete mode 100644 mods/throwing/textures/throwing_arrow_tnt.png delete mode 100644 mods/throwing/textures/throwing_empty.png delete mode 100644 mods/throwing/textures/throwing_string.png diff --git a/mods/default/crafting.lua b/mods/default/crafting.lua index 3a82e4dc21..5a4c81c335 100644 --- a/mods/default/crafting.lua +++ b/mods/default/crafting.lua @@ -767,8 +767,8 @@ minetest.register_craft({ minetest.register_craft({ output = 'default:snowblock', recipe = { - {'default:snowball', 'default:snowball'}, - {'default:snowball', 'default:snowball'}, + {'mcl_throwing:snowball', 'mcl_throwing:snowball'}, + {'mcl_throwing:snowball', 'mcl_throwing:snowball'}, } }) diff --git a/mods/default/functions.lua b/mods/default/functions.lua index 373deb7e27..f20df4c4d5 100644 --- a/mods/default/functions.lua +++ b/mods/default/functions.lua @@ -658,50 +658,6 @@ minetest.register_abm({ }) --- --- Snowballs --- - -snowball_GRAVITY=9 -snowball_VELOCITY=19 - ---Shoot snowball. -snow_shoot_snowball=function (item, player, pointed_thing) - local playerpos=player:getpos() - local obj=minetest.add_entity({x=playerpos.x,y=playerpos.y+1.5,z=playerpos.z}, "default:snowball_entity") - local dir=player:get_look_dir() - obj:setvelocity({x=dir.x*snowball_VELOCITY, y=dir.y*snowball_VELOCITY, z=dir.z*snowball_VELOCITY}) - obj:setacceleration({x=dir.x*-3, y=-snowball_GRAVITY, z=dir.z*-3}) - item:take_item() - return item -end - ---The snowball Entity -snowball_ENTITY={ - physical = false, - timer=0, - textures = {"default_snowball.png"}, - lastpos={}, - collisionbox = {0,0,0,0,0,0}, -} - ---Snowball_entity.on_step()--> called when snowball is moving. -snowball_ENTITY.on_step = function(self, dtime) - self.timer=self.timer+dtime - local pos = self.object:getpos() - local node = minetest.get_node(pos) - - --Become item when hitting a node. - if self.lastpos.x~=nil then --If there is no lastpos for some reason. - if node.name ~= "air" then - self.object:remove() - end - end - self.lastpos={x=pos.x, y=pos.y, z=pos.z} -- Set lastpos-->Node will be added at last pos outside the node -end - -minetest.register_entity("default:snowball_entity", snowball_ENTITY) - -- Global environment step function function on_step(dtime) -- print("on_step") diff --git a/mods/default/nodes.lua b/mods/default/nodes.lua index 2afeaa9804..7a025568b1 100644 --- a/mods/default/nodes.lua +++ b/mods/default/nodes.lua @@ -2148,7 +2148,7 @@ minetest.register_node("default:snow", { sounds = default.node_sound_dirt_defaults({ footstep = {name="default_grass_footstep", gain=0.4}, }), - drop = "default:snowball 2", + drop = "mcl_throwing:snowball 2", }) minetest.register_node("default:snowblock", { @@ -2160,7 +2160,7 @@ minetest.register_node("default:snowblock", { sounds = default.node_sound_dirt_defaults({ footstep = {name="default_grass_footstep", gain=0.4}, }), - drop = "default:snowball 4", + drop = "mcl_throwing:snowball 4", }) minetest.register_node("default:cobweb", { diff --git a/mods/default/textures/default_snowball.png b/mods/default/textures/default_snowball.png deleted file mode 100644 index 11b9676241ba8f9a02f4be49d925f5461922078e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 320 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnF3?v&v(vJfvl>na**Z=?jXXND-*VN2fvSi^} z5IB7C;@LYO@c8rRcmMzY{{Md#+sjEn^^7G!e!&b5&u*jvIj1~b978mM*Iqcw+vFg? z`d})T%0?!Cm3cg(5}oDzVG4b+Z^|4v!ZsAJ%WxUIGkLzjzM=fy+uD<}bHX~VZhHRb z>m;9@6KdlpzU;R6vf@ai5BK)9?MsxDTz>9gdypp({Zdg%W&z9g&N#N0)=uvfHU=oK z`t!tJA#3q#PQE?$=1bBgzVim!I`__cXzah`nn}R&cgJ7G)`(B#35a+x<;&z140RdH zMN&t;ucLK6U+?}~W< diff --git a/mods/default/tools.lua b/mods/default/tools.lua index d6dd4c96aa..887244cf64 100644 --- a/mods/default/tools.lua +++ b/mods/default/tools.lua @@ -412,17 +412,4 @@ minetest.register_tool("default:shears", { } }) --- Snowball -minetest.register_craftitem("default:snowball", { - description = "Snowball", - inventory_image = "default_snowball.png", - stack_max = 64, - on_use = snow_shoot_snowball, - groups = { weapon_ranged = 1 }, - on_construct = function(pos) - pos.y = pos.y - 1 - if minetest.get_node(pos).name == "default:dirt_with_grass" then - minetest.set_node(pos, {name="default:dirt_with_snow"}) - end - end, -}) + diff --git a/mods/mcl_cake/init.lua b/mods/mcl_cake/init.lua index 79a2fda733..aa2024c935 100644 --- a/mods/mcl_cake/init.lua +++ b/mods/mcl_cake/init.lua @@ -16,7 +16,7 @@ minetest.register_craft({ output = "mcl_cake:cake", recipe = { {'bucket:bucket_water', 'bucket:bucket_water', 'bucket:bucket_water'}, - {'default:sugar', 'default:leaves', 'default:sugar'}, + {'default:sugar', 'mcl_throwing:egg', 'default:sugar'}, {'farming:wheat_harvested', 'farming:wheat_harvested', 'farming:wheat_harvested'}, }, replacements = {{"bucket:bucket_water", "bucket:bucket_empty"}}, diff --git a/mods/mcl_mobitems/init.lua b/mods/mcl_mobitems/init.lua index 43a35d6076..33fe09f475 100644 --- a/mods/mcl_mobitems/init.lua +++ b/mods/mcl_mobitems/init.lua @@ -151,6 +151,14 @@ minetest.register_craftitem("mcl_mobitems:leather", { stack_max = 64, }) +minetest.register_craftitem("mcl_mobitems:egg", { + description = "Egg", + inventory_image = "mcl_mobitems_rotten_flesh.png", + wield_image = "mcl_mobitems_rotten_flesh.png", + stack_max = 16, + +}) + minetest.register_craftitem("mcl_mobitems:feather", { description = "Feather", wield_image = "mcl_mobitems_feather.png", diff --git a/mods/throwing/README.txt b/mods/mcl_throwing/README.txt similarity index 100% rename from mods/throwing/README.txt rename to mods/mcl_throwing/README.txt diff --git a/mods/throwing/arrow.lua b/mods/mcl_throwing/arrow.lua similarity index 74% rename from mods/throwing/arrow.lua rename to mods/mcl_throwing/arrow.lua index 6bd96230f1..d27ce5bcca 100644 --- a/mods/throwing/arrow.lua +++ b/mods/mcl_throwing/arrow.lua @@ -1,10 +1,10 @@ -minetest.register_craftitem("throwing:arrow", { +minetest.register_craftitem("mcl_throwing:arrow", { description = "Arrow", - inventory_image = "throwing_arrow_inv.png", + inventory_image = "mcl_throwing_arrow_inv.png", groups = { ammo=1, ammo_bow=1 }, }) -minetest.register_node("throwing:arrow_box", { +minetest.register_node("mcl_throwing:arrow_box", { drawtype = "nodebox", is_ground_content = false, node_box = { @@ -27,7 +27,7 @@ minetest.register_node("throwing:arrow_box", { {7.5/17, -2.5/17, -2.5/17, 8.5/17, -3.5/17, -3.5/17}, } }, - tiles = {"throwing_arrow.png", "throwing_arrow.png", "throwing_arrow_back.png", "throwing_arrow_front.png", "throwing_arrow_2.png", "throwing_arrow.png"}, + tiles = {"mcl_throwing_arrow.png", "mcl_throwing_arrow.png", "mcl_throwing_arrow_back.png", "mcl_throwing_arrow_front.png", "mcl_throwing_arrow_2.png", "mcl_throwing_arrow.png"}, groups = {not_in_creative_inventory=1}, }) @@ -36,7 +36,7 @@ local THROWING_ARROW_ENTITY={ timer=0, visual = "wielditem", visual_size = {x=0.4, y=0.4}, - textures = {"throwing:arrow_box"}, + textures = {"mcl_throwing:arrow_box"}, lastpos={}, collisionbox = {0,0,0,0,0,0}, } @@ -50,7 +50,7 @@ THROWING_ARROW_ENTITY.on_step = function(self, dtime) 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_entity" and obj:get_luaentity().name ~= "__builtin:item" then + if obj:get_luaentity().name ~= "mcl_throwing:arrow_entity" and obj:get_luaentity().name ~= "__builtin:item" then local damage = 3 obj:punch(self.object, 1.0, { full_punch_interval=1.0, @@ -71,17 +71,17 @@ THROWING_ARROW_ENTITY.on_step = function(self, dtime) if self.lastpos.x~=nil then if node.name ~= "air" then - minetest.add_item(self.lastpos, 'throwing:arrow') + minetest.add_item(self.lastpos, 'mcl_throwing:arrow') self.object:remove() end end self.lastpos={x=pos.x, y=pos.y, z=pos.z} end -minetest.register_entity("throwing:arrow_entity", THROWING_ARROW_ENTITY) +minetest.register_entity("mcl_throwing:arrow_entity", THROWING_ARROW_ENTITY) minetest.register_craft({ - output = 'throwing:arrow 4', + output = 'mcl_throwing:arrow 4', recipe = { {'default:flint'}, {'default:stick'}, diff --git a/mods/throwing/depends.txt b/mods/mcl_throwing/depends.txt similarity index 100% rename from mods/throwing/depends.txt rename to mods/mcl_throwing/depends.txt diff --git a/mods/throwing/init.lua b/mods/mcl_throwing/init.lua similarity index 68% rename from mods/throwing/init.lua rename to mods/mcl_throwing/init.lua index a1eb384b83..1f700c61c7 100644 --- a/mods/throwing/init.lua +++ b/mods/mcl_throwing/init.lua @@ -1,11 +1,14 @@ -dofile(minetest.get_modpath("throwing").."/arrow.lua") +dofile(minetest.get_modpath("mcl_throwing").."/arrow.lua") +dofile(minetest.get_modpath("mcl_throwing").."/throwable.lua") arrows = { - {"throwing:arrow", "throwing:arrow_entity"}, + {"mcl_throwing:arrow", "mcl_throwing:arrow_entity"}, } -local throwing_shoot_arrow = function(itemstack, player) +local GRAVITY = 9.81 + +local mcl_throwing_shoot_arrow = function(itemstack, player) for _,arrow in ipairs(arrows) do if player:get_inventory():get_stack("main", player:get_wield_index()+1):get_name() == arrow[1] then player:get_inventory():remove_item("main", arrow[1]) @@ -13,9 +16,9 @@ local throwing_shoot_arrow = function(itemstack, player) 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*19, y=dir.y*19, z=dir.z*19}) - obj:setacceleration({x=dir.x*-3, y=-10, z=dir.z*-3}) + obj:setacceleration({x=dir.x*-3, y=-GRAVITY, z=dir.z*-3}) obj:setyaw(player:get_look_yaw()+math.pi) - minetest.sound_play("throwing_sound", {pos=playerpos}) + minetest.sound_play("mcl_throwing_bow_shoot", {pos=playerpos}) if obj:get_luaentity().player == "" then obj:get_luaentity().player = player end @@ -26,13 +29,13 @@ local throwing_shoot_arrow = function(itemstack, player) return false end -minetest.register_tool("throwing:bow", { +minetest.register_tool("mcl_throwing:bow", { description = "Bow", - inventory_image = "throwing_bow.png", + inventory_image = "mcl_throwing_bow.png", stack_max = 1, on_place = function(itemstack, placer, pointed_thing) wear = itemstack:get_wear() - itemstack:replace("throwing:bow_0") + itemstack:replace("mcl_throwing:bow_0") itemstack:add_wear(wear) return itemstack end, @@ -40,7 +43,7 @@ minetest.register_tool("throwing:bow", { on_use = function(itemstack, user, pointed_thing) local wear = itemstack:get_wear() itemstack:add_wear(wear) - if throwing_shoot_arrow(itemstack, user, pointed_thing) then + if mcl_throwing_shoot_arrow(itemstack, user, pointed_thing) then if not minetest.setting_getbool("creative_mode") then itemstack:add_wear(65535/385) end @@ -49,21 +52,21 @@ minetest.register_tool("throwing:bow", { end, }) -minetest.register_tool("throwing:bow_0", { +minetest.register_tool("mcl_throwing:bow_0", { description = "Bow", - inventory_image = "throwing_bow_0.png", + inventory_image = "mcl_throwing_bow_0.png", stack_max = 1, groups = {not_in_creative_inventory=1}, on_place = function(itemstack, placer, pointed_thing) wear = itemstack:get_wear() - itemstack:replace("throwing:bow_1") + itemstack:replace("mcl_throwing:bow_1") itemstack:add_wear(wear) return itemstack end, on_use = function(itemstack, user, pointed_thing) wear = itemstack:get_wear() itemstack:add_wear(wear) - if throwing_shoot_arrow(itemstack, user, pointed_thing) then + if mcl_throwing_shoot_arrow(itemstack, user, pointed_thing) then if not minetest.setting_getbool("creative_mode") then itemstack:add_wear(65535/385) end @@ -72,21 +75,21 @@ minetest.register_tool("throwing:bow_0", { end, }) -minetest.register_tool("throwing:bow_1", { +minetest.register_tool("mcl_throwing:bow_1", { description = "Bow", - inventory_image = "throwing_bow_1.png", + inventory_image = "mcl_throwing_bow_1.png", stack_max = 1, groups = {not_in_creative_inventory=1}, on_place = function(itemstack, placer, pointed_thing) wear = itemstack:get_wear() - itemstack:replace("throwing:bow_2") + itemstack:replace("mcl_throwing:bow_2") itemstack:add_wear(wear) return itemstack end, on_use = function(itemstack, user, pointed_thing) wear = itemstack:get_wear() itemstack:add_wear(wear) - if throwing_shoot_arrow(itemstack, user, pointed_thing) then + if mcl_throwing_shoot_arrow(itemstack, user, pointed_thing) then if not minetest.setting_getbool("creative_mode") then itemstack:add_wear(65535/385) end @@ -95,16 +98,16 @@ minetest.register_tool("throwing:bow_1", { end, }) -minetest.register_tool("throwing:bow_2", { +minetest.register_tool("mcl_throwing:bow_2", { description = "Bow", - inventory_image = "throwing_bow_2.png", + inventory_image = "mcl_throwing_bow_2.png", stack_max = 1, groups = {not_in_creative_inventory=1}, on_use = function(itemstack, user, pointed_thing) wear = itemstack:get_wear() - itemstack:replace("throwing:bow") + itemstack:replace("mcl_throwing:bow") itemstack:add_wear(wear) - if throwing_shoot_arrow(itemstack, user, pointed_thing) then + if mcl_throwing_shoot_arrow(itemstack, user, pointed_thing) then if not minetest.setting_getbool("creative_mode") then itemstack:add_wear(65535/385) end @@ -114,7 +117,7 @@ minetest.register_tool("throwing:bow_2", { }) minetest.register_craft({ - output = 'throwing:bow', + output = 'mcl_throwing:bow', recipe = { {'', 'default:stick', 'default:string'}, {'default:stick', '', 'default:string'}, @@ -122,7 +125,7 @@ minetest.register_craft({ } }) minetest.register_craft({ - output = 'throwing:bow', + output = 'mcl_throwing:bow', recipe = { {'default:string', 'default:stick', ''}, {'default:string', '', 'default:stick'}, @@ -132,6 +135,6 @@ minetest.register_craft({ minetest.register_craft({ type = "fuel", - recipe = "throwing:bow", + recipe = "mcl_throwing:bow", burntime = 15, }) diff --git a/mods/mcl_throwing/mod.conf b/mods/mcl_throwing/mod.conf new file mode 100644 index 0000000000..117ca80a76 --- /dev/null +++ b/mods/mcl_throwing/mod.conf @@ -0,0 +1 @@ +name = mcl_throwing diff --git a/mods/throwing/sounds/throwing_sound.ogg b/mods/mcl_throwing/sounds/mcl_throwing_bow_shoot.ogg similarity index 100% rename from mods/throwing/sounds/throwing_sound.ogg rename to mods/mcl_throwing/sounds/mcl_throwing_bow_shoot.ogg diff --git a/mods/throwing/textures/throwing_arrow.png b/mods/mcl_throwing/textures/mcl_throwing_arrow.png similarity index 100% rename from mods/throwing/textures/throwing_arrow.png rename to mods/mcl_throwing/textures/mcl_throwing_arrow.png diff --git a/mods/throwing/textures/throwing_arrow_2.png b/mods/mcl_throwing/textures/mcl_throwing_arrow_2.png similarity index 100% rename from mods/throwing/textures/throwing_arrow_2.png rename to mods/mcl_throwing/textures/mcl_throwing_arrow_2.png diff --git a/mods/throwing/textures/throwing_arrow_back.png b/mods/mcl_throwing/textures/mcl_throwing_arrow_back.png similarity index 100% rename from mods/throwing/textures/throwing_arrow_back.png rename to mods/mcl_throwing/textures/mcl_throwing_arrow_back.png diff --git a/mods/throwing/textures/throwing_arrow_front.png b/mods/mcl_throwing/textures/mcl_throwing_arrow_front.png similarity index 100% rename from mods/throwing/textures/throwing_arrow_front.png rename to mods/mcl_throwing/textures/mcl_throwing_arrow_front.png diff --git a/mods/throwing/textures/throwing_arrow_inv.png b/mods/mcl_throwing/textures/mcl_throwing_arrow_inv.png similarity index 100% rename from mods/throwing/textures/throwing_arrow_inv.png rename to mods/mcl_throwing/textures/mcl_throwing_arrow_inv.png diff --git a/mods/throwing/textures/throwing_bow.png b/mods/mcl_throwing/textures/mcl_throwing_bow.png similarity index 100% rename from mods/throwing/textures/throwing_bow.png rename to mods/mcl_throwing/textures/mcl_throwing_bow.png diff --git a/mods/throwing/textures/throwing_bow_0.png b/mods/mcl_throwing/textures/mcl_throwing_bow_0.png similarity index 100% rename from mods/throwing/textures/throwing_bow_0.png rename to mods/mcl_throwing/textures/mcl_throwing_bow_0.png diff --git a/mods/throwing/textures/throwing_bow_1.png b/mods/mcl_throwing/textures/mcl_throwing_bow_1.png similarity index 100% rename from mods/throwing/textures/throwing_bow_1.png rename to mods/mcl_throwing/textures/mcl_throwing_bow_1.png diff --git a/mods/throwing/textures/throwing_bow_2.png b/mods/mcl_throwing/textures/mcl_throwing_bow_2.png similarity index 100% rename from mods/throwing/textures/throwing_bow_2.png rename to mods/mcl_throwing/textures/mcl_throwing_bow_2.png diff --git a/mods/mcl_throwing/textures/mcl_throwing_egg.png b/mods/mcl_throwing/textures/mcl_throwing_egg.png new file mode 100644 index 0000000000000000000000000000000000000000..b54bf27704154d0ad11c53486a6919f90dbba282 GIT binary patch literal 254 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=ffJqn<8~Ar-gYUf;{xY#`8<_0Yee{Ktfwg05EzBBe-yb-oOF_|0aAqG!ZKbLh*2~7Z( C&|XFW literal 0 HcmV?d00001 diff --git a/mods/mcl_throwing/textures/mcl_throwing_snowball.png b/mods/mcl_throwing/textures/mcl_throwing_snowball.png new file mode 100644 index 0000000000000000000000000000000000000000..8934c67075d677041216a551851d3e4c62d8ee46 GIT binary patch literal 365 zcmV-z0h0cSP)Y%RE;JAxgK)?zNVP~m%x%s{|ug15z&IHkL3iAa=saz0@l0%RN2Dwz%a;a00000 LNkvXXu0mjfyRe%S literal 0 HcmV?d00001 diff --git a/mods/mcl_throwing/throwable.lua b/mods/mcl_throwing/throwable.lua new file mode 100644 index 0000000000..cc3682442f --- /dev/null +++ b/mods/mcl_throwing/throwable.lua @@ -0,0 +1,78 @@ +-- +-- Snowballs +-- + +local GRAVITY = 9.81 +local snowball_VELOCITY=19 +local egg_VELOCITY=19 + +--Shoot snowball. +local throw_function = function (entity_name, velocity) + local func = function(item, player, pointed_thing) + local playerpos=player:getpos() + local obj=minetest.add_entity({x=playerpos.x,y=playerpos.y+1.5,z=playerpos.z}, entity_name) + local dir=player:get_look_dir() + obj:setvelocity({x=dir.x*velocity, y=dir.y*velocity, z=dir.z*velocity}) + obj:setacceleration({x=dir.x*-3, y=-GRAVITY, z=dir.z*-3}) + item:take_item() + return item + end + return func +end + +-- The snowball entity +local snowball_ENTITY={ + physical = false, + timer=0, + textures = {"mcl_throwing_snowball.png"}, + lastpos={}, + collisionbox = {0,0,0,0,0,0}, +} +local egg_ENTITY={ + physical = false, + timer=0, + textures = {"mcl_throwing_egg.png"}, + lastpos={}, + collisionbox = {0,0,0,0,0,0}, +} + +-- Snowball_entity.on_step()--> called when snowball is moving. +local on_step = function(self, dtime) + self.timer=self.timer+dtime + local pos = self.object:getpos() + local node = minetest.get_node(pos) + + --Become item when hitting a node. + if self.lastpos.x~=nil then --If there is no lastpos for some reason. + if node.name ~= "air" then + self.object:remove() + end + end + self.lastpos={x=pos.x, y=pos.y, z=pos.z} -- Set lastpos-->Node will be added at last pos outside the node +end + +minetest.register_entity("mcl_throwing:snowball_entity", snowball_ENTITY) +minetest.register_entity("mcl_throwing:egg_entity", egg_ENTITY) + +-- Snowball +minetest.register_craftitem("mcl_throwing:snowball", { + description = "Snowball", + inventory_image = "mcl_throwing_snowball.png", + stack_max = 16, + on_use = throw_function("mcl_throwing:snowball_entity", snowball_VELOCITY), + groups = { weapon_ranged = 1 }, + on_construct = function(pos) + pos.y = pos.y - 1 + if minetest.get_node(pos).name == "default:dirt_with_grass" then + minetest.set_node(pos, {name="default:dirt_with_snow"}) + end + end, +}) + +minetest.register_craftitem("mcl_throwing:egg", { + description = "Egg", + inventory_image = "mcl_throwing_egg.png", + stack_max = 16, + on_use = throw_function("mcl_throwing:egg_entity", egg_VELOCITY), + groups = { weapon_ranged = 1 }, +}) diff --git a/mods/mobs_mc/chicken.lua b/mods/mobs_mc/chicken.lua index 899fbcd5f9..5dbab11c03 100644 --- a/mods/mobs_mc/chicken.lua +++ b/mods/mobs_mc/chicken.lua @@ -107,7 +107,7 @@ mobs:register_mob("mobs_mc:chicken", { local pos = self.object:getpos() - minetest.add_item(pos, "mcl_mobitems:egg") + minetest.add_item(pos, "mcl_throwing:egg") minetest.sound_play("default_place_node_hard", { pos = pos, @@ -121,32 +121,6 @@ mobs:register_mob("mobs_mc:chicken", { --mobs:register_spawn("mobs_mc:chicken", {"default:dirt_with_grass"}, 20, 8, 7000, 1, 31000) --- from mobs_redo --- egg -minetest.register_node(":mobs:egg", { - description = "Chicken Egg", - tiles = {"mobs_chicken_egg.png"}, - inventory_image = "mobs_chicken_egg.png", - visual_scale = 0.7, - drawtype = "plantlike", - wield_image = "mobs_chicken_egg.png", - paramtype = "light", - walkable = false, - is_ground_content = true, - sunlight_propagates = true, - selection_box = { - type = "fixed", - fixed = {-0.2, -0.5, -0.2, 0.2, 0, 0.2} - }, - groups = {snappy = 2, dig_immediate = 3}, - after_place_node = function(pos, placer, itemstack) - if placer:is_player() then - minetest.set_node(pos, {name = "mobs:egg", param2 = 1}) - end - end, - on_use = mobs_shoot_egg -}) - -- compatibility mobs:alias_mob("mobs:chicken", "mobs_mc:chicken") diff --git a/mods/mobs_mc/skeleton.lua b/mods/mobs_mc/skeleton.lua index f577db73c5..9acf50aff6 100644 --- a/mods/mobs_mc/skeleton.lua +++ b/mods/mobs_mc/skeleton.lua @@ -28,15 +28,11 @@ mobs:register_mob("mobs_mc:skeleton", { damage = 1, armor = 200, drops = { - {name = "throwing:arrow", + {name = "mcl_throwing:arrow", chance = 1, min = 0, max = 2,}, - {name = "throwing:bow", - chance = 11, - min = 1, - max = 1,}, - {name = "bonemeal:bone", + {name = "default:bone", chance = 1, min = 0, max = 2,}, @@ -63,7 +59,7 @@ mobs:register_mob("mobs_mc:skeleton", { light_damage = 1, view_range = 16, attack_type = "dogshoot", - arrow = "throwing:arrow_entity", + arrow = "mcl_throwing:arrow_entity", shoot_interval = 2.5, shoot_offset = 1, --'dogshoot_switch' allows switching between shoot and dogfight modes inside dogshoot using timer (1 = shoot, 2 = dogfight) @@ -96,18 +92,18 @@ mobs:register_mob("mobs_mc:skeleton2", { damage = 3, armor = 200, drops = { - {name = "throwing:arrow", + {name = "default:coal_lump", + chance = 1, + min = 0, + max = 1,}, + {name = "default:bone", chance = 1, min = 0, max = 2,}, - {name = "throwing:bow", - chance = 11, + {name = "heads:wither_skeleton", + chance = 40, min = 1, max = 1,}, - {name = "bonemeal:bone", - chance = 1, - min = 0, - max = 2,}, }, animation = { speed_normal = 30, @@ -131,7 +127,7 @@ mobs:register_mob("mobs_mc:skeleton2", { light_damage = 0, view_range = 16, attack_type = "dogshoot", - arrow = "throwing:arrow_entity", + arrow = "mcl_throwing:arrow_entity", shoot_interval = 0.5, shoot_offset = 1, --'dogshoot_switch' allows switching between shoot and dogfight modes inside dogshoot using timer (1 = shoot, 2 = dogfight) @@ -143,7 +139,7 @@ mobs:register_spawn("mobs_mc:skeleton2", {"group:crumbly", "group:cracky", "grou arrows = { - {"throwing:arrow", "throwing:arrow_entity" }, + {"mcl_throwing:arrow", "mcl_throwing:arrow_entity" }, } -- compatibility diff --git a/mods/throwing/textures/throwing_arrow_tnt.png b/mods/throwing/textures/throwing_arrow_tnt.png deleted file mode 100644 index 651cf299f3058c05021c923824de636cd5400524..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 240 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!73?$#)eFPFv4DbnY{r>&?j~_pN{`~pt*RS8d zfB*UO=kMRY|Ni~^|NlQw36PBK^1A?Jah3%61p{daC{CHZ5XdU^ba4#fkQF_6khdv7 z!1ZEyo9c!##}^J#3Xd*HJkIIuJa_4Y{Ig4p`&n0+%vpT?q~-0Fv=25F$~!Jvosivi zFrfdoN9@-<0ydHnPqErU eAfxLO>nVAoskUFI+Ekf=oZ{)~=d#Wzp$Pzwhibn7 diff --git a/mods/throwing/textures/throwing_empty.png b/mods/throwing/textures/throwing_empty.png deleted file mode 100644 index 4b5b3029265a4ef9b9c654442d56c7f198ffdeb8..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 68 zcmeAS@N?(olHy`uVBq!ia0vp^j3CUx0wlM}@Gt=>Zci7-5DwYogajamnSs&YgKIsI O#o+1c=d#Wzp$Pyq!wQA~ diff --git a/mods/throwing/textures/throwing_string.png b/mods/throwing/textures/throwing_string.png deleted file mode 100644 index ec92a7e66e87c3afd1ff4f9801567659f570fbb2..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 382 zcmV-^0fGLBP)-l7>)u;1@HO_XIBP@QRNz4353yx{S8yjkUaI$N|&ib_xj?)SuEvA}kp z&nNLNcrzj$O9I&5a=H8jpVq{iFg@1L&~HMUd2Ju4z2EOWBe`0w25tlHXK*|oGgek( z{3hfFu|5bJh3oZt=yr%zG0pxS5wDR61dSp%olYZ~V6)kb{XND;eFTMisw!B-5aB=g0w#M9e@Zch_{1VXm|<~H*v!;`!1;Wh`g^8R@RgGg!w`>xV@n%c zVCH}0928R=@i^coJ=N6UKgR2FxllZ>Lq3Yk^lfw&0^i`tKss6IjPz8U^hY2i#