From 91f7b244f6afd60dbc80ec75e2ac301d94cb2b5c Mon Sep 17 00:00:00 2001 From: kakalak-lumberJack Date: Wed, 21 Feb 2018 10:55:33 -0500 Subject: [PATCH] made modpack: creative mod from 0.5.0 added for 0.4.16 support --- creative/README.txt | 17 ++ creative/depends.txt | 2 + creative/init.lua | 70 ++++++++ creative/inventory.lua | 193 +++++++++++++++++++++ creative/license.txt | 61 +++++++ creative/textures/creative_clear_icon.png | Bin 0 -> 708 bytes creative/textures/creative_next_icon.png | Bin 0 -> 728 bytes creative/textures/creative_prev_icon.png | Bin 0 -> 729 bytes creative/textures/creative_search_icon.png | Bin 0 -> 1908 bytes creative/textures/creative_trash_icon.png | Bin 0 -> 712 bytes README.md => creative_areas/README.md | 0 TODO.md => creative_areas/TODO.md | 0 depends.txt => creative_areas/depends.txt | 0 init.lua => creative_areas/init.lua | 4 +- mod.conf | 1 - modpack.txt | 0 16 files changed, 345 insertions(+), 3 deletions(-) create mode 100644 creative/README.txt create mode 100644 creative/depends.txt create mode 100644 creative/init.lua create mode 100644 creative/inventory.lua create mode 100644 creative/license.txt create mode 100644 creative/textures/creative_clear_icon.png create mode 100644 creative/textures/creative_next_icon.png create mode 100644 creative/textures/creative_prev_icon.png create mode 100644 creative/textures/creative_search_icon.png create mode 100644 creative/textures/creative_trash_icon.png rename README.md => creative_areas/README.md (100%) rename TODO.md => creative_areas/TODO.md (100%) rename depends.txt => creative_areas/depends.txt (100%) rename init.lua => creative_areas/init.lua (98%) delete mode 100644 mod.conf create mode 100644 modpack.txt diff --git a/creative/README.txt b/creative/README.txt new file mode 100644 index 0000000..32e8d22 --- /dev/null +++ b/creative/README.txt @@ -0,0 +1,17 @@ +Minetest Game mod: creative +=========================== +See license.txt for license information. + +Authors of source code +---------------------- +Originally by Perttu Ahola (celeron55) (MIT) +Jean-Patrick G. (kilbith) (MIT) + +Author of media (textures) +-------------------------- +paramat (CC BY-SA 3.0): +* creative_prev_icon.png +* creative_next_icon.png +* creative_search_icon.png +* creative_clear_icon.png +* creative_trash_icon.png derived from a texture by kilbith (CC BY-SA 3.0) diff --git a/creative/depends.txt b/creative/depends.txt new file mode 100644 index 0000000..975e652 --- /dev/null +++ b/creative/depends.txt @@ -0,0 +1,2 @@ +default +sfinv diff --git a/creative/init.lua b/creative/init.lua new file mode 100644 index 0000000..ef190b8 --- /dev/null +++ b/creative/init.lua @@ -0,0 +1,70 @@ +creative = {} + +minetest.register_privilege("creative", { + description = "Allow player to use creative inventory", + give_to_singleplayer = false, + give_to_admin = false +}) + +local creative_mode_cache = minetest.settings:get_bool("creative_mode") + +function creative.is_enabled_for(name) + return creative_mode_cache or + minetest.check_player_privs(name, {creative = true}) +end + +dofile(minetest.get_modpath("creative") .. "/inventory.lua") + +if creative_mode_cache then + -- Dig time is modified according to difference (leveldiff) between tool + -- 'maxlevel' and node 'level'. Digtime is divided by the larger of + -- leveldiff and 1. + -- To speed up digging in creative, hand 'maxlevel' and 'digtime' have been + -- increased such that nodes of differing levels have an insignificant + -- effect on digtime. + local digtime = 42 + local caps = {times = {digtime, digtime, digtime}, uses = 0, maxlevel = 256} + + minetest.register_item(":", { + type = "none", + wield_image = "wieldhand.png", + wield_scale = {x = 1, y = 1, z = 2.5}, + range = 10, + tool_capabilities = { + full_punch_interval = 0.5, + max_drop_level = 3, + groupcaps = { + crumbly = caps, + cracky = caps, + snappy = caps, + choppy = caps, + oddly_breakable_by_hand = caps, + }, + damage_groups = {fleshy = 10}, + } + }) +end + +-- Unlimited node placement +minetest.register_on_placenode(function(pos, newnode, placer, oldnode, itemstack) + if placer and placer:is_player() then + return creative.is_enabled_for(placer:get_player_name()) + end +end) + +-- Don't pick up if the item is already in the inventory +local old_handle_node_drops = minetest.handle_node_drops +function minetest.handle_node_drops(pos, drops, digger) + if not digger or not digger:is_player() or + not creative.is_enabled_for(digger:get_player_name()) then + return old_handle_node_drops(pos, drops, digger) + end + local inv = digger:get_inventory() + if inv then + for _, item in ipairs(drops) do + if not inv:contains_item("main", item, true) then + inv:add_item("main", item) + end + end + end +end diff --git a/creative/inventory.lua b/creative/inventory.lua new file mode 100644 index 0000000..79a8529 --- /dev/null +++ b/creative/inventory.lua @@ -0,0 +1,193 @@ +local player_inventory = {} +local inventory_cache = {} + +local function init_creative_cache(items) + inventory_cache[items] = {} + local i_cache = inventory_cache[items] + + for name, def in pairs(items) do + if def.groups.not_in_creative_inventory ~= 1 and + def.description and def.description ~= "" then + i_cache[name] = def + end + end + table.sort(i_cache) + return i_cache +end + +function creative.init_creative_inventory(player) + local player_name = player:get_player_name() + player_inventory[player_name] = { + size = 0, + filter = "", + start_i = 0 + } + + minetest.create_detached_inventory("creative_" .. player_name, { + allow_move = function(inv, from_list, from_index, to_list, to_index, count, player2) + local name = player2 and player2:get_player_name() or "" + if not creative.is_enabled_for(name) or + to_list == "main" then + return 0 + end + return count + end, + allow_put = function(inv, listname, index, stack, player2) + return 0 + end, + allow_take = function(inv, listname, index, stack, player2) + local name = player2 and player2:get_player_name() or "" + if not creative.is_enabled_for(name) then + return 0 + end + return -1 + end, + on_move = function(inv, from_list, from_index, to_list, to_index, count, player2) + end, + on_take = function(inv, listname, index, stack, player2) + if stack and stack:get_count() > 0 then + minetest.log("action", player_name .. " takes " .. stack:get_name().. " from creative inventory") + end + end, + }, player_name) + + return player_inventory[player_name] +end + +function creative.update_creative_inventory(player_name, tab_content) + local creative_list = {} + local inv = player_inventory[player_name] or + creative.init_creative_inventory(minetest.get_player_by_name(player_name)) + local player_inv = minetest.get_inventory({type = "detached", name = "creative_" .. player_name}) + + local items = inventory_cache[tab_content] or init_creative_cache(tab_content) + + for name, def in pairs(items) do + if def.name:find(inv.filter, 1, true) or + def.description:lower():find(inv.filter, 1, true) then + creative_list[#creative_list+1] = name + end + end + + table.sort(creative_list) + player_inv:set_size("main", #creative_list) + player_inv:set_list("main", creative_list) + inv.size = #creative_list +end + +-- Create the trash field +local trash = minetest.create_detached_inventory("creative_trash", { + -- Allow the stack to be placed and remove it in on_put() + -- This allows the creative inventory to restore the stack + allow_put = function(inv, listname, index, stack, player) + return stack:get_count() + end, + on_put = function(inv, listname) + inv:set_list(listname, {}) + end, +}) +trash:set_size("main", 1) + +creative.formspec_add = "" + +function creative.register_tab(name, title, items) + sfinv.register_page("creative:" .. name, { + title = title, + is_in_nav = function(self, player, context) + return creative.is_enabled_for(player:get_player_name()) + end, + get = function(self, player, context) + local player_name = player:get_player_name() + creative.update_creative_inventory(player_name, items) + local inv = player_inventory[player_name] + local start_i = inv.start_i or 0 + local pagenum = math.floor(start_i / (3*8) + 1) + local pagemax = math.ceil(inv.size / (3*8)) + return sfinv.make_formspec(player, context, + "label[6.2,3.35;" .. minetest.colorize("#FFFF00", tostring(pagenum)) .. " / " .. tostring(pagemax) .. "]" .. + [[ + image[4.06,3.4;0.8,0.8;creative_trash_icon.png] + listcolors[#00000069;#5A5A5A;#141318;#30434C;#FFF] + list[current_player;main;0,4.7;8,1;] + list[current_player;main;0,5.85;8,3;8] + list[detached:creative_trash;main;4,3.3;1,1;] + listring[] + image_button[5.4,3.25;0.8,0.8;creative_prev_icon.png;creative_prev;] + image_button[7.2,3.25;0.8,0.8;creative_next_icon.png;creative_next;] + image_button[2.1,3.25;0.8,0.8;creative_search_icon.png;creative_search;] + image_button[2.75,3.25;0.8,0.8;creative_clear_icon.png;creative_clear;] + tooltip[creative_search;Search] + tooltip[creative_clear;Reset] + tooltip[creative_prev;Previous page] + tooltip[creative_next;Next page] + listring[current_player;main] + field_close_on_enter[creative_filter;false] + ]] .. + "field[0.3,3.5;2.2,1;creative_filter;;" .. minetest.formspec_escape(inv.filter) .. "]" .. + "listring[detached:creative_" .. player_name .. ";main]" .. + "list[detached:creative_" .. player_name .. ";main;0,0;8,3;" .. tostring(start_i) .. "]" .. + default.get_hotbar_bg(0,4.7) .. + default.gui_bg .. default.gui_bg_img .. default.gui_slots + .. creative.formspec_add, false) + end, + on_enter = function(self, player, context) + local player_name = player:get_player_name() + local inv = player_inventory[player_name] + if inv then + inv.start_i = 0 + end + end, + on_player_receive_fields = function(self, player, context, fields) + local player_name = player:get_player_name() + local inv = player_inventory[player_name] + assert(inv) + + if fields.creative_clear then + inv.start_i = 0 + inv.filter = "" + creative.update_creative_inventory(player_name, items) + sfinv.set_player_inventory_formspec(player, context) + elseif fields.creative_search or + fields.key_enter_field == "creative_filter" then + inv.start_i = 0 + inv.filter = fields.creative_filter:lower() + creative.update_creative_inventory(player_name, items) + sfinv.set_player_inventory_formspec(player, context) + elseif not fields.quit then + local start_i = inv.start_i or 0 + + if fields.creative_prev then + start_i = start_i - 3*8 + if start_i < 0 then + start_i = inv.size - (inv.size % (3*8)) + if inv.size == start_i then + start_i = math.max(0, inv.size - (3*8)) + end + end + elseif fields.creative_next then + start_i = start_i + 3*8 + if start_i >= inv.size then + start_i = 0 + end + end + + inv.start_i = start_i + sfinv.set_player_inventory_formspec(player, context) + end + end + }) +end + +creative.register_tab("all", "All", minetest.registered_items) +creative.register_tab("nodes", "Nodes", minetest.registered_nodes) +creative.register_tab("tools", "Tools", minetest.registered_tools) +creative.register_tab("craftitems", "Items", minetest.registered_craftitems) + +local old_homepage_name = sfinv.get_homepage_name +function sfinv.get_homepage_name(player) + if creative.is_enabled_for(player:get_player_name()) then + return "creative:all" + else + return old_homepage_name(player) + end +end diff --git a/creative/license.txt b/creative/license.txt new file mode 100644 index 0000000..50ff9c7 --- /dev/null +++ b/creative/license.txt @@ -0,0 +1,61 @@ +License of source code +---------------------- + +The MIT License (MIT) +Copyright (C) 2012-2016 Perttu Ahola (celeron55) +Copyright (C) 2015-2016 Jean-Patrick G. (kilbith) + +Permission is hereby granted, free of charge, to any person obtaining a copy of this +software and associated documentation files (the "Software"), to deal in the Software +without restriction, including without limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of the Software, and to permit +persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or +substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE +FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. + +For more details: +https://opensource.org/licenses/MIT + + +Licenses of media (textures) +---------------------------- + +Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0) +Copyright (C) 2016 Jean-Patrick G. (kilbith) +Copyright (C) 2018 paramat + +You are free to: +Share — copy and redistribute the material in any medium or format. +Adapt — remix, transform, and build upon the material for any purpose, even commercially. +The licensor cannot revoke these freedoms as long as you follow the license terms. + +Under the following terms: + +Attribution — You must give appropriate credit, provide a link to the license, and +indicate if changes were made. You may do so in any reasonable manner, but not in any way +that suggests the licensor endorses you or your use. + +ShareAlike — If you remix, transform, or build upon the material, you must distribute +your contributions under the same license as the original. + +No additional restrictions — You may not apply legal terms or technological measures that +legally restrict others from doing anything the license permits. + +Notices: + +You do not have to comply with the license for elements of the material in the public +domain or where your use is permitted by an applicable exception or limitation. +No warranties are given. The license may not give you all of the permissions necessary +for your intended use. For example, other rights such as publicity, privacy, or moral +rights may limit how you use the material. + +For more details: +http://creativecommons.org/licenses/by-sa/3.0/ diff --git a/creative/textures/creative_clear_icon.png b/creative/textures/creative_clear_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..9244264adcf8a710ff13a2d684f148f997f1522f GIT binary patch literal 708 zcmeAS@N?(olHy`uVBq!ia0vp^4Is?H1|$#LC7xzrVCwdCaSW-r_4ck|p0J|`+k@?8 z)4T38Ghetp_qK?~6E??3JeK}D7|j>(if@>5FNQ(xtQ%9xq#I|>oJ-rk-tWo9fB*MH zp5A261T+u{c%448b?emavpj!@3x2dSE|*=GYrgL7A+xn2b!l~{&a|J|bNs}_tEEWpk`5!2*`a}1RyVnJUKYCsTDmAJZ691N{Rw#iPDykKZKfD4SDBXYZavSfp zt(M8LUICfU&F8YHzp0s=(DY%oUz2h9J|Q20x{sb8K$MJ(p@+4@qz<4 z!kg0dK3Eysi%9);Rd;NiTfc_o`reublauX^hYkL8bi5ZVT=BywU-{9yDV`H%&hFSD z{eSy3XBU}c*&BW+C(O>xi5IGCE-m?*7^bhf!nSDs-Ve5G964XH7nBIy_{nX@*CKED zC9J9A$E62L@3|g1-|-{rXX!rIBX13O=8G=aFLdP6;d1{6XTq5t?lu(JC&Y2TP@!hB z!wW0ribzTW? zv>WHHXDQnUw9_l$Ihb?k|95ulYSoBmH}=bWKa)PledlLA%OVzTzIe`-^(=?Nn=}vK z|5|oXdfI~7>hssAan;KT<|{qg^yu`QKY#yx%+Ejmf9+EvCB5Qf=OwiwTl#JLZgovQ z!0-C6bfNb@zk-X!W`9H8=%_c!chCE&^5PxeZU@em`wuKW9OwuSX$khe@MP~-NmYTm zX3qx;1G)7Yj~~>EaktaqI1!y?MfpA`TCY z(>7Xrv21cZ%&p)es8PXjPgJF%k;PKT<4S-^gqo<(T*H$AZ*+7fE>+<>d&YLY$kXM; z=ia>edS1_Cl8Pq=%G6)^jeSD#K4zcO>z`{bou9UM-nz!)1@bePjT7b;$1R;=wruaM zC5^{7Fz_{mAK-ovc#~J;!HIef8^*Y4tp>Wwn}y38zCAwQP<`O>r(*U$THFu3ye^0?Pjk z*mb-r{232E>K8xo`Jz(9F6JX0_I9i#PygKC$$X@SKQ@;uDmRnJz#wC{4f?(cga zu20UYXRv&3`L|av?Mwc}bv*Lw|EBCOKXT(**~~3ik`6F2t>oIzc>Ce(H7ZX_R{~Qk NgQu&X%Q~loCICs?Scw1t literal 0 HcmV?d00001 diff --git a/creative/textures/creative_prev_icon.png b/creative/textures/creative_prev_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..4fa6f26f02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TP&C zcdY$f=J{hbR^H#JQa?PKHouPy0s)EE-W+MDc;Xz%zs`T$`R%Yt?QXQVAN^tty#4`5(6Lbv2~siR@4 z@`h)pegmd;G66wTd;1v6$`5#mabMDZA>){oRw~(J+i2oaY0;7FQaR<-xTRoy>!JU5 oz)Hy+PJ7*y{67!tO!d0_mw-1lpr~N2?{5lnuywWJ5y{E_0lF-AYXATM literal 0 HcmV?d00001 diff --git a/creative/textures/creative_trash_icon.png b/creative/textures/creative_trash_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..7d7a0a62f36472ffcc08cd07422d1c5e17e45e3b GIT binary patch literal 712 zcmeAS@N?(olHy`uVBq!ia0vp^4Is?H1|$#LC7xzrVCwgDaSW-r_4e+?-dhe5trxww zq*naqXuWX$%VVcGb_I&R1tv_`WU!j2d1GzgmQ#n_%r@D(8r!SMY)V`@C3wbkp`zrO9YquH$qXGj<1H+Alhfi&G|FJ(}SLs?`@OU z=Ko=Q^1aIOQ@pdR=KhzuvG=pT`FdxDxp@Z+zq8vWPg;3>!84VT2}&@z?=%LBL9Hq~$8|9AiV@%4Xy%;s14dR}%* zon77A&m;qutR!##$3==^`3{2oa1xFUptOVYBf1?jSv-y|x zQ#1GeuC3o5=i4=WKHIvdyz#uX-M?+jJ8Bj`d-DSr7ho$7bd@n~t^F`3MPuolJ6-v_ z)3Z&!%~Jltw_qE;+@zXk@59#=*ZUcKouw=zcJKN8Nip?5uFpu(S=s~FpY@DkZE@4y u*Z=k$xWstn8Ot*UZhL(O28IL6Y8X5J>