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()
|
mcl_compatibility = {}
|
||||||
return false
|
|
||||||
end
|
|
||||||
|
|
||||||
function vector.offset(v,x,y,z)
|
function vector.offset(v,x,y,z)
|
||||||
return vector.add(v,{x=x,y=y,z=z})
|
return vector.add(v,{x=x,y=y,z=z})
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[
|
local minetest_get_node = minetest.get_node
|
||||||
minetest.register_on_joinplayer(function(ObjectRef, last_login)
|
|
||||||
if not ObjectRef.set_moon then
|
mcl_compatibility.sort_nodes = function(nodes)
|
||||||
function ObjectRef.set_moon()
|
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
|
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
|
self.death_animation_timer = self.death_animation_timer + dtime
|
||||||
|
|
||||||
--get all attached entities and sort through them
|
--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
|
if #attached_entities > 0 then
|
||||||
for _,entity in pairs(attached_entities) do
|
for _,entity in pairs(attached_entities) do
|
||||||
--kick the player off
|
--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
|
--if player is falling multiply damage by 1.5
|
||||||
--critical hit
|
--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
|
damage = damage * 1.5
|
||||||
mobs.critical_effect(self)
|
mobs.critical_effect(self)
|
||||||
end
|
end
|
||||||
|
@ -207,7 +208,9 @@ mobs.mob_punch = function(self, hitter, tflp, tool_capabilities, dir)
|
||||||
self.pause_timer = 0.4
|
self.pause_timer = 0.4
|
||||||
|
|
||||||
--don't do knockback from a rider
|
--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
|
if obj == hitter then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
|
@ -107,6 +107,7 @@ end
|
||||||
|
|
||||||
function process_mapgen_block_lvm(vm_context)
|
function process_mapgen_block_lvm(vm_context)
|
||||||
local nodes = minetest.find_nodes_in_area(vm_context.minp, vm_context.maxp, {"group:struct"}, true)
|
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
|
for node_name, pos_list in pairs(nodes) do
|
||||||
local lvm_callback = on_finished_block_callbacks[node_name]
|
local lvm_callback = on_finished_block_callbacks[node_name]
|
||||||
if lvm_callback then
|
if lvm_callback then
|
||||||
|
@ -117,6 +118,7 @@ end
|
||||||
|
|
||||||
function process_mapgen_chunk(minp, maxp, seed, vm_context)
|
function process_mapgen_chunk(minp, maxp, seed, vm_context)
|
||||||
local nodes = minetest.find_nodes_in_area(minp, maxp, {"group:struct"}, true)
|
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
|
for node_name, pos_list in pairs(nodes) do
|
||||||
local chunk_callback = on_finished_chunk_callbacks[node_name]
|
local chunk_callback = on_finished_chunk_callbacks[node_name]
|
||||||
if chunk_callback then
|
if chunk_callback then
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
name = mcl_structures
|
name = mcl_structures
|
||||||
author = Wuzzy, kay27, cora
|
author = Wuzzy, kay27, cora
|
||||||
description = Structures for MineClone 2/5
|
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