forked from MineClone5/MineClone5
Merge remote-tracking branch 'spawner/spawner' into spawner
These are my changes that fix a spawning bug that allowed monsters to spawn no matter what light level if you had manually created the spawner
This commit is contained in:
commit
bc3ecb175e
Binary file not shown.
BIN
menu/icon.png
BIN
menu/icon.png
Binary file not shown.
Before Width: | Height: | Size: 3.9 KiB After Width: | Height: | Size: 547 KiB |
Binary file not shown.
After Width: | Height: | Size: 419 KiB |
|
@ -144,6 +144,7 @@ dofile(api_path .. "mob_effects.lua")
|
||||||
dofile(api_path .. "projectile_handling.lua")
|
dofile(api_path .. "projectile_handling.lua")
|
||||||
dofile(api_path .. "breeding.lua")
|
dofile(api_path .. "breeding.lua")
|
||||||
dofile(api_path .. "head_logic.lua")
|
dofile(api_path .. "head_logic.lua")
|
||||||
|
dofile(api_path .. "monster_light.lua")
|
||||||
|
|
||||||
|
|
||||||
mobs.spawning_mobs = {}
|
mobs.spawning_mobs = {}
|
||||||
|
@ -436,55 +437,6 @@ function mobs:register_mob(name, def)
|
||||||
|
|
||||||
end -- END mobs:register_mob function
|
end -- END mobs:register_mob function
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
-- register arrow for shoot attack
|
-- register arrow for shoot attack
|
||||||
function mobs:register_arrow(name, def)
|
function mobs:register_arrow(name, def)
|
||||||
|
|
||||||
|
@ -586,36 +538,6 @@ function mobs:register_arrow(name, def)
|
||||||
self.object:remove();
|
self.object:remove();
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[
|
|
||||||
local entity = player:get_luaentity()
|
|
||||||
|
|
||||||
if entity
|
|
||||||
and self.hit_mob
|
|
||||||
and entity._cmi_is_mob == true
|
|
||||||
and tostring(player) ~= self.owner_id
|
|
||||||
and entity.name ~= self.object:get_luaentity().name
|
|
||||||
and (self._shooter and entity.name ~= self._shooter:get_luaentity().name) then
|
|
||||||
|
|
||||||
--self.hit_mob(self, player)
|
|
||||||
self.object:remove();
|
|
||||||
return
|
|
||||||
end
|
|
||||||
]]--
|
|
||||||
|
|
||||||
--[[
|
|
||||||
if entity
|
|
||||||
and self.hit_object
|
|
||||||
and (not entity._cmi_is_mob)
|
|
||||||
and tostring(player) ~= self.owner_id
|
|
||||||
and entity.name ~= self.object:get_luaentity().name
|
|
||||||
and (self._shooter and entity.name ~= self._shooter:get_luaentity().name) then
|
|
||||||
|
|
||||||
--self.hit_object(self, player)
|
|
||||||
self.object:remove();
|
|
||||||
return
|
|
||||||
end
|
|
||||||
]]--
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -630,7 +552,6 @@ end
|
||||||
-- * spawn_egg=1: Spawn egg (generic mob, no metadata)
|
-- * spawn_egg=1: Spawn egg (generic mob, no metadata)
|
||||||
-- * spawn_egg=2: Spawn egg (captured/tamed mob, metadata)
|
-- * spawn_egg=2: Spawn egg (captured/tamed mob, metadata)
|
||||||
function mobs:register_egg(mob, desc, background, addegg, no_creative)
|
function mobs:register_egg(mob, desc, background, addegg, no_creative)
|
||||||
|
|
||||||
local grp = {spawn_egg = 1}
|
local grp = {spawn_egg = 1}
|
||||||
|
|
||||||
-- do NOT add this egg to creative inventory (e.g. dungeon master)
|
-- do NOT add this egg to creative inventory (e.g. dungeon master)
|
||||||
|
@ -647,7 +568,6 @@ function mobs:register_egg(mob, desc, background, addegg, no_creative)
|
||||||
|
|
||||||
-- register old stackable mob egg
|
-- register old stackable mob egg
|
||||||
minetest.register_craftitem(mob, {
|
minetest.register_craftitem(mob, {
|
||||||
|
|
||||||
description = desc,
|
description = desc,
|
||||||
inventory_image = invimg,
|
inventory_image = invimg,
|
||||||
groups = grp,
|
groups = grp,
|
||||||
|
@ -668,20 +588,50 @@ function mobs:register_egg(mob, desc, background, addegg, no_creative)
|
||||||
|
|
||||||
if pos
|
if pos
|
||||||
--and within_limits(pos, 0)
|
--and within_limits(pos, 0)
|
||||||
|
|
||||||
|
--testing to see if the block you are trying to mess with is protected
|
||||||
and not minetest.is_protected(pos, placer:get_player_name()) then
|
and not minetest.is_protected(pos, placer:get_player_name()) then
|
||||||
|
|
||||||
|
--getting the name of the player that placed the egg, and their privileges.
|
||||||
local name = placer:get_player_name()
|
local name = placer:get_player_name()
|
||||||
local privs = minetest.get_player_privs(name)
|
local privs = minetest.get_player_privs(name)
|
||||||
|
|
||||||
if mod_mobspawners and under.name == "mcl_mobspawners:spawner" then
|
if mod_mobspawners and under.name == "mcl_mobspawners:spawner" then
|
||||||
|
--If the thing you are trying to spawn the egg on is protected
|
||||||
|
--the violation gets reported
|
||||||
if minetest.is_protected(pointed_thing.under, name) then
|
if minetest.is_protected(pointed_thing.under, name) then
|
||||||
minetest.record_protection_violation(pointed_thing.under, name)
|
minetest.record_protection_violation(pointed_thing.under, name)
|
||||||
return itemstack
|
return itemstack
|
||||||
end
|
end
|
||||||
|
|
||||||
if not privs.maphack then
|
if not privs.maphack then
|
||||||
minetest.chat_send_player(name, S("You need the “maphack” privilege to change the mob spawner."))
|
minetest.chat_send_player(name, S("You need the “maphack” privilege to change the mob spawner."))
|
||||||
return itemstack
|
return itemstack
|
||||||
end
|
end
|
||||||
mcl_mobspawners.setup_spawner(pointed_thing.under, itemstack:get_name())
|
|
||||||
|
--Changes the mob spawner type with the egg that you used to click on it
|
||||||
|
--determining monster spawn lvl
|
||||||
|
|
||||||
|
local hold_light = 15
|
||||||
|
local mon_name
|
||||||
|
|
||||||
|
--Extracts mob name from item name
|
||||||
|
for name in string.gmatch(itemstack:get_name(), ":%a.*") do
|
||||||
|
mon_name = name:gsub(":", "")
|
||||||
|
end
|
||||||
|
|
||||||
|
--For every monster in the monster_lightlvl table check if
|
||||||
|
--it matches the spawn egg you're holding
|
||||||
|
for name, lightlvl in pairs(monster_lightlvl) do
|
||||||
|
print(mon_name == name)
|
||||||
|
if name == mon_name then
|
||||||
|
hold_light = lightlvl
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
--Switch out the mob spawner to spawn mobs from the egg that you're holding
|
||||||
|
mcl_mobspawners.setup_spawner(pointed_thing.under, itemstack:get_name(), 0, hold_light)
|
||||||
|
|
||||||
if not mobs.is_creative(name) then
|
if not mobs.is_creative(name) then
|
||||||
itemstack:take_item()
|
itemstack:take_item()
|
||||||
end
|
end
|
||||||
|
@ -692,6 +642,7 @@ function mobs:register_egg(mob, desc, background, addegg, no_creative)
|
||||||
return itemstack
|
return itemstack
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--If only peaceful mobs are allowed, player is not allowed to spawn a monster
|
||||||
if minetest_settings:get_bool("only_peaceful_mobs", false)
|
if minetest_settings:get_bool("only_peaceful_mobs", false)
|
||||||
and minetest_registered_entities[mob].type == "monster" then
|
and minetest_registered_entities[mob].type == "monster" then
|
||||||
minetest.chat_send_player(name, S("Only peaceful mobs allowed!"))
|
minetest.chat_send_player(name, S("Only peaceful mobs allowed!"))
|
||||||
|
@ -699,18 +650,11 @@ function mobs:register_egg(mob, desc, background, addegg, no_creative)
|
||||||
end
|
end
|
||||||
|
|
||||||
local mob = minetest_add_entity(pos, mob)
|
local mob = minetest_add_entity(pos, mob)
|
||||||
|
|
||||||
|
--Log that a mob was spawned by the player who spawned it and the coordinates
|
||||||
minetest.log("action", "Mob spawned: "..name.." at "..minetest.pos_to_string(pos))
|
minetest.log("action", "Mob spawned: "..name.." at "..minetest.pos_to_string(pos))
|
||||||
local ent = mob:get_luaentity()
|
local ent = mob:get_luaentity()
|
||||||
|
|
||||||
-- don't set owner if monster or sneak pressed
|
|
||||||
--[[
|
|
||||||
if ent.type ~= "monster"
|
|
||||||
and not placer:get_player_control().sneak then
|
|
||||||
ent.owner = placer:get_player_name()
|
|
||||||
ent.tamed = true
|
|
||||||
end
|
|
||||||
]]--
|
|
||||||
|
|
||||||
-- set nametag
|
-- set nametag
|
||||||
local nametag = itemstack:get_meta():get_string("name")
|
local nametag = itemstack:get_meta():get_string("name")
|
||||||
if nametag ~= "" then
|
if nametag ~= "" then
|
||||||
|
@ -721,7 +665,8 @@ function mobs:register_egg(mob, desc, background, addegg, no_creative)
|
||||||
--update_tag(ent)
|
--update_tag(ent)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- if not in creative then take item
|
-- if not in creative then remove the item from the stack
|
||||||
|
-- taking the player's item
|
||||||
if not mobs.is_creative(placer:get_player_name()) then
|
if not mobs.is_creative(placer:get_player_name()) then
|
||||||
itemstack:take_item()
|
itemstack:take_item()
|
||||||
end
|
end
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
-- This file contains all of the light levels for monsters in the game
|
||||||
|
-- If the mob is not here they either do not exist or can spawn at any light level
|
||||||
|
monster_lightlvl = {
|
||||||
|
zombie = 0,
|
||||||
|
skeleton = 0,
|
||||||
|
stray = 0,
|
||||||
|
blaze = 11,
|
||||||
|
skeleton_wither = 7,
|
||||||
|
pigman = 10,
|
||||||
|
baby_pigman = 10,
|
||||||
|
slime_big = 7,
|
||||||
|
creeper = 0,
|
||||||
|
witch = 0,
|
||||||
|
spider = 0,
|
||||||
|
silverfish = 11,
|
||||||
|
endermen = 7,
|
||||||
|
bat = 3
|
||||||
|
}
|
|
@ -129,7 +129,7 @@ if minetest.get_modpath("mcl_armor") then
|
||||||
pumpkin_blur = player:hud_add({
|
pumpkin_blur = player:hud_add({
|
||||||
hud_elem_type = "image",
|
hud_elem_type = "image",
|
||||||
position = {x = 0.5, y = 0.5},
|
position = {x = 0.5, y = 0.5},
|
||||||
scale = {x = -100, y = -100},
|
scale = {x = -101, y = -101},
|
||||||
text = "mcl_farming_pumpkin_hud.png",
|
text = "mcl_farming_pumpkin_hud.png",
|
||||||
z_index = -200
|
z_index = -200
|
||||||
}),
|
}),
|
||||||
|
|
|
@ -317,7 +317,12 @@ minetest.register_node("mcl_mobspawners:spawner", {
|
||||||
if obj then
|
if obj then
|
||||||
obj:remove()
|
obj:remove()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--Make sure the player is not in creative mode before
|
||||||
|
--giving them xp
|
||||||
|
if not minetest.is_creative_enabled(name) then
|
||||||
mcl_experience.throw_xp(pos, math.random(15, 43))
|
mcl_experience.throw_xp(pos, math.random(15, 43))
|
||||||
|
end
|
||||||
end,
|
end,
|
||||||
|
|
||||||
on_punch = function(pos)
|
on_punch = function(pos)
|
||||||
|
|
|
@ -175,12 +175,6 @@ minetest.register_globalstep(function(dtime)
|
||||||
and (fly_node == "air" or fly_node == "ignore")
|
and (fly_node == "air" or fly_node == "ignore")
|
||||||
|
|
||||||
if elytra.active then
|
if elytra.active then
|
||||||
if player_velocity.x < (player_velocity_old.x - 10) or player_velocity.x > (player_velocity_old.x + 10) and fly_node ~= "ignore" then
|
|
||||||
mcl_util.deal_damage(player, math.abs(player_velocity_old.x) * 0.2, {type = "fly_into_wall"})
|
|
||||||
end
|
|
||||||
if player_velocity.z < (player_velocity_old.z - 10) or player_velocity.z > (player_velocity_old.z + 10) and fly_node ~= "ignore" then
|
|
||||||
mcl_util.deal_damage(player, math.abs(player_velocity_old.z) * 0.2, {type = "fly_into_wall"})
|
|
||||||
end
|
|
||||||
mcl_player.player_set_animation(player, "fly")
|
mcl_player.player_set_animation(player, "fly")
|
||||||
if player_velocity.y < -1.5 then
|
if player_velocity.y < -1.5 then
|
||||||
player:add_velocity({x=0, y=0.17, z=0})
|
player:add_velocity({x=0, y=0.17, z=0})
|
||||||
|
|
Loading…
Reference in New Issue