Merge branch 'master' into elytra-overhaul
commit
fab3c35c28
|
@ -13,6 +13,12 @@ local function is_group(pos, group)
|
||||||
end
|
end
|
||||||
|
|
||||||
local is_water = flowlib.is_water
|
local is_water = flowlib.is_water
|
||||||
|
local function is_river_water(p)
|
||||||
|
local n = minetest.get_node(p).name
|
||||||
|
if n == "mclx_core:river_water_source" or n == "mclx_core:river_water_flowing" then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
local function is_ice(pos)
|
local function is_ice(pos)
|
||||||
return is_group(pos, "ice")
|
return is_group(pos, "ice")
|
||||||
|
@ -204,6 +210,7 @@ function boat.on_step(self, dtime, moveresult)
|
||||||
local on_water = true
|
local on_water = true
|
||||||
local on_ice = false
|
local on_ice = false
|
||||||
local in_water = is_water({x=p.x, y=p.y-boat_y_offset+1, z=p.z})
|
local in_water = is_water({x=p.x, y=p.y-boat_y_offset+1, z=p.z})
|
||||||
|
local in_river_water = is_river_water({x=p.x, y=p.y-boat_y_offset+1, z=p.z})
|
||||||
local waterp = {x=p.x, y=p.y-boat_y_offset - 0.1, z=p.z}
|
local waterp = {x=p.x, y=p.y-boat_y_offset - 0.1, z=p.z}
|
||||||
if not is_water(waterp) then
|
if not is_water(waterp) then
|
||||||
on_water = false
|
on_water = false
|
||||||
|
@ -213,7 +220,7 @@ function boat.on_step(self, dtime, moveresult)
|
||||||
v_slowdown = 0.04
|
v_slowdown = 0.04
|
||||||
v_factor = 0.5
|
v_factor = 0.5
|
||||||
end
|
end
|
||||||
elseif in_water then
|
elseif in_water and not in_river_water then
|
||||||
on_water = false
|
on_water = false
|
||||||
in_water = true
|
in_water = true
|
||||||
v_factor = 0.75
|
v_factor = 0.75
|
||||||
|
@ -345,7 +352,18 @@ function boat.on_step(self, dtime, moveresult)
|
||||||
else
|
else
|
||||||
p.y = p.y + 1
|
p.y = p.y + 1
|
||||||
local is_obsidian_boat = self.object:get_luaentity()._itemstring == "mcl_boats:boat_obsidian"
|
local is_obsidian_boat = self.object:get_luaentity()._itemstring == "mcl_boats:boat_obsidian"
|
||||||
if is_water(p) or is_obsidian_boat then
|
if is_river_water(p) then
|
||||||
|
local y = self.object:get_velocity().y
|
||||||
|
if y >= 5 then
|
||||||
|
y = 5
|
||||||
|
elseif y < 0 then
|
||||||
|
new_acce = {x = 0, y = 10, z = 0}
|
||||||
|
else
|
||||||
|
new_acce = {x = 0, y = 2, z = 0}
|
||||||
|
end
|
||||||
|
new_velo = get_velocity(self._v, self.object:get_yaw(), y)
|
||||||
|
self.object:set_pos(self.object:get_pos())
|
||||||
|
elseif is_water(p) and not is_river_water(p) or is_obsidian_boat then
|
||||||
-- Inside water: Slowly sink
|
-- Inside water: Slowly sink
|
||||||
local y = self.object:get_velocity().y
|
local y = self.object:get_velocity().y
|
||||||
y = y - 0.01
|
y = y - 0.01
|
||||||
|
|
|
@ -2,300 +2,342 @@ local S = minetest.get_translator(minetest.get_current_modname())
|
||||||
--[[
|
--[[
|
||||||
there are strings in meta, which are being used to see which effect will be given to the player(s)
|
there are strings in meta, which are being used to see which effect will be given to the player(s)
|
||||||
Valid strings:
|
Valid strings:
|
||||||
swiftness
|
swiftness
|
||||||
leaping
|
leaping
|
||||||
strenght
|
strenght
|
||||||
regeneration
|
regeneration
|
||||||
]]--
|
]]--
|
||||||
|
|
||||||
|
mcl_beacons = {
|
||||||
|
blocks ={"mcl_core:diamondblock","mcl_core:ironblock","mcl_core:goldblock","mcl_core:emeraldblock","mcl_nether:netheriteblock"},
|
||||||
|
fuel = {"mcl_core:diamond","mcl_core:emerald","mcl_core:iron_ingot","mcl_core:gold_ingot","mcl_nether:netherite_ingot"}
|
||||||
|
}
|
||||||
|
local beacon_blocklist = mcl_beacons.blocks
|
||||||
|
local beacon_fuellist = mcl_beacons.fuel
|
||||||
|
|
||||||
|
local pallete_order = {
|
||||||
|
glass_cyan = 1,
|
||||||
|
pane_cyan_flat = 1,
|
||||||
|
pane_cyan = 1,
|
||||||
|
|
||||||
|
glass_white = 2,
|
||||||
|
pane_white_flat = 2,
|
||||||
|
pane_white = 2,
|
||||||
|
|
||||||
|
glass_brown = 3,
|
||||||
|
pane_brown_flat = 3,
|
||||||
|
pane_brown = 3,
|
||||||
|
|
||||||
|
glass_blue = 4,
|
||||||
|
pane_blue_flat = 4,
|
||||||
|
pane_blue = 4,
|
||||||
|
|
||||||
|
glass_light_blue = 5,
|
||||||
|
pane_light_blue_flat = 5,
|
||||||
|
pane_light_blue = 5,
|
||||||
|
|
||||||
|
glass_pink = 6,
|
||||||
|
pane_pink_flat = 6,
|
||||||
|
pane_pink = 6,
|
||||||
|
|
||||||
|
glass_purple = 7,
|
||||||
|
pane_purple_flat = 7,
|
||||||
|
pane_purple = 7,
|
||||||
|
|
||||||
|
glass_red = 8,
|
||||||
|
pane_red_flat = 8,
|
||||||
|
pane_red = 8,
|
||||||
|
|
||||||
|
glass_silver = 9,
|
||||||
|
pane_silver_flat = 9,
|
||||||
|
pane_silver = 9,
|
||||||
|
|
||||||
|
glass_gray = 10,
|
||||||
|
pane_gray_flat = 10,
|
||||||
|
pane_gray = 10,
|
||||||
|
|
||||||
|
glass_lime = 11,
|
||||||
|
pane_lime_flat = 11,
|
||||||
|
pane_lime = 11,
|
||||||
|
|
||||||
|
glass_green = 12,
|
||||||
|
pane_green_flat = 12,
|
||||||
|
pane_green = 12,
|
||||||
|
|
||||||
|
glass_orange = 13,
|
||||||
|
pane_orange_flat = 13,
|
||||||
|
pane_orange = 13,
|
||||||
|
|
||||||
|
glass_yellow = 14,
|
||||||
|
pane_yellow_flat = 14,
|
||||||
|
pane_yellow = 14,
|
||||||
|
|
||||||
|
glass_black = 15,
|
||||||
|
pane_black_flat = 15,
|
||||||
|
pane_black = 15,
|
||||||
|
|
||||||
|
glass_magenta = 16,
|
||||||
|
pane_magenta_flat = 16,
|
||||||
|
pane_magenta = 16
|
||||||
|
}
|
||||||
|
|
||||||
local function get_beacon_beam(glass_nodename)
|
local function get_beacon_beam(glass_nodename)
|
||||||
if string.match(glass_nodename, "cyan") then
|
if glass_nodename == "air" then return 0 end
|
||||||
return 1
|
local glass_string = glass_nodename:split(':')[2]
|
||||||
elseif string.match(glass_nodename,"white") then
|
if not pallete_order[glass_string] then return 0 end
|
||||||
return 2
|
return pallete_order[glass_string]
|
||||||
elseif string.match(glass_nodename,"brown") then
|
|
||||||
return 3
|
|
||||||
elseif string.match(glass_nodename,"blue") and not string.match(glass_nodename, "light") then
|
|
||||||
return 4
|
|
||||||
elseif string.match(glass_nodename,"light_blue") then
|
|
||||||
return 5
|
|
||||||
elseif string.match(glass_nodename,"pink") then
|
|
||||||
return 6
|
|
||||||
elseif string.match(glass_nodename, "purple") then
|
|
||||||
return 7
|
|
||||||
elseif string.match(glass_nodename, "red") then
|
|
||||||
return 8
|
|
||||||
elseif string.match(glass_nodename, "silver") then
|
|
||||||
return 9
|
|
||||||
elseif string.match(glass_nodename, "gray") then
|
|
||||||
return 10
|
|
||||||
elseif string.match(glass_nodename, "lime") then
|
|
||||||
return 11
|
|
||||||
elseif string.match(glass_nodename, "green") then
|
|
||||||
return 12
|
|
||||||
elseif string.match(glass_nodename, "orange") then
|
|
||||||
return 13
|
|
||||||
elseif string.match(glass_nodename, "yellow") then
|
|
||||||
return 14
|
|
||||||
elseif string.match(glass_nodename, "black") then
|
|
||||||
return 15
|
|
||||||
elseif string.match(glass_nodename, "magenta") then
|
|
||||||
return 16
|
|
||||||
else
|
|
||||||
return 0
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_node("mcl_beacons:beacon_beam", {
|
minetest.register_node("mcl_beacons:beacon_beam", {
|
||||||
tiles = {"^[colorize:#b8bab9"},
|
tiles = {"^[colorize:#b8bab9"},
|
||||||
drawtype = "nodebox",
|
drawtype = "nodebox",
|
||||||
node_box = {
|
node_box = {
|
||||||
type = "fixed",
|
type = "fixed",
|
||||||
fixed = {
|
fixed = {
|
||||||
{-0.1250, -0.5000, -0.1250, 0.1250, 0.5000, 0.1250}
|
{-0.1250, -0.5000, -0.1250, 0.1250, 0.5000, 0.1250}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
pointable= false,
|
pointable= false,
|
||||||
light_source = 15,
|
light_source = 15,
|
||||||
walkable = false,
|
walkable = false,
|
||||||
groups = {not_in_creative_inventory=1},
|
groups = {not_in_creative_inventory=1},
|
||||||
_mcl_blast_resistance = 1200,
|
_mcl_blast_resistance = 1200,
|
||||||
paramtype2 = "color",
|
paramtype2 = "color",
|
||||||
palette = "beacon_beam_palette.png",
|
palette = "beacon_beam_palette.png",
|
||||||
palette_index = 0,
|
palette_index = 0,
|
||||||
buildable_to = true,
|
buildable_to = true,
|
||||||
})
|
})
|
||||||
|
|
||||||
mesecon.register_mvps_stopper("mcl_beacons:beacon_beam")
|
mesecon.register_mvps_stopper("mcl_beacons:beacon_beam")
|
||||||
|
|
||||||
local formspec_string=
|
local formspec_string=
|
||||||
"size[11,14]"..
|
"size[11,14]"..
|
||||||
|
|
||||||
"label[4.5,0.5;"..minetest.formspec_escape(S("Beacon:")).."]"..
|
"label[4.5,0.5;"..minetest.formspec_escape(S("Beacon:")).."]"..
|
||||||
"label[0.5,1;"..minetest.formspec_escape(S("Primary Power:")).."]"..
|
"label[0.5,1;"..minetest.formspec_escape(S("Primary Power:")).."]"..
|
||||||
"label[0.5,8.25;"..minetest.formspec_escape( S("Inventory:")).."]"..
|
"label[0.5,8.25;"..minetest.formspec_escape( S("Inventory:")).."]"..
|
||||||
|
|
||||||
"image[1,1.5;1,1;custom_beacom_symbol_4.png]"..
|
"image[1,1.5;1,1;custom_beacom_symbol_4.png]"..
|
||||||
"image[1,3;1,1;custom_beacom_symbol_3.png]"..
|
"image[1,3;1,1;custom_beacom_symbol_3.png]"..
|
||||||
"image[1,4.5;1,1;custom_beacom_symbol_2.png]"..
|
"image[1,4.5;1,1;custom_beacom_symbol_2.png]"..
|
||||||
"image[1,6;1,1;custom_beacom_symbol_1.png]"..
|
"image[1,6;1,1;custom_beacom_symbol_1.png]"..
|
||||||
|
|
||||||
"image_button[5.2,1.5;1,1;mcl_potions_effect_swift.png;swiftness;]"..
|
"image_button[5.2,1.5;1,1;mcl_potions_effect_swift.png;swiftness;]"..
|
||||||
"image_button[5.2,3;1,1;mcl_potions_effect_leaping.png;leaping;]"..
|
"image_button[5.2,3;1,1;mcl_potions_effect_leaping.png;leaping;]"..
|
||||||
"image_button[5.2,4.5;1,1;mcl_potions_effect_strong.png;strenght;]"..
|
"image_button[5.2,4.5;1,1;mcl_potions_effect_strong.png;strenght;]"..
|
||||||
"image_button[5.2,6;1,1;mcl_potions_effect_regenerating.png;regeneration;]"..
|
"image_button[5.2,6;1,1;mcl_potions_effect_regenerating.png;regeneration;]"..
|
||||||
|
|
||||||
"item_image[1,7;1,1;mcl_core:diamond]"..
|
"item_image[1,7;1,1;mcl_core:diamond]"..
|
||||||
"item_image[2.2,7;1,1;mcl_core:emerald]"..
|
"item_image[2.2,7;1,1;mcl_core:emerald]"..
|
||||||
"item_image[3.4,7;1,1;mcl_core:iron_ingot]"..
|
"item_image[3.4,7;1,1;mcl_core:iron_ingot]"..
|
||||||
"item_image[4.6,7;1,1;mcl_core:gold_ingot]"..
|
"item_image[4.6,7;1,1;mcl_core:gold_ingot]"..
|
||||||
"item_image[5.8,7;1,1;mcl_nether:netherite_ingot]"..
|
"item_image[5.8,7;1,1;mcl_nether:netherite_ingot]"..
|
||||||
|
|
||||||
mcl_formspec.get_itemslot_bg(7.2,7,1,1)..
|
mcl_formspec.get_itemslot_bg(7.2,7,1,1)..
|
||||||
"list[context;input;7.2,7;1,1;]"..
|
"list[context;input;7.2,7;1,1;]"..
|
||||||
mcl_formspec.get_itemslot_bg(1,9,9,3)..
|
mcl_formspec.get_itemslot_bg(1,9,9,3)..
|
||||||
"list[current_player;main;1,9;9,3;9]"..
|
"list[current_player;main;1,9;9,3;9]"..
|
||||||
mcl_formspec.get_itemslot_bg(1,12.5,9,1)..
|
mcl_formspec.get_itemslot_bg(1,12.5,9,1)..
|
||||||
"list[current_player;main;1,12.5;9,1;]"
|
"list[current_player;main;1,12.5;9,1;]"
|
||||||
|
|
||||||
local function remove_beacon_beam(pos)
|
local function remove_beacon_beam(pos)
|
||||||
for y=pos.y, pos.y+301 do
|
for y=pos.y, pos.y+301 do
|
||||||
local node = minetest.get_node({x=pos.x,y=y,z=pos.z})
|
local node = minetest.get_node({x=pos.x,y=y,z=pos.z})
|
||||||
if node.name ~= "air" and node.name ~= "mcl_core:bedrock" and node.name ~= "mcl_core:void" then
|
if node.name ~= "air" and node.name ~= "mcl_core:bedrock" and node.name ~= "mcl_core:void" then
|
||||||
if node.name == "ignore" then
|
if node.name == "ignore" then
|
||||||
minetest.get_voxel_manip():read_from_map({x=pos.x,y=y,z=pos.z}, {x=pos.x,y=y,z=pos.z})
|
minetest.get_voxel_manip():read_from_map({x=pos.x,y=y,z=pos.z}, {x=pos.x,y=y,z=pos.z})
|
||||||
node = minetest.get_node({x=pos.x,y=y,z=pos.z})
|
node = minetest.get_node({x=pos.x,y=y,z=pos.z})
|
||||||
end
|
end
|
||||||
|
|
||||||
if node.name == "mcl_beacons:beacon_beam" then
|
if node.name == "mcl_beacons:beacon_beam" then
|
||||||
minetest.remove_node({x=pos.x,y=y,z=pos.z})
|
minetest.remove_node({x=pos.x,y=y,z=pos.z})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function beacon_blockcheck(pos)
|
local function beacon_blockcheck(pos)
|
||||||
for y_offset = 1,4 do
|
for y_offset = 1,4 do
|
||||||
local block_y = pos.y - y_offset
|
local block_y = pos.y - y_offset
|
||||||
for block_x = (pos.x-y_offset),(pos.x+y_offset) do
|
for block_x = (pos.x-y_offset),(pos.x+y_offset) do
|
||||||
for block_z = (pos.z-y_offset),(pos.z+y_offset) do
|
for block_z = (pos.z-y_offset),(pos.z+y_offset) do
|
||||||
local valid_block = false --boolean which stores if block is valid or not
|
local valid_block = false --boolean which stores if block is valid or not
|
||||||
for _, beacon_block in pairs(beacon_blocklist) do
|
for _, beacon_block in pairs(beacon_blocklist) do
|
||||||
if beacon_block == minetest.get_node({x=block_x,y=block_y,z=block_z}).name and not valid_block then --is the block in the pyramid a valid beacon block
|
if beacon_block == minetest.get_node({x=block_x,y=block_y,z=block_z}).name and not valid_block then --is the block in the pyramid a valid beacon block
|
||||||
valid_block =true
|
valid_block =true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if not valid_block then
|
if not valid_block then
|
||||||
return y_offset -1 --the last layer is complete, this one is missing or incomplete
|
return y_offset -1 --the last layer is complete, this one is missing or incomplete
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if y_offset == 4 then --all checks are done, beacon is maxed
|
if y_offset == 4 then --all checks are done, beacon is maxed
|
||||||
return y_offset
|
return y_offset
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function effect_player(effect,pos,power_level, effect_level,player)
|
local function effect_player(effect,pos,power_level, effect_level,player)
|
||||||
local distance = vector.distance(player:get_pos(), pos)
|
local distance = vector.distance(player:get_pos(), pos)
|
||||||
if distance > (power_level+1)*10 then return end
|
if distance > (power_level+1)*10 then return end
|
||||||
if effect == "swiftness" then
|
if effect == "swiftness" then
|
||||||
mcl_potions.swiftness_func(player,effect_level,16)
|
mcl_potions.swiftness_func(player,effect_level,16)
|
||||||
elseif effect == "leaping" then
|
elseif effect == "leaping" then
|
||||||
mcl_potions.leaping_func(player, effect_level, 16)
|
mcl_potions.leaping_func(player, effect_level, 16)
|
||||||
elseif effect == "strenght" then
|
elseif effect == "strenght" then
|
||||||
mcl_potions.strength_func(player, effect_level, 16)
|
mcl_potions.strength_func(player, effect_level, 16)
|
||||||
elseif effect == "regeneration" then
|
elseif effect == "regeneration" then
|
||||||
mcl_potions.regeneration_func(player, effect_level, 16)
|
mcl_potions.regeneration_func(player, effect_level, 16)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function globalstep_function(pos,player)
|
local function globalstep_function(pos,player)
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
local power_level = beacon_blockcheck(pos)
|
local power_level = beacon_blockcheck(pos)
|
||||||
local effect_string = meta:get_string("effect")
|
local effect_string = meta:get_string("effect")
|
||||||
if meta:get_int("effect_level") == 2 and power_level < 4 then
|
if meta:get_int("effect_level") == 2 and power_level < 4 then
|
||||||
return
|
return
|
||||||
else
|
else
|
||||||
local obstructed = false
|
local obstructed = false
|
||||||
for y=pos.y+1, pos.y+100 do
|
for y=pos.y+1, pos.y+100 do
|
||||||
|
|
||||||
local nodename = minetest.get_node({x=pos.x,y=y, z = pos.z}).name
|
local nodename = minetest.get_node({x=pos.x,y=y, z = pos.z}).name
|
||||||
if nodename ~= "mcl_core:bedrock" and nodename ~= "air" and nodename ~= "mcl_core:void" and nodename ~= "ignore" then --ignore means not loaded, let's just assume that's air
|
if nodename ~= "mcl_core:bedrock" and nodename ~= "air" and nodename ~= "mcl_core:void" and nodename ~= "ignore" then --ignore means not loaded, let's just assume that's air
|
||||||
if nodename ~="mcl_beacons:beacon_beam" then
|
if nodename ~="mcl_beacons:beacon_beam" then
|
||||||
if minetest.get_item_group(nodename,"glass") == 0 then
|
if minetest.get_item_group(nodename,"glass") == 0 and minetest.get_item_group(nodename,"material_glass") == 0 then
|
||||||
obstructed = true
|
obstructed = true
|
||||||
remove_beacon_beam(pos)
|
remove_beacon_beam(pos)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if obstructed then
|
if obstructed then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
effect_player(effect_string,pos,power_level,meta:get_int("effect_level"),player)
|
effect_player(effect_string,pos,power_level,meta:get_int("effect_level"),player)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_node("mcl_beacons:beacon", {
|
minetest.register_node("mcl_beacons:beacon", {
|
||||||
description = S"Beacon",
|
description = S"Beacon",
|
||||||
drawtype = "mesh",
|
drawtype = "mesh",
|
||||||
collisionbox = {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
|
collisionbox = {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
|
||||||
mesh = "mcl_beacon.b3d",
|
mesh = "mcl_beacon.b3d",
|
||||||
tiles = {"beacon_UV.png"},
|
tiles = {"beacon_UV.png"},
|
||||||
on_construct = function(pos)
|
on_construct = function(pos)
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
local inv = meta:get_inventory()
|
local inv = meta:get_inventory()
|
||||||
inv:set_size("input", 1)
|
inv:set_size("input", 1)
|
||||||
local form = formspec_string
|
local form = formspec_string
|
||||||
meta:set_string("formspec", form)
|
meta:set_string("formspec", form)
|
||||||
end,
|
end,
|
||||||
on_destruct = function(pos)
|
on_destruct = function(pos)
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
local input = meta:get_inventory():get_stack("input",1)
|
local input = meta:get_inventory():get_stack("input",1)
|
||||||
if not input:is_empty() then
|
if not input:is_empty() then
|
||||||
local p = {x=pos.x+math.random(0, 10)/10-0.5, y=pos.y, z=pos.z+math.random(0, 10)/10-0.5} --from mcl_anvils
|
local p = {x=pos.x+math.random(0, 10)/10-0.5, y=pos.y, z=pos.z+math.random(0, 10)/10-0.5} --from mcl_anvils
|
||||||
minetest.add_item(p, input)
|
minetest.add_item(p, input)
|
||||||
end
|
end
|
||||||
remove_beacon_beam(pos)
|
remove_beacon_beam(pos)
|
||||||
end,
|
end,
|
||||||
on_receive_fields = function(pos, formname, fields, sender)
|
on_receive_fields = function(pos, formname, fields, sender)
|
||||||
if fields.swiftness or fields.regeneration or fields.leaping or fields.strenght then
|
if fields.swiftness or fields.regeneration or fields.leaping or fields.strenght then
|
||||||
local sender_name = sender:get_player_name()
|
local sender_name = sender:get_player_name()
|
||||||
local power_level = beacon_blockcheck(pos)
|
local power_level = beacon_blockcheck(pos)
|
||||||
if minetest.is_protected(pos, sender_name) then
|
if minetest.is_protected(pos, sender_name) then
|
||||||
minetest.record_protection_violation(pos, sender_name)
|
minetest.record_protection_violation(pos, sender_name)
|
||||||
return
|
return
|
||||||
elseif power_level == 0 then
|
elseif power_level == 0 then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
local inv = meta:get_inventory()
|
local inv = meta:get_inventory()
|
||||||
local input = inv:get_stack("input",1)
|
local input = inv:get_stack("input",1)
|
||||||
|
|
||||||
if input:is_empty() then
|
if input:is_empty() then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local valid_item = false
|
local valid_item = false
|
||||||
|
|
||||||
for _, item in ipairs(beacon_fuellist) do
|
for _, item in ipairs(beacon_fuellist) do
|
||||||
if input:get_name() == item then
|
if input:get_name() == item then
|
||||||
valid_item = true
|
valid_item = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if not valid_item then
|
if not valid_item then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local successful = false
|
local successful = false
|
||||||
if fields.swiftness then
|
if fields.swiftness then
|
||||||
if power_level == 4 then
|
if power_level == 4 then
|
||||||
minetest.get_meta(pos):set_int("effect_level",2)
|
minetest.get_meta(pos):set_int("effect_level",2)
|
||||||
else
|
else
|
||||||
minetest.get_meta(pos):set_int("effect_level",1)
|
minetest.get_meta(pos):set_int("effect_level",1)
|
||||||
end
|
end
|
||||||
minetest.get_meta(pos):set_string("effect","swiftness")
|
minetest.get_meta(pos):set_string("effect","swiftness")
|
||||||
successful = true
|
successful = true
|
||||||
elseif fields.leaping and power_level >= 2 then
|
elseif fields.leaping and power_level >= 2 then
|
||||||
if power_level == 4 then
|
if power_level == 4 then
|
||||||
minetest.get_meta(pos):set_int("effect_level",2)
|
minetest.get_meta(pos):set_int("effect_level",2)
|
||||||
else
|
else
|
||||||
minetest.get_meta(pos):set_int("effect_level",1)
|
minetest.get_meta(pos):set_int("effect_level",1)
|
||||||
end
|
end
|
||||||
minetest.get_meta(pos):set_string("effect","leaping")
|
minetest.get_meta(pos):set_string("effect","leaping")
|
||||||
successful = true
|
successful = true
|
||||||
elseif fields.strenght and power_level >= 3 then
|
elseif fields.strenght and power_level >= 3 then
|
||||||
if power_level == 4 then
|
if power_level == 4 then
|
||||||
minetest.get_meta(pos):set_int("effect_level",2)
|
minetest.get_meta(pos):set_int("effect_level",2)
|
||||||
else
|
else
|
||||||
minetest.get_meta(pos):set_int("effect_level",1)
|
minetest.get_meta(pos):set_int("effect_level",1)
|
||||||
end
|
end
|
||||||
minetest.get_meta(pos):set_string("effect","strenght")
|
minetest.get_meta(pos):set_string("effect","strenght")
|
||||||
successful = true
|
successful = true
|
||||||
elseif fields.regeneration and power_level == 4 then
|
elseif fields.regeneration and power_level == 4 then
|
||||||
minetest.get_meta(pos):set_int("effect_level",2)
|
minetest.get_meta(pos):set_int("effect_level",2)
|
||||||
minetest.get_meta(pos):set_string("effect","regeneration")
|
minetest.get_meta(pos):set_string("effect","regeneration")
|
||||||
successful = true
|
successful = true
|
||||||
end
|
end
|
||||||
if successful then
|
if successful then
|
||||||
if power_level == 4 then
|
if power_level == 4 then
|
||||||
awards.unlock(sender:get_player_name(),"mcl:maxed_beacon")
|
awards.unlock(sender:get_player_name(),"mcl:maxed_beacon")
|
||||||
end
|
end
|
||||||
awards.unlock(sender:get_player_name(),"mcl:beacon")
|
awards.unlock(sender:get_player_name(),"mcl:beacon")
|
||||||
input:take_item()
|
input:take_item()
|
||||||
inv:set_stack("input",1,input)
|
inv:set_stack("input",1,input)
|
||||||
|
|
||||||
local beam_palette_index = 0
|
local beam_palette_index = 0
|
||||||
remove_beacon_beam(pos)
|
remove_beacon_beam(pos)
|
||||||
for y = pos.y +1, pos.y + 201 do
|
for y = pos.y +1, pos.y + 201 do
|
||||||
local node = minetest.get_node({x=pos.x,y=y,z=pos.z})
|
local node = minetest.get_node({x=pos.x,y=y,z=pos.z})
|
||||||
if node.name == ignore then
|
if node.name == ignore then
|
||||||
minetest.get_voxel_manip():read_from_map({x=pos.x,y=y,z=pos.z}, {x=pos.x,y=y,z=pos.z})
|
minetest.get_voxel_manip():read_from_map({x=pos.x,y=y,z=pos.z}, {x=pos.x,y=y,z=pos.z})
|
||||||
node = minetest.get_node({x=pos.x,y=y,z=pos.z})
|
node = minetest.get_node({x=pos.x,y=y,z=pos.z})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
if minetest.get_item_group(node.name, "glass") ~= 0 then
|
if minetest.get_item_group(node.name, "glass") ~= 0 or minetest.get_item_group(node.name,"material_glass") ~= 0 then
|
||||||
beam_palette_index = get_beacon_beam(node.name)
|
beam_palette_index = get_beacon_beam(node.name)
|
||||||
end
|
end
|
||||||
|
|
||||||
if node.name == "air" then
|
if node.name == "air" then
|
||||||
minetest.set_node({x=pos.x,y=y,z=pos.z},{name="mcl_beacons:beacon_beam",param2=beam_palette_index})
|
minetest.set_node({x=pos.x,y=y,z=pos.z},{name="mcl_beacons:beacon_beam",param2=beam_palette_index})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
globalstep_function(pos,sender)--call it once outside the globalstep so the player gets the effect right after selecting it
|
globalstep_function(pos,sender)--call it once outside the globalstep so the player gets the effect right after selecting it
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
light_source = 15,
|
light_source = 15,
|
||||||
groups = {handy=1},
|
groups = {handy=1},
|
||||||
drop = "mcl_beacons:beacon",
|
drop = "mcl_beacons:beacon",
|
||||||
sounds = mcl_sounds.node_sound_glass_defaults(),
|
sounds = mcl_sounds.node_sound_glass_defaults(),
|
||||||
_mcl_hardness = 3,
|
_mcl_hardness = 3,
|
||||||
})
|
})
|
||||||
|
|
||||||
mesecon.register_mvps_stopper("mcl_beacons:beacon")
|
mesecon.register_mvps_stopper("mcl_beacons:beacon")
|
||||||
|
@ -305,51 +347,58 @@ beacon_blocklist = {"mcl_core:diamondblock","mcl_core:ironblock","mcl_core:goldb
|
||||||
beacon_fuellist ={"mcl_core:diamond","mcl_core:emerald","mcl_core:iron_ingot","mcl_core:gold_ingot","mcl_nether:netherite_ingot"}
|
beacon_fuellist ={"mcl_core:diamond","mcl_core:emerald","mcl_core:iron_ingot","mcl_core:gold_ingot","mcl_nether:netherite_ingot"}
|
||||||
|
|
||||||
function register_beaconblock (itemstring)--API function for other mods
|
function register_beaconblock (itemstring)--API function for other mods
|
||||||
table.insert(beacon_blocklist, itemstring)
|
table.insert(beacon_blocklist, itemstring)
|
||||||
end
|
end
|
||||||
|
|
||||||
function register_beaconfuel(itemstring)
|
function register_beaconfuel(itemstring)
|
||||||
table.insert(beacon_fuellist, itemstring)
|
table.insert(beacon_fuellist, itemstring)
|
||||||
end
|
end
|
||||||
|
|
||||||
local timer = 0
|
local timer = 0
|
||||||
|
|
||||||
minetest.register_globalstep(function(dtime)
|
minetest.register_globalstep(function(dtime)
|
||||||
timer = timer + dtime
|
timer = timer + dtime
|
||||||
if timer >= 3 then
|
if timer >= 3 then
|
||||||
for _, player in ipairs(minetest.get_connected_players()) do
|
for _, player in ipairs(minetest.get_connected_players()) do
|
||||||
local player_pos = player:get_pos()
|
local player_pos = player:get_pos()
|
||||||
local pos_list = minetest.find_nodes_in_area({x=player_pos.x-50, y=player_pos.y-50, z=player_pos.z-50}, {x=player_pos.x+50, y=player_pos.y+50, z=player_pos.z+50},"mcl_beacons:beacon")
|
local pos_list = minetest.find_nodes_in_area({x=player_pos.x-50, y=player_pos.y-50, z=player_pos.z-50}, {x=player_pos.x+50, y=player_pos.y+50, z=player_pos.z+50},"mcl_beacons:beacon")
|
||||||
for _, pos in ipairs(pos_list) do
|
for _, pos in ipairs(pos_list) do
|
||||||
globalstep_function(pos,player)
|
globalstep_function(pos,player)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
timer = 0
|
timer = 0
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
minetest.register_abm{
|
|
||||||
label="update beacon beam",
|
|
||||||
nodenames = {"mcl_beacons:beacon_beam"},
|
|
||||||
interval = 1,
|
|
||||||
chance = 1,
|
|
||||||
action = function(pos)
|
|
||||||
local node_below = minetest.get_node({x=pos.x,y=pos.y-1,z=pos.z})
|
|
||||||
local node_above = minetest.get_node({x=pos.x,y=pos.y+1,z=pos.z})
|
|
||||||
|
|
||||||
if node_below.name == "air" then
|
minetest.register_abm{
|
||||||
remove_beacon_beam(pos)
|
label="update beacon beam",
|
||||||
elseif node_above.name == "air" then
|
nodenames = {"mcl_beacons:beacon_beam"},
|
||||||
minetest.set_node({x=pos.x,y=pos.y+1,z=pos.z},{name="mcl_beacons:beacon_beam",param2=node_below.param2})
|
interval = 1,
|
||||||
end
|
chance = 1,
|
||||||
end,
|
action = function(pos)
|
||||||
|
local node_below = minetest.get_node({x=pos.x,y=pos.y-1,z=pos.z})
|
||||||
|
local node_above = minetest.get_node({x=pos.x,y=pos.y+1,z=pos.z})
|
||||||
|
local node_current = minetest.get_node(pos)
|
||||||
|
|
||||||
|
if node_below.name == "air" then
|
||||||
|
if minetest.get_node({x=pos.x,y=pos.y-2,z=pos.z}).name == "mcl_beacons:beacon" then
|
||||||
|
minetest.set_node({x=pos.x,y=pos.y-1,z=pos.z},{name="mcl_beacons:beacon_beam",param2=0})
|
||||||
|
end
|
||||||
|
remove_beacon_beam(pos)
|
||||||
|
elseif node_above.name == "air" or (node_above.name == "mcl_beacons:beacon_beam" and node_above.param2 ~= node_current.param2) then
|
||||||
|
minetest.set_node({x=pos.x,y=pos.y+1,z=pos.z},{name="mcl_beacons:beacon_beam",param2=node_current.param2})
|
||||||
|
elseif minetest.get_item_group(node_above.name, "glass") ~= 0 or minetest.get_item_group(node_above.name,"material_glass") ~= 0 then
|
||||||
|
minetest.set_node({x=pos.x,y=pos.y+2,z=pos.z},{name="mcl_beacons:beacon_beam",param2=get_beacon_beam(node_above.name)})
|
||||||
|
end
|
||||||
|
end,
|
||||||
}
|
}
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
output = "mcl_beacons:beacon",
|
output = "mcl_beacons:beacon",
|
||||||
recipe = {
|
recipe = {
|
||||||
{"mcl_core:glass", "mcl_core:glass", "mcl_core:glass"},
|
{"mcl_core:glass", "mcl_core:glass", "mcl_core:glass"},
|
||||||
{"mcl_core:glass", "mcl_mobitems:nether_star", "mcl_core:glass"},
|
{"mcl_core:glass", "mcl_mobitems:nether_star", "mcl_core:glass"},
|
||||||
{"mcl_core:obsidian", "mcl_core:obsidian", "mcl_core:obsidian"}
|
{"mcl_core:obsidian", "mcl_core:obsidian", "mcl_core:obsidian"}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue