forked from MineClone5/MineClone5
Merge branch 'testing' into break_range_fix
This commit is contained in:
commit
26cc290342
BIN
menu/icon.png
BIN
menu/icon.png
Binary file not shown.
Before Width: | Height: | Size: 3.9 KiB After Width: | Height: | Size: 60 KiB |
|
@ -22,100 +22,14 @@ function table.update_nil(t, ...)
|
|||
return t
|
||||
end
|
||||
|
||||
-- Based on minetest.rotate_and_place
|
||||
-- Creates a function that calls to the minetest
|
||||
-- function minetest_rotate_and_place. It rotates
|
||||
-- a block based on where it thinks the player is facing
|
||||
-- at the moment. This is typically called by pillar-like nodes.
|
||||
|
||||
--[[
|
||||
Attempt to predict the desired orientation of the pillar-like node
|
||||
defined by `itemstack`, and place it accordingly in one of 3 possible
|
||||
orientations (X, Y or Z).
|
||||
|
||||
Stacks are handled normally if the `infinitestacks`
|
||||
field is false or omitted (else, the itemstack is not changed).
|
||||
* `invert_wall`: if `true`, place wall-orientation on the ground and ground-
|
||||
orientation on wall
|
||||
|
||||
This function is a simplified version of minetest.rotate_and_place.
|
||||
The Minetest function is seen as inappropriate because this includes mirror
|
||||
images of possible orientations, causing problems with pillar shadings.
|
||||
]]
|
||||
function mcl_util.rotate_axis_and_place(itemstack, placer, pointed_thing, infinitestacks, invert_wall)
|
||||
local unode = minetest.get_node_or_nil(pointed_thing.under)
|
||||
if not unode then
|
||||
return
|
||||
end
|
||||
local undef = minetest.registered_nodes[unode.name]
|
||||
if undef and undef.on_rightclick then
|
||||
undef.on_rightclick(pointed_thing.under, unode, placer,
|
||||
itemstack, pointed_thing)
|
||||
return
|
||||
end
|
||||
local fdir = minetest.dir_to_facedir(placer:get_look_dir())
|
||||
local wield_name = itemstack:get_name()
|
||||
|
||||
local above = pointed_thing.above
|
||||
local under = pointed_thing.under
|
||||
local is_x = (above.x ~= under.x)
|
||||
local is_y = (above.y ~= under.y)
|
||||
local is_z = (above.z ~= under.z)
|
||||
|
||||
local anode = minetest.get_node_or_nil(above)
|
||||
if not anode then
|
||||
return
|
||||
end
|
||||
local pos = pointed_thing.above
|
||||
local node = anode
|
||||
|
||||
if undef and undef.buildable_to then
|
||||
pos = pointed_thing.under
|
||||
node = unode
|
||||
end
|
||||
|
||||
if minetest.is_protected(pos, placer:get_player_name()) then
|
||||
minetest.record_protection_violation(pos, placer:get_player_name())
|
||||
return
|
||||
end
|
||||
|
||||
local ndef = minetest.registered_nodes[node.name]
|
||||
if not ndef or not ndef.buildable_to then
|
||||
return
|
||||
end
|
||||
|
||||
local p2
|
||||
if is_y then
|
||||
if invert_wall then
|
||||
if fdir == 3 or fdir == 1 then
|
||||
p2 = 12
|
||||
else
|
||||
p2 = 6
|
||||
end
|
||||
end
|
||||
elseif is_x then
|
||||
if invert_wall then
|
||||
p2 = 0
|
||||
else
|
||||
p2 = 12
|
||||
end
|
||||
elseif is_z then
|
||||
if invert_wall then
|
||||
p2 = 0
|
||||
else
|
||||
p2 = 6
|
||||
end
|
||||
end
|
||||
minetest.set_node(pos, {name = wield_name, param2 = p2})
|
||||
|
||||
if not infinitestacks then
|
||||
itemstack:take_item()
|
||||
return itemstack
|
||||
end
|
||||
end
|
||||
|
||||
-- Wrapper of above function for use as `on_place` callback (Recommended).
|
||||
-- Similar to minetest.rotate_node.
|
||||
function mcl_util.rotate_axis(itemstack, placer, pointed_thing)
|
||||
mcl_util.rotate_axis_and_place(itemstack, placer, pointed_thing,
|
||||
minetest.is_creative_enabled(placer:get_player_name()),
|
||||
placer:get_player_control().sneak)
|
||||
minetest.rotate_and_place(itemstack, placer, pointed_thing,
|
||||
minetest.is_creative_enabled(placer:get_player_name()))
|
||||
return itemstack
|
||||
end
|
||||
|
||||
|
|
|
@ -144,6 +144,7 @@ dofile(api_path .. "mob_effects.lua")
|
|||
dofile(api_path .. "projectile_handling.lua")
|
||||
dofile(api_path .. "breeding.lua")
|
||||
dofile(api_path .. "head_logic.lua")
|
||||
dofile(api_path .. "monster_light.lua")
|
||||
|
||||
|
||||
mobs.spawning_mobs = {}
|
||||
|
@ -436,55 +437,6 @@ function mobs:register_mob(name, def)
|
|||
|
||||
end -- END mobs:register_mob function
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
-- register arrow for shoot attack
|
||||
function mobs:register_arrow(name, def)
|
||||
|
||||
|
@ -586,36 +538,6 @@ function mobs:register_arrow(name, def)
|
|||
self.object:remove();
|
||||
return
|
||||
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
|
||||
|
||||
|
@ -630,7 +552,6 @@ end
|
|||
-- * spawn_egg=1: Spawn egg (generic mob, no metadata)
|
||||
-- * spawn_egg=2: Spawn egg (captured/tamed mob, metadata)
|
||||
function mobs:register_egg(mob, desc, background, addegg, no_creative)
|
||||
|
||||
local grp = {spawn_egg = 1}
|
||||
|
||||
-- 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
|
||||
minetest.register_craftitem(mob, {
|
||||
|
||||
description = desc,
|
||||
inventory_image = invimg,
|
||||
groups = grp,
|
||||
|
@ -668,20 +588,50 @@ function mobs:register_egg(mob, desc, background, addegg, no_creative)
|
|||
|
||||
if pos
|
||||
--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
|
||||
|
||||
--getting the name of the player that placed the egg, and their privileges.
|
||||
local name = placer:get_player_name()
|
||||
local privs = minetest.get_player_privs(name)
|
||||
|
||||
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
|
||||
minetest.record_protection_violation(pointed_thing.under, name)
|
||||
return itemstack
|
||||
end
|
||||
|
||||
if not privs.maphack then
|
||||
minetest.chat_send_player(name, S("You need the “maphack” privilege to change the mob spawner."))
|
||||
return itemstack
|
||||
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
|
||||
itemstack:take_item()
|
||||
end
|
||||
|
@ -691,7 +641,8 @@ function mobs:register_egg(mob, desc, background, addegg, no_creative)
|
|||
if not minetest_registered_entities[mob] then
|
||||
return itemstack
|
||||
end
|
||||
|
||||
|
||||
--If only peaceful mobs are allowed, player is not allowed to spawn a monster
|
||||
if minetest_settings:get_bool("only_peaceful_mobs", false)
|
||||
and minetest_registered_entities[mob].type == "monster" then
|
||||
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
|
||||
|
||||
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))
|
||||
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
|
||||
local nametag = itemstack:get_meta():get_string("name")
|
||||
if nametag ~= "" then
|
||||
|
@ -721,7 +665,8 @@ function mobs:register_egg(mob, desc, background, addegg, no_creative)
|
|||
--update_tag(ent)
|
||||
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
|
||||
itemstack:take_item()
|
||||
end
|
||||
|
|
|
@ -214,6 +214,7 @@ end
|
|||
--a function used for despawning mobs
|
||||
mobs.check_for_player_within_area = function(self, radius)
|
||||
local pos1 = self.object:get_pos()
|
||||
if not pos1 then return end
|
||||
--get players in radius
|
||||
for _,player in pairs(minetest_get_connected_players()) do
|
||||
if player and player:get_hp() > 0 then
|
||||
|
|
|
@ -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({
|
||||
hud_elem_type = "image",
|
||||
position = {x = 0.5, y = 0.5},
|
||||
scale = {x = -100, y = -100},
|
||||
scale = {x = -101, y = -101},
|
||||
text = "mcl_farming_pumpkin_hud.png",
|
||||
z_index = -200
|
||||
}),
|
||||
|
|
|
@ -317,7 +317,12 @@ minetest.register_node("mcl_mobspawners:spawner", {
|
|||
if obj then
|
||||
obj:remove()
|
||||
end
|
||||
mcl_experience.throw_xp(pos, math.random(15, 43))
|
||||
|
||||
--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))
|
||||
end
|
||||
end,
|
||||
|
||||
on_punch = function(pos)
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
# mcl_tridents by j45
|
||||
# mcl_tridents by j45, model by epCode
|
||||
|
||||
Adds tridents to MineClone2.
|
||||
Adds tridents to MineClone 2/5
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
name = mcl_tridents
|
||||
author = j45, epCode
|
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Before Width: | Height: | Size: 249 B After Width: | Height: | Size: 1.1 KiB |
|
@ -1286,18 +1286,43 @@ local function generate_clay(minp, maxp, blockseed, voxelmanip_data, voxelmanip_
|
|||
return lvm_used
|
||||
end
|
||||
|
||||
local dragon_spawn_pos = false
|
||||
local dragon_spawned, portal_generated = false, false
|
||||
|
||||
local function spawn_ender_dragon()
|
||||
local obj = minetest.add_entity(dragon_spawn_pos, "mobs_mc:enderdragon")
|
||||
if not obj then return false end
|
||||
local dragon_entity = obj:get_luaentity()
|
||||
dragon_entity._initial = true
|
||||
dragon_entity._portal_pos = pos
|
||||
return obj
|
||||
end
|
||||
|
||||
local function try_to_spawn_ender_dragon()
|
||||
if spawn_ender_dragon() then
|
||||
dragon_spawned = true
|
||||
return
|
||||
end
|
||||
minetest.after(2, try_to_spawn_ender_dragon)
|
||||
minetest.log("warning", "[mcl_mapgen_core] WARNING! Ender dragon doesn't want to spawn at "..minetest.pos_to_string(dragon_spawn_pos))
|
||||
end
|
||||
|
||||
if portal_generated and not dragon_spawned then
|
||||
minetest.after(10, try_to_spawn_ender_dragon)
|
||||
end
|
||||
|
||||
local function generate_end_exit_portal(pos)
|
||||
local obj = minetest.add_entity(vector.add(pos, vector.new(3, 11, 3)), "mobs_mc:enderdragon")
|
||||
if obj then
|
||||
local dragon_entity = obj:get_luaentity()
|
||||
dragon_entity._initial = true
|
||||
dragon_entity._portal_pos = pos
|
||||
else
|
||||
minetest.log("error", "[mcl_mapgen_core] ERROR! Ender dragon doesn't want to spawn")
|
||||
end
|
||||
if mcl_structures ~= nil then
|
||||
mcl_structures.call_struct(pos, "end_exit_portal")
|
||||
end
|
||||
if dragon_spawn_pos then return false end
|
||||
dragon_spawn_pos = vector.add(pos, vector.new(3, 11, 3))
|
||||
mcl_structures.call_struct(pos, "end_exit_portal", nil, nil, function()
|
||||
minetest.after(2, function()
|
||||
minetest.emerge_area(vector.subtract(dragon_spawn_pos, {x = 64, y = 12, z = 5}), vector.add(dragon_spawn_pos, {x = 3, y = 3, z = 5}), function(blockpos, action, calls_remaining, param)
|
||||
if calls_remaining > 0 then return end
|
||||
minetest.after(2, try_to_spawn_ender_dragon)
|
||||
end)
|
||||
end)
|
||||
end)
|
||||
portal_generated = true
|
||||
end
|
||||
|
||||
-- TODO: Try to use more efficient structure generating code
|
||||
|
|
|
@ -69,7 +69,7 @@ local function init_node_construct(pos)
|
|||
end
|
||||
|
||||
-- The call of Struct
|
||||
function mcl_structures.call_struct(pos, struct_style, rotation, pr)
|
||||
function mcl_structures.call_struct(pos, struct_style, rotation, pr, callback)
|
||||
minetest.log("action","[mcl_structures] call_struct " .. struct_style.." at "..minetest.pos_to_string(pos))
|
||||
if not rotation then
|
||||
rotation = "random"
|
||||
|
@ -91,13 +91,31 @@ function mcl_structures.call_struct(pos, struct_style, rotation, pr)
|
|||
elseif struct_style == "fossil" then
|
||||
return mcl_structures.generate_fossil(pos, rotation, pr)
|
||||
elseif struct_style == "end_exit_portal" then
|
||||
return mcl_structures.generate_end_exit_portal(pos, rotation)
|
||||
return mcl_structures.generate_end_exit_portal(pos, rotation, pr, callback)
|
||||
elseif struct_style == "end_exit_portal_open" then
|
||||
return mcl_structures.generate_end_exit_portal_open(pos, rotation)
|
||||
elseif struct_style == "end_gateway_portal" then
|
||||
return mcl_structures.generate_end_gateway_portal(pos, rotation)
|
||||
elseif struct_style == "end_portal_shrine" then
|
||||
return mcl_structures.generate_end_portal_shrine(pos, rotation, pr)
|
||||
elseif struct_style == "end_portal" then
|
||||
return mcl_structures.generate_end_portal(pos, rotation, pr)
|
||||
end
|
||||
end
|
||||
|
||||
function mcl_structures.generate_end_portal(pos, rotation, pr)
|
||||
-- todo: proper facedir
|
||||
local x0, y0, z0 = pos.x - 2, pos.y, pos.z - 2
|
||||
for x = 0, 4 do
|
||||
for z = 0, 4 do
|
||||
if x % 4 == 0 or z % 4 == 0 then
|
||||
if x % 4 ~= 0 or z % 4 ~= 0 then
|
||||
minetest.swap_node({x = x0 + x, y = y0, z = z0 + z}, {name = "mcl_portals:end_portal_frame_eye"})
|
||||
end
|
||||
else
|
||||
minetest.swap_node({x = x0 + x, y = y0, z = z0 + z}, {name = "mcl_portals:portal_end"})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -324,9 +342,9 @@ function mcl_structures.generate_fossil(pos, rotation, pr)
|
|||
return mcl_structures.place_schematic(newpos, path, rotation or "random", nil, true)
|
||||
end
|
||||
|
||||
function mcl_structures.generate_end_exit_portal(pos, rot)
|
||||
function mcl_structures.generate_end_exit_portal(pos, rot, pr, callback)
|
||||
local path = modpath.."/schematics/mcl_structures_end_exit_portal.mts"
|
||||
return mcl_structures.place_schematic(pos, path, rot or "0", {["mcl_portals:portal_end"] = "air"}, true)
|
||||
return mcl_structures.place_schematic(pos, path, rot or "0", {["mcl_portals:portal_end"] = "air"}, true, nil, callback)
|
||||
end
|
||||
|
||||
function mcl_structures.generate_end_exit_portal_open(pos, rot)
|
||||
|
@ -556,7 +574,7 @@ end
|
|||
|
||||
-- Debug command
|
||||
minetest.register_chatcommand("spawnstruct", {
|
||||
params = "desert_temple | desert_well | igloo | witch_hut | boulder | ice_spike_small | ice_spike_large | fossil | end_exit_portal | end_exit_portal_open | end_gateway_portal | end_portal_shrine | nether_portal | dungeon",
|
||||
params = "desert_temple | desert_well | igloo | witch_hut | boulder | ice_spike_small | ice_spike_large | fossil | end_exit_portal | end_exit_portal_open | end_gateway_portal | end_portal_shrine | end_portal | nether_portal | dungeon",
|
||||
description = S("Generate a pre-defined structure near your position."),
|
||||
privs = {debug = true},
|
||||
func = function(name, param)
|
||||
|
@ -596,6 +614,8 @@ minetest.register_chatcommand("spawnstruct", {
|
|||
mcl_structures.generate_end_portal_shrine(pos, rot, pr)
|
||||
elseif param == "dungeon" and mcl_dungeons and mcl_dungeons.spawn_dungeon then
|
||||
mcl_dungeons.spawn_dungeon(pos, rot, pr)
|
||||
elseif param == "end_portal" then
|
||||
mcl_structures.generate_end_portal(pos, rot, pr)
|
||||
elseif param == "nether_portal" and mcl_portals and mcl_portals.spawn_nether_portal then
|
||||
mcl_portals.spawn_nether_portal(pos, rot, pr, name)
|
||||
elseif param == "" then
|
||||
|
|
|
@ -175,12 +175,6 @@ minetest.register_globalstep(function(dtime)
|
|||
and (fly_node == "air" or fly_node == "ignore")
|
||||
|
||||
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")
|
||||
if player_velocity.y < -1.5 then
|
||||
player:add_velocity({x=0, y=0.17, z=0})
|
||||
|
|
Loading…
Reference in New Issue