Compare commits

...

19 Commits

Author SHA1 Message Date
AFCMS 2714f3345e Revert "fix emerald help text translation"
This reverts commit 250b1dca78.
2021-09-20 09:59:40 +02:00
AFCMS 250b1dca78 fix emerald help text translation 2021-09-20 09:47:24 +02:00
AFCMS fd8808af1d Merge branch 'master' of ssh://git.minetest.land:29418/MineClone2/MineClone2 into formspec-v4 2021-09-20 09:38:30 +02:00
AFCMS 27d9c8449b survival inventory 2021-09-20 09:22:13 +02:00
AFCMS 1d39c9e9a1 some things 2021-09-18 11:05:17 +02:00
AFCMS a1afa3746a fix all chest formspecs 2021-09-18 09:53:45 +02:00
AFCMS 7253e17bd7 chest + shulkerbox formspec 2021-09-18 00:36:33 +02:00
AFCMS 0baef425d5 ender chest formspec v4 2021-09-17 23:58:58 +02:00
AFCMS 0c7243609f create some files 2021-09-17 20:00:25 +02:00
AFCMS 7f03c4f50e Merge branch 'master' into formspec-v4 2021-09-11 08:48:32 +02:00
AFCMS 4de3f1265b Merge branch 'master' into formspec-v4 2021-06-04 19:11:59 +02:00
AFCMS ac86cf2214 Merge branch 'master' into formspec-v4 2021-05-27 09:11:03 +02:00
AFCMS 966991ce4d Merge branch 'master' into formspec-v4 2021-05-19 00:20:13 +02:00
AFCMS 1673c62391 Merge branch 'master' into formspec-v4 2021-05-04 10:30:00 +02:00
AFCMS e28f7e1ee9 Merge branch 'master' into formspec-v4 2021-05-03 23:25:59 +02:00
AFCMS bf53ca18d6 Merge branch 'master' into formspec-v4 2021-04-29 23:58:58 +02:00
AFCMS 0bf3dde857 Merge branch 'master' into formspec-v4 2021-04-26 11:20:46 +02:00
AFCMS 09739b0d89 Merge branch 'master' into formspec-v4 2021-04-26 08:30:53 +02:00
AFCMS 8fac3d1189 add basic temp function to get v4 itemslots 2021-04-25 23:35:27 +02:00
9 changed files with 325 additions and 121 deletions

View File

View File

@ -0,0 +1,25 @@
# MineClone2 Formspec Guide
***This guide will learn you rules about creation of formspecs for the MineClone2 game.***
Formspecs are an important part of game and mod development.
First of all, MineClone2 aims to support ONLY last formspec version. Many utility functions will not work with formspec v1 or v2.
Label font size should be 25 to be minecraft like. We arent modifying formspec prepend in order to not break existing mods.
Just add this code to apply it to your formspec:
```lua
mcl_formspec.apply_label_size
```
The typical width of an 9 slots width inventory formspec is `0.375 + 9 + ((9-1) * 0.25) + 0.375 = 11.75`
Margins is 0.375
Space between 1st inventory line and the rest of inventory is 0.45
Labels should have 0.375 space above if there is no other stuff above and 0.45 between content
+ 0.375 under
According to minetest modding book, table.concat is faster than string concatenation, so this method should be prefered (the code is also more clear)

View File

@ -1,5 +1,16 @@
local string = string
local table = table
local sf = string.format
mcl_formspec = {}
mcl_formspec.label_color = "#313131"
mcl_formspec.label_size = tonumber(minetest.settings:get("mcl_label_font_size")) or 24
mcl_formspec.apply_label_size = sf("style_type[label;font_size=%s]", mcl_formspec.label_size)
function mcl_formspec.get_itemslot_bg(x, y, w, h)
local out = ""
for i = 0, w - 1, 1 do
@ -9,3 +20,24 @@ function mcl_formspec.get_itemslot_bg(x, y, w, h)
end
return out
end
--This function will replace mcl_formspec.get_itemslot_bg then every formspec will be upgrade to version 4
local function get_slot(x, y, size)
local t = "image["..x-size..","..y-size..";".. 1+(size*2)..",".. 1+(size*2)..";mcl_formspec_itemslot.png]"
return t
end
mcl_formspec.itemslot_border_size = 0.05
function mcl_formspec.get_itemslot_bg_v4(x, y, w, h, size)
if not size then
size = mcl_formspec.itemslot_border_size
end
local out = ""
for i = 0, w - 1, 1 do
for j = 0, h - 1, 1 do
out = out .. get_slot(x+i+(i*0.25), y+j+(j*0.25), size)
end
end
return out
end

