Compare commits

...

34 Commits

Author SHA1 Message Date
cora c6185338eb Optimize abm, make it work with intermittent glass 2022-07-28 01:08:17 +02:00
cora 6b746ec6a5 beacon_beam -> beam
what other beam is there in this mod ?
2022-07-27 16:39:39 +02:00
cora bcfd664e9b Use ABM to propagate / remove the beam 2022-07-27 16:38:37 +02:00
cora 2f868afedb Allow glass anywhere in the beam to color change 2022-07-27 16:09:14 +02:00
cora 3723870c11 Single itemstring and color palette for beam 2022-07-27 11:49:12 +02:00
cora 8e95ba85a0 spaces -> tabs 2022-07-27 11:46:08 +02:00
cora c56e84489d stray globals -> mcl_beacons global 2022-07-27 11:34:28 +02:00
chmodsayshello 0a0e85ba53 remove last beam completly before placing a new one 2022-07-26 11:07:45 +02:00
chmodsayshello 3fae0baa81 minor optimisations 2022-07-26 11:01:39 +02:00
chmodsayshello c1f9685381 mesh by Sumi 2022-07-26 10:40:45 +02:00
chmodsayshello d61c93c429 prevent pistons from pushing beacon beams 2022-07-25 21:52:07 +02:00
chmodsayshello 335c09b1df change 301 to 501 here as well 2022-07-25 21:47:03 +02:00
chmodsayshello 066fa1fcbe remove unnecessary minetest.log call 2022-07-25 21:37:05 +02:00
chmodsayshello 6bf905ad46 glass changes color of beacon beam 2022-07-25 21:35:15 +02:00
chmodsayshello b71a8364c8 minor changes 2022-07-25 17:54:15 +02:00
chmodsayshello 0868d73c33 translation template + german translation 2022-07-25 17:47:36 +02:00
chmodsayshello 4276fabf7a changing some comments 2022-07-25 17:23:28 +02:00
chmodsayshello ef568323c2 add beacon beam 2022-07-25 17:21:29 +02:00
chmodsayshello cb303353a9 Use overlay properly in mcl_achievements 2022-07-25 12:31:30 +02:00
chmodsayshello ead50562cc drop items once beacon gets destroyed 2022-07-25 12:20:15 +02:00
chmodsayshello 0833f3417b 'fix' beacon texture 2022-07-25 11:59:19 +02:00
chmodsayshello 99174f0fb4 add netherite to beacon materials 2022-07-24 13:00:58 +02:00
chmodsayshello fd65be17a0 make beacons mineable 2022-07-24 12:52:57 +02:00
chmodsayshello dd37fe03b0 beacon crafting recipie 2022-07-24 12:45:30 +02:00
chmodsayshello 974b0f2810 beacon related achievements 2022-07-24 12:32:20 +02:00
chmodsayshello a8b2e99ec9 fix mayor multiplayer bug
because i escape the loop using return after applying the effect to ONE player, which causes the other ones to not get the effect
2022-07-23 22:15:17 +00:00
chmodsayshello 870d2ac9e6 check if there are no blocks above beacons 2022-07-23 21:07:18 +00:00
chmodsayshello 5ed495aa41 remove unnecessary code 2022-07-23 11:06:47 +00:00
chmodsayshello 3e8835cf5f use globalstep instead of abm 2022-07-23 10:46:02 +00:00
chmodsayshello 614c4a41e2 remove debug logging 2022-07-22 19:07:49 +00:00
chmodsayshello 6cca4ca805 upload mod (mcl_beacons) itself 2022-07-22 18:48:36 +00:00
chmodsayshello d4324bb1a9 upload textures 2/2 2022-07-22 18:48:01 +00:00
chmodsayshello 143def257e upload textures 1/2 2022-07-22 18:47:35 +00:00
chmodsayshello c7225a1715 add mod.conf 2022-07-22 18:46:37 +00:00
15 changed files with 378 additions and 0 deletions

View File

