add armor specs to rainbow armor, add technic armor mod, add redef mod, add technic recycle mod

This commit is contained in:
N-Nachtigal 2025-07-26 13:07:52 +02:00
parent 00106c85c6
commit c1e648877d
138 changed files with 1321 additions and 4 deletions

21
mods/redef/LICENSE.txt Normal file
View file

@ -0,0 +1,21 @@
MIT License
Copyright (c) “Linuxdirk”
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.

86
mods/redef/README.md Normal file
View file

@ -0,0 +1,86 @@
Changes smaller things that are issues for [Minetest Game](https://github.com/minetest/minetest_game), and some well-known mods that are technically fixable but wont be fixed due to several non-technical reasons.
## Configuration
All configuration options are set to values intended by the redefinitions. For changing or disabling the values set the corresponding options to the preferred values or to the value that disables the redefinition.
The configurations can be set in the global config file used for the server, as well as in a world-specific configuration file located at `./worlds/worldname/_redef.conf`. Global settings overwrite the given defaults and world-specific settings overwrite the global settings and defaults.
### 3D Ladders
![Result](screenshots/redef_3d_ladders.png)
* setting: `redef_3d_ladders = true`
* disable: set to `false`
* fixes: [mtg2423]
* default: no 3D ladders
Redefining the 2D ladders so that they use a 3D model. No new textures are needed since he normal textures are used. Only works properly if using the 16x16 default textures or texture packs that use the same size and shape for the ladders.
### Maximum Stack Size
![Result](screenshots/redef_stack_max.png)
* setting: `redef_stack_max = 100`
* disable: set to 0
* fixes: [mtg1843], [mtg5730], [mtg1724], [mt394]
* default: stack size at 99
It changes the maximum stack size of all registered things whose stack size is 99 to the given `redef_stack_max` value. Unfortunately the maximum stack size of 99 is hardcoded in some places and cant be changed using a mod.
### Grass Box Height
![Result](screenshots/redef_grass_box_height.png)
* setting: `redef_grass_box_height = 2`
* disable: set to 0
* fixes: [mtg1980]
* default: various heights for grass selection boxes
Make grass selection box x/16 high for easy building or punching through regardless of actual height of the box.
### Aligned Textures
![Result](screenshots/redef_aligned_textures.png)
* setting: `redef_aligned_textures = true`
* disable: set to `false`
* fixes: [mtg2287], [mtg1931], [mt5222]
* default: textures not aligned for most relevant nodes
This fixes the texture orientation of stairs and slabs regardless of how they were defined to achieve a clean look. This redefinition also world-alignes moreblocks nodes that are nodeboxes (world-alignment of textures only works on nodeboxes).
### Proper Rotation
![Result](screenshots/redef_proper_rotation.png)
* setting: `redef_proper_rotation = true`
* disable: set to `false`
* fixes: [moreblocks138] for example
* default: slabs and stairs do not align properly on placement
Moreblocks re-implements all stairs and slabs for unknown reason and thus breaking their placement and auto-rotation. By enabling this, the original functionality is replicated. This also addresses weird placement of *bakedclay* mods objects.
### Show Steps (slabs and stairs)
![Result](screenshots/redef_show_steps.png)
* setting: `redef_show_steps = true`
* disable: set to `false`
* fixes: [moreblocks141] for example
* default: slabs and stairs are hidden in creative inventory
This mainly exists to prevent crashing the server when setting `moreblocks.stairsplus_in_creative_inventory = true` (see example issue). But what this does in general is removing the `not_in_creative_inventory` group from all nodes that have `stair = 1` or `slab = 1` group set. In result all stairs and slabs are shown in creative inventory.
[mtg2423]: https://github.com/minetest/minetest_game/issues/2423
[mtg1843]: https://github.com/minetest/minetest/pull/1843
[mtg5730]: https://github.com/minetest/minetest/issues/5730
[mtg1724]: https://github.com/minetest/minetest_game/issues/1724
[mt394]: https://github.com/minetest/minetest/issues/394
[mtg1980]: https://github.com/minetest/minetest_game/issues/1980
[mtg2287]: https://github.com/minetest/minetest_game/issues/2287
[mtg1931]: https://github.com/minetest/minetest_game/issues/1931
[mt5222]: https://github.com/minetest/minetest/issues/5222
[moreblocks138]: https://github.com/minetest-mods/moreblocks/issues/138
[moreblocks141]: https://github.com/minetest-mods/moreblocks/issues/141

42
mods/redef/init.lua Normal file
View file

@ -0,0 +1,42 @@
local modpath = core.get_modpath('redef')
local path = modpath..DIR_DELIM..'redefinitions'..DIR_DELIM
local worldpath = core.get_worldpath()..DIR_DELIM
-- Get aconfiguration value or return a default
--
-- This function takes an unprefixed value, automatically prefixes it and
-- tries to get the value from the global configuration or the world-specific
-- configuration. If the option is not found in any of those the given default
-- value is returned.
--
-- @param value The unprefixed option to get
-- @param default The default value in case the option is not found
-- @return mixed The value
local g = function (value, default)
local global_value = core.settings:get('redef_'..value) or default
local world_config_path = worldpath..DIR_DELIM..'_redef.conf'
local world_config = Settings(world_config_path)
local world_value = world_config:get('redef_'..value)
return world_value or global_value
end
core.register_on_mods_loaded(function()
local redefinitions = {
['3D Ladders'] = core.is_yes(g('3d_ladders', true)),
['Aligned Textures'] = core.is_yes(g('aligned_textures', true)),
['Grass Box Height'] = tonumber(g('grass_box_height', 2)) >= 1,
['Maximum Stack Size'] = tonumber(g('stack_max', 100)) >= 1,
['Proper Rotation'] = core.is_yes(g('proper_rotation', true)),
['Show Steps'] = core.is_yes(g('show_steps', true))
}
for name,use in pairs(redefinitions) do
if use == true then
dofile(path..name:lower():gsub(' ', '_')..'.lua')
core.log('info', '[redef] Applied redefinition “'..name..'')
end
end
end)

16
mods/redef/mod.conf Normal file
View file

@ -0,0 +1,16 @@
name = redef
title = Minor Redefinitions
depends = default
description = """
Changes smaller things that are issues for Minetest Game that are technically fixable but wont be fixed due to several non-technical reasons.
The following redefinitions are applied by default:
* 3D Ladders (only works with default ladder texture shape)
* Maximum stack size set to 100
* Grass selection box height set to 2
* World-aligned textures for all stairs and slabs
* Properly rotate nodes from some well-known mods
"""
release = 28636
author = Linuxdirk

View file

@ -0,0 +1,31 @@
local ladders = {
{'ladder_wood', 'default_ladder_wood.png', 'default_wood.png'},
{'ladder_steel', 'default_ladder_steel.png', 'default_steel_block.png'}
}
for l,def in pairs(ladders) do
core.override_item('default:'..def[1], {
tiles = { def[2], def[2], def[3], def[3], def[3], def[3] },
use_texture_alpha = 'clip',
drawtype = 'nodebox',
paramtype = 'light',
node_box = {
type = 'fixed',
fixed = {
{-0.375, -0.5, -0.5, -0.25, -0.375, 0.5}, -- strut_1
{0.25, -0.5, -0.5, 0.375, -0.375, 0.5}, -- strut_2
{-0.4375, -0.5, 0.3125, 0.4375, -0.375, 0.4375}, -- rung_1
{-0.4375, -0.5, 0.0625, 0.4375, -0.375, 0.1875}, -- rung_2
{-0.4375, -0.5, -0.1875, 0.4375, -0.375, -0.0625}, -- rung_3
{-0.4375, -0.5, -0.4375, 0.4375, -0.375, -0.3125} -- rung_4
}
},
selection_box = {
type = 'wallmounted',
wall_top = {-0.4375, 0.375, -0.5, 0.4375, 0.5, 0.5},
wall_side = {-0.5, -0.5, -0.4375, -0.375, 0.5, 0.4375},
wall_bottom = {-0.4375, -0.5, -0.5, 0.4375, -0.375, 0.5}
}
})
end

View file

@ -0,0 +1,29 @@
for id,definition in pairs(core.registered_nodes) do
local groups = definition.groups
local origin = definition.mod_origin
local circular_saw = id == 'moreblocks:circular_saw'
local stair_or_slab = groups.stair or groups.slab
local moreblocks_object = origin == 'moreblocks' and not circular_saw
if stair_or_slab or moreblocks_object then
local tiles = definition.tiles
local target_tiles = {}
for index,_ in pairs(tiles) do
if type(tiles[index]) == 'table' then
tiles[index].align_style = 'world'
target_tiles[index] = tiles[index]
else
target_tiles[index] = {
name = tiles[index],
align_style = 'world'
}
end
end
core.override_item(id, {
tiles = target_tiles
})
end
end

View file

@ -0,0 +1,37 @@
local height = core.settings:get('redef_grass_box_height') or '2'
local target = -0.5 + (tonumber(height) * 0.0625)
local grass_nodes = {
'default:junglegrass',
'default:dry_grass_1',
'default:dry_grass_2',
'default:dry_grass_3',
'default:dry_grass_4',
'default:dry_grass_5',
'default:grass_1',
'default:grass_2',
'default:grass_3',
'default:grass_4',
'default:grass_5',
}
for _,grass in pairs(grass_nodes) do
local current_box = core.registered_nodes[grass].selection_box.fixed
if (current_box[5] > target) then
core.override_item(grass, {
selection_box = {
type = 'fixed',
fixed = {
current_box[1],
current_box[2],
current_box[3],
current_box[4],
target,
current_box[6]
}
}
})
end
end

View file

@ -0,0 +1,24 @@
local _stack_max = tonumber(core.settings:get('redef_stack_max') or 100)
local all_objects = {}
-- Get the things that have to be altered.
for w,what in pairs({'items', 'nodes', 'craftitems', 'tools'}) do
for name,definition in pairs(core['registered_'..what]) do
if definition.stack_max == 99 then
table.insert(all_objects, name)
end
end
end
-- Set stack size to the given value.
for _,name in pairs(all_objects) do
core.override_item(name, {
stack_max = _stack_max
})
end
-- Set Luanti default values in case mods or something within the engine
-- will use them after the above code ran.
core.craftitemdef_default.stack_max = _stack_max
core.nodedef_default.stack_max = _stack_max
core.noneitemdef_default.stack_max = _stack_max

View file

@ -0,0 +1,150 @@
local override_item = core.override_item
local pointed_thing_to_face_pos = core.pointed_thing_to_face_pos
local dir_to_facedir = core.dir_to_facedir
local is_creative_enabled = core.is_creative_enabled
local item_place_node = core.item_place_node
local stairs = {}
local slabs = {}
local slopes = {}
-- Correct stairs placement
--
-- Derived from the original stairs on_place function of Minetest Game.
--
-- @param itemstack An itemstack according to Luanti API
-- @param placer A placer object according to Luanti API
-- @param pointed_thing A pointed_thing according to Luanti API
-- @return mixed itemstack and position according to Luanti API
local properly_rotate = function (itemstack, placer, pointed_thing)
local under = pointed_thing.under
local above = pointed_thing.above
local param2 = 0
if placer then
local placer_pos = placer:get_pos()
local finepos = pointed_thing_to_face_pos(placer, pointed_thing)
local fpos = finepos.y % 1
local under_above = under.y - 1 == above.y
local fpos_perimeter = (fpos > 0 and fpos < 0.5)
local fpos_limit = (fpos < -0.5 and fpos > -0.999999999)
if placer_pos then
param2 = dir_to_facedir(vector.subtract(above, placer_pos))
end
if under_above or fpos_perimeter or fpos_limit then
param2 = param2 + 20
if param2 == 21 then
param2 = 23
elseif param2 == 23 then
param2 = 21
end
end
end
return core.item_place(itemstack, placer, pointed_thing, param2)
end
-- Correct slabs placement
--
-- Derived from the original stairs on_place function of Minetest Game.
--
-- @param itemstack An itemstack according to LuantI API
-- @param placer A placer object according to Luanti API
-- @param pointed_thing A pointed_thing according to Luanti API
-- @return mixed itemstack and position according to Luanti API
local on_place_slabs = function (itemstack, placer, pointed_thing)
local under = core.get_node(pointed_thing.under)
local wield_item = itemstack:get_name()
local player_name = placer and placer:get_player_name() or ''
-- Special behavior if placed on a slab
if under and under.name:find(':slab_') then
local pt_above = pointed_thing.above
local pt_under = pointed_thing.under
local fdir = dir_to_facedir(vector.subtract(pt_above, pt_under), true)
local p2 = under.param2
-- Slab placement based on upside-down slabs or below slabs
--
-- ┌────────┐
-- │ │
-- ┢━━━━━━━━┪ <-- Slab A (bottom half of the node seen sideways)
-- ┃ ┃
-- ┈┈┈┈┣━━━━━━━━┫┈┈┈┈
-- ┃ ┃
-- ┡━━━━━━━━┩ <-- Slab B (top half of the node, seen sideways)
-- │ │
-- └────────┘
--
-- Slabs A and B are rotated according slab B or A on placement so that
-- slabs placed on regular slabs from below automatically become
-- upside-down slabs and slabs placed on top of upside-down slabs are
-- not rotated into the same position.
if p2 >= 20 and fdir == 8 then p2 = p2 - 20 end -- Slab A rotation
if p2 <= 3 and fdir == 4 then p2 = p2 + 20 end -- Slab B rotation
-- Place node usind the calculated rotation
item_place_node(ItemStack(wield_item), placer, pointed_thing, p2)
-- Remove one item if not in creative and return the itemstack
if not is_creative_enabled(player_name) then itemstack:take_item() end
return itemstack
end
-- When not placed on a slab just properly rotate the slab
return properly_rotate(itemstack, placer, pointed_thing)
end
-- Determine all stairs and slabs and put them into the respective tables.
for name,definition in pairs(core.registered_nodes) do
local from_moreblocks = definition.mod_origin == 'moreblocks'
local from_bakedclay = definition.mod_origin == 'bakedclay'
local mod_origin = from_moreblocks or from_bakedclay
local stair = string.match(name, ':stair_') ~= nil
local slab = string.match(name, ':slab_') ~= nil
local slope = string.match(name, ':slope_') ~= nil
if stair and mod_origin then table.insert(stairs, name) end
if slab and mod_origin then table.insert(slabs, name) end
if slope and mod_origin then table.insert(slopes, name) end
end
-- Iterate over all stairs and override the broken on_place function.
for _,name in pairs(stairs) do
override_item(name, {
on_place = function (itemstack, placer, pointed_thing)
if pointed_thing.type ~= "node" then return itemstack end
return properly_rotate(itemstack, placer, pointed_thing)
end
})
end
-- Iterate over all slopes and override the broken on_place function.
for _,name in pairs(slopes) do
override_item(name, {
on_place = function (itemstack, placer, pointed_thing)
if pointed_thing.type ~= "node" then return itemstack end
return properly_rotate(itemstack, placer, pointed_thing)
end
})
end
-- Iterate over all slabs and override the broken on_place function.
for _,name in pairs(slabs) do
override_item(name, {
on_place = function (itemstack, placer, pointed_thing)
return on_place_slabs(itemstack, placer, pointed_thing)
end
})
end

View file

@ -0,0 +1,23 @@
local override_item = core.override_item
local registered_nodes = table.copy(core.registered_nodes)
local relevant_nodes = {}
-- Determine all stairs and slabs by their respective groups and add them to
-- the table of nodes to handle.
for name,definition in pairs(registered_nodes) do
local groups = definition.groups or {}
local relevant = ((groups.stair == 1) or (groups.slab == 1))
if relevant then
table.insert(relevant_nodes, name)
end
end
-- Iterate over all stairs and slabs and remove the not_in_creative_inventory
-- group to show them in the creative inventory again.
for _,name in pairs(relevant_nodes) do
local groups = registered_nodes[name].groups
groups.not_in_creative_inventory = nil
override_item(name, { groups = groups })
end

BIN
mods/redef/screenshot.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 286 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 231 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 121 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 97 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 101 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

View file

@ -0,0 +1,62 @@
# This will render ladders in 3D using a nodebox.
#
# Please note that this will only work properly when
# using the default textures or when the texture pack
# uses the same shape of ladders than the default
# texture pack!
#
# Fixes https://github.com/minetest/minetest/issues/2423
redef_3d_ladders (Render ladders in 3D) bool true
# Alter the maximum stack size.
#
# By default Minetest Game uses an arbitrary set max
# stack size of 99. When setting this value to any
# value the STACK_MAX size will be changed to that
# value in most places.
#
# Please note that 99 is hardcoded on some places and
# still will be 99 even if set different here.
#
# Fixes https://forum.minetest.net/viewtopic.php?t=16817
redef_stack_max (Maximum stack size) int 100
# Set the grass selection box to a lower height.
#
# Grass nodeboxes might be too high. This can disturb
# Building or punching mobs or other players. This
# Setting allows to reduce the selection boxes of
# all grass types to the given value. Set to 0 to
# leave the selection box unaltered.
#
# If a selection box is smaller than the given value
# it remains unaltered.
#
# Fixes https://github.com/minetest/minetest_game/issues/1980
redef_grass_box_height (Grass selection box height x/16) int 2
# World-aligned textures for stairs, slabs, etc.
#
# By default the most critical nodes are not
# properly aligned. This fixes it.
#
# Fixes:
#
# https://github.com/minetest/minetest_game/issues/2287
# https://github.com/minetest/minetest_game/issues/1931
# https://github.com/minetest/minetest/issues/5222
redef_aligned_textures (Use world-aligned textures) bool true
# Proper rotation of shaped nodes
#
# Grass nodeboxes might be too high. This can disturb
# The moreblocks (for example) introduces a custom, not
# properly working rotation mechanism. This redefinition
# fixes that and replaces it with a mechanism that is
# derived from the one that is used by “Minetest Game”.
#
# Fixes:
#
# https://github.com/minetest-mods/moreblocks/issues/138
redef_proper_rotation (Properly rotate shaped nodes) bool true

Binary file not shown.

Binary file not shown.

Binary file not shown.