View File

@ -1,5 +1,8 @@
local S = minetest.get_translator(minetest.get_current_modname())
local F = minetest.formspec_escape
local C = minetest.colorize
local table = table
mcl_inventory = {}
@ -63,21 +66,88 @@ local function set_inventory(player, armor_change_only)
-- Show armor and player image
local player_preview
if minetest.settings:get_bool("3d_player_preview", true) then
player_preview = mcl_player.get_player_formspec_model(player, 1.0, 0.0, 2.25, 4.5, "")
player_preview = mcl_player.get_player_formspec_model(player, 1.625, 0.375, 3.5, 4.75, "")
else
player_preview = "image[1.1,0.2;2,4;"..mcl_player.player_get_preview(player).."]"
player_preview = "image[1.625,0.375;3.5,4.75;"..mcl_player.player_get_preview(player).."]"
end
--player_preview = "image[1.625,0.375;3.5,4.75;"..mcl_player.player_get_preview(player).."]"
local armor_slots = {"helmet", "chestplate", "leggings", "boots"}
local armor_slot_imgs = ""
for a=1,4 do
if inv:get_stack("armor", a+1):is_empty() then
armor_slot_imgs = armor_slot_imgs .. "image[0,"..(a-1)..";1,1;mcl_inventory_empty_armor_slot_"..armor_slots[a]..".png]"
armor_slot_imgs = armor_slot_imgs .. "image[0.375,".. 0.375 + (a-1) + (a-1)* 0.25 ..";1,1;mcl_inventory_empty_armor_slot_"..armor_slots[a]..".png]"
end
end
local form = "size[9,8.75]"..
"background[-0.19,-0.25;9.41,9.49;crafting_formspec_bg.png]"..
--"label[0.375,5.575;"..F(C(mcl_formspec.label_color, S("Inventory"))).."]",
local form = table.concat({
"formspec_version[4]",
"size[11.75,10.9]",
mcl_formspec.apply_label_size,
mcl_formspec.get_itemslot_bg_v4(0.375, 0.375, 1, 1),
mcl_formspec.get_itemslot_bg_v4(0.375, 1.625, 1, 1),
mcl_formspec.get_itemslot_bg_v4(0.375, 2.875, 1, 1),
mcl_formspec.get_itemslot_bg_v4(0.375, 4.125, 1, 1),
armor_slot_imgs,
"list[current_player;armor;0.375,0.375;1,1;1]",
"list[current_player;armor;0.375,1.625;1,1;2]",
"list[current_player;armor;0.375,2.875;1,1;3]",
"list[current_player;armor;0.375,4.125;1,1;4]",
--TMP FAKE PLAYER PREVIEW
"box[1.625,0.375;3.5,4.75;"..mcl_formspec.label_color.."]",
player_preview,
--left hand presupport
--mcl_formspec.get_itemslot_bg_v4(5.375, 4.125, 1, 1),
--"list[current_player;armor;5.375,4.125;1,1;4]",
--buttons
--skins
"image_button[5.375,4.125;1,1;mcl_skins_button.png;__mcl_skins;]",
"tooltip[__mcl_skins;"..F(S("Select player skin")).."]",
--crafting guide button
"image_button[7.25,4.125;1,1;craftguide_book.png;__mcl_craftguide;]",
"tooltip[__mcl_craftguide;"..F(S("Recipe book")).."]",
--achievements button
"image_button[9.125,4.125;1,1;mcl_achievements_button.png;__mcl_achievements;]",
"tooltip[__mcl_achievements;"..F(S("Achievements")).."]",
--help button
"image_button[10.375,4.125;1,1;doc_button_icon_lores.png;__mcl_doc;]",
"tooltip[__mcl_doc;"..F(S("Help")).."]",
"label[6.625,0.375;"..F(C(mcl_formspec.label_color, S("Crafting"))).."]",
--crafting interface
mcl_formspec.get_itemslot_bg_v4(6.625, 0.75, 2, 2),
"list[current_player;craft;6.625,0.75;2,2]",
"image[9.125,1.375;1,1;crafting_formspec_arrow.png]",
mcl_formspec.get_itemslot_bg_v4(10.375, 1.375, 1, 1),
"list[current_player;craftpreview;10.375,1.375;1,1;]",
--player inventory
mcl_formspec.get_itemslot_bg_v4(0.375, 5.575, 9, 3),
mcl_formspec.get_itemslot_bg_v4(0.375, 9.525, 9, 1),
"list[current_player;main;0.375,5.575;9,3;9]",
"list[current_player;main;0.375,9.525;9,1;]",
--for shortcuts
"listring[current_player;main]",
"listring[current_player;armor]",
"listring[current_player;main]",
"listring[current_player;craft]",
"listring[current_player;main]",
})
local form2 = "size[9,8.75]"..
--"background[-0.19,-0.25;9.41,9.49;crafting_formspec_bg.png]"..
player_preview..
--armor
"list[current_player;armor;0,0;1,1;1]"..
@ -88,12 +158,12 @@ local function set_inventory(player, armor_change_only)
mcl_formspec.get_itemslot_bg(0,1,1,1)..
mcl_formspec.get_itemslot_bg(0,2,1,1)..
mcl_formspec.get_itemslot_bg(0,3,1,1)..
armor_slot_imgs..
--armor_slot_imgs..
-- craft and inventory
"label[0,4;"..F(minetest.colorize("#313131", S("Inventory"))).."]"..
"label[0,4;"..F(C("#313131", S("Inventory"))).."]"..
"list[current_player;main;0,4.5;9,3;9]"..
"list[current_player;main;0,7.74;9,1;]"..
"label[4,0.5;"..F(minetest.colorize("#313131", S("Crafting"))).."]"..
"label[4,0.5;"..F(C("#313131", S("Crafting"))).."]"..
"list[current_player;craft;4,1;2,2]"..
"list[current_player;craftpreview;7,1.5;1,1;]"..
mcl_formspec.get_itemslot_bg(0,4.5,9,3)..

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

