From 515900c1690b5d82f099576c3b29efa0f6f86dc4 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Sat, 1 Jul 2017 18:37:11 +0200 Subject: [PATCH 01/12] Add snow golem --- 0_gameconfig.lua | 2 + init.lua | 1 + snowman.lua | 118 +++++++-------------------- textures/mobs_mc_snowman.png | Bin 1606 -> 1325 bytes textures/mobs_mc_snowman_pumpkin.png | Bin 0 -> 944 bytes 5 files changed, 31 insertions(+), 90 deletions(-) create mode 100644 textures/mobs_mc_snowman_pumpkin.png diff --git a/0_gameconfig.lua b/0_gameconfig.lua index 8b83b3f..da025a1 100644 --- a/0_gameconfig.lua +++ b/0_gameconfig.lua @@ -48,6 +48,8 @@ mobs_mc.items = { shulker_shell = "mobs_mc:shulker_shell", magma_cream = "mobs_mc:magma_cream", spider_eye = "mobs_mc:spider_eye", + snowball = "default:snow", + top_snow = "default:snow", totem = "mobs_mc:totem", rotten_flesh = "mobs_mc:rotten_flesh", nether_star = "mobs_mc:nether_star", diff --git a/init.lua b/init.lua index fcabbd1..f59cf97 100644 --- a/init.lua +++ b/init.lua @@ -87,6 +87,7 @@ dofile(path .. "/villager_illusioner.lua") -- Mesh and animation by toby109tt / dofile(path .. "/ghast.lua") -- maikerumine dofile(path .. "/guardian.lua") -- maikerumine Mesh and animation by toby109tt / https://github.com/22i dofile(path .. "/guardian_elder.lua") -- maikerumine Mesh and animation by toby109tt / https://github.com/22i +dofile(path .. "/snowman.lua") dofile(path .. "/iron_golem.lua") -- maikerumine Mesh and animation by toby109tt / https://github.com/22i dofile(path .. "/shulker.lua") -- maikerumine Mesh and animation by toby109tt / https://github.com/22i dofile(path .. "/silverfish.lua") -- maikerumine Mesh and animation by toby109tt / https://github.com/22i diff --git a/snowman.lua b/snowman.lua index 6c3eca4..c00dec2 100644 --- a/snowman.lua +++ b/snowman.lua @@ -3,109 +3,47 @@ --made for MC like Survival game --License for code WTFPL and otherwise stated in readmes - ---dofile(minetest.get_modpath("mobs").."/api.lua") - ---################### ---################### SNOWMAN ---################### ---[[ -mobs:register_mob("mobs_mc:26snowman", { - type = "animal", +mobs:register_mob("mobs_mc:snowman", { + type = "npc", passive = true, - runaway = true, - stepheight = 1.2, - hp_min = 30, - hp_max = 60, - armor = 150, - collisionbox = {-0.35, -0.01, -0.35, 0.35, 2, 0.35}, + hp_min = 4, + hp_max = 4, + pathfinding = 1, + view_range = 16, + fall_damage = 0, + water_damage = 4, + lava_damage = 20, + attacks_monsters = true, + collisionbox = {-0.35, -0.01, -0.35, 0.35, 1.89, 0.35}, visual = "mesh", - mesh = "snowman.b3d", + mesh = "mobs_mc_snowman.b3d", textures = { - {"snowman.png"}, + {"mobs_mc_snowman.png^mobs_mc_snowman_pumpkin.png"}, }, + gotten_texture = "mobs_mc_snowman.png", + drops = {{ name = mobs_mc.items.snowball, chance = 1, min = 0, max = 15 }}, visual_size = {x=3, y=3}, walk_velocity = 0.6, run_velocity = 2, jump = true, animation = { - speed_normal = 25, speed_run = 50, - stand_start = 40, stand_end = 80, - walk_start = 0, walk_end = 40, - run_start = 0, run_end = 40, + speed_normal = 25, + speed_run = 50, + stand_start = 20, + stand_end = 40, + walk_start = 0, + walk_end = 20, + run_start = 0, + run_end = 20, + die_start = 40, + die_end = 50, + die_loop = false, }, + blood_amount = 0, }) -mobs:register_egg("mobs_mc:26snowman", "Snowman", "snowman_inv.png", 0) -]] - -mobs:register_mob("mobs_mc:enderman", { - type = "monster", - hp_max = 79, - collisionbox = {-0.4, -2.4, -0.4, 0.4, 1.8, 0.4}, - - visual = "mesh", - mesh = "mobs_mc_snowman.b3d", - textures = { - {"mobs_mc_snowman.png"} - }, - visual_size = {x=1.2, y=2.5}, - makes_footstep_sound = true, - sounds = { - -- TODO - distance = 16, - }, - walk_velocity = 3.2, - run_velocity = 5.4, - damage = 3, - armor = 200, - drops = { - {name = "default:obsidian", - chance = 40, - min = 0, - max = 2,}, - {name = "default:diamond", - chance = 61, - min = 1, - max = 1,}, - {name = "farorb:farorb", - chance = 3, - min = 0, - max = 1,}, - {name = "mobs_mc:enderman_head", - chance = 50, - min = 0, - max = 1,}, - }, - animation = { - speed_normal = 45, - speed_run = 15, - stand_start = 0, - stand_end = 39, - walk_start = 41, - walk_end = 72, - run_start = 74, - run_end = 105, - punch_start = 74, - punch_end = 105, - }, - water_damage = 1, - lava_damage = 5, - light_damage = 0, - view_range = 16, - attack_type = "dogfight", - replace_rate = 1, - replace_what = {"default:torch","default:sand","default:desert_sand","default:cobble","default:dirt","default:dirt_with_glass","default:dirt_with_dry_grass","default:wood","default:stone","default:sandstone"}, - replace_with = "air", - replace_offset = -1, - -}) - - --- spawn eggs mobs:register_egg("mobs_mc:snowman", "Snow Golem", "mobs_mc_spawn_icon_snowman.png", 0) - if minetest.settings:get_bool("log_mods") then - minetest.log("action", "MC Enderman loaded") + minetest.log("action", "MC Snow Golem loaded") end diff --git a/textures/mobs_mc_snowman.png b/textures/mobs_mc_snowman.png index 1bd733e3a457bcd9157dd4821da1863e5524e219..47b2820e7d001576d6375b1b245fb73e1814a13b 100644 GIT binary patch delta 1317 zcmV+=1={+?46O=~8Gi-<0063Kaozv`00d`2O+f$vv5yPZ+{h%!usnG3MbYe);{+OX8HDiuT-mmD!BT4%$0Zo*pD<9cl}5}3je#{T&0@9P?{2AEts2R#EY)(o~tV{7M$mRD__ zADF_N2Dvg62Y;aX_PqBEXrEpp4TCifcn+`H_J>A&#f3&0z}mTQL6zBz6rNA8MK5m; z+*@t?Lqk4cpR&;C+Ii0arVorb1P$g;Fu8U9-VGql`jq+3x6a?20SF9%%=u&I888Q` z%w{a#=Bwf+d}8gBYxCm&K3^00lDG*(AP8Z6zpO!i&wrnM_Qe%j=STPNov(>}N!$b? z5T`({h*ltY_wIu$G?D}Hp1u3`&eue~ByK_>h)SeTjQdTK%YpRVzjt0T?iVRYv8+X& z`_x(IKzi?AJ1-gcixjCq_kOQD?e?5uFo2``kIqZR{UVj9Ylo3%d-orm zmyG)b0)GKwMCM!{?Y+0n9i5kq`9tyf8uJwMO<}D$d3ojZ$}4u|#HP+Hz;2asmc5HN?iBY)m0KLHH2M$#l}%ww+Q`Bum~?ErEJ z?lma<4cN-LuCn(JMW!*ImS?$sZC+{Y!cfqJ<|%}$Ld++Ryk~nn&{J=ZhsI^!g`rq( zyf$xvkQA9b*8VHB$4iXzN@Ev>V!83AsYqch&wquEc)j(uc%`umLqWq<$WrX)3AMcZ zVSn4>_14?sp>fG|VJK(}vguOni7>COITw38@n3joT=HEQ3L3Ue0Xap=k+(E^@*A+l z>#euPLt|@n3qwJZ<>trcDL@e-MdojSJnDGusdvQV9F5Dh3q!Ho_~ctoaa_rH-sa59 zcfVFoWW6;WdvlzZ#x4v6O%wtYlQ}scg@2k`>EvhKpG#M0<0E(hUW6Xrl` z)P3eMUv1_MOe)&7!*BquHMYhlpZwDdz#l0MAzp);1D;{3mw$=@AXFm>4LTr@`Cfjt znK#-2xKA_5X$RmLX!&rf&AhQ@BG;`^zxCwgT0Z7aF#v@kUNh`lL+%+sFQ0t1nSVDB zsR2a;pQ3pUGk|;xw)pa@&Ag$3G?~UUq`~L#Pcs0-YKAq?1dyXi*1h~{GjF7!G~rsK z?BViMTfUzJYdP|(&Afp~p>d&kjRDMw+Ec~)D9u&2hYn$89 zHBV_ae%TlgUt1eeTmfs%XXBTR@qeI@#S#iokonp8Wn(;Ysz3qR%)LKUGx5vDcu*u8 zWdqhJ1nzA7vN0YurMS)Vb<2iaXXBTR@u0X3Yz8Qvc^l8hFB{{L4cn==4b9EOFB{`Q z5sKN2wZ+>t*V*`GV?6lYEbL@~d4+K1_c;^4Y>Wp}q!3r35cdi&Hxs{XydK3{yv17# b#KXfsphs`$M0fxK00000NkvXXu0mjf5$cAu literal 1606 zcmeAS@N?(olHy`uVBq!ia0vp^4j|0I3?%1nZ+ru!SkfJR9T^xl_H+M9WMyDrW(e>J zaRrKJ_{q7rxOAqgPnqhK@yhIa@kzB0~bU|?h@3GxdDr}~jg zFa&>RR|ST}Q%@Jikch)~r#Vh*HsEn~bvX2We?dBBqLv^f67vp;cwWwjJIdWOBu)gFAkhhxs)~6Y{&cmGus;*RirK!3RG4Y z?D(cXscBwC#k&XF{;SKeDbM+>Kk3Yjr;OMCajtBLl)Lb4J(C$H{^3{@%d>>nCtYv$DM^{xkIyap zBr~D+(8}*Z`#w%j6tb<4e(7104y0LaJKy^}lCGCjyZCwg)OknBfpqwV$v@7i;8gg~ z-sIgMNlQEV=EfzDcUs!!KH&IblC`h-)LfVK!pd{*bbhI-YdJMnrdhK2*xd99Ck6YQ zXU3hE4tZC0{K3BE^BS-It)9#H^2hFyIq#>Ro9HoVN~P`3uy;S_pJko*14uCakLHY& zc*@lHziC2ipq{|b?O^K1eXkRTG{ianh_~qU6g3{$e-upp4|5W8+v)INzd}ml6mFZ3 i_Ol^G&A*Dj%+2zmp=~WJ&54si+1u0A&t;ucLK6T<$`u*_ diff --git a/textures/mobs_mc_snowman_pumpkin.png b/textures/mobs_mc_snowman_pumpkin.png new file mode 100644 index 0000000000000000000000000000000000000000..e9db35addbc124ee066254032e155772c4a33e47 GIT binary patch literal 944 zcmV;h15f;kP)48(C;$s5+S-TS}RGg3KGvONBpD*1oO2%8~IEv9LD)aS_Q|M>X)!1H+|=hVUl z5Od2XfujU}pJ(m_9@Arm5bUvtclhfNaGSybD>q<(|e*RB|z1 z_bA-?@3}M@d6EQmTPeJ4t61UAe@kjK@+66^8w6xSHFTo?26P@My!{RoS_^mndoGQl zCw&KW3=~?8JO3@I(a4j;wywMqVOdwB;J*Q#1-7-tX4LubxipHNbb()m4WZQeZ%K`! zC*6sgZ3rx?6#X}#%Rmt`5*6`*(oMzsI^PYHI2CIHo$m)qoQjV#r<;gV5rxiS2Yck2 zeV}wx5g$KuH&8^FDIX~z;#5SDb0@$gswTv$KGMQeM0V~3RM;S3rj$b$4&R~7xf2jA zg_TJQ`+uf>Dt^I(&KCh9wj$p@d6%$G05wzV|CuiW%tZY9ei3Ua(MTvf{NvmSs4D%u zeliiqHXhEOA3*1;fEWs2uguJV;Qu?WRwk}LMNy{U|2xho)GEQnR4MxZxt#ApU=lMn zB_Ux1MgK49d=~;|rmVZhegew$#{bia=fIh=sFK?50*FQbKbP}e2%L#o7$Qs}5QzR? z()lg~uGhG}AS}`Ulk?5J82JCWRKC9#BmXbSd3-PK{eN>W?*0GY2;~a|7zF^@fie5N Syu}g#0000 Date: Sat, 1 Jul 2017 18:53:02 +0200 Subject: [PATCH 02/12] Snow golems leave snow trail behind --- snowman.lua | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/snowman.lua b/snowman.lua index c00dec2..9b0b197 100644 --- a/snowman.lua +++ b/snowman.lua @@ -3,6 +3,8 @@ --made for MC like Survival game --License for code WTFPL and otherwise stated in readmes +local snow_trail_frequency = 1 + mobs:register_mob("mobs_mc:snowman", { type = "npc", passive = true, @@ -40,6 +42,28 @@ mobs:register_mob("mobs_mc:snowman", { die_loop = false, }, blood_amount = 0, + do_custom = function(self, dtime) + -- Leave a trail of top snow behind. + -- This is done in do_custom instead of just using replace_what because with replace_what, + -- the top snop may end up floating in the air. + if not self._snowtimer then + self._snowtimer = 0 + return + end + self._snowtimer = self._snowtimer + dtime + if self.health > 0 and self._snowtimer > snow_trail_frequency then + local pos = self.object:getpos() + local below = {x=pos.x, y=pos.y-1, z=pos.z} + local def = minetest.registered_nodes[minetest.get_node(pos).name] + if def and def.buildable_to then + local belowdef = minetest.registered_nodes[minetest.get_node(below).name] + if belowdef and belowdef.walkable then + -- Place top snow + minetest.set_node(pos, {name = mobs_mc.items.top_snow}) + end + end + end + end, }) mobs:register_egg("mobs_mc:snowman", "Snow Golem", "mobs_mc_spawn_icon_snowman.png", 0) From 4d7c457892779427bd542996a80f358b0f6825db Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Sat, 1 Jul 2017 18:59:00 +0200 Subject: [PATCH 03/12] Fix some snow golem snow trail oddities --- snowman.lua | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/snowman.lua b/snowman.lua index 9b0b197..b724e09 100644 --- a/snowman.lua +++ b/snowman.lua @@ -3,7 +3,7 @@ --made for MC like Survival game --License for code WTFPL and otherwise stated in readmes -local snow_trail_frequency = 1 +local snow_trail_frequency = 0.5 -- Time in seconds for checking to add a new snow trail mobs:register_mob("mobs_mc:snowman", { type = "npc", @@ -52,12 +52,16 @@ mobs:register_mob("mobs_mc:snowman", { end self._snowtimer = self._snowtimer + dtime if self.health > 0 and self._snowtimer > snow_trail_frequency then + self._snowtimer = 0 local pos = self.object:getpos() local below = {x=pos.x, y=pos.y-1, z=pos.z} local def = minetest.registered_nodes[minetest.get_node(pos).name] + -- Node at snow golem's position must be replacable if def and def.buildable_to then + -- Node below must be walkable + -- and a full cube (this prevents oddities like top snow on top snow, lower slabs, etc.) local belowdef = minetest.registered_nodes[minetest.get_node(below).name] - if belowdef and belowdef.walkable then + if belowdef and belowdef.walkable and (belowdef.node_box == nil or belowdef.node_box.type == "regular") then -- Place top snow minetest.set_node(pos, {name = mobs_mc.items.top_snow}) end From 099c963a45d373828d9080762077df6e3f024a0d Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Sat, 1 Jul 2017 19:43:03 +0200 Subject: [PATCH 04/12] Add rudimentary throwable snowballs --- 0_gameconfig.lua | 4 +- 1_items_default.lua | 20 +++++++ 2_throwing.lua | 85 +++++++++++++++++++++++++++-- snowman.lua | 7 ++- textures/mcl_throwing_snowball.png | Bin 0 -> 212 bytes 5 files changed, 109 insertions(+), 7 deletions(-) create mode 100644 textures/mcl_throwing_snowball.png diff --git a/0_gameconfig.lua b/0_gameconfig.lua index da025a1..63abbcd 100644 --- a/0_gameconfig.lua +++ b/0_gameconfig.lua @@ -48,8 +48,7 @@ mobs_mc.items = { shulker_shell = "mobs_mc:shulker_shell", magma_cream = "mobs_mc:magma_cream", spider_eye = "mobs_mc:spider_eye", - snowball = "default:snow", - top_snow = "default:snow", + snowball = "mobs_mc:snowball", totem = "mobs_mc:totem", rotten_flesh = "mobs_mc:rotten_flesh", nether_star = "mobs_mc:nether_star", @@ -63,6 +62,7 @@ mobs_mc.items = { shears = "mobs:shears", -- Minetest Game + top_snow = "default:snow", mushroom_red = "flowers:mushroom_red", bucket = "bucket:bucket_empty", grass_block = "default:dirt_with_grass", diff --git a/1_items_default.lua b/1_items_default.lua index 5719503..220985c 100644 --- a/1_items_default.lua +++ b/1_items_default.lua @@ -495,3 +495,23 @@ if c("nether_star") then }) end +if c("snowball") and minetest.get_modpath("default") then + minetest.register_craft({ + output = "mobs_mc:snowball 2", + recipe = { + {"default:snow"}, + }, + }) + minetest.register_craft({ + output = "default:snow 2", + recipe = { + {"mobs_mc:snowball", "mobs_mc:snowball"}, + {"mobs_mc:snowball", "mobs_mc:snowball"}, + }, + }) + -- Change the appearance of default snow to avoid confusion with snowball + minetest.override_item("default:snow", { + inventory_image = "", + wield_image = "default_snow.png", + }) +end diff --git a/2_throwing.lua b/2_throwing.lua index 823b099..94d2ebd 100644 --- a/2_throwing.lua +++ b/2_throwing.lua @@ -173,11 +173,14 @@ end -- egg throwing item -- egg entity if c("egg") then + local egg_GRAVITY = 9 + local egg_VELOCITY = 19 + mobs:register_arrow("mobs_mc:egg_entity", { visual = "sprite", visual_size = {x=.5, y=.5}, textures = {"mobs_chicken_egg.png"}, - velocity = 6, + velocity = egg_velocity, hit_player = function(self, player) player:punch(minetest.get_player_by_name(self.playername) or self.object, 1.0, { @@ -233,9 +236,6 @@ if c("egg") then end }) - local egg_GRAVITY = 9 - local egg_VELOCITY = 19 - -- shoot egg local mobs_shoot_egg = function (item, player, pointed_thing) @@ -287,6 +287,83 @@ if c("egg") then }) end +if c("snowball") then + local snowball_GRAVITY = 9 + local snowball_VELOCITY = 19 + + mobs:register_arrow("mobs_mc:snowball_entity", { + visual = "sprite", + visual_size = {x=.5, y=.5}, + textures = {"mcl_throwing_snowball.png"}, + velocity = snowball_VELOCITY, + + hit_player = function(self, player) + -- FIXME: No knockback + player:punch(self.object, 1.0, { + full_punch_interval = 1.0, + damage_groups = {}, + }, nil) + end, + + hit_mob = function(self, player) + -- FIXME: No knockback + player:punch(self.object, 1.0, { + full_punch_interval = 1.0, + damage_groups = {}, + }, nil) + end, + + }) + + -- shoot snowball + local mobs_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 + }, "mobs_mc:snowball_entity") + + local ent = obj:get_luaentity() + local dir = player:get_look_dir() + + ent.velocity = snowball_VELOCITY -- needed for api internal timing + ent.switch = 1 -- needed so that egg doesn't despawn straight away + + 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 + }) + + -- pass player name to egg for chick ownership + local ent2 = obj:get_luaentity() + ent2.playername = player:get_player_name() + + item:take_item() + + return item + end + + + -- Snowball + minetest.register_craftitem("mobs_mc:snowball", { + description = "Snowball", + _doc_items_longdesc = "Snowballs can be thrown by hand for fun. Hitting something with a snowball does nothing.", + _doc_items_usagehelp = how_to_throw, + inventory_image = "mcl_throwing_snowball.png", + on_use = mobs_shoot_snowball, + }) +end + --end maikerumine code if minetest.settings:get_bool("log_mods") then diff --git a/snowman.lua b/snowman.lua index b724e09..3e4d634 100644 --- a/snowman.lua +++ b/snowman.lua @@ -11,7 +11,7 @@ mobs:register_mob("mobs_mc:snowman", { hp_min = 4, hp_max = 4, pathfinding = 1, - view_range = 16, + view_range = 10, fall_damage = 0, water_damage = 4, lava_damage = 20, @@ -28,6 +28,11 @@ mobs:register_mob("mobs_mc:snowman", { walk_velocity = 0.6, run_velocity = 2, jump = true, + makes_footstep_sound = true, + attack_type = "shoot", + arrow = "mobs_mc:snowball_entity", + shoot_interval = 1, + shoot_offset = 1, animation = { speed_normal = 25, speed_run = 50, diff --git a/textures/mcl_throwing_snowball.png b/textures/mcl_throwing_snowball.png new file mode 100644 index 0000000000000000000000000000000000000000..5fcc76f2fc18fbf3508a494bd7126cb2741633d5 GIT binary patch literal 212 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!73?$#)eFPGa2=EDU1=71uoVj`T{=a|!*6lyi zGi~n7WvhCp&r?3X@C;Cnu_VYZn8D%MjWi%9%hSa%q=M1M>!>KR0*~+8J|71Aeq$pC z+w?LAw->)kyXzMJzx3;??1BFMC)n!B*_SDN{>dmaNwR!-%ImXh${7yZhD23A(fPYj zMnY-oiAPtS+xk@V71cHL&iVcHoxoi&scBpy44a)M&ShX=T`kbyqE-|Nw3Wfr)z4*} HQ$iB}9)nUv literal 0 HcmV?d00001 From 245ab56cc18e9e659ba264cccf621915e94bcee8 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Sat, 1 Jul 2017 19:58:04 +0200 Subject: [PATCH 05/12] Remove snow golem pumpkin if using shears --- snowman.lua | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/snowman.lua b/snowman.lua index 3e4d634..7505d0c 100644 --- a/snowman.lua +++ b/snowman.lua @@ -22,7 +22,7 @@ mobs:register_mob("mobs_mc:snowman", { textures = { {"mobs_mc_snowman.png^mobs_mc_snowman_pumpkin.png"}, }, - gotten_texture = "mobs_mc_snowman.png", + gotten_texture = { "mobs_mc_snowman.png" }, drops = {{ name = mobs_mc.items.snowball, chance = 1, min = 0, max = 15 }}, visual_size = {x=3, y=3}, walk_velocity = 0.6, @@ -73,6 +73,26 @@ mobs:register_mob("mobs_mc:snowman", { end end end, + -- Remove pumpkin if using shears + on_rightclick = function(self, clicker) + local item = clicker:get_wielded_item() + if self.gotten ~= true and item:get_name() == mobs_mc.items.shears then + -- Remove pumpkin + self.gotten = true + self.object:set_properties({ + textures = {"mobs_mc_snowman.png"}, + }) + + local pos = self.object:getpos() + minetest.sound_play("shears", {pos = pos}) + + -- Wear out + if not minetest.settings:get_bool("creative_mode") then + item:add_wear(300) + clicker:get_inventory():set_stack("main", clicker:get_wield_index(), item) + end + end + end, }) mobs:register_egg("mobs_mc:snowman", "Snow Golem", "mobs_mc_spawn_icon_snowman.png", 0) From f832972d38270760b042dcf4946a6e3728eae600 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Sat, 1 Jul 2017 20:06:37 +0200 Subject: [PATCH 06/12] Centralize shears use count --- 0_gameconfig.lua | 6 +++++- cow+mooshroom.lua | 2 +- sheep.lua | 2 +- snowman.lua | 2 +- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/0_gameconfig.lua b/0_gameconfig.lua index 63abbcd..5bd7a39 100644 --- a/0_gameconfig.lua +++ b/0_gameconfig.lua @@ -246,9 +246,13 @@ mobs_mc.spawn = { water = { mobs_mc.items.water_source, "mcl_core:water_source", "default:water_source" }, } +mobs_mc.misc = { + shears_wear = 276, -- Wear to add per shears usage (238 uses) +} + -- Item name overrides from mobs_mc_gameconfig (if present) if minetest.get_modpath("mobs_mc_gameconfig") and mobs_mc.override then - local tables = {"items", "follow", "replace", "spawn"} + local tables = {"items", "follow", "replace", "spawn", "misc"} for t=1, #tables do local tbl = tables[t] if mobs_mc.override[tbl] then diff --git a/cow+mooshroom.lua b/cow+mooshroom.lua index e396447..da62e5e 100644 --- a/cow+mooshroom.lua +++ b/cow+mooshroom.lua @@ -88,7 +88,7 @@ mooshroom_def.on_rightclick = function(self, clicker) cow:setyaw(oldyaw) if not minetest.setting_getbool("creative_mode") then - item:add_wear(300) + item:add_wear(mobs_mc.misc.shears_wear) clicker:get_inventory():set_stack("main", clicker:get_wield_index(), item) end -- Use bucket to milk diff --git a/sheep.lua b/sheep.lua index ba26a51..6201de0 100644 --- a/sheep.lua +++ b/sheep.lua @@ -176,7 +176,7 @@ mobs:register_mob("mobs_mc:sheep", { textures = self.base_texture, }) if not minetest.settings:get_bool("creative_mode") then - item:add_wear(300) + item:add_wear(mobs_mc.misc.shears_wear) clicker:get_inventory():set_stack("main", clicker:get_wield_index(), item) end self.drops = { diff --git a/snowman.lua b/snowman.lua index 7505d0c..6fe06ff 100644 --- a/snowman.lua +++ b/snowman.lua @@ -88,7 +88,7 @@ mobs:register_mob("mobs_mc:snowman", { -- Wear out if not minetest.settings:get_bool("creative_mode") then - item:add_wear(300) + item:add_wear(mobs_mc.misc.shears_wear) clicker:get_inventory():set_stack("main", clicker:get_wield_index(), item) end end From beb40dc3cf6efb0490de92e06a5de831e8d5060a Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Sat, 1 Jul 2017 20:58:22 +0200 Subject: [PATCH 07/12] Add snow golem summon utility function --- 0_gameconfig.lua | 2 ++ init.lua | 3 +++ snowman.lua | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 40 insertions(+) diff --git a/0_gameconfig.lua b/0_gameconfig.lua index 5bd7a39..193f7b9 100644 --- a/0_gameconfig.lua +++ b/0_gameconfig.lua @@ -63,6 +63,7 @@ mobs_mc.items = { -- Minetest Game top_snow = "default:snow", + snow_block = "default:snowblock", mushroom_red = "flowers:mushroom_red", bucket = "bucket:bucket_empty", grass_block = "default:dirt_with_grass", @@ -137,6 +138,7 @@ mobs_mc.items = { wool_black = "wool:black", -- Light blue intentionally missing + -- Special items music_discs = {}, -- No music discs by default; used by creeper. Override this if your subgame has music discs. } diff --git a/init.lua b/init.lua index f59cf97..d9291b4 100644 --- a/init.lua +++ b/init.lua @@ -9,6 +9,9 @@ if not minetest.get_modpath("mobs_mc_gameconfig") then mobs_mc = {} end +-- For utility functions +mobs_mc.tools = {} + -- This function checks if the item ID has been overwritten and returns true if it is unchanged if minetest.get_modpath("mobs_mc_gameconfig") and mobs_mc.override and mobs_mc.override.items then mobs_mc.is_item_variable_overridden = function(id) diff --git a/snowman.lua b/snowman.lua index 6fe06ff..94c5929 100644 --- a/snowman.lua +++ b/snowman.lua @@ -95,6 +95,41 @@ mobs:register_mob("mobs_mc:snowman", { end, }) +-- This is to be called when a pumpkin or jack'o lantern has been placed. Recommended: In the on_construct function +-- of the node. +-- This summons a snow golen when pos is next to a row of two snow blocks. +mobs_mc.tools.check_snow_golem_summon = function(pos) + local checks = { + -- These are the possible placement patterns + -- { snow block pos. 1, snow block pos. 2, snow golem spawn position } + { {x=pos.x, y=pos.y-1, z=pos.z}, {x=pos.x, y=pos.y-2, z=pos.z}, {x=pos.x, y=pos.y-2.5, z=pos.z} }, + { {x=pos.x, y=pos.y+1, z=pos.z}, {x=pos.x, y=pos.y+2, z=pos.z}, {x=pos.x, y=pos.y-0.5, z=pos.z} }, + { {x=pos.x-1, y=pos.y, z=pos.z}, {x=pos.x-2, y=pos.y, z=pos.z}, {x=pos.x-2, y=pos.y-0.5, z=pos.z} }, + { {x=pos.x+1, y=pos.y, z=pos.z}, {x=pos.x+2, y=pos.y, z=pos.z}, {x=pos.x+2, y=pos.y-0.5, z=pos.z} }, + { {x=pos.x, y=pos.y, z=pos.z-1}, {x=pos.x, y=pos.y, z=pos.z-2}, {x=pos.x, y=pos.y-0.5, z=pos.z-2} }, + { {x=pos.x, y=pos.y, z=pos.z+1}, {x=pos.x, y=pos.y, z=pos.z+2}, {x=pos.x, y=pos.y-0.5, z=pos.z+2} }, + } + + for c=1, #checks do + local b1 = checks[c][1] + local b2 = checks[c][2] + local place = checks[c][3] + local b1n = minetest.get_node(b1) + local b2n = minetest.get_node(b2) + if b1n.name == mobs_mc.items.snow_block and b2n.name == mobs_mc.items.snow_block then + -- Remove the pumpkin and both snow blocks and summon the snow golem + minetest.remove_node(pos) + minetest.remove_node(b1) + minetest.remove_node(b2) + core.check_for_falling(pos) + core.check_for_falling(b1) + core.check_for_falling(b2) + minetest.add_entity(place, "mobs_mc:snowman") + break + end + end +end + mobs:register_egg("mobs_mc:snowman", "Snow Golem", "mobs_mc_spawn_icon_snowman.png", 0) if minetest.settings:get_bool("log_mods") then From 28ef66c331f2f1939edc3adb65571ce45e03e3b1 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Sat, 1 Jul 2017 22:48:35 +0200 Subject: [PATCH 08/12] Add helper function for summoning iron golems --- 0_gameconfig.lua | 1 + iron_golem.lua | 108 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 109 insertions(+) diff --git a/0_gameconfig.lua b/0_gameconfig.lua index 193f7b9..17eaf7c 100644 --- a/0_gameconfig.lua +++ b/0_gameconfig.lua @@ -71,6 +71,7 @@ mobs_mc.items = { stick = "default:stick", flint = "default:flint", iron_ingot = "default:steel_ingot", + iron_block = "default:steelblock", fire = "fire:basic_flame", gunpowder = "tnt:gunpowder", flint_and_steel = "fire:flint_and_steel", diff --git a/iron_golem.lua b/iron_golem.lua index 42150c6..72fff85 100644 --- a/iron_golem.lua +++ b/iron_golem.lua @@ -70,6 +70,114 @@ mobs:register_mob("mobs_mc:iron_golem", { mobs:register_egg("mobs_mc:iron_golem", "Iron Golem", "mobs_mc_spawn_icon_iron_golem.png", 0) +--[[ This is to be called when a pumpkin or jack'o lantern has been placed. Recommended: In the on_construct function of the node. +This summons an iron golen if placing the pumpkin created an iron golem summon pattern: + +.P. +III +.I. + +P = Pumpkin or jack'o lantern +I = Iron block +. = Air +]] + +mobs_mc.tools.check_iron_golem_summon = function(pos) + local checks = { + -- These are the possible placement patterns, with offset from the pumpkin block. + -- These tables include the positions of the iron blocks (1-4) and air blocks (5-8) + -- 4th element is used to determine spawn position. + -- If a 9th element is present, that one is used for the spawn position instead. + -- Standing (x axis) + { + {x=-1, y=-1, z=0}, {x=1, y=-1, z=0}, {x=0, y=-1, z=0}, {x=0, y=-2, z=0}, -- iron blocks + {x=-1, y=0, z=0}, {x=1, y=0, z=0}, {x=-1, y=-2, z=0}, {x=1, y=-2, z=0}, -- air + }, + -- Upside down standing (x axis) + { + {x=-1, y=1, z=0}, {x=1, y=1, z=0}, {x=0, y=1, z=0}, {x=0, y=2, z=0}, + {x=-1, y=0, z=0}, {x=1, y=0, z=0}, {x=-1, y=2, z=0}, {x=1, y=2, z=0}, + {x=0, y=0, z=0}, -- Different offset for upside down pattern + }, + + -- Standing (z axis) + { + {x=0, y=-1, z=-1}, {x=0, y=-1, z=1}, {x=0, y=-1, z=0}, {x=0, y=-2, z=0}, + {x=0, y=0, z=-1}, {x=0, y=0, z=1}, {x=0, y=-2, z=-1}, {x=0, y=-2, z=1}, + }, + -- Upside down standing (z axis) + { + {x=0, y=1, z=-1}, {x=0, y=1, z=1}, {x=0, y=1, z=0}, {x=0, y=2, z=0}, + {x=0, y=0, z=-1}, {x=0, y=0, z=1}, {x=0, y=2, z=-1}, {x=0, y=2, z=1}, + {x=0, y=0, z=0}, + }, + + -- Lying + { + {x=-1, y=0, z=-1}, {x=0, y=0, z=-1}, {x=1, y=0, z=-1}, {x=0, y=0, z=-2}, + {x=-1, y=0, z=0}, {x=1, y=0, z=0}, {x=-1, y=0, z=-2}, {x=1, y=0, z=-2}, + }, + { + {x=-1, y=0, z=1}, {x=0, y=0, z=1}, {x=1, y=0, z=1}, {x=0, y=0, z=2}, + {x=-1, y=0, z=0}, {x=1, y=0, z=0}, {x=-1, y=0, z=2}, {x=1, y=0, z=2}, + }, + { + {x=-1, y=0, z=-1}, {x=-1, y=0, z=0}, {x=-1, y=0, z=1}, {x=-2, y=0, z=0}, + {x=0, y=0, z=-1}, {x=0, y=0, z=1}, {x=-2, y=0, z=-1}, {x=-2, y=0, z=1}, + }, + { + {x=1, y=0, z=-1}, {x=1, y=0, z=0}, {x=1, y=0, z=1}, {x=2, y=0, z=0}, + {x=0, y=0, z=-1}, {x=0, y=0, z=1}, {x=2, y=0, z=-1}, {x=2, y=0, z=1}, + }, + + + } + + for c=1, #checks do + -- Check all possible patterns + local ok = true + -- Check iron block nodes + for i=1, 4 do + local cpos = vector.add(pos, checks[c][i]) + local node = minetest.get_node(cpos) + if node.name ~= mobs_mc.items.iron_block then + ok = false + break + end + end + -- Check air nodes + for a=5, 8 do + local cpos = vector.add(pos, checks[c][a]) + local node = minetest.get_node(cpos) + if node.name ~= "air" then + ok = false + break + end + end + -- Pattern found! + if ok then + -- Remove the nodes + minetest.remove_node(pos) + core.check_for_falling(pos) + for i=1, 4 do + local cpos = vector.add(pos, checks[c][i]) + minetest.remove_node(cpos) + core.check_for_falling(cpos) + end + -- Summon iron golem + local place + if checks[c][9] then + place = vector.add(pos, checks[c][9]) + else + place = vector.add(pos, checks[c][4]) + end + place.y = place.y - 0.5 + minetest.add_entity(place, "mobs_mc:iron_golem") + break + end + end +end + if minetest.settings:get_bool("log_mods") then minetest.log("action", "MC Iron Golem loaded") end From abab4fc51ef77863e4215f4d641715d097c8d59f Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Sat, 1 Jul 2017 22:54:51 +0200 Subject: [PATCH 09/12] Update gameconfig.md about pumpkin stuff --- gameconfig.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/gameconfig.md b/gameconfig.md index 3090b69..dabfb93 100644 --- a/gameconfig.md +++ b/gameconfig.md @@ -2,7 +2,7 @@ This mod has been designed to make subgame integration rather easy. Ideally, it should be possible to include this mod verbatim in your subgame, with modifications only done by an external mod. -To integrate this mod in a subgame, you have to do 2 things: Adding the mod, and adding another mod which tells `mobs_mc` which items to use. The idea is that `mobs_mc` should work with any items. Specifically, theres are the steps you need to follow +To integrate this mod in a subgame, you have to do 2 things: Adding the mod, and adding another mod which tells `mobs_mc` which items to use. The idea is that `mobs_mc` should work with any items. Specifically, these are the steps you need to follow: * Add the `mobs_mc` mod and its dependencies * Add a mod with name “`mobs_mc_gameconfig`” @@ -12,6 +12,10 @@ To integrate this mod in a subgame, you have to do 2 things: Adding the mod, and * Create the table `mobs_mc.override` * In `mobs_mc.override`, create subtables (`items`, `spawn`, etc.) like in `0_gameconfig.lua`, defining the na * Read `0_gameconfig.lua` to see which items you can override (and more explanations) +* In `on_construct` of a pumpkin or jack'o lantern node, call: + * `mobs_mc.tools.check_iron_golem_summon(pos)` + * `mobs_mc.tools.check_snow_golem_summon(pos)` + * For more information, see `snowman.lua` and `iron_golem.lua` Some things to note: From de51c35bf1d6191569b188865f720ff69c90c086 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Sat, 1 Jul 2017 23:05:37 +0200 Subject: [PATCH 10/12] Snowballs now hurt blazes --- 2_throwing.lua | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/2_throwing.lua b/2_throwing.lua index 94d2ebd..9e364d7 100644 --- a/2_throwing.lua +++ b/2_throwing.lua @@ -305,11 +305,17 @@ if c("snowball") then }, nil) end, - hit_mob = function(self, player) + hit_mob = function(self, mob) + -- Hurt blazes, but not damage to anything else + local dmg = {} + minetest.log("error", dump(mob)) + if mob:get_luaentity().name == "mobs_mc:blaze" then + dmg = {fleshy = 3} + end -- FIXME: No knockback - player:punch(self.object, 1.0, { + mob:punch(self.object, 1.0, { full_punch_interval = 1.0, - damage_groups = {}, + damage_groups = dmg, }, nil) end, @@ -357,8 +363,7 @@ if c("snowball") then -- Snowball minetest.register_craftitem("mobs_mc:snowball", { description = "Snowball", - _doc_items_longdesc = "Snowballs can be thrown by hand for fun. Hitting something with a snowball does nothing.", - _doc_items_usagehelp = how_to_throw, + _doc_items_longdesc = "Snowballs can be thrown for fun. A snowball deals 3 damage to blazes, but is harmless to anything else.", inventory_image = "mcl_throwing_snowball.png", on_use = mobs_shoot_snowball, }) From a78120857ca92bcf705008b9a86e1faf1edd3c52 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Sat, 1 Jul 2017 23:09:44 +0200 Subject: [PATCH 11/12] Infinite snowballs/eggs in creative --- 2_throwing.lua | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/2_throwing.lua b/2_throwing.lua index 9e364d7..8a8db2a 100644 --- a/2_throwing.lua +++ b/2_throwing.lua @@ -275,7 +275,9 @@ if c("egg") then local ent2 = obj:get_luaentity() ent2.playername = player:get_player_name() - item:take_item() + if not minetest.settings:get_bool("creative_mode") then + item:take_item() + end return item end @@ -354,7 +356,9 @@ if c("snowball") then local ent2 = obj:get_luaentity() ent2.playername = player:get_player_name() - item:take_item() + if not minetest.settings:get_bool("creative_mode") then + item:take_item() + end return item end From b9edb9de3fdcd2e63e16c57a77942adea8dbeda3 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Sat, 1 Jul 2017 23:26:09 +0200 Subject: [PATCH 12/12] Fix weird fall image of default snow --- 1_items_default.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1_items_default.lua b/1_items_default.lua index 220985c..2ed8e09 100644 --- a/1_items_default.lua +++ b/1_items_default.lua @@ -512,6 +512,6 @@ if c("snowball") and minetest.get_modpath("default") then -- Change the appearance of default snow to avoid confusion with snowball minetest.override_item("default:snow", { inventory_image = "", - wield_image = "default_snow.png", + wield_image = "", }) end