Compare commits

...

96 Commits

Author SHA1 Message Date
b7e0c40fb3
Merge branch 'feature/kattarmor' 2024-11-29 02:23:20 -05:00
83307387ae
Minor reorganizing 2024-11-29 02:22:43 -05:00
a2b23f3d03
Update TODO.md 2024-11-29 02:20:18 -05:00
0251fe4391
Add tail boot trims 2024-11-29 02:20:18 -05:00
ebf40878ce
Change tail boot UV 2024-11-29 02:20:17 -05:00
f429b83bc4
KattArmor: add chestplate, fix code 2024-11-29 02:20:17 -05:00
9e914039bf
Adjust tail movement amplitude
This helps prevent armor clipping
2024-11-29 02:20:17 -05:00
9f4f7c9882
Switch tail UV mappings to vanilla armor 2024-11-29 02:20:17 -05:00
fca93572ce
(wip) setup armor visibility rules 2024-11-29 02:20:17 -05:00
5d055c0ea6
(wip) script, bbmodel
- Imported textures into bbmodel
- minor script changes
2024-11-29 02:18:29 -05:00
048bd9cec3
Update TODO.md 2024-11-29 02:18:19 -05:00
0de5c72900
Normalize .bbmodel 2024-11-28 03:13:25 -05:00
607af0d166
Add information/reference for KattArmor UVs 2024-11-28 03:10:24 -05:00
41cfa6ab32
Add and import KattArmor 2024-11-28 00:51:22 -05:00
d93c689a93
Reinstall Figura documentation 2024-11-27 19:59:44 -05:00
a19683b439
Update Figura docs submodule 2024-11-27 19:59:34 -05:00
09d045ff8b
Move Figura docs 2024-11-27 19:59:23 -05:00
43e4d45364
fix tail ParentType pivot 2024-07-19 14:29:13 -04:00
247ddcb8d5
Update Blockbench format 2023-11-09 20:07:57 -05:00
5c314f3f8a
Make paperdoll always visible when mermaid tail is 2023-10-22 14:00:35 -04:00
2ea036680d
Fix amplitude multiplier for mermaid tail 2023-10-21 04:39:29 -04:00
e50074c916
Add overrides to mermaid tail animation 2023-10-21 04:39:06 -04:00
31253ccc85
Curve mermaid tail if needed to prevent clipping 2023-10-21 04:28:27 -04:00
fc20da305c
Revert "Change angle of mermaid tail when sitting"
This reverts commit cbc79e9d9481600b89494fc5d26d036c8205033e.
2023-10-21 02:50:08 -04:00
4a671d8f21
Add curve to mermaid tail dependant on seat 2023-10-21 02:48:28 -04:00
16f2464144
Make mermaid tail move less when seated 2023-10-21 02:38:22 -04:00
cbc79e9d94
Change angle of mermaid tail when sitting 2023-10-21 02:37:07 -04:00
c0df299c84
Add pose for seated underwater to mermaid tail 2023-10-20 19:02:39 -04:00
165e052d0c
Rename a vague variable 2023-10-20 18:38:54 -04:00
19bfb41a0a
Fix nil index error in purr sound function 2023-10-19 16:51:54 -04:00
c400a17b88
Ignore nulllib.logging if missing 2023-07-02 02:28:37 -04:00
15d5d78b88
Update nulllib 2023-07-02 02:26:33 -04:00
3789b2b3a2
gay idiot detector: handle player disappear 2023-07-01 13:05:28 -04:00
4f390aaa94
Add callback for armor config change 2023-07-01 13:05:14 -04:00
39d1b95307
Shorten wiper blade 2023-07-01 01:21:55 -04:00
7bdebf2506
Add code for wiper animation 2023-07-01 01:12:15 -04:00
2174a86ae7
Fix wiper animation 2023-07-01 01:12:11 -04:00
902f41239d
avoid hardcoding model name 2023-07-01 01:11:08 -04:00
14cb566681
Remove embedded textures from model, don't minify 2023-06-30 22:47:37 -04:00
229d3bfadd
Add wiper object and animation to model 2023-06-30 20:29:34 -04:00
4790caffa5
Fix white emissives 2023-06-28 01:55:25 -04:00
eb6c6f1fe2
add gay detector uwu 2023-06-28 01:44:13 -04:00
a8b2b841f8
use world.getTime() instead of getTimeOfDay()
getTimeOfDay() breaks if doDaylightCycle is false (i.e. testing world)
2023-06-28 01:43:19 -04:00
da20d7517b
Update nulllib 2023-06-28 01:35:32 -04:00
658f197051
Rearrange optimized checks 2023-06-28 00:56:58 -04:00
35401336d2
Prevent meowing when using commands 2023-06-28 00:56:02 -04:00
56a46ae567
Rewrite purring to be usable outside of snore 2023-06-28 00:55:26 -04:00
74506315b5
remove comment 2023-06-27 23:45:29 -04:00
36ab666e50
add kitty sounds to some events :3
- hurt
- chat (meow)
2023-06-27 23:43:20 -04:00
61bd9a30fb
Update comments 2023-06-27 23:01:38 -04:00
ae6a6db247
Move sound_settings function to global scope 2023-06-27 23:01:20 -04:00
e5162146af
Update nulllib 2023-06-27 00:07:01 -04:00
c2328e6493
Update nulllib 2023-06-26 15:44:41 -04:00
8b0fca18cf
Fix pmRefresh spam from tail check 2023-06-26 15:39:30 -04:00
a36bad8b3f
Remove deprecated armor_model usage 2023-06-26 14:22:53 -04:00
2a1d6adf3e
Rename deprecated PartsManager calls 2023-06-26 14:17:13 -04:00
f04ee0a829
Update nulllib 2023-06-26 14:10:57 -04:00
48892c5700
Re-enable snoring 2023-06-26 02:14:47 -04:00
779c71b281
Update nulllib 2023-06-25 23:15:45 -04:00
26edd3c2da
Update TODO.md
I actually fixed so much stuff on here holy shit
2023-06-25 02:21:04 -04:00
408f83242b
Add convenience functions for /figura run 2023-06-25 02:00:48 -04:00
db47bec57e
Remove deprecated functions
thank fuck it is over
2023-06-25 01:59:55 -04:00
8abdc839be
Stop using deprecated code 2023-06-25 01:49:29 -04:00
02cd7e6ea1
Update nulllib 2023-06-25 01:49:21 -04:00
09adab0b35
Update nulllib 2023-06-24 23:35:21 -04:00
7ae278bee2
Update nulllib 2023-06-23 16:45:55 -04:00
bcceb0d2d2
Update nulllib 2023-06-23 02:38:34 -04:00
fdc744f5b3
Add sharedconfig and deprecate more stuff 2023-06-23 02:25:23 -04:00
705c42c287
Update nulllib 2023-06-23 01:52:02 -04:00
c4d582ce0f
Comment out unused armor block 2023-06-23 01:49:04 -04:00
36adf3a7f0
Get rid of a lot of warnings, add deprecations 2023-06-23 01:48:41 -04:00
a5dfb68598
Update nulllib and fix UVManager to reflect change 2023-06-23 01:10:42 -04:00
5b13f3b4c9
require nulllib.sharedstate 2023-06-22 20:27:13 -04:00
278d456a26
Update nulllib
- Add sharedstate
2023-06-22 19:38:30 -04:00
e982583c94
Add Lua LSP docs for Figura
https://github.com/GrandpaScout/FiguraRewriteVSDocs
2023-06-22 13:43:51 -04:00
c5b46bbbfc
Update TODO.md 2023-06-22 02:44:37 -04:00
7697a6d387
comment 2023-06-22 02:42:57 -04:00
964c6ec8cb
Update nulllib 2023-06-22 02:42:57 -04:00
7f3b96c5d4
Update TODO.md
- add very ambitious plans to rewrite state syncing
- move partial_vanilla to unplanned section
2023-06-22 02:42:57 -04:00
7c874e16fe
Add luarc so autocompletions work 2023-06-22 00:31:09 -04:00
394f161604
Merge branch 'feature/library_split'
This splits off most reusable code snippets into a separate libraries
submodule
2023-06-21 21:28:24 -04:00
b31f52b179
Group imports 2023-06-21 21:19:04 -04:00
8d29652ce4
Update TODO.md 2023-06-21 21:15:00 -04:00
12717afd32
Split off timers into library 2023-06-21 21:14:39 -04:00
7cc97b9756
Split off UVManager 2023-06-21 19:42:35 -04:00
e4c0c288a2
Update nulllib submodule URL to public URL 2023-06-21 16:39:47 -04:00
d454a6340f
Split off util, logging, math, PartsManager 2023-06-21 16:11:06 -04:00
9e64a077e1
Rename unstring to parse 2023-06-21 15:18:55 -04:00
cc084d355b
Add README.md 2023-06-16 14:17:07 -04:00
b3d646e040
Update script to Figura 0.1.0-rc.14 2023-05-09 00:31:53 -04:00
5fbea8ebd9
Make syncState rate limit stricter 2022-10-31 08:24:09 -04:00
cca938ccc1
Update TODO.md 2022-10-30 23:01:03 -04:00
5c9563750e
Update TODO.md 2022-10-30 20:35:59 -04:00
a6367f64dd
Add debug logging for pings 2022-10-30 20:35:34 -04:00
58910fc16d
Add basic logging functions 2022-10-30 20:35:03 -04:00
df86b4cf2e
Add placeholder function for snore 2022-10-30 14:12:55 -04:00
24 changed files with 6353 additions and 780 deletions

