diff --git a/api.lua b/api.lua index e1c49b3..e7fc566 100644 --- a/api.lua +++ b/api.lua @@ -3,7 +3,7 @@ mobs = {} mobs.mod = "redo" -mobs.version = "20180708" +mobs.version = "20180710" -- Intllib @@ -213,17 +213,17 @@ local get_distance = function(a, b) end --- check line of sight (BrunoMine) +-- check line of sight (by BrunoMine, tweaked by Astrobe) local line_of_sight = function(self, pos1, pos2, stepsize) stepsize = stepsize or 1 + local stepv = vector.multiply(vector.direction(pos1, pos2), stepsize) + local s, pos = minetest.line_of_sight(pos1, pos2, stepsize) -- normal walking and flying mobs can see you through air - if s == true then - return true - end + if s == true then return true end -- New pos1 to be analyzed local npos1 = {x = pos1.x, y = pos1.y, z = pos1.z} @@ -236,39 +236,15 @@ local line_of_sight = function(self, pos1, pos2, stepsize) -- Nodename found local nn = minetest.get_node(pos).name - -- Target Distance (td) to travel - local td = get_distance(pos1, pos2) - - -- Actual Distance (ad) traveled - local ad = 0 - -- It continues to advance in the line of sight in search of a real -- obstruction which counts as 'normal' nodebox. while minetest.registered_nodes[nn] and (minetest.registered_nodes[nn].walkable == false or minetest.registered_nodes[nn].drawtype == "nodebox") do - -- Check if you can still move forward - if td < ad + stepsize then - return true -- Reached the target - end + npos1 = vector.add(npos1, stepv) - -- Moves the analyzed pos - local d = get_distance(pos1, pos2) - - npos1.x = ((pos2.x - pos1.x) / d * stepsize) + pos1.x - npos1.y = ((pos2.y - pos1.y) / d * stepsize) + pos1.y - npos1.z = ((pos2.z - pos1.z) / d * stepsize) + pos1.z - - -- NaN checks - if d == 0 - or npos1.x ~= npos1.x - or npos1.y ~= npos1.y - or npos1.z ~= npos1.z then - return false - end - - ad = ad + stepsize + if get_distance(npos1, pos2) < stepsize then return true end -- scan again r, pos = minetest.line_of_sight(npos1, pos2, stepsize) @@ -277,7 +253,6 @@ local line_of_sight = function(self, pos1, pos2, stepsize) -- New Nodename found nn = minetest.get_node(pos).name - end return false diff --git a/crafts.lua b/crafts.lua index 0bf42ad..0460f89 100644 --- a/crafts.lua +++ b/crafts.lua @@ -146,6 +146,37 @@ default.register_fence("mobs:fence_wood", { }, }) +-- mob fence top (has enlarged collisionbox to stop mobs getting over) + minetest.register_node("mobs:fence_top", { + description = S("Mob Fence Top"), + drawtype = "nodebox", + tiles = {"default_wood.png"}, + paramtype = "light", + is_ground_content = false, + groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2}, + sounds = default.node_sound_wood_defaults(), + node_box = { + type = "fixed", + fixed = {-0.2, -0.5, -0.2, 0.2, 0, 0.2}, + }, + collision_box = { + type = "fixed", + fixed = {-0.4, -1.5, -0.4, 0.4, 0, 0.4}, + }, + selection_box = { + type = "fixed", + fixed = {-0.4, -1.5, -0.4, 0.4, 0, 0.4}, + }, +}) + +minetest.register_craft({ + output = "mobs:fence_top 12", + recipe = { + {"group:wood", "group:wood", "group:wood"}, + {"", "default:fence_wood", ""}, + } +}) + -- items that can be used as fuel minetest.register_craft({ type = "fuel", @@ -182,3 +213,9 @@ minetest.register_craft({ recipe = "mobs:fence_wood", burntime = 7, }) + +minetest.register_craft({ + type = "fuel", + recipe = "mobs:fence_top", + burntime = 2, +}) diff --git a/lucky_block.lua b/lucky_block.lua index 8cf20ed..ef7d59c 100644 --- a/lucky_block.lua +++ b/lucky_block.lua @@ -12,6 +12,7 @@ if minetest.get_modpath("lucky_block") then {"dro", {"mobs:shears"}, 1}, {"dro", {"mobs:protector"}, 1}, {"dro", {"mobs:fence_wood"}, 10}, + {"dro", {"mobs:fence_top"}, 12}, {"lig"}, }) end diff --git a/readme.MD b/readme.MD index 714945d..af984e9 100644 --- a/readme.MD +++ b/readme.MD @@ -17,11 +17,13 @@ Crafts: - Magic Lasso is similar to nets but with a better chance of picking up larger mobs. - Shears are used to right-click sheep and return 1-3 wool. - Protection Rune lets you protect tamed mobs from harm by other players + - Mob Fence and Fence Top (to stop mobs escaping/glitching through fences) Lucky Blocks: 9 Changelog: +- 1.45- Added Fence Top to add on top of any fence to stop mobs escaping, new line_of_sight tweaked by Astrobe - 1.44- Added ToolRanks support for swords when attacking mobs - 1.43- Better 0.4.16 compatibility, added general attack function and settings - 1.42- Added "all" option to immune_to table, tidied floating mobs to be less intensive