3 --made for MC like Survival game
4 --License for code WTFPL and otherwise stated in readmes
7 local MP
= minetest
.get_modpath(minetest
.get_current_modname())
8 local S
, NS
= dofile(MP
.."/intllib.lua")
10 --dofile(minetest.get_modpath("mobs").."/api.lua")
12 --################### IRON GOLEM
17 mobs
:register_mob("mobs_mc:iron_golem", {
22 collisionbox
= {-0.7, -0.01, -0.7, 0.7, 2.69, 0.7},
24 mesh
= "mobs_mc_iron_golem.b3d",
26 {"mobs_mc_iron_golem.png"},
28 visual_size
= {x
=3, y
=3},
29 makes_footstep_sound
= true,
45 attacks_monsters
= true,
46 attack_type
= "dogfight",
48 {name
= mobs_mc
.items
.iron_ingot
,
52 {name
= mobs_mc
.items
.poppy
,
62 stand_speed
= 15, walk_speed
= 15, run_speed
= 25, punch_speed
= 15,
63 stand_start
= 0, stand_end
= 0,
64 walk_start
= 0, walk_end
= 40,
65 run_start
= 0, run_end
= 40,
66 punch_start
= 40, punch_end
= 50,
74 mobs
:register_egg("mobs_mc:iron_golem", S("Iron Golem"), "mobs_mc_spawn_icon_iron_golem.png", 0)
77 --[[ This is to be called when a pumpkin or jack'o lantern has been placed. Recommended: In the on_construct function of the node.
78 This summons an iron golen if placing the pumpkin created an iron golem summon pattern:
84 P = Pumpkin or jack'o lantern
89 mobs_mc
.tools
.check_iron_golem_summon
= function(pos
)
91 -- These are the possible placement patterns, with offset from the pumpkin block.
92 -- These tables include the positions of the iron blocks (1-4) and air blocks (5-8)
93 -- 4th element is used to determine spawn position.
94 -- If a 9th element is present, that one is used for the spawn position instead.
97 {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
98 {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
100 -- Upside down standing (x axis)
102 {x
=-1, y
=1, z
=0}, {x
=1, y
=1, z
=0}, {x
=0, y
=1, z
=0}, {x
=0, y
=2, z
=0},
103 {x
=-1, y
=0, z
=0}, {x
=1, y
=0, z
=0}, {x
=-1, y
=2, z
=0}, {x
=1, y
=2, z
=0},
104 {x
=0, y
=0, z
=0}, -- Different offset for upside down pattern
109 {x
=0, y
=-1, z
=-1}, {x
=0, y
=-1, z
=1}, {x
=0, y
=-1, z
=0}, {x
=0, y
=-2, z
=0},
110 {x
=0, y
=0, z
=-1}, {x
=0, y
=0, z
=1}, {x
=0, y
=-2, z
=-1}, {x
=0, y
=-2, z
=1},
112 -- Upside down standing (z axis)
114 {x
=0, y
=1, z
=-1}, {x
=0, y
=1, z
=1}, {x
=0, y
=1, z
=0}, {x
=0, y
=2, z
=0},
115 {x
=0, y
=0, z
=-1}, {x
=0, y
=0, z
=1}, {x
=0, y
=2, z
=-1}, {x
=0, y
=2, z
=1},
121 {x
=-1, y
=0, z
=-1}, {x
=0, y
=0, z
=-1}, {x
=1, y
=0, z
=-1}, {x
=0, y
=0, z
=-2},
122 {x
=-1, y
=0, z
=0}, {x
=1, y
=0, z
=0}, {x
=-1, y
=0, z
=-2}, {x
=1, y
=0, z
=-2},
125 {x
=-1, y
=0, z
=1}, {x
=0, y
=0, z
=1}, {x
=1, y
=0, z
=1}, {x
=0, y
=0, z
=2},
126 {x
=-1, y
=0, z
=0}, {x
=1, y
=0, z
=0}, {x
=-1, y
=0, z
=2}, {x
=1, y
=0, z
=2},
129 {x
=-1, y
=0, z
=-1}, {x
=-1, y
=0, z
=0}, {x
=-1, y
=0, z
=1}, {x
=-2, y
=0, z
=0},
130 {x
=0, y
=0, z
=-1}, {x
=0, y
=0, z
=1}, {x
=-2, y
=0, z
=-1}, {x
=-2, y
=0, z
=1},
133 {x
=1, y
=0, z
=-1}, {x
=1, y
=0, z
=0}, {x
=1, y
=0, z
=1}, {x
=2, y
=0, z
=0},
134 {x
=0, y
=0, z
=-1}, {x
=0, y
=0, z
=1}, {x
=2, y
=0, z
=-1}, {x
=2, y
=0, z
=1},
141 -- Check all possible patterns
143 -- Check iron block nodes
145 local cpos
= vector
.add(pos
, checks
[c
][i
])
146 local node
= minetest
.get_node(cpos
)
147 if node
.name
~= mobs_mc
.items
.iron_block
then
154 local cpos
= vector
.add(pos
, checks
[c
][a
])
155 local node
= minetest
.get_node(cpos
)
156 if node
.name
~= "air" then
164 minetest
.remove_node(pos
)
165 core
.check_for_falling(pos
)
167 local cpos
= vector
.add(pos
, checks
[c
][i
])
168 minetest
.remove_node(cpos
)
169 core
.check_for_falling(cpos
)
174 place
= vector
.add(pos
, checks
[c
][9])
176 place
= vector
.add(pos
, checks
[c
][4])
178 place
.y
= place
.y
- 0.5
179 minetest
.add_entity(place
, "mobs_mc:iron_golem")
185 if minetest
.settings
:get_bool("log_mods") then
186 minetest
.log("action", "MC Iron Golem loaded")