forked from MineClone5/MineClone5
Fix mob click in minetest 5.1.1
This commit is contained in:
parent
0096100228
commit
98ddf778cf
|
@ -1,16 +1,27 @@
|
|||
function minetest.is_creative_enabled()
|
||||
return false
|
||||
end
|
||||
mcl_compatibility = {}
|
||||
|
||||
function vector.offset(v,x,y,z)
|
||||
return vector.add(v,{x=x,y=y,z=z})
|
||||
end
|
||||
|
||||
--[[
|
||||
minetest.register_on_joinplayer(function(ObjectRef, last_login)
|
||||
if not ObjectRef.set_moon then
|
||||
function ObjectRef.set_moon()
|
||||
local minetest_get_node = minetest.get_node
|
||||
|
||||
mcl_compatibility.sort_nodes = function(nodes)
|
||||
if not nodes then return {} end
|
||||
for _, pos in pairs(nodes) do
|
||||
if not pos.x or not pos.y or not pos.z then
|
||||
return nodes
|
||||
end
|
||||
end
|
||||
end)
|
||||
]]
|
||||
local new_nodes = {}
|
||||
for _, pos in pairs(nodes) do
|
||||
local node = minetest_get_node(pos)
|
||||
local name = node.name
|
||||
if not new_nodes[name] then
|
||||
new_nodes[name] = { pos }
|
||||
else
|
||||
table.insert(new_nodes[name], pos)
|
||||
end
|
||||
end
|
||||
return new_nodes
|
||||
end
|
||||
|
|
|
@ -99,7 +99,8 @@ mobs.death_logic = function(self, dtime)
|
|||
self.death_animation_timer = self.death_animation_timer + dtime
|
||||
|
||||
--get all attached entities and sort through them
|
||||
local attached_entities = self.object:get_children()
|
||||
-- TODO: support 5.1.1
|
||||
local attached_entities = self.object.get_children and self.object:get_children() or {}
|
||||
if #attached_entities > 0 then
|
||||
for _,entity in pairs(attached_entities) do
|
||||
--kick the player off
|
||||
|
|
|
@ -185,7 +185,8 @@ mobs.mob_punch = function(self, hitter, tflp, tool_capabilities, dir)
|
|||
|
||||
--if player is falling multiply damage by 1.5
|
||||
--critical hit
|
||||
if hitter:get_velocity().y < 0 then
|
||||
local hitter_velocity = hitter:get_velocity() or hitter:get_player_velocity() or vector.new(0, 0, 0)
|
||||
if hitter_velocity.y < 0 then
|
||||
damage = damage * 1.5
|
||||
mobs.critical_effect(self)
|
||||
end
|
||||
|
@ -207,7 +208,9 @@ mobs.mob_punch = function(self, hitter, tflp, tool_capabilities, dir)
|
|||
self.pause_timer = 0.4
|
||||
|
||||
--don't do knockback from a rider
|
||||
for _,obj in pairs(self.object:get_children()) do
|
||||
local object_children = self.object.get_children and self.object:get_children()
|
||||
-- TODO: support 5.1.1
|
||||
for _,obj in pairs(object_children or {}) do
|
||||
if obj == hitter then
|
||||
return
|
||||
end
|
||||
|
|
|
@ -107,6 +107,7 @@ end
|
|||
|
||||
function process_mapgen_block_lvm(vm_context)
|
||||
local nodes = minetest.find_nodes_in_area(vm_context.minp, vm_context.maxp, {"group:struct"}, true)
|
||||
nodes = mcl_compatibility.sort_nodes(nodes)
|
||||
for node_name, pos_list in pairs(nodes) do
|
||||
local lvm_callback = on_finished_block_callbacks[node_name]
|
||||
if lvm_callback then
|
||||
|
@ -117,6 +118,7 @@ end
|
|||
|
||||
function process_mapgen_chunk(minp, maxp, seed, vm_context)
|
||||
local nodes = minetest.find_nodes_in_area(minp, maxp, {"group:struct"}, true)
|
||||
nodes = mcl_compatibility.sort_nodes(nodes)
|
||||
for node_name, pos_list in pairs(nodes) do
|
||||
local chunk_callback = on_finished_chunk_callbacks[node_name]
|
||||
if chunk_callback then
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
name = mcl_structures
|
||||
author = Wuzzy, kay27, cora
|
||||
description = Structures for MineClone 2/5
|
||||
depends = mcl_loot, mcl_mapgen, mcl_worlds
|
||||
depends = mcl_init, mcl_loot, mcl_mapgen, mcl_worlds
|
||||
|
|
Loading…
Reference in New Issue