1
.gitattributes vendored
View File

@ -2,3 +2,4 @@
*.png filter=lfs diff=lfs merge=lfs -text
*.ogg filter=lfs diff=lfs merge=lfs -text
* text=auto
*.zip filter=lfs diff=lfs merge=lfs -text

9
.gitmodules vendored Normal file
View File

@ -0,0 +1,9 @@
[submodule "nulllib"]
path = nulllib
url = https://gitea.protogen.io/nullbite/nulllib-lua.git
[submodule ".vim/figuradocs"]
path = figuradocs
url = https://github.com/GrandpaScout/FiguraRewriteVSDocs
[submodule "kattarmor"]
path = kattarmor
url = https://github.com/KitCat962/Figura-KattArmor

6
.luarc-local.json Normal file
View File

@ -0,0 +1,6 @@
{
"workspace": {
"ignoreDir": [ ".**", "figuradocs/**"],
"ignoreSubmodules": false
}
}

291
.luarc.json Normal file
View File

@ -0,0 +1,291 @@
{
"workspace": {
"library": [
".vscode/docs",
"../../avatars/.vscode/docs",
"../../../avatars/.vscode/docs",
"../../../../avatars/.vscode/docs",
"../../../../../avatars/.vscode/docs",
"../../../../../../avatars/.vscode/docs"
],
"checkThirdParty": false,
"userThirdParty": [],
"ignoreDir": [
".**",
"figuradocs/**"
],
"useGitIgnore": true,
"ignoreSubmodules": false,
"supportScheme": [
"file",
"untitled",
"git"
],
"maxPreload": 5000,
"preloadFileSize": 500
},
"runtime": {
"version": "Lua 5.2",
"builtin": {
"basic": "disable",
"bit": "disable",
"bit32": "enable",
"builtin": "enable",
"coroutine": "disable",
"debug": "disable",
"ffi": "disable",
"io": "disable",
"jit": "disable",
"math": "enable",
"os": "disable",
"package": "disable",
"string": "enable",
"table": "enable",
"table.clear": "disable",
"table.new": "disable",
"utf8": "disable"
},
"path": [
"?.lua"
],
"pathStrict": true,
"fileEncoding": "utf8",
"meta": "${version} ${language} ${encoding}",
"nonstandardSymbol": [],
"plugin": "",
"pluginArgs": [],
"special": {},
"unicodeName": false
},
"completion": {
"enable": true,
"keywordSnippet": "Both",
"callSnippet": "Disable",
"showParams": true,
"autoRequire": true,
"displayContext": 0,
"postfix": "@",
"requireSeparator": ".",
"showWord": "Disable",
"workspaceWord": false
},
"diagnostics": {
"enable": true,
"workspaceDelay": 5000,
"workspaceRate": 25,
"severity": {
"ambiguity-1": "Warning",
"count-down-loop": "Error",
"different-requires": "Error",
"newfield-call": "Warning",
"newline-call": "Warning",
"await-in-sync": "Error",
"not-yieldable": "Error",
"codestyle-check": "Information",
"spell-check": "Hint",
"duplicate-index": "Warning",
"duplicate-set-field": "Warning",
"global-in-nil-env": "Error",
"lowercase-global": "Information",
"undefined-env-child": "Warning",
"undefined-global": "Warning",
"circle-doc-class": "Error",
"doc-field-no-class": "Error",
"duplicate-doc-alias": "Warning",
"duplicate-doc-field": "Warning",
"duplicate-doc-param": "Warning",
"undefined-doc-class": "Warning",
"undefined-doc-name": "Error",
"undefined-doc-param": "Warning",
"unknown-cast-variable": "Error",
"unknown-diag-code": "Information",
"unknown-operator": "Error",
"redefined-local": "Warning",
"close-non-object": "Error",
"deprecated": "Warning",
"discard-returns": "Warning",
"no-unknown": "Warning",
"assign-type-mismatch": "Warning",
"cast-local-type": "Warning",
"cast-type-mismatch": "Warning",
"need-check-nil": "Warning",
"param-type-mismatch": "Warning",
"return-type-mismatch": "Warning",
"undefined-field": "Warning",
"missing-parameter": "Error",
"missing-return": "Warning",
"missing-return-value": "Warning",
"redundant-parameter": "Warning",
"redundant-return-value": "Warning",
"redundant-value": "Warning",
"unbalanced-assignments": "Warning",
"code-after-break": "Information",
"empty-block": "Hint",
"redundant-return": "Warning",
"trailing-space": "Hint",
"unreachable-code": "Information",
"unused-function": "Hint",
"unused-label": "Hint",
"unused-local": "Hint",
"unused-vararg": "Hint",
"inject-field": "Warning"
},
"neededFileStatus": {
"codestyle-check": "Any"
},
"disable": [
"different-requires",
"await-in-sync",
"not-yieldable",
"codestyle-check",
"spell-check",
"duplicate-set-field",
"close-non-object",
"no-unknown",
"cast-local-type",
"cast-type-mismatch",
"need-check-nil",
"trailing-space",
"inject-field"
],
"groupSeverity": {
"ambiguity": "Fallback",
"await": "Fallback",
"codestyle": "Fallback",
"duplicate": "Fallback",
"global": "Fallback",
"luadoc": "Fallback",
"redefined": "Fallback",
"strict": "Fallback",
"strong": "Fallback",
"type-check": "Fallback",
"unbalanced": "Fallback",
"unused": "Fallback"
},
"groupFileStatus": {
"ambiguity": "Fallback",
"await": "Fallback",
"codestyle": "Fallback",
"duplicate": "Fallback",
"global": "Fallback",
"luadoc": "Fallback",
"redefined": "Fallback",
"strict": "Fallback",
"strong": "Fallback",
"type-check": "Fallback",
"unbalanced": "Fallback",
"unused": "Fallback"
},
"disableScheme": [],
"ignoredFiles": "Opened",
"libraryFiles": "Opened",
"globals": [],
"unusedLocalExclude": []
},
"format": {
"enable": true,
"defaultConfig": {
"align_call_args": "false",
"align_chained_expression_statement": "false",
"align_function_define_params": "false",
"align_table_field_to_first_field": "false",
"call_arg_parentheses": "keep",
"class_name_define_style": "pascal_case",
"continuation_indent_size": "2",
"continuous_assign_statement_align_to_equal_sign": "true",
"continuous_assign_table_field_align_to_equal_sign": "true",
"detect_end_of_line": "true",
"do_statement_no_indent": "false",
"enable_check_codestyle": "true",
"enable_name_style_check": "true",
"end_of_line": "lf",
"function_name_define_style": "camel_case",
"function_param_name_style": "snake_case",
"global_variable_name_define_style": "upper_case",
"if_branch_comments_after_block_no_indent": "false",
"if_condition_no_continuation_indent": "false",
"indent_size": "2",
"indent_style": "space",
"insert_final_newline": "true",
"keep_line_after_do_statement": "keepLine",
"keep_line_after_expression_statement": "keepLine",
"keep_line_after_for_statement": "keepLine",
"keep_line_after_function_define_statement": "keepLine",
"keep_line_after_if_statement": "keepLine",
"keep_line_after_local_or_assign_statement": "keepLine",
"keep_line_after_repeat_statement": "keepLine",
"keep_line_after_while_statement": "keepLine",
"keep_one_space_between_namedef_and_attribute": "true",
"keep_one_space_between_table_and_bracket": "false",
"label_no_indent": "false",
"local_assign_continuation_align_to_first_expression": "false",
"local_function_name_define_style": "camel_case",
"local_name_define_style": "snake_case",
"long_chain_expression_allow_one_space_after_colon": "false",
"max_continuous_line_distance": "0",
"max_line_length": "100",
"module_name_define_style": "same('this')|same(filename, snake_case|pascal_case|camel_case)",
"quote_style": "double",
"remove_empty_header_and_footer_lines_in_function": "true",
"remove_expression_list_finish_comma": "true",
"require_module_name_style": "off",
"space_before_function_open_parenthesis": "false",
"space_before_open_square_bracket": "false",
"space_inside_function_call_parentheses": "false",
"space_inside_function_param_list_parentheses": "false",
"space_inside_square_brackets": "false",
"statement_inline_comment_space": "1",
"table_append_expression_no_space": "true",
"table_field_name_define_style": "snake_case",
"table_seperator_style": "comma",
"trailing_table_separator": "smart"
}
},
"hint": {
"enable": true,
"setType": true,
"paramName": "All",
"paramType": true,
"await": true,
"arrayIndex": "Auto",
"semicolon": "Disable"
},
"hover": {
"enable": true,
"enumsLimit": 100,
"expandAlias": false,
"previewFields": 100,
"viewNumber": true,
"viewString": true,
"viewStringMax": 1024
},
"type": {
"castNumberToInteger": true,
"weakNilCheck": true,
"weakUnionCheck": false
},
"semantic": {
"enable": true,
"annotation": true,
"keyword": false,
"variable": true
},
"signatureHelp": {
"enable": true
},
"spell": {
"dict": [
"figura"
]
},
"telemetry": {
"enable": false
},
"window": {
"progressBar": true,
"statusBar": true
},
"misc": {
"parameters": []
}
}

View File

@ -1,48 +0,0 @@
{
"Lua": {
"diagnostics": {
"globals":[
"action_wheel",
"animation",
"armor_model",
"camera",
"chat",
"client",
"data",
"elytra_model",
"events",
"first_person_model",
"held_item_model",
"host",
"keybind",
"log",
"logJson",
"logTable",
"matrices",
"meta",
"model",
"models",
"nameplate",
"parrot_model",
"particle",
"ping",
"player",
"print",
"printJson",
"printTable",
"renderer",
"require",
"sound",
"spyglass_model",
"vanilla_model",
"vec",
"vectoros",
"vectors",
"world"
],
"disable":[
"lowercase-global"
]
}
}
}

1
.vscode Symbolic link
View File

@ -0,0 +1 @@
figuradocs/src/.vscode

9
README.md Normal file
View File

@ -0,0 +1,9 @@
# Figura Protogen
This is my personal avatar for
[Figura](https://github.com/Kingdom-of-The-Moon/FiguraRewriteRewrite), a
Minecraft mod that allows for fully customizable avatars. This avatar is a
vanilla-style avatar with minor enhancements such as emissive textures, a tail,
and hurt animations.
I originally wrote this avatar for the old version of Figura, and I am
currently in the process of rewriting it for the current Figura version.

54
TODO.md
View File

@ -3,28 +3,60 @@
## General
- [ ] use matrix thing for UVManager (linear algebra is hard)
- [ ] Add action wheel icons
- [.] add separate function for updating relevant state variables instead of
sending full state to save bandwidth
- [ ] add function that gets total health with absoprtion
- [ ] retractable wipers when it rains
- [ ] avatar themes?? (AvatarAPI.getColor)
## Rewrite
- [ ] fix data api
- [ ] reimplement avatar settings
- [ ] fix sound
- [.] fix data api
- [.] ConfigAPI
- [.] reimplement avatar settings
- [.] fix sound
- [ ] fix Blockbench animations
- [ ] fix or disable custom commands (can probably use `/figura run`)
- [.] fix or disable custom commands (can probably use `/figura run`)
- [ ] fix armor, won't re-enable until cleanup
## Cleanup
- [ ] potentailly rework shared state variables
- [ ] Rewrite state management and synchronization code to be less horrifying
- [ ] one library for syncing state
- [ ] sender side: allow syncing entire state (EXPENSIVE) or just
single values
- [ ] internally map variable names to a number deterministically
to reduce unnecessary data transfer
i.e. t["this_is_a_very_long_but_readable_variable_name"]=42 ->
t[6]=42
- [.] use a lookup table/array based on order added
- [.] user should never see this, variable name to number
translation should be completely transparent
- [.] alternatively no manual syncing; state should be implicitly
"shared" and can only be written to/read from via functions to
prevent bad programming from desyncing state
- [.] receiver side: register handler function that has access to both
old and new state
- [.] receive value -> run handler function -> replace old value
with current
- [ ] i think figura has a shared storage thing but it's not real time,
mirror values to this so newly initialized players load with
correct state
- [.] one library for storing configs and their default values
- [.] this will insert values into the shared state using the other
library
- [.] potentailly rework shared state variables
- [ ] rework appropriate action wheel items as ToggleAction instead of ClickAction
- [.] split off large snippets of code into separate files
- [.] PartsManager
- [.] UVManager
- [.] utility functions
- [ ] cleanup tick functions, timers
- [ ] cleanup armor code to make less redundant
# Low priority
- [ ] reimplement partial vanilla as texture swap
- [x] remove partial_vanilla stuff from PartsManager
- [ ] fix UVManager with matrices or something
- [ ] add swap to skin texture
- [ ] split off large snippets of code into separate files
- [ ] PartsManager
- [ ] UVManager
- [ ] utility functions
- [ ] cleanup tick functions, timers
- [ ] cleanup armor code to make less redundant
# Done
- [x] fix pings

1
avatar.code-workspace Symbolic link
View File

@ -0,0 +1 @@
figuradocs/src/avatar.code-workspace

BIN
docs/Figura-KattArmor-VanillaDemo.zip (Stored with Git LFS) Normal file

Binary file not shown.

291
docs/kattarmor.md Normal file
View File

@ -0,0 +1,291 @@
At it's fundamentals, KattArmor changes the texture of specific user defined cubes to different textures depending on the detected material of the worn armor.
# Initializing the KattArmor library
First step is to `require` KattArmor into your own script. KattArmor itself should never be modified.
Curious about that extra `()`? KattArmor supports multiple Instances of itself. Those will be described later.
```lua
local kattArmor=require("KattArmor")()
```
# Creating Armor cubes
For vanilla armor, a template avatar is provided that contains the correct setup for vanilla armor.
The exact size, position, rotation or armor cubes does not matter. However, the uvs of the cubes do matter. In the template, a texture the same size as the vanilla armor textures is used to align the uvs correctly, and it makes editing the model in blockbench easier. If anything goes wrong, the texture assigned to the cubes in blockbench will be what appears.
To create vanilla-like armor, duplicate the cube you are wrapping the armor around, then inflate it by 0.25, 0.5, 0.75, or 1. Then switch the texture to one that allows you to align the uvs.
# Registering ModelParts to the KattArmor Library
Inside `kattArmor` is `Armor`, which contains `Helmet`, `Chestplate`, `Leggings`, and `Boots`. Calling `addParts` on any of these will add the given ModelParts to that Armor piece.
The ModelParts will be visible while armor is equipped in those slots, and the ModelParts will have their texture changed based on the material of the equipped armor.
```lua
kattArmor.Armor.Helmet
:addParts(
models.model.Head.Helmet,
models.model.Head.HelmetHat
)
kattArmor.Armor.Chestplate
:addParts(
models.model.Body.Chestplate,
models.model.RightArm.RightArmArmor,
models.model.LeftArm.LeftArmArmor
)
kattArmor.Armor.Leggings
:addParts(
models.model.Body.Belt,
models.model.RightLeg.RightLegArmor,
models.model.LeftLeg.LeftLegArmor
)
kattArmor.Armor.Boots
:addParts(
models.model.RightLeg.RightBoot,
models.model.LeftLeg.LeftBoot
)
```
# Identifying Materials
Materials are gotten from the itemID of armor. `minecraft:leather_helmet` has the material `"leather"` because it follows the format `namespace:material_armor`
This is known as a MaterialID. The vanilla materialIDs are as follows: `"leather"`, `"chainmail"`, `"iron"`, `"golden"`, `"diamond"`, `"netherite"`, and `"turtle"`.
There is the special Material which is the boolean value `true`, which represents having no equipped armor.
# Changing the texture of Materials
Materials are stored in the `Materials` table in `kattArmor`. It contains all Materials, even ones that do not exist.
It contains `Material` objects, which we can call `setTexture` and `setTextureLayer2` on. In vanilla, armor is divided into 2 layers: Layer 1 which contains textures for the helmet, chestplate, and boots, and Layer 2 which contains textures for the leggings.
By default, all materials will attempt to find a texture for itself in the resource location `minecraft:textures/models/armor`. If it cannot find a texture there, the error texture will be shown which is the texture defined in blockbench for the ModelParts.
You can manually set the texture by calling `setTexture` and `setTextureLayer2` on a Material, passing in either a resource location, or a Texture object.
```lua
kattArmor.Materials.leather
:setTexture(textures["customLeather"])
:setTextureLayer2(textures["customLeatherLayer2"])
```
To access the `true` material, you need to use `[]` indexing instead of `.` indexing, as the value used is a boolean value, not a string.
`true` was used to prevent any clashing with potential custom materials.
```lua
kattArmor.Materials[true]
:setVisible(true)
:setTexture(textures["armorDefault"])
:setTextureLayer2(textures["armorDefaultLayer2"])
```
# Custom Armor
If your character does not conform to vanilla armor, you do not have to worry about conforming to vanilla's standards at all.
Your UVs can be whereever you feel is best, your armor cubes can be in whatever shape you feel like, and you can ignore legging's layer2 shenanigans. If you do not use layer2 and do not set any textures to use layer2, be sure to set the layer that the Leggings use to layer2.
```lua
kattArmor.Armor.Leggings:setLayer(2)
```
# Modded armors
Some modded armors will be recognized by the script and have the textures accounted for. However, most mods do not use the vanilla rendering system for armor, meaning KattArmor will not be able to find the textures.
The fix is simple. Figure out the Material of the modded armor, and set the texture to the correct resource location.
For example, the fiery armor from the twilight forrest mod. It's helmet has the itemID `twilightforest:fiery_helmet`, and following the pattern `namespace:material_armor`, `"fiery"` is determined to be the material for this item.
```lua
kattArmor.Materials.fiery
:setTexture("twilightforest:textures/armor/fiery_1.png")
:setTextureLayer2("twilightforest:textures/armor/fiery_2.png")
```
# Adding Material Specific ModelParts to Materials
If a ModelPart is supposed to render on a specific Material and no-where else, you can call the `addParts` function on a Material object, passing in the Armor part object you want to add the ModelPart to.
As an example, this is how the leather layer is done on the template avatar. It uses this Material Parts system.
Material Parts do not change textures and do not change color. They appear when the Material is worn, and disappear when the Material is not worn. However, they do have enchantment glint if the armor item itself is enchanted.
```lua
kattArmor.Materials.leather
:addParts(kattArmor.Armor.Helmet,
models.model.Head.HelmetLeather,
models.model.Head.HelmetHatLeather
)
:addParts(kattArmor.Armor.Chestplate,
models.model.Body.ChestplateLeather,
models.model.RightArm.RightArmArmorLeather,
models.model.LeftArm.LeftArmArmorLeather
)
:addParts(kattArmor.Armor.Leggings,
models.model.Body.BeltLeather,
models.model.RightLeg.RightLegLeather,
models.model.LeftLeg.LeftLegLeather
)
:addParts(kattArmor.Armor.Boots,
models.model.RightLeg.RightBootLeather,
models.model.LeftLeg.LeftBootLeather
)
```
# Custom Materials
You can define custom materials with KattArmor, allowing for unique textures for unique situations.
For an example, we will be defining a custom `"philza"` material.
First step is to define the custom material. This is done by indexing `Materials` like you would for materials that you know exist.
Indexing `Materials` will create a new Material object if the Material didnt exist previously. Plot twist: Zero materials exist when KattArmor is initialized. They are generated when you wear armor for the first time, because KattArmor itself indexes Materials.
We then call `setTexture` and `setTextureLayer2` on the Material to define the textures to use when we use the material.
```lua
kattArmor.Materials.philza
:setTexture(textures["model.philzaLayer1"])
:setTextureLayer2(textures["model.philzaLayer2"])
```
We then need to define when the script will use the custom material. This is done via the `registerOnChange` function.
It takes in a function that should return a string or nil. When the function returns a string, KattArmor will use that as the Material. When it is nil, KattArmor will parse the MaterialID from the itemID as normal.
```lua
kattArmor.registerOnChange(function (partID, item)
-- When the name of the item is "Philza Helmet" on the helmet slot, return "philza".
-- The compared name is "Philza Chestplate", "Philza Leggings", and "Philza Boots" for the other armor parts
-- Functions return nil when no return is defined.
if item:getName() == ("Philza " .. partID) then
return "philza"
end
end)
```
And thats it. KattArmor will now use the `"philza"` material when the armor item's name is correct.
# Armor Trims
KattArmor supports armor trims.
Setting them up requires a bit of work. First of all, duplicate all of your armor cubes and give the duplicate a unique name. Do not touch the scale, leave it the same as the original cube.
You probably want to take the time to make a dummy trim texture in blockbench so that your bbmodel stays readable. A dummy texture for the vanilla armor is available in the template. This is not required by KattArmor and you can leave the trim cube's texture as whatever it was set to before.
Then in KattArmor, register the new cubes as Trim Parts via the `addTrimParts` function.
```lua
kattArmor.Armor.Chestplate:addTrimParts(
models.model.Body.ChestplateTrim,
models.model.RightArm.RightArmArmorTrim,
models.model.LeftArm.LeftArmArmorTrim
)
```
Now the new cubes will use the vanilla trim textures.
# Custom Armor Trims
Fuck custom armor trims.
KattArmor does not support custom Armor Trims in the same format as vanilla, where a source trim texture is provided and using some palate textures, extra textures are dynamically generated.
No. In KattArmor, you have 4 choices for Custom Armor Trims:
* Dont at all
* Dont, instead using the Custom Material system
* for when you have one specific material-pattern combo that you care about and will ignore the rest
* Set a single texture per trim pattern and allow KattArmor to setColor the cube based on the trim material
* for when you have a large project and want everything perfect, within reason
* Set a texture for each material-pattern combo, preferably using a texture generation system
* For when you want to absolutely demolish your instruction count or file size. Texture manipulation is *very* expensive, which is why KattArmor does not care to do it.
Info for 2:
Trim data is stored in nbt, and can be accessed via `item.tag.Trim.pattern` and `item.tag.Trim.material`. Dont forget to do a nil check for `item.tag.Trim`.
Info for 3:
use the `setTexture` and `setTextureLayer2` function on a TrimPattern object.
```lua
kattArmor.TrimPatterns.wild
:setTexture(textures["model.sentry"])
:setTextureLayer2(textures["model.sentry_leggings"])
```
The textures should be a gray-scale image so that ModelPart:setColor can do it's work.
If you do not like the colors that I defined for each material, you can set them yourself via the `setColor` function on a TrimMaterial object.
```lua
-- setColor expects a Vector3. I myself was lazy and used hex code number literals converted to Vec3 rbg via the `intToRGB` function.
kattArmor.TrimMaterials.amethyst:setColor(vectors.intToRGB(0x9a5cc6))
```
Info for 4:
you can use the `setTexture` and `setTextureLayer2` functions on a TrimMaterial object to completely override the texture used by a material-pattern combo.
```lua
kattArmor.TrimMaterials.lapis:setTexture("ward", textures["model.sentry"])
```
This texture is expected to be full color. KattArmor will apply no colors or other modifiers to the texture.
As stated before, this is expected to be used by your own instruction burning texture generating script, or by burning file size by manually creating textures in Blockbench for each material-pattern combo
I might make a texture generating script at some point, just so I can say that KattArmor *can* do it. Or I might not. Probably wont. Regardless, advanced texture manipulation will never be a base KattArmor feature due to it's expensive nature.
# KattArmor Instances
You heard at the top. KattArmor has instances. What does that mean?
`require` returns a function that when called, creates a new KattArmor instance. Every instance has it's own armor cubes, materials, textures, trim data. Basically, its a duplicated KattArmor script file.
This allows asset creators to create assets that depend on KattArmor, without denying the user the ability to use KattArmor.
Before, each material had a single texture per layer. This meant that if you wanted to merge 2 projects that used KattArmor, you would either need to have a duplicate KattArmor script file, or merge the 2 projects so that the custom textures and uvs worked properly with each other.
You can see how this can be a pain for users that don't even know what they are doing.
There are some things that are shared globally with all instances.
* The `forceUpdate` function found in all instances will cause *all* instances to update when called.
* All onChange functions get added to a global list, meaning all instances will obey the material changing brought by onChange.
* when multiple onChange functions are registered, the first truthy value will be used and all functions afterwords will not be called.
* `ArmorPart_SlotID_Map` and `SlotID_ArmorPart_Map`, which are static utility tables for mapping ArmorPartIDs with Slot numbers.
One thing that asset creators *do* have to worry about is giving users access to your KattArmor instance so they can add textures for their custom materials or modded armors. That is, unless you want the users to edit your script, making it difficult for users to update to newer versions of the asset.
# Custom Custom Custom Custom Custom
Not enough for you? There is `onRender` event which gets called after KattArmor has finished all of it's processing. In it's arguments is every single variable that KattArmor uses for determining how to render armor/trims.
```lua
kattArmor.registerOnRender(function (materialID, partID, item, visible, renderType, color, texture, textureType, texture_e, textureType_e, damageOverlay, trim, trimPattern, trimMaterial, trimTexture, trimTextureType, trimColor, trimUV)
print("oh god thats alot")
end)
```
yea its a bit of a joke. The most useful things are the first 3 arguments anyways, but who knows. Someone might find it useful. For the record, you do not need to define every argument. You can ignore the ones you do not use, using `_` to pad out the positions.
```lua
kattArmor.registerOnRender(function (materialID, partID, item)
print("ok this is more managable")
end)
kattArmor.registerOnRender(function (materialID, partID, item, _, _, _, _, _, _, _, _, trim, trimPattern, trimMaterial)
print("I just want trim data for `x` reason")
end)
```
# Armor doesn't update when I do stuff?
KattArmor only updates Armor Parts when the equipped item changes.
If you have additional code executing that onChange needs to watch for, you have to call `forceUpdate` when the variables change so that KattArmor knows to update the visuals.
Additionally, KattArmor functions do not automatically update the armor visuals, meaning you have to call `forceUpdate` when you modify Material textures or add more parts during tick, neither of which you should be doing anyways. Material textures should instead be handled via custom materials, and adding parts during tick should never be done in the first place.
```lua
local animatedArmor=0
function events.tick()
if world.getTime()%4==0 then
animatedArmor=(animatedArmor+1)%4
kattArmor.forceUpdate()
end
end
kattArmor.registerOnChange(function(partID, item)
if item.id == "minecraft:netherite_"..partID:lower() then
-- returns either "netherite-0", "netherite-1", "netherite-2", "netherite-3", which are custom materials.
return "netherite-"..animatedArmor
end
end)
```

1
figuradocs Submodule

@ -0,0 +1 @@
Subproject commit 725e04de1f0568cbeddf766b42edb6cf2b899316

1
kattarmor Submodule

@ -0,0 +1 @@
Subproject commit a243caa9d8f4a5369e45f16c566bfcc145782b0f

1
nulllib Submodule

@ -0,0 +1 @@
Subproject commit 618c082c0f5809bafc9a43a1e6ce81d2897a5333

File diff suppressed because one or more lines are too long

1284
script.lua

File diff suppressed because it is too large Load Diff

BIN
textures/armorLayer1.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
textures/armorLayer2.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
textures/blank.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
textures/leather_layer_1_overlay.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
textures/leather_layer_2_overlay.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
textures/trimsLayer1.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
textures/trimsLayer2.png (Stored with Git LFS) Normal file

Binary file not shown.

21
update-docs.sh Executable file
View File

@ -0,0 +1,21 @@
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p jq hjson stow
set -Eeuxo pipefail
cd "$(dirname "$0")"
(
cd figuradocs
git checkout latest
git fetch --all
git pull
stow src --ignore='^\.luarc\.json$'
)
< figuradocs/src/.luarc.json hjson -c | jq -s '.[0] * .[1]' - ./.luarc-local.json > .luarc.json
git add .luarc.json
git status