View File

@ -1,4 +1,13 @@
local S = minetest.get_translator(minetest.get_current_modname())
local F = minetest.formspec_escape
local C = minetest.colorize
local string = string
local table = table
local math = math
local sf = string.format
local mod_doc = minetest.get_modpath("doc")
-- Chest Entity
@ -13,7 +22,7 @@ local entity_animations = {
speed = 25,
open = {x = 0, y = 7},
close = {x = 13, y = 20},
}
},
}
minetest.register_entity("mcl_chests:chest", {
@ -207,23 +216,23 @@ local function chest_update_after_close(pos)
local node = minetest.get_node(pos)
if node.name == "mcl_chests:trapped_chest_on_small" then
minetest.swap_node(pos, {name="mcl_chests:trapped_chest_small", param2 = node.param2})
minetest.swap_node(pos, {name = "mcl_chests:trapped_chest_small", param2 = node.param2})
find_or_create_entity(pos, "mcl_chests:trapped_chest_small", {"mcl_chests_trapped.png"}, node.param2, false, "default_chest", "mcl_chests_chest", "chest"):reinitialize("mcl_chests:trapped_chest_small")
mesecon.receptor_off(pos, trapped_chest_mesecons_rules)
elseif node.name == "mcl_chests:trapped_chest_on_left" then
minetest.swap_node(pos, {name="mcl_chests:trapped_chest_left", param2 = node.param2})
minetest.swap_node(pos, {name = "mcl_chests:trapped_chest_left", param2 = node.param2})
find_or_create_entity(pos, "mcl_chests:trapped_chest_left", {"mcl_chests_trapped_double.png"}, node.param2, true, "default_chest", "mcl_chests_chest", "chest"):reinitialize("mcl_chests:trapped_chest_left")
mesecon.receptor_off(pos, trapped_chest_mesecons_rules)
local pos_other = mcl_util.get_double_container_neighbor_pos(pos, node.param2, "left")
minetest.swap_node(pos_other, {name="mcl_chests:trapped_chest_right", param2 = node.param2})
minetest.swap_node(pos_other, {name = "mcl_chests:trapped_chest_right", param2 = node.param2})
mesecon.receptor_off(pos_other, trapped_chest_mesecons_rules)
elseif node.name == "mcl_chests:trapped_chest_on_right" then
minetest.swap_node(pos, {name="mcl_chests:trapped_chest_right", param2 = node.param2})
minetest.swap_node(pos, {name = "mcl_chests:trapped_chest_right", param2 = node.param2})
mesecon.receptor_off(pos, trapped_chest_mesecons_rules)
local pos_other = mcl_util.get_double_container_neighbor_pos(pos, node.param2, "right")
minetest.swap_node(pos_other, {name="mcl_chests:trapped_chest_left", param2 = node.param2})
minetest.swap_node(pos_other, {name = "mcl_chests:trapped_chest_left", param2 = node.param2})
find_or_create_entity(pos_other, "mcl_chests:trapped_chest_left", {"mcl_chests_trapped_double.png"}, node.param2, true, "default_chest", "mcl_chests_chest", "chest"):reinitialize("mcl_chests:trapped_chest_left")
mesecon.receptor_off(pos_other, trapped_chest_mesecons_rules)
end
@ -474,18 +483,29 @@ local function register_chest(basename, desc, longdesc, usagehelp, tt_help, tile
end
minetest.show_formspec(clicker:get_player_name(),
"mcl_chests:"..canonical_basename.."_"..pos.x.."_"..pos.y.."_"..pos.z,
"size[9,8.75]"..
"label[0,0;"..minetest.formspec_escape(minetest.colorize("#313131", name)).."]"..
"list[nodemeta:"..pos.x..","..pos.y..","..pos.z..";main;0,0.5;9,3;]"..
mcl_formspec.get_itemslot_bg(0,0.5,9,3)..
"label[0,4.0;"..minetest.formspec_escape(minetest.colorize("#313131", S("Inventory"))).."]"..
"list[current_player;main;0,4.5;9,3;9]"..
mcl_formspec.get_itemslot_bg(0,4.5,9,3)..
"list[current_player;main;0,7.74;9,1;]"..
mcl_formspec.get_itemslot_bg(0,7.74,9,1)..
"listring[nodemeta:"..pos.x..","..pos.y..","..pos.z..";main]"..
"listring[current_player;main]")
sf("mcl_chests:%s_%s_%s_%s", canonical_basename, pos.x, pos.y, pos.z),
table.concat({
"formspec_version[4]",
"size[11.75,10.425]",
mcl_formspec.apply_label_size,
"label[0.375,0.375;"..F(C(mcl_formspec.label_color, name)).."]",
mcl_formspec.get_itemslot_bg_v4(0.375, 0.75, 9, 3),
sf("list[nodemeta:%s,%s,%s;main;0.375,0.75;9,3;]", pos.x, pos.y, pos.z),
"label[0.375,4.7;"..F(C(mcl_formspec.label_color, S("Inventory"))).."]",
mcl_formspec.get_itemslot_bg_v4(0.375, 5.1, 9, 3),
"list[current_player;main;0.375,5.1;9,3;9]",
mcl_formspec.get_itemslot_bg_v4(0.375, 9.05, 9, 1),
"list[current_player;main;0.375,9.05;9,1;]",
sf("listring[nodemeta:%s,%s,%s;main]", pos.x, pos.y, pos.z),
"listring[current_player;main]",
})
)
if on_rightclick_addendum then
on_rightclick_addendum(pos, node, clicker)
@ -623,26 +643,38 @@ local function register_chest(basename, desc, longdesc, usagehelp, tt_help, tile
end
minetest.show_formspec(clicker:get_player_name(),
"mcl_chests:"..canonical_basename.."_"..pos.x.."_"..pos.y.."_"..pos.z,
"size[9,11.5]"..
"label[0,0;"..minetest.formspec_escape(minetest.colorize("#313131", name)).."]"..
"list[nodemeta:"..pos.x..","..pos.y..","..pos.z..";main;0,0.5;9,3;]"..
mcl_formspec.get_itemslot_bg(0,0.5,9,3)..
"list[nodemeta:"..pos_other.x..","..pos_other.y..","..pos_other.z..";main;0,3.5;9,3;]"..
mcl_formspec.get_itemslot_bg(0,3.5,9,3)..
"label[0,7;"..minetest.formspec_escape(minetest.colorize("#313131", S("Inventory"))).."]"..
"list[current_player;main;0,7.5;9,3;9]"..
mcl_formspec.get_itemslot_bg(0,7.5,9,3)..
"list[current_player;main;0,10.75;9,1;]"..
mcl_formspec.get_itemslot_bg(0,10.75,9,1)..
-- BEGIN OF LISTRING WORKAROUND
"listring[current_player;main]"..
"listring[nodemeta:"..pos.x..","..pos.y..","..pos.z..";input]"..
-- END OF LISTRING WORKAROUND
"listring[current_player;main]"..
"listring[nodemeta:"..pos.x..","..pos.y..","..pos.z..";main]"..
"listring[current_player;main]"..
"listring[nodemeta:"..pos_other.x..","..pos_other.y..","..pos_other.z..";main]")
sf("mcl_chests:%s_%s_%s_%s", canonical_basename, pos.x, pos.y, pos.z),
table.concat({
"formspec_version[4]",
"size[11.75,14.15]",
mcl_formspec.apply_label_size,
"label[0.375,0.375;"..F(C(mcl_formspec.label_color, name)).."]",
mcl_formspec.get_itemslot_bg_v4(0.375, 0.75, 9, 3),
sf("list[nodemeta:%s,%s,%s;main;0.375,0.75;9,3;]", pos.x, pos.y, pos.z),
mcl_formspec.get_itemslot_bg_v4(0.375, 4.5, 9, 3),
sf("list[nodemeta:%s,%s,%s;main;0.375,4.5;9,3;]", pos_other.x, pos_other.y, pos_other.z),
"label[0.375,8.45;"..F(C(mcl_formspec.label_color, S("Inventory"))).."]",
mcl_formspec.get_itemslot_bg_v4(0.375, 8.825, 9, 3),
"list[current_player;main;0.375,8.825;9,3;9]",
mcl_formspec.get_itemslot_bg_v4(0.375, 12.775, 9, 1),
"list[current_player;main;0.375,12.775;9,1;]",
--BEGIN OF LISTRING WORKAROUND
"listring[current_player;main]",
sf("listring[nodemeta:%s,%s,%s;input]", pos.x, pos.y, pos.z),
--END OF LISTRING WORKAROUND
"listring[current_player;main]"..
sf("listring[nodemeta:%s,%s,%s;main]", pos.x, pos.y, pos.z),
"listring[current_player;main]",
sf("listring[nodemeta:%s,%s,%s;main]", pos_other.x, pos_other.y, pos_other.z),
})
)
if on_rightclick_addendum_left then
on_rightclick_addendum_left(pos, node, clicker)
@ -770,27 +802,38 @@ local function register_chest(basename, desc, longdesc, usagehelp, tt_help, tile
end
minetest.show_formspec(clicker:get_player_name(),
"mcl_chests:"..canonical_basename.."_"..pos.x.."_"..pos.y.."_"..pos.z,
sf("mcl_chests:%s_%s_%s_%s", canonical_basename, pos.x, pos.y, pos.z),
table.concat({
"formspec_version[4]",
"size[11.75,14.15]",
mcl_formspec.apply_label_size,
"size[9,11.5]"..
"label[0,0;"..minetest.formspec_escape(minetest.colorize("#313131", name)).."]"..
"list[nodemeta:"..pos_other.x..","..pos_other.y..","..pos_other.z..";main;0,0.5;9,3;]"..
mcl_formspec.get_itemslot_bg(0,0.5,9,3)..
"list[nodemeta:"..pos.x..","..pos.y..","..pos.z..";main;0,3.5;9,3;]"..
mcl_formspec.get_itemslot_bg(0,3.5,9,3)..
"label[0,7;"..minetest.formspec_escape(minetest.colorize("#313131", S("Inventory"))).."]"..
"list[current_player;main;0,7.5;9,3;9]"..
mcl_formspec.get_itemslot_bg(0,7.5,9,3)..
"list[current_player;main;0,10.75;9,1;]"..
mcl_formspec.get_itemslot_bg(0,10.75,9,1)..
-- BEGIN OF LISTRING WORKAROUND
"listring[current_player;main]"..
"listring[nodemeta:"..pos.x..","..pos.y..","..pos.z..";input]"..
-- END OF LISTRING WORKAROUND
"listring[current_player;main]"..
"listring[nodemeta:"..pos_other.x..","..pos_other.y..","..pos_other.z..";main]"..
"listring[current_player;main]"..
"listring[nodemeta:"..pos.x..","..pos.y..","..pos.z..";main]")
"label[0.375,0.375;"..F(C(mcl_formspec.label_color, name)).."]",
mcl_formspec.get_itemslot_bg_v4(0.375, 0.75, 9, 3),
sf("list[nodemeta:%s,%s,%s;main;0.375,0.75;9,3;]", pos_other.x, pos_other.y, pos_other.z),
mcl_formspec.get_itemslot_bg_v4(0.375, 4.5, 9, 3),
sf("list[nodemeta:%s,%s,%s;main;0.375,4.5;9,3;]", pos.x, pos.y, pos.z),
"label[0.375,8.45;"..F(C(mcl_formspec.label_color, S("Inventory"))).."]",
mcl_formspec.get_itemslot_bg_v4(0.375, 8.825, 9, 3),
"list[current_player;main;0.375,8.825;9,3;9]",
mcl_formspec.get_itemslot_bg_v4(0.375, 12.775, 9, 1),
"list[current_player;main;0.375,12.775;9,1;]",
--BEGIN OF LISTRING WORKAROUND
"listring[current_player;main]",
sf("listring[nodemeta:%s,%s,%s;input]", pos.x, pos.y, pos.z),
--END OF LISTRING WORKAROUND
"listring[current_player;main]"..
sf("listring[nodemeta:%s,%s,%s;main]", pos_other.x, pos_other.y, pos_other.z),
"listring[current_player;main]",
sf("listring[nodemeta:%s,%s,%s;main]", pos.x, pos.y, pos.z),
})
)
if on_rightclick_addendum_right then
on_rightclick_addendum_right(pos, node, clicker)
@ -854,10 +897,12 @@ register_chest("trapped_chest",
S("27 inventory slots") .. "\n" .. S("Can be combined to a large chest") .. "\n" .. S("Emits a redstone signal when opened"),
traptiles,
nil,
{receptor = {
state = mesecon.state.off,
rules = trapped_chest_mesecons_rules,
}},
{
receptor = {
state = mesecon.state.off,
rules = trapped_chest_mesecons_rules,
},
},
function(pos, node, clicker)
minetest.swap_node(pos, {name="mcl_chests:trapped_chest_on_small", param2 = node.param2})
find_or_create_entity(pos, "mcl_chests:trapped_chest_on_small", {"mcl_chests_trapped.png"}, node.param2, false, "default_chest", "mcl_chests_chest", "chest"):reinitialize("mcl_chests:trapped_chest_on_small")
@ -889,10 +934,12 @@ register_chest("trapped_chest",
register_chest("trapped_chest_on",
nil, nil, nil, nil, traptiles, true,
{receptor = {
state = mesecon.state.on,
rules = trapped_chest_mesecons_rules,
}},
{
receptor = {
state = mesecon.state.on,
rules = trapped_chest_mesecons_rules,
},
},
nil, nil, nil,
"trapped_chest",
"trapped_chest"
@ -949,19 +996,19 @@ minetest.register_craft({
{"group:wood", "group:wood", "group:wood"},
{"group:wood", "", "group:wood"},
{"group:wood", "group:wood", "group:wood"},
}
},
})
minetest.register_craft({
type = "fuel",
recipe = "mcl_chests:chest",
burntime = 15
burntime = 15,
})
minetest.register_craft({
type = "fuel",
recipe = "mcl_chests:trapped_chest",
burntime = 15
burntime = 15,
})
minetest.register_node("mcl_chests:ender_chest", {
@ -985,17 +1032,27 @@ minetest.register_node("mcl_chests:ender_chest", {
end,
})
local formspec_ender_chest = "size[9,8.75]"..
"label[0,0;"..minetest.formspec_escape(minetest.colorize("#313131", S("Ender Chest"))).."]"..
"list[current_player;enderchest;0,0.5;9,3;]"..
mcl_formspec.get_itemslot_bg(0,0.5,9,3)..
"label[0,4.0;"..minetest.formspec_escape(minetest.colorize("#313131", S("Inventory"))).."]"..
"list[current_player;main;0,4.5;9,3;9]"..
mcl_formspec.get_itemslot_bg(0,4.5,9,3)..
"list[current_player;main;0,7.74;9,1;]"..
mcl_formspec.get_itemslot_bg(0,7.74,9,1)..
"listring[current_player;enderchest]"..
"listring[current_player;main]"
local formspec_ender_chest = table.concat({
"formspec_version[4]",
"size[11.75,10.425]",
mcl_formspec.apply_label_size,
"label[0.375,0.375;"..F(C(mcl_formspec.label_color, S("Ender Chest"))).."]",
mcl_formspec.get_itemslot_bg_v4(0.375, 0.75, 9, 3),
"list[current_player;enderchest;0.375,0.75;9,3;]",
"label[0.375,4.7;"..F(C(mcl_formspec.label_color, S("Inventory"))).."]",
mcl_formspec.get_itemslot_bg_v4(0.375, 5.1, 9, 3),
"list[current_player;main;0.375,5.1;9,3;9]",
mcl_formspec.get_itemslot_bg_v4(0.375, 9.05, 9, 1),
"list[current_player;main;0.375,9.05;9,1;]",
"listring[current_player;enderchest]",
"listring[current_player;main]",
})
minetest.register_node("mcl_chests:ender_chest_small", {
@ -1059,7 +1116,7 @@ minetest.register_craft({
{"mcl_core:obsidian", "mcl_core:obsidian", "mcl_core:obsidian"},
{"mcl_core:obsidian", "mcl_end:ender_eye", "mcl_core:obsidian"},
{"mcl_core:obsidian", "mcl_core:obsidian", "mcl_core:obsidian"},
}
},
})
-- Shulker boxes
@ -1102,21 +1159,33 @@ local shulker_mob_textures = {
}
local canonical_shulker_color = "violet"
--WARNING: after formspec v4 update, old shulker boxes will need to be placed again to get the new formspec
local function formspec_shulker_box(name)
if name == "" then
if not name or name == "" then
name = S("Shulker Box")
end
return "size[9,8.75]"..
"label[0,0;"..minetest.formspec_escape(minetest.colorize("#313131", name)).."]"..
"list[context;main;0,0.5;9,3;]"..
mcl_formspec.get_itemslot_bg(0,0.5,9,3)..
"label[0,4.0;"..minetest.formspec_escape(minetest.colorize("#313131", S("Inventory"))).."]"..
"list[current_player;main;0,4.5;9,3;9]"..
mcl_formspec.get_itemslot_bg(0,4.5,9,3)..
"list[current_player;main;0,7.74;9,1;]"..
mcl_formspec.get_itemslot_bg(0,7.74,9,1)..
"listring[context;main]"..
"listring[current_player;main]"
return table.concat({
"formspec_version[4]",
"size[11.75,10.425]",
mcl_formspec.apply_label_size,
"label[0.375,0.375;"..F(C(mcl_formspec.label_color, name)).."]",
mcl_formspec.get_itemslot_bg_v4(0.375, 0.75, 9, 3),
"list[context;main;0.375,0.75;9,3;]",
"label[0.375,4.7;"..F(C(mcl_formspec.label_color, S("Inventory"))).."]",
mcl_formspec.get_itemslot_bg_v4(0.375, 5.1, 9, 3),
"list[current_player;main;0.375,5.1;9,3;9]",
mcl_formspec.get_itemslot_bg_v4(0.375, 9.05, 9, 1),
"list[current_player;main;0.375,9.05;9,1;]",
"listring[context;main]",
"listring[current_player;main]",
})
end
local function set_shulkerbox_meta(nmeta, imeta)
@ -1227,9 +1296,9 @@ for color, desc in pairs(boxtypes) do
drop = "",
paramtype = "light",
paramtype2 = "facedir",
-- TODO: Make shulker boxes rotatable
-- This doesn't work, it just destroys the inventory:
-- on_place = minetest.rotate_node,
-- TODO: Make shulker boxes rotatable
-- This doesn't work, it just destroys the inventory:
-- on_place = minetest.rotate_node,
on_construct = function(pos)
local meta = minetest.get_meta(pos)
meta:set_string("formspec", formspec_shulker_box(nil))
@ -1315,7 +1384,7 @@ for color, desc in pairs(boxtypes) do
minetest.register_craft({
type = "shapeless",
output = "mcl_chests:"..color.."_shulker_box",
recipe = { "group:shulker_box", "mcl_dye:"..color }
recipe = {"group:shulker_box", "mcl_dye:"..color},
})
end
@ -1325,7 +1394,7 @@ minetest.register_craft({
{"mcl_mobitems:shulker_shell"},
{"mcl_chests:chest"},
{"mcl_mobitems:shulker_shell"},
}
},
})
-- Save metadata of shulker box when used in crafting
@ -1399,13 +1468,13 @@ minetest.register_lbm({
})
minetest.register_lbm({
label = "Update shulker box formspecs (0.60.0)",
name = "mcl_chests:update_shulker_box_formspecs_0_60_0",
label = "Update shulker box formspecs (0.72.0)",
name = "mcl_chests:update_shulker_box_formspecs_0_72_0",
nodenames = { "group:shulker_box" },
run_at_every_load = false,
action = function(pos, node)
local meta = minetest.get_meta(pos)
meta:set_string("formspec", formspec_shulker_box)
meta:set_string("formspec", formspec_shulker_box(meta:get_string("name")))
end,
})

View File

@ -1,19 +1,22 @@
local S = minetest.get_translator(minetest.get_current_modname())
local F = minetest.formspec_escape
local C = minetest.colorize
--[[ BEGIN OF NODE DEFINITIONS ]]
local mcl_hoppers_formspec =
"size[9,7]"..
"label[2,0;"..minetest.formspec_escape(minetest.colorize("#313131", S("Hopper"))).."]"..
"list[context;main;2,0.5;5,1;]"..
mcl_formspec.get_itemslot_bg(2,0.5,5,1)..
"label[0,2;"..minetest.formspec_escape(minetest.colorize("#313131", S("Inventory"))).."]"..
"list[current_player;main;0,2.5;9,3;9]"..
mcl_formspec.get_itemslot_bg(0,2.5,9,3)..
"list[current_player;main;0,5.74;9,1;]"..
mcl_formspec.get_itemslot_bg(0,5.74,9,1)..
"listring[context;main]"..
local mcl_hoppers_formspec = table.concat({
"size[9,7]",
"label[2,0;"..F(C(mcl_formspec.label_color, S("Hopper"))).."]",
"list[context;main;2,0.5;5,1;]",
mcl_formspec.get_itemslot_bg(2,0.5,5,1),
"label[0,2;"..F(C(mcl_formspec.label_color, S("Inventory"))).."]",
"list[current_player;main;0,2.5;9,3;9]",
mcl_formspec.get_itemslot_bg(0,2.5,9,3),
"list[current_player;main;0,5.74;9,1;]",
mcl_formspec.get_itemslot_bg(0,5.74,9,1),
"listring[context;main]",
"listring[current_player;main]"
})
-- Downwards hopper (base definition)

View File

@ -117,7 +117,7 @@ function mcl_player.player_get_preview(player)
if preview == "" then
preview = "player.png"
end
local armor_preview = player:get_meta():set_string("mcl_player:armor_preview")
local armor_preview = player:get_meta():get_string("mcl_player:armor_preview")
if armor_preview ~= "" then
preview = preview .. "^" .. armor_preview
end

View File

@ -100,6 +100,11 @@ animated_chests (Animated chests) bool true
# The maximum number of boss bars to simultaniously display on the screen
max_bossbars (Maximum Boss bars) int 5
# Define how wide font will be displayed in mineclone2 formspecs
# This allow MineClone2 to have a label size similar to minecraft, but allowing at least singleplayer to use his own font with custom size
# (some fonts may be bigger than the default one and break formspecs)
mcl_label_font_size (Label Font Size) int 24
[Experimental]
# Whether ice is translucent. If disabled, ice is fully opaque.
#