@ -266,6 +266,19 @@ awards.register_achievement("mcl:enchanter", {
icon = "mcl_enchanting_book_enchanted.png",
})
--Triggered in mcl_beacons
awards.register_achievement("mcl:beacon", {
title = S("Bring Home the Beacon"),
description = S("Use a beacon."),
icon = "beacon_achievement_icon.png",
})
awards.register_achievement("mcl:maxed_beacon", {
title = S("Beaconator"),
description = S("Use a fully powered beacon."),
icon = "beacon_achievement_icon.png",
})
-- NON-PC ACHIEVEMENTS (XBox, Pocket Edition, etc.)
if non_pc_achievements then

View File

@ -47,3 +47,7 @@ Use a crafting table to craft a wooden hoe from wooden planks and sticks.=Benutz
Use a crafting table to craft a wooden pickaxe from wooden planks and sticks.=Benutzen Sie eine Werkbank, um eine Holzspitzhacke aus Holzplanken und Stöcken zu fertigen.
Use obsidian and a fire starter to construct a Nether portal.=Benutzen Sie Obsidian und ein Feuerzeug, um ein Netherportal zu errichten.
Use wheat to craft a bread.=Benutzen Sie Weizen, um ein Brot zu machen.
Bring Home the Beacon=Den Nachbarn heimleuchten
Use a beacon.=Benutzen Sie ein Leuchtfeuer.
Beaconator=Leuchtturmwärter
Use a fully powered beacon.=Benutzen Sie ein vollständiges Leuchtfeuer.

View File

@ -73,3 +73,7 @@ Local Brewery=
Brew a Potion.@nHint: Take a potion or glass bottle out of the brewing stand.=
Enchanter=
Enchant an item using an Enchantment Table.=
Bring Home the Beacon=
Use a beacon.=
Beaconator=
Use a fully powered beacon.=

View File

@ -0,0 +1,344 @@
local S = minetest.get_translator(minetest.get_current_modname())
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
--[[
there are strings in meta, which are being used to see which effect will be given to the player(s)
Valid strings:
swiftness
leaping
strenght
regeneration
]]--
local colors = {
"white",
"silver",
"gray",
"black",
"brown",
"red",
"orange",
"yellow",
"lime",
"green",
"cyan",
"light_blue",
"blue",
"magenta",
"purple",
"pink",
} -- the order of this array determines the index of the palette - do not change it
local function glass_to_p2(glass_itemstring)
if not glass_itemstring or glass_itemstring == "air" then return 0 end
local c = glass_itemstring:split(":")[2]:gsub("glass_","")
if c then
local p2 = table.indexof(colors,c) - 1
if p2 == -1 then p2 = 0 end
return p2
end
return 0
end
minetest.register_node("mcl_beacons:beam",{
tiles = {"^[colorize:white"},
drawtype = "nodebox",
paramtype2 = "color",
palette = "mcl_beacons_palette.png",
node_box = {
type = "fixed",
fixed = {
{-0.1250, -0.5000, -0.1250, 0.1250, 0.5000, 0.1250}
}
},
light_source = 15,
walkable = false,
pointable = false,
floodable = false,
buildable_to = true,
groups = {not_in_creative_inventory=1},
_mcl_blast_resistance = 1200,
})
mesecon.register_mvps_stopper("mcl_beacons:beam")
local formspec_string=
"size[11,14]"..
"label[4.5,0.5;"..minetest.formspec_escape(S("Beacon:")).."]"..
"label[0.5,1;"..minetest.formspec_escape(S("Primary Power:")).."]"..
"label[0.5,8.25;"..minetest.formspec_escape( S("Inventory:")).."]"..
"image[1,1.5;1,1;custom_beacom_symbol_4.png]"..
"image[1,3;1,1;custom_beacom_symbol_3.png]"..
"image[1,4.5;1,1;custom_beacom_symbol_2.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,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,6;1,1;mcl_potions_effect_regenerating.png;regeneration;]"..
"item_image[1,7;1,1;mcl_core:diamond]"..
"item_image[2.2,7;1,1;mcl_core:emerald]"..
"item_image[3.4,7;1,1;mcl_core:iron_ingot]"..
"item_image[4.6,7;1,1;mcl_core:gold_ingot]"..
"item_image[5.8,7;1,1;mcl_nether:netherite_ingot]"..
mcl_formspec.get_itemslot_bg(7.2,7,1,1)..
"list[context;input;7.2,7;1,1;]"..
mcl_formspec.get_itemslot_bg(1,9,9,3)..
"list[current_player;main;1,9;9,3;9]"..
mcl_formspec.get_itemslot_bg(1,12.5,9,1)..
"list[current_player;main;1,12.5;9,1;]"
local function beacon_blockcheck(pos)
for y_offset = 1,4 do
local block_y = pos.y - y_offset
for block_x = (pos.x-y_offset),(pos.x+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
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
valid_block =true
end
end
if not valid_block then
return y_offset -1 --the last layer is complete, this one is missing or incomplete
end
end
end
if y_offset == 4 then --all checks are done, beacon is maxed
return y_offset
end
end
end
local function effect_player(effect,pos,power_level, effect_level,player)
local distance = vector.distance(player:get_pos(), pos)
if distance > (power_level+1)*10 then return end
if effect == "swiftness" then
mcl_potions.swiftness_func(player,effect_level,16)
elseif effect == "leaping" then
mcl_potions.leaping_func(player, effect_level, 16)
elseif effect == "strenght" then
mcl_potions.strength_func(player, effect_level, 16)
elseif effect == "regeneration" then
mcl_potions.regeneration_func(player, effect_level, 16)
end
end
local function is_obstructed(pos)
for y=pos.y+1, pos.y+301 do
local nodename = minetest.get_node({x=pos.x,y=y, z = pos.z}).name
if nodename ~= "mcl_core:bedrock" and nodename ~= "air" and nodename ~= "ignore" and nodename ~= "mcl_core:void" then --ignore means not loaded, let's just assume that's air
if nodename ~= "mcl_beacons:beam" then
if minetest.get_item_group(nodename,"glass") == 0 then
return true
end
end
end
end
return false
end
local function globalstep_function(pos,player)
local meta = minetest.get_meta(pos)
local power_level = beacon_blockcheck(pos)
local effect_string = meta:get_string("effect")
if meta:get_int("effect_level") == 2 and power_level < 4 then
return
else
if is_obstructed(pos) then return end
effect_player(effect_string,pos,power_level,meta:get_int("effect_level"),player)
end
end
local function set_beam_column(p,n,h)
if is_obstructed(p) then
minetest.set_node(p,n) -- pos itsself is already checked for air
return
end
local p2 = vector.offset(p,0,h,0)
local column = minetest.find_nodes_in_area(p,p2,{"air","mcl_beacons:beam"})
if column then
minetest.bulk_set_node(column,n)
end
end
minetest.register_node("mcl_beacons:beacon", {
description = S"Beacon",
drawtype = "mesh",
collisionbox = {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
mesh = "mcl_beacon.b3d",
tiles = {"beacon_UV.png"},
on_construct = function(pos)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
inv:set_size("input", 1)
local form = formspec_string
meta:set_string("formspec", form)
end,
on_destruct = function(pos)
local meta = minetest.get_meta(pos)
local input = meta:get_inventory():get_stack("input",1)
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
minetest.add_item(p, input)
end
set_beam_column(pos,{name="air"},500)
end,
on_receive_fields = function(pos, formname, fields, sender)
if fields.swiftness or fields.regeneration or fields.leaping or fields.strenght then
local sender_name = sender:get_player_name()
local power_level = beacon_blockcheck(pos)
if minetest.is_protected(pos, sender_name) then
minetest.record_protection_violation(pos, sender_name)
return
elseif power_level == 0 then
return
end
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
local input = inv:get_stack("input",1)
if input:is_empty() then
return
end
local valid_item = false
for _, item in ipairs(beacon_fuellist) do
if input:get_name() == item then
valid_item = true
end
end
if not valid_item then
return
end
local successful = false
if fields.swiftness then
if power_level == 4 then
minetest.get_meta(pos):set_int("effect_level",2)
else
minetest.get_meta(pos):set_int("effect_level",1)
end
minetest.get_meta(pos):set_string("effect","swiftness")
successful = true
elseif fields.leaping and power_level >= 2 then
if power_level == 4 then
minetest.get_meta(pos):set_int("effect_level",2)
else
minetest.get_meta(pos):set_int("effect_level",1)
end
minetest.get_meta(pos):set_string("effect","leaping")
successful = true
elseif fields.strenght and power_level >= 3 then
if power_level == 4 then
minetest.get_meta(pos):set_int("effect_level",2)
else
minetest.get_meta(pos):set_int("effect_level",1)
end
minetest.get_meta(pos):set_string("effect","strenght")
successful = true
elseif fields.regeneration and power_level == 4 then
minetest.get_meta(pos):set_int("effect_level",2)
minetest.get_meta(pos):set_string("effect","regeneration")
successful = true
end
if successful then
if power_level == 4 then
awards.unlock(sender:get_player_name(),"mcl:maxed_beacon")
end
awards.unlock(sender:get_player_name(),"mcl:beacon")
input:take_item()
inv:set_stack("input",1,input)
local above = vector.offset(pos,0,1,0)
local node = minetest.get_node(above)
local p2 = 0
if minetest.get_item_group(node.name, "glass") > 0 then
p2 = glass_to_p2(node.name)
above.y = above.y + 1
node = minetest.get_node(above)
end
if node.name == "air" then
set_beam_column(above,{name="mcl_beacons:beam",param2=p2},50)
end
globalstep_function(pos,sender)--call it once outside the globalstep so the player gets the effect right after selecting it
end
end
end,
light_source = 15,
groups = {handy=1},
drop = "mcl_beacons:beacon",
sounds = mcl_sounds.node_sound_glass_defaults(),
_mcl_hardness = 3,
})
mesecon.register_mvps_stopper("mcl_beacons:beacon")
mcl_wip.register_wip_item("mcl_beacons:beacon")
function register_beaconblock (itemstring)--API function for other mods
table.insert(beacon_blocklist, itemstring)
end
function register_beaconfuel(itemstring)
table.insert(beacon_fuellist, itemstring)
end
minetest.register_abm({
label = "Beacon beams propagation",
nodenames ={ "mcl_beacons:beam" },
interval = 5,
chance = 1,
action = function(pos,node)
local p1 = vector.offset(pos,0,-1,0)
local p2 = vector.offset(pos,0,1,0)
local n1 = minetest.get_node_or_nil(p1)
local n2 = minetest.get_node_or_nil(p2)
local is_glass = minetest.get_item_group(n1.name,"glass") > 0
if not n1 or not n2 then return end
if n1.name == "air" then
minetest.remove_node(pos)
set_beam_column(pos,{name="air"},500)
elseif is_glass and node.param2 ~= glass_to_p2(n1.name) then
node.param2 = glass_to_p2(n1.name)
set_beam_column(pos,node,500)
elseif n1.name == "mcl_beacons:beam" and node.param2 ~= n1.param2 then
set_beam_column(pos,n1,500)
elseif n2.name == "air" then
set_beam_column(p2,node,500)
end
end
})
local timer = 0
minetest.register_globalstep(function(dtime)
timer = timer + dtime
if timer >= 3 then
for _, player in ipairs(minetest.get_connected_players()) do
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")
for _, pos in ipairs(pos_list) do
globalstep_function(pos,player)
end
end
timer = 0
end
end)
minetest.register_craft({
output = "mcl_beacons:beacon",
recipe = {
{"mcl_core:glass", "mcl_core:glass", "mcl_core:glass"},
{"mcl_core:glass", "mcl_mobitems:nether_star", "mcl_core:glass"},
{"mcl_core:obsidian", "mcl_core:obsidian", "mcl_core:obsidian"}
}
})

View File

@ -0,0 +1,5 @@
# textdomain: mcl_beacons
Beacon=Leuchtfeuer
Beacon:=Leuchtfeuer:
Primary Power:=Primäre Kraft:
Inventory:=Inventar:

View File

@ -0,0 +1,6 @@
# textdomain: mcl_beacons
Beacon=
Beacon:=
Primary Power:=
Inventory:=

View File

@ -0,0 +1,2 @@
author=chmodsayshello
depends=mcl_formspec, mcl_init, mcl_wip, mesecons_mvps, mcl_core, mcl_sounds, awards, mcl_achievements, mcl_mobitems, mcl_nether

Binary file not shown.

After

Width:  |  Height:  |  Size: 1014 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 635 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 635 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 641 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 635 B

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 196 B