├── .github
├── ISSUE_TEMPLATE
│ ├── bug-report.yml
│ ├── config.yml
│ └── pack-conversion.yml
├── renovate.json
└── workflows
│ └── conversion-request.yml
├── .gitignore
├── CODE_OF_CONDUCT.md
├── LICENSE
├── README.md
├── armor.py
├── blank256.png
├── blocks.py
├── blocks_util.py
├── bow.py
├── bow_util.py
├── converter.sh
├── font.py
├── font_sprite.py
├── manager.py
├── meg3.py
├── shield.py
└── sound.py
/.github/ISSUE_TEMPLATE/bug-report.yml:
--------------------------------------------------------------------------------
1 | name: Bug Report
2 | description: Report a bug with the converter
3 | title: "[Bug]: "
4 | labels: ["bug"]
5 | body:
6 | - type: markdown
7 | attributes:
8 | value: |
9 | In order to file a bug report, you must first attempt to convert your pack via the [pack conversion action](https://github.com/Kas-tle/java2bedrock.sh/issues/new?assignees=&labels=conversion&template=pack-conversion.yml&title=%5BPack%5D%3A+) and include a link to the resulting issue. Any issues without such a link will be automatically rejected.
10 | If you simply need help with running the converter locally, please use the [Converter Help](https://github.com/Kas-tle/java2bedrock.sh/discussions/categories/converter-help) category on the discussions page.
11 | - type: input
12 | id: conversion-issue-link
13 | attributes:
14 | label: Conversion Issue Link
15 | description: Please provide a direct link to the issue that contains the conversion result.
16 | placeholder: e.g. https://github.com/Kas-tle/java2bedrock.sh/issues/15
17 | validations:
18 | required: true
19 | - type: textarea
20 | id: expected-output
21 | attributes:
22 | label: Expected Output
23 | description: Please describe in detail what the expected output of the converter should be with the given pack. Please be as specific as possible.
24 | validations:
25 | required: true
26 | - type: textarea
27 | id: actual-output
28 | attributes:
29 | label: Actual Output
30 | description: Please describe in detail what the actual output of the converter was with the given pack. Please be as specific as possible with regards to what went wrong. Where possible, refer to and reference the action log.
31 | validations:
32 | required: true
33 | - type: textarea
34 | id: additional-context
35 | attributes:
36 | label: Additional Context
37 | description: Please provide any additional information that you feel is relevant to the bug in question.
38 | validations:
39 | required: false
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/config.yml:
--------------------------------------------------------------------------------
1 | blank_issues_enabled: false
2 | contact_links:
3 | - name: Converter Help
4 | url: https://github.com/Kas-tle/java2bedrock.sh/discussions/categories/converter-help
5 | about: Help with setting up the converter.
6 | - name: Feature Requests
7 | url: https://github.com/Kas-tle/java2bedrock.sh/discussions/categories/feature-requests
8 | about: Discuss ideas for features to be added to the converter.
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/pack-conversion.yml:
--------------------------------------------------------------------------------
1 | name: Pack Conversion
2 | description: Request an automated pack conversion
3 | title: "[Pack]: "
4 | labels: ["conversion"]
5 | body:
6 | - type: markdown
7 | attributes:
8 | value: |
9 | Please be sure to include a directly downloadable link to your pack. The action will fail if the pack cannot be downloaded.
10 | - type: input
11 | id: java-pack-direct-download-url
12 | attributes:
13 | label: Java Pack Direct Download URL
14 | description: Please provide a direct link to the Java Edition resource pack to be converted.
15 | placeholder: e.g. https://github.com/Paradisu/ParadisuResourcePack/releases/latest/download/ParadisuResourcePack.zip
16 | validations:
17 | required: true
18 | - type: input
19 | id: default-pack-direct-download-url
20 | attributes:
21 | label: Default Pack Direct Download URL
22 | description: Optionally provide a direct link to a Java Edition resource pack to be used for default textures before the vanilla default pack.
23 | placeholder: e.g. https://github.com/Paradisu/ParadisuResourcePack/releases/latest/download/ParadisuResourcePack.zip
24 | validations:
25 | required: false
26 | - type: input
27 | id: bedrock-merge-pack-direct-download-url
28 | attributes:
29 | label: Bedrock Merge Pack Direct Download URL
30 | description: Optionally provide a direct link to the Bedrock Edition resource pack to be merged into the converted pack.
31 | placeholder: e.g. https://github.com/Kas-tle/imaginefun-bedrock-rp/releases/download/1.1.3/imaginefun_rp-v1.1.3.mcpack
32 | validations:
33 | required: false
34 | - type: dropdown
35 | id: default-assets-version
36 | attributes:
37 | label: Default Assets Version
38 | description: Optinally select the default assets version to use for the converted pack.
39 | options:
40 | - 1.13.2
41 | - 1.14.4
42 | - 1.15.2
43 | - 1.16.5
44 | - 1.17.1
45 | - 1.18.2
46 | - 1.19.2
47 | - 1.19.3
48 | - 1.19.4
49 | - '1.20'
50 | - 1.20.1
51 | validations:
52 | required: false
53 |
54 | - type: dropdown
55 | id: block-material
56 | attributes:
57 | label: Block Material
58 | description: |
59 | Please provide a block material to be used in the script. If one is not selected, `alpha_test` will be used.
60 | See the [Bedrock Wiki](https://wiki.bedrock.dev/blocks/block-materials.html) for more info.
61 | - `opaque`: no support for transparent or translucent pixels and renders only on outside faces
62 | - `alpha_test`: support for transparent pixels and renders only on outside faces
63 | - `blend`: support for translucent pixels and renders only on outside faces
64 | - `double_sided`: no support for transparent or translucent pixels. but renders both outside and inside faces
65 | options:
66 | - opaque
67 | - alpha_test
68 | - blend
69 | - double_sided
70 | validations:
71 | required: false
72 | - type: dropdown
73 | id: attachable-material
74 | attributes:
75 | label: Attachable Material
76 | description: |
77 | Please provide an attachable material to be used in the script. If one is not selected, `entity_alphatest_one_sided` will be used.
78 | See the [Bedrock Wiki](https://wiki.bedrock.dev/documentation/materials.html) for more info.
79 | - `entity`: basic opaque material with no support for transparent or translucent pixels
80 | - `entity_alphatest`: supports transparent pixels but lacks backface culling, which will cause z-fighting on thin elements
81 | - `entity_alphablend`: supports translucent pixels and backface culling, though objects behind may render inconsistently
82 | - `entity_alphatest_one_sided`: supports transparent pixels and backface culling
83 | options:
84 | - entity
85 | - entity_alphatest
86 | - entity_alphablend
87 | - entity_alphatest_one_sided
88 | - entity_emissive_alpha_one_sided
89 | validations:
90 | required: false
91 | - type: dropdown
92 | id: archive-scratch
93 | attributes:
94 | label: Archive Scratch Files
95 | description: |
96 | Should scratch files be archived? This will create a zip file containing the scratch files used by the script during the conversion process. If not selected, this will default to `false`.
97 | options:
98 | - 'true'
99 | - 'false'
100 | - type: dropdown
101 | id: rename-model-files
102 | attributes:
103 | label: Rename Model Files
104 | description: |
105 | Should scratch files be renamed to reduce path length? If not selected, this will default to `false`.
106 | options:
107 | - 'true'
108 | - 'false'
109 | - type: dropdown
110 | id: font-conversion
111 | attributes:
112 | label: Font Conversion
113 | description: |
114 | Enable font conversion (Can Error) default `false`.
115 | options:
116 | - 'true'
117 | - 'false'
118 | - type: dropdown
119 | id: armor-conversion
120 | attributes:
121 | label: Armor Conversion
122 | description: |
123 | Enable armor conversion (Only Itemsadder) default `false`.
124 | options:
125 | - 'true'
126 | - 'false'
127 | - type: dropdown
128 | id: meg3-fix
129 | attributes:
130 | label: Meg3 Fix
131 | description: |
132 | Fix Black Model for MEG3 default `false`.
133 | options:
134 | - 'true'
135 | - 'false'
136 | - type: dropdown
137 | id: sounds-conversion
138 | attributes:
139 | label: Sounds Conversion
140 | description: |
141 | Conversion Sounds default `false`.
142 | options:
143 | - 'true'
144 | - 'false'
145 | - type: dropdown
146 | id: bow-conversion
147 | attributes:
148 | label: Bow Conversion
149 | description: |
150 | Conversion Bow default `false`.
151 | options:
152 | - 'true'
153 | - 'false'
154 | - type: dropdown
155 | id: shield-conversion
156 | attributes:
157 | label: Shield Conversion
158 | description: |
159 | Conversion Shield default `false`, **Not ready for use**
160 | options:
161 | - 'true'
162 | - 'false'
163 | - type: dropdown
164 | id: block-conversion
165 | attributes:
166 | label: Block Conversion
167 | description: |
168 | Conversion Block default `false`
169 | options:
170 | - 'true'
171 | - 'false'
172 | - type: checkboxes
173 | id: terms
174 | attributes:
175 | label: Code of Conduct
176 | description: |
177 | By submitting this issue, you agree to follow our [Code of Conduct](https://github.com/Kas-tle/java2bedrock.sh/blob/main/CODE_OF_CONDUCT.md)
178 | You further agree that you either own or have permission to use any content you have linked to within this form.
179 | options:
180 | - label: I agree to follow this project's Code of Conduct. I have permission to use all assets I have linked to within this form.
181 | required: true
182 |
--------------------------------------------------------------------------------
/.github/renovate.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "https://docs.renovatebot.com/renovate-schema.json",
3 | "extends": [
4 | "config:recommended",
5 | ":disableDependencyDashboard"
6 | ]
7 | }
8 |
--------------------------------------------------------------------------------
/.github/workflows/conversion-request.yml:
--------------------------------------------------------------------------------
1 | name: Conversion Request
2 | on:
3 | issues:
4 | types:
5 | - labeled
6 |
7 | jobs:
8 | get-pack-info:
9 | runs-on: ubuntu-latest
10 | if: github.event.label.name == 'conversion'
11 | permissions:
12 | issues: read
13 | timeout-minutes: 2
14 | outputs:
15 | pack_url: ${{ steps.organize-inputs.outputs.PACK_URL }}
16 | default_pack_url: ${{ steps.organize-inputs.outputs.DEFAULT_PACK_URL }}
17 | merge_pack_url: ${{ steps.organize-inputs.outputs.MERGE_PACK_URL }}
18 | default_assets_version: ${{ steps.organize-inputs.outputs.DEFAULT_ASSETS_VERSION }}
19 | block_material: ${{ steps.organize-inputs.outputs.BLOCK_MATERIAL }}
20 | attachable_material: ${{ steps.organize-inputs.outputs.ATTACHABLE_MATERIAL }}
21 | archive_scratch: ${{ steps.organize-inputs.outputs.ARCHIVE_SCRATCH }}
22 | rename_model_files: ${{ steps.organize-inputs.outputs.RENAME_MODEL_FILES }}
23 | font_conversion: ${{ steps.organize-inputs.outputs.FONT_CONVERSION}}
24 | armor_conversion: ${{ steps.organize-inputs.outputs.ARMOR_CONVERSION}}
25 | meg3_fix: ${{ steps.organize-inputs.outputs.MEG3_FIX}}
26 | sounds_conversion: ${{ steps.organize-inputs.outputs.SOUNDS_CONVERSION }}
27 | bow_conversion: ${{ steps.organize-inputs.outputs.BOW_CONVERSION }}
28 | shield_conversion: ${{ steps.organize-inputs.outputs.SHIELD_CONVERSION }}
29 | block_conversion: ${{ steps.organize-inputs.outputs.BLOCK_CONVERSION }}
30 | steps:
31 | - name: Issue Forms Body Parser
32 | id: parse-issue
33 | uses: zentered/issue-forms-body-parser@v2.2.0
34 | - name: Organize Inputs
35 | id: organize-inputs
36 | run: |
37 | echo ${{ toJSON(steps.parse-issue.outputs.data) }} | jq '
38 | def test_input($input; $default):
39 | if ($input == "*No response*" or $input == "None") then $default else ($input | tostring | gsub("\\\\";"")) end;
40 | {
41 | "pack_url": .["java-pack-direct-download-url"].text[1:-1],
42 | "default_pack_url": test_input(.["default-pack-direct-download-url"].text; " null ")[1:-1],
43 | "merge_pack_url": test_input(.["bedrock-merge-pack-direct-download-url"].text; " null ")[1:-1],
44 | "default_assets_version": test_input(.["default-assets-version"].text; "1.19.3"),
45 | "block_material": test_input(.["block-material"].text; "alpha_test"),
46 | "attachable_material": test_input(.["attachable-material"].text; "entity_alphatest_one_sided"),
47 | "archive_scratch": test_input(.["archive-scratch-files"].text; "false"),
48 | "rename_model_files": test_input(.["rename-model-files"].text; "false"),
49 | "font_conversion": test_input(.["font-conversion"].text; "false"),
50 | "armor_conversion": test_input(.["armor-conversion"].text; "false"),
51 | "meg3_fix": test_input(.["meg3-fix"].text; "false"),
52 | "sounds_conversion": test_input(.["sounds-conversion"].text; "false"),
53 | "bow_conversion": test_input(.["bow-conversion"].text; "false"),
54 | "shield_conversion": test_input(.["shield-conversion"].text; "false"),
55 | "block_conversion": test_input(.["block-conversion"].text; "false")
56 | }' > inputs.json
57 | echo "PACK_URL=$(jq -r '.pack_url' inputs.json)" >> $GITHUB_OUTPUT
58 | echo "DEFAULT_PACK_URL=$(jq -r '.default_pack_url' inputs.json)" >> $GITHUB_OUTPUT
59 | echo "MERGE_PACK_URL=$(jq -r '.merge_pack_url' inputs.json)" >> $GITHUB_OUTPUT
60 | echo "DEFAULT_ASSETS_VERSION=$(jq -r '.default_assets_version' inputs.json)" >> $GITHUB_OUTPUT
61 | echo "BLOCK_MATERIAL=$(jq -r '.block_material' inputs.json)" >> $GITHUB_OUTPUT
62 | echo "ATTACHABLE_MATERIAL=$(jq -r '.attachable_material' inputs.json)" >> $GITHUB_OUTPUT
63 | echo "ARCHIVE_SCRATCH=$(jq -r '.archive_scratch' inputs.json)" >> $GITHUB_OUTPUT
64 | echo "RENAME_MODEL_FILES=$(jq -r '.rename_model_files' inputs.json)" >> $GITHUB_OUTPUT
65 | echo "FONT_CONVERSION=$(jq -r '.font_conversion' inputs.json)" >> $GITHUB_OUTPUT
66 | echo "ARMOR_CONVERSION=$(jq -r '.armor_conversion' inputs.json)" >> $GITHUB_OUTPUT
67 | echo "MEG3_FIX=$(jq -r '.meg3_fix' inputs.json)" >> $GITHUB_OUTPUT
68 | echo "SOUNDS_CONVERSION=$(jq -r '.sounds_conversion' inputs.json)" >> $GITHUB_OUTPUT
69 | echo "BOW_CONVERSION=$(jq -r '.bow_conversion' inputs.json)" >> $GITHUB_OUTPUT
70 | echo "SHIELD_CONVERSION=$(jq -r '.bow_conversion' inputs.json)" >> $GITHUB_OUTPUT
71 | echo "BLOCK_CONVERSION=$(jq -r '.block_conversion' inputs.json)" >> $GITHUB_OUTPUT
72 |
73 | convert-pack:
74 | runs-on: ubuntu-latest
75 | needs: get-pack-info
76 | permissions:
77 | contents: read
78 | timeout-minutes: 90
79 | outputs:
80 | run_id: ${{ steps.get-pack-info.outputs.pack_url }}
81 | steps:
82 | - uses: actions/checkout@v4
83 | with:
84 | fetch-depth: 0
85 | - name: Enable default asset cache
86 | id: cache-default-assets
87 | uses: actions/cache@v4
88 | with:
89 | path: /home/runner/work/java2bedrock.sh/java2bedrock.sh/staging/default_assets.zip
90 | key: ${{ runner.os }}-${{ needs.get-pack-info.outputs.default_assets_version }}
91 | - name: Install NodeJS
92 | uses: actions/setup-node@v4
93 | with:
94 | node-version: 20
95 | - name: Install Python
96 | uses: actions/setup-python@v5
97 | with:
98 | python-version: '3.11'
99 | - name: Install dependencies
100 | run: |
101 | sudo apt-get update || sudo apt-get update --fix-missing
102 | sudo apt-get install -y moreutils zip imagemagick
103 | yarn global add spritesheet-js
104 | pip install Pillow requests jproperties
105 | - name: Convert Pack
106 | id: convert-pack
107 | continue-on-error: false
108 | env:
109 | PACK_URL: ${{ needs.get-pack-info.outputs.pack_url }}
110 | DEFAULT_PACK_URL: ${{ needs.get-pack-info.outputs.default_pack_url }}
111 | MERGE_PACK_URL: ${{ needs.get-pack-info.outputs.merge_pack_url }}
112 | DEFAULT_ASSETS_VERSION: ${{ needs.get-pack-info.outputs.default_assets_version }}
113 | BLOCK_MATERIAL: ${{ needs.get-pack-info.outputs.block_material }}
114 | ATTACHABLE_MATERIAL: ${{ needs.get-pack-info.outputs.attachable_material }}
115 | ARCHIVE_SCRATCH: ${{ needs.get-pack-info.outputs.archive_scratch }}
116 | RENAME_MODEL_FILES: ${{ needs.get-pack-info.outputs.rename_model_files }}
117 | FONT_CONVERSION: ${{ needs.get-pack-info.outputs.font_conversion }}
118 | ARMOR_CONVERSION: ${{ needs.get-pack-info.outputs.armor_conversion }}
119 | MEG3_FIX: ${{ needs.get-pack-info.outputs.meg3_fix }}
120 | SOUNDS_CONVERSION: ${{ needs.get-pack-info.outputs.sounds_conversion }}
121 | BOW_CONVERSION: ${{ needs.get-pack-info.outputs.bow_conversion }}
122 | SHIELD_CONVERSION: ${{ needs.get-pack-info.outputs.shield_conversion }}
123 | BLOCK_CONVERSION: ${{ needs.get-pack-info.outputs.block_conversion }}
124 | run: |
125 | mkdir -p staging
126 | cp converter.sh staging/
127 | cd staging
128 | chmod +x converter.sh
129 | COLUMNS=$COLUMNS-1 curl --no-styled-output -#L -o input_pack.zip "${PACK_URL}"
130 | MERGE_PACK_FILE="${MERGE_PACK_URL}"
131 | if [ "${MERGE_PACK_URL}" != "null" ]; then
132 | COLUMNS=$COLUMNS-1 curl --no-styled-output -#L -o merge_pack.zip "${MERGE_PACK_URL}"
133 | MERGE_PACK_FILE="merge_pack.zip"
134 | fi
135 | ./converter.sh input_pack.zip -w "false" -m ${MERGE_PACK_FILE} -a ${ATTACHABLE_MATERIAL} -b ${BLOCK_MATERIAL} -f ${DEFAULT_PACK_URL} -v ${DEFAULT_ASSETS_VERSION} -r ${RENAME_MODEL_FILES} -s ${ARCHIVE_SCRATCH} -u "true"
136 | - name: Upload converted pack
137 | uses: actions/upload-artifact@v4
138 | with:
139 | name: PackFiles
140 | path: |
141 | staging/target/packaged/geyser_resources.mcpack
142 | staging/target/packaged/geyser_addon.mcaddon
143 | staging/target/*.json
144 | staging/target/scratch_files.zip
145 | staging/config.json
146 | post-result:
147 | runs-on: ubuntu-latest
148 | needs: convert-pack
149 | timeout-minutes: 2
150 | permissions:
151 | issues: write
152 | steps:
153 | - name: Post Result
154 | id: post-result
155 | uses: peter-evans/create-or-update-comment@v4
156 | with:
157 | issue-number: ${{ github.event.issue.number }}
158 | body: |
159 | ## :sparkles: The run has finished! :sparkles:
160 | - Download the pack files from the [action run][1] page. :arrow_double_down:
161 | - Upload the resource pack `geyser_resources.mcpack` to the `packs` folder of your Geyser folder. :file_folder:
162 | - Upload the mappings file `geyser_mappings.json` to the `custom_mappings` folder of your Geyser folder. :page_with_curl:
163 |
164 | If you notice issues with the converted files, please refer to the action log for errors and open a bug report if you believe there is an issue with the converter. This issue will be closed automatically.
165 |
166 | [1]: https://github.com/azpixel-team/java2bedrock/actions/runs/${{ github.run_id}}
167 | reactions: 'rocket'
168 |
169 | - name: Close Issue
170 | uses: peter-evans/close-issue@v3
171 | with:
172 | issue-number: ${{ github.event.issue.number }}
173 | conversion-failed:
174 | runs-on: ubuntu-latest
175 | needs: [get-pack-info, convert-pack, post-result]
176 | if: always() && (needs.get-pack-info.result == 'failure' || needs.convert-pack.result == 'failure' || needs.convert-pack.result == 'post-result')
177 | timeout-minutes: 2
178 | permissions:
179 | issues: write
180 | steps:
181 | - name: Post Result
182 | id: post-result
183 | uses: peter-evans/create-or-update-comment@v4
184 | with:
185 | issue-number: ${{ github.event.issue.number }}
186 | body: |
187 | ## :stop_sign: The run has failed :stop_sign:
188 | - Check the [action run][1] page for errors. :clipboard:
189 | - Status by job:
190 | - Get Pack Info: *${{ needs.get-pack-info.result }}*
191 | - Convert Pack: *${{ needs.convert-pack.result }}*
192 | - Post Result: *${{ needs.post-result.result }}*
193 |
194 | If you believe this is an issue with the converter. please open a bug report. This issue will be closed automatically.
195 |
196 | [1]: https://github.com/azpixel-team/java2bedrock/actions/runs/${{ github.run_id}}
197 | reactions: 'x'
198 | - name: Close issue
199 | uses: peter-evans/close-issue@v3
200 | with:
201 | issue-number: ${{ github.event.issue.number }}
202 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | target/
2 | *.zip
3 | config.json
4 | test_config.json
5 | hashmap.json
6 | pack.png
7 | pack.mcmeta
8 | assets/
9 | parents.json
10 | *.csv
11 | *.temp
12 | spritesheet.json
13 | item_mappings.json
14 | item_texture.json
15 | spritesheet/
16 | sprites.json
17 | sprite_hashmap.json
18 | nongenerated.json
19 | item_textures.json
20 | atlases.json
21 | icons.json
22 | generated.json
23 | scratch_files/
24 | .vscode/settings.json
25 |
--------------------------------------------------------------------------------
/CODE_OF_CONDUCT.md:
--------------------------------------------------------------------------------
1 | # Community Member and Contributor Code of Conduct
2 |
3 | ## Our Pledge
4 |
5 | We as members, contributors, and leaders pledge to make participation in our
6 | community a harassment-free experience for everyone, regardless of age, body
7 | size, visible or invisible disability, ethnicity, sex characteristics, gender
8 | identity and expression, level of experience, education, socio-economic status,
9 | nationality, personal appearance, race, religion, or sexual identity
10 | and orientation.
11 |
12 | We pledge to act and interact in ways that contribute to an open, welcoming,
13 | diverse, inclusive, and healthy community.
14 |
15 | ## Our Standards
16 |
17 | Examples of behavior that contributes to a positive environment for our
18 | community include:
19 |
20 | * Demonstrating empathy and kindness toward other people
21 | * Being respectful of differing opinions, viewpoints, and experiences
22 | * Giving and gracefully accepting constructive feedback
23 | * Accepting responsibility and apologizing to those affected by our mistakes,
24 | and learning from the experience
25 | * Focusing on what is best not just for us as individuals, but for the
26 | overall community
27 |
28 | Examples of unacceptable behavior include:
29 |
30 | * The use of sexualized language or imagery, and sexual attention or
31 | advances of any kind
32 | * Trolling, insulting or derogatory comments, and personal or political attacks
33 | * Public or private harassment
34 | * Publishing others' private information, such as a physical or email
35 | address, without their explicit permission
36 | * Other conduct which could reasonably be considered inappropriate in a
37 | professional setting
38 |
39 | ## Enforcement Responsibilities
40 |
41 | Community leaders are responsible for clarifying and enforcing our standards of
42 | acceptable behavior and will take appropriate and fair corrective action in
43 | response to any behavior that they deem inappropriate, threatening, offensive,
44 | or harmful.
45 |
46 | Community leaders have the right and responsibility to remove, edit, or reject
47 | comments, commits, code, wiki edits, issues, and other contributions that are
48 | not aligned to this Code of Conduct, and will communicate reasons for moderation
49 | decisions when appropriate.
50 |
51 | ## Scope
52 |
53 | This Code of Conduct applies within all community spaces, and also applies when
54 | an individual is officially representing the community in public spaces.
55 | Examples of representing our community include using an official e-mail address,
56 | posting via an official social media account, or acting as an appointed
57 | representative at an online or offline event.
58 |
59 | ## Enforcement
60 |
61 | Instances of abusive, harassing, or otherwise unacceptable behavior may be
62 | reported to the community leaders responsible for enforcement at
63 | conduct@kastle.tk.
64 | All complaints will be reviewed and investigated promptly and fairly.
65 |
66 | All community leaders are obligated to respect the privacy and security of the
67 | reporter of any incident.
68 |
69 | ## Enforcement Guidelines
70 |
71 | Community leaders will follow these Community Impact Guidelines in determining
72 | the consequences for any action they deem in violation of this Code of Conduct:
73 |
74 | ### 1. Correction
75 |
76 | **Community Impact**: Use of inappropriate language or other behavior deemed
77 | unprofessional or unwelcome in the community.
78 |
79 | **Consequence**: A private, written warning from community leaders, providing
80 | clarity around the nature of the violation and an explanation of why the
81 | behavior was inappropriate. A public apology may be requested.
82 |
83 | ### 2. Warning
84 |
85 | **Community Impact**: A violation through a single incident or series
86 | of actions.
87 |
88 | **Consequence**: A warning with consequences for continued behavior. No
89 | interaction with the people involved, including unsolicited interaction with
90 | those enforcing the Code of Conduct, for a specified period of time. This
91 | includes avoiding interactions in community spaces as well as external channels
92 | like social media. Violating these terms may lead to a temporary or
93 | permanent ban.
94 |
95 | ### 3. Temporary Ban
96 |
97 | **Community Impact**: A serious violation of community standards, including
98 | sustained inappropriate behavior.
99 |
100 | **Consequence**: A temporary ban from any sort of interaction or public
101 | communication with the community for a specified period of time. No public or
102 | private interaction with the people involved, including unsolicited interaction
103 | with those enforcing the Code of Conduct, is allowed during this period.
104 | Violating these terms may lead to a permanent ban.
105 |
106 | ### 4. Permanent Ban
107 |
108 | **Community Impact**: Demonstrating a pattern of violation of community
109 | standards, including sustained inappropriate behavior, harassment of an
110 | individual, or aggression toward or disparagement of classes of individuals.
111 |
112 | **Consequence**: A permanent ban from any sort of public interaction within
113 | the community.
114 |
115 | ## Attribution
116 |
117 | This Code of Conduct is adapted from the [Contributor Covenant][homepage],
118 | version 2.0, available at
119 | https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
120 |
121 | Community Impact Guidelines were inspired by [Mozilla's code of conduct
122 | enforcement ladder](https://github.com/mozilla/diversity).
123 |
124 | [homepage]: https://www.contributor-covenant.org
125 |
126 | For answers to common questions about this code of conduct, see the FAQ at
127 | https://www.contributor-covenant.org/faq. Translations are available at
128 | https://www.contributor-covenant.org/translations.
129 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU AFFERO GENERAL PUBLIC LICENSE
2 | Version 3, 19 November 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU Affero General Public License is a free, copyleft license for
11 | software and other kinds of works, specifically designed to ensure
12 | cooperation with the community in the case of network server software.
13 |
14 | The licenses for most software and other practical works are designed
15 | to take away your freedom to share and change the works. By contrast,
16 | our General Public Licenses are intended to guarantee your freedom to
17 | share and change all versions of a program--to make sure it remains free
18 | software for all its users.
19 |
20 | When we speak of free software, we are referring to freedom, not
21 | price. Our General Public Licenses are designed to make sure that you
22 | have the freedom to distribute copies of free software (and charge for
23 | them if you wish), that you receive source code or can get it if you
24 | want it, that you can change the software or use pieces of it in new
25 | free programs, and that you know you can do these things.
26 |
27 | Developers that use our General Public Licenses protect your rights
28 | with two steps: (1) assert copyright on the software, and (2) offer
29 | you this License which gives you legal permission to copy, distribute
30 | and/or modify the software.
31 |
32 | A secondary benefit of defending all users' freedom is that
33 | improvements made in alternate versions of the program, if they
34 | receive widespread use, become available for other developers to
35 | incorporate. Many developers of free software are heartened and
36 | encouraged by the resulting cooperation. However, in the case of
37 | software used on network servers, this result may fail to come about.
38 | The GNU General Public License permits making a modified version and
39 | letting the public access it on a server without ever releasing its
40 | source code to the public.
41 |
42 | The GNU Affero General Public License is designed specifically to
43 | ensure that, in such cases, the modified source code becomes available
44 | to the community. It requires the operator of a network server to
45 | provide the source code of the modified version running there to the
46 | users of that server. Therefore, public use of a modified version, on
47 | a publicly accessible server, gives the public access to the source
48 | code of the modified version.
49 |
50 | An older license, called the Affero General Public License and
51 | published by Affero, was designed to accomplish similar goals. This is
52 | a different license, not a version of the Affero GPL, but Affero has
53 | released a new version of the Affero GPL which permits relicensing under
54 | this license.
55 |
56 | The precise terms and conditions for copying, distribution and
57 | modification follow.
58 |
59 | TERMS AND CONDITIONS
60 |
61 | 0. Definitions.
62 |
63 | "This License" refers to version 3 of the GNU Affero General Public License.
64 |
65 | "Copyright" also means copyright-like laws that apply to other kinds of
66 | works, such as semiconductor masks.
67 |
68 | "The Program" refers to any copyrightable work licensed under this
69 | License. Each licensee is addressed as "you". "Licensees" and
70 | "recipients" may be individuals or organizations.
71 |
72 | To "modify" a work means to copy from or adapt all or part of the work
73 | in a fashion requiring copyright permission, other than the making of an
74 | exact copy. The resulting work is called a "modified version" of the
75 | earlier work or a work "based on" the earlier work.
76 |
77 | A "covered work" means either the unmodified Program or a work based
78 | on the Program.
79 |
80 | To "propagate" a work means to do anything with it that, without
81 | permission, would make you directly or secondarily liable for
82 | infringement under applicable copyright law, except executing it on a
83 | computer or modifying a private copy. Propagation includes copying,
84 | distribution (with or without modification), making available to the
85 | public, and in some countries other activities as well.
86 |
87 | To "convey" a work means any kind of propagation that enables other
88 | parties to make or receive copies. Mere interaction with a user through
89 | a computer network, with no transfer of a copy, is not conveying.
90 |
91 | An interactive user interface displays "Appropriate Legal Notices"
92 | to the extent that it includes a convenient and prominently visible
93 | feature that (1) displays an appropriate copyright notice, and (2)
94 | tells the user that there is no warranty for the work (except to the
95 | extent that warranties are provided), that licensees may convey the
96 | work under this License, and how to view a copy of this License. If
97 | the interface presents a list of user commands or options, such as a
98 | menu, a prominent item in the list meets this criterion.
99 |
100 | 1. Source Code.
101 |
102 | The "source code" for a work means the preferred form of the work
103 | for making modifications to it. "Object code" means any non-source
104 | form of a work.
105 |
106 | A "Standard Interface" means an interface that either is an official
107 | standard defined by a recognized standards body, or, in the case of
108 | interfaces specified for a particular programming language, one that
109 | is widely used among developers working in that language.
110 |
111 | The "System Libraries" of an executable work include anything, other
112 | than the work as a whole, that (a) is included in the normal form of
113 | packaging a Major Component, but which is not part of that Major
114 | Component, and (b) serves only to enable use of the work with that
115 | Major Component, or to implement a Standard Interface for which an
116 | implementation is available to the public in source code form. A
117 | "Major Component", in this context, means a major essential component
118 | (kernel, window system, and so on) of the specific operating system
119 | (if any) on which the executable work runs, or a compiler used to
120 | produce the work, or an object code interpreter used to run it.
121 |
122 | The "Corresponding Source" for a work in object code form means all
123 | the source code needed to generate, install, and (for an executable
124 | work) run the object code and to modify the work, including scripts to
125 | control those activities. However, it does not include the work's
126 | System Libraries, or general-purpose tools or generally available free
127 | programs which are used unmodified in performing those activities but
128 | which are not part of the work. For example, Corresponding Source
129 | includes interface definition files associated with source files for
130 | the work, and the source code for shared libraries and dynamically
131 | linked subprograms that the work is specifically designed to require,
132 | such as by intimate data communication or control flow between those
133 | subprograms and other parts of the work.
134 |
135 | The Corresponding Source need not include anything that users
136 | can regenerate automatically from other parts of the Corresponding
137 | Source.
138 |
139 | The Corresponding Source for a work in source code form is that
140 | same work.
141 |
142 | 2. Basic Permissions.
143 |
144 | All rights granted under this License are granted for the term of
145 | copyright on the Program, and are irrevocable provided the stated
146 | conditions are met. This License explicitly affirms your unlimited
147 | permission to run the unmodified Program. The output from running a
148 | covered work is covered by this License only if the output, given its
149 | content, constitutes a covered work. This License acknowledges your
150 | rights of fair use or other equivalent, as provided by copyright law.
151 |
152 | You may make, run and propagate covered works that you do not
153 | convey, without conditions so long as your license otherwise remains
154 | in force. You may convey covered works to others for the sole purpose
155 | of having them make modifications exclusively for you, or provide you
156 | with facilities for running those works, provided that you comply with
157 | the terms of this License in conveying all material for which you do
158 | not control copyright. Those thus making or running the covered works
159 | for you must do so exclusively on your behalf, under your direction
160 | and control, on terms that prohibit them from making any copies of
161 | your copyrighted material outside their relationship with you.
162 |
163 | Conveying under any other circumstances is permitted solely under
164 | the conditions stated below. Sublicensing is not allowed; section 10
165 | makes it unnecessary.
166 |
167 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
168 |
169 | No covered work shall be deemed part of an effective technological
170 | measure under any applicable law fulfilling obligations under article
171 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
172 | similar laws prohibiting or restricting circumvention of such
173 | measures.
174 |
175 | When you convey a covered work, you waive any legal power to forbid
176 | circumvention of technological measures to the extent such circumvention
177 | is effected by exercising rights under this License with respect to
178 | the covered work, and you disclaim any intention to limit operation or
179 | modification of the work as a means of enforcing, against the work's
180 | users, your or third parties' legal rights to forbid circumvention of
181 | technological measures.
182 |
183 | 4. Conveying Verbatim Copies.
184 |
185 | You may convey verbatim copies of the Program's source code as you
186 | receive it, in any medium, provided that you conspicuously and
187 | appropriately publish on each copy an appropriate copyright notice;
188 | keep intact all notices stating that this License and any
189 | non-permissive terms added in accord with section 7 apply to the code;
190 | keep intact all notices of the absence of any warranty; and give all
191 | recipients a copy of this License along with the Program.
192 |
193 | You may charge any price or no price for each copy that you convey,
194 | and you may offer support or warranty protection for a fee.
195 |
196 | 5. Conveying Modified Source Versions.
197 |
198 | You may convey a work based on the Program, or the modifications to
199 | produce it from the Program, in the form of source code under the
200 | terms of section 4, provided that you also meet all of these conditions:
201 |
202 | a) The work must carry prominent notices stating that you modified
203 | it, and giving a relevant date.
204 |
205 | b) The work must carry prominent notices stating that it is
206 | released under this License and any conditions added under section
207 | 7. This requirement modifies the requirement in section 4 to
208 | "keep intact all notices".
209 |
210 | c) You must license the entire work, as a whole, under this
211 | License to anyone who comes into possession of a copy. This
212 | License will therefore apply, along with any applicable section 7
213 | additional terms, to the whole of the work, and all its parts,
214 | regardless of how they are packaged. This License gives no
215 | permission to license the work in any other way, but it does not
216 | invalidate such permission if you have separately received it.
217 |
218 | d) If the work has interactive user interfaces, each must display
219 | Appropriate Legal Notices; however, if the Program has interactive
220 | interfaces that do not display Appropriate Legal Notices, your
221 | work need not make them do so.
222 |
223 | A compilation of a covered work with other separate and independent
224 | works, which are not by their nature extensions of the covered work,
225 | and which are not combined with it such as to form a larger program,
226 | in or on a volume of a storage or distribution medium, is called an
227 | "aggregate" if the compilation and its resulting copyright are not
228 | used to limit the access or legal rights of the compilation's users
229 | beyond what the individual works permit. Inclusion of a covered work
230 | in an aggregate does not cause this License to apply to the other
231 | parts of the aggregate.
232 |
233 | 6. Conveying Non-Source Forms.
234 |
235 | You may convey a covered work in object code form under the terms
236 | of sections 4 and 5, provided that you also convey the
237 | machine-readable Corresponding Source under the terms of this License,
238 | in one of these ways:
239 |
240 | a) Convey the object code in, or embodied in, a physical product
241 | (including a physical distribution medium), accompanied by the
242 | Corresponding Source fixed on a durable physical medium
243 | customarily used for software interchange.
244 |
245 | b) Convey the object code in, or embodied in, a physical product
246 | (including a physical distribution medium), accompanied by a
247 | written offer, valid for at least three years and valid for as
248 | long as you offer spare parts or customer support for that product
249 | model, to give anyone who possesses the object code either (1) a
250 | copy of the Corresponding Source for all the software in the
251 | product that is covered by this License, on a durable physical
252 | medium customarily used for software interchange, for a price no
253 | more than your reasonable cost of physically performing this
254 | conveying of source, or (2) access to copy the
255 | Corresponding Source from a network server at no charge.
256 |
257 | c) Convey individual copies of the object code with a copy of the
258 | written offer to provide the Corresponding Source. This
259 | alternative is allowed only occasionally and noncommercially, and
260 | only if you received the object code with such an offer, in accord
261 | with subsection 6b.
262 |
263 | d) Convey the object code by offering access from a designated
264 | place (gratis or for a charge), and offer equivalent access to the
265 | Corresponding Source in the same way through the same place at no
266 | further charge. You need not require recipients to copy the
267 | Corresponding Source along with the object code. If the place to
268 | copy the object code is a network server, the Corresponding Source
269 | may be on a different server (operated by you or a third party)
270 | that supports equivalent copying facilities, provided you maintain
271 | clear directions next to the object code saying where to find the
272 | Corresponding Source. Regardless of what server hosts the
273 | Corresponding Source, you remain obligated to ensure that it is
274 | available for as long as needed to satisfy these requirements.
275 |
276 | e) Convey the object code using peer-to-peer transmission, provided
277 | you inform other peers where the object code and Corresponding
278 | Source of the work are being offered to the general public at no
279 | charge under subsection 6d.
280 |
281 | A separable portion of the object code, whose source code is excluded
282 | from the Corresponding Source as a System Library, need not be
283 | included in conveying the object code work.
284 |
285 | A "User Product" is either (1) a "consumer product", which means any
286 | tangible personal property which is normally used for personal, family,
287 | or household purposes, or (2) anything designed or sold for incorporation
288 | into a dwelling. In determining whether a product is a consumer product,
289 | doubtful cases shall be resolved in favor of coverage. For a particular
290 | product received by a particular user, "normally used" refers to a
291 | typical or common use of that class of product, regardless of the status
292 | of the particular user or of the way in which the particular user
293 | actually uses, or expects or is expected to use, the product. A product
294 | is a consumer product regardless of whether the product has substantial
295 | commercial, industrial or non-consumer uses, unless such uses represent
296 | the only significant mode of use of the product.
297 |
298 | "Installation Information" for a User Product means any methods,
299 | procedures, authorization keys, or other information required to install
300 | and execute modified versions of a covered work in that User Product from
301 | a modified version of its Corresponding Source. The information must
302 | suffice to ensure that the continued functioning of the modified object
303 | code is in no case prevented or interfered with solely because
304 | modification has been made.
305 |
306 | If you convey an object code work under this section in, or with, or
307 | specifically for use in, a User Product, and the conveying occurs as
308 | part of a transaction in which the right of possession and use of the
309 | User Product is transferred to the recipient in perpetuity or for a
310 | fixed term (regardless of how the transaction is characterized), the
311 | Corresponding Source conveyed under this section must be accompanied
312 | by the Installation Information. But this requirement does not apply
313 | if neither you nor any third party retains the ability to install
314 | modified object code on the User Product (for example, the work has
315 | been installed in ROM).
316 |
317 | The requirement to provide Installation Information does not include a
318 | requirement to continue to provide support service, warranty, or updates
319 | for a work that has been modified or installed by the recipient, or for
320 | the User Product in which it has been modified or installed. Access to a
321 | network may be denied when the modification itself materially and
322 | adversely affects the operation of the network or violates the rules and
323 | protocols for communication across the network.
324 |
325 | Corresponding Source conveyed, and Installation Information provided,
326 | in accord with this section must be in a format that is publicly
327 | documented (and with an implementation available to the public in
328 | source code form), and must require no special password or key for
329 | unpacking, reading or copying.
330 |
331 | 7. Additional Terms.
332 |
333 | "Additional permissions" are terms that supplement the terms of this
334 | License by making exceptions from one or more of its conditions.
335 | Additional permissions that are applicable to the entire Program shall
336 | be treated as though they were included in this License, to the extent
337 | that they are valid under applicable law. If additional permissions
338 | apply only to part of the Program, that part may be used separately
339 | under those permissions, but the entire Program remains governed by
340 | this License without regard to the additional permissions.
341 |
342 | When you convey a copy of a covered work, you may at your option
343 | remove any additional permissions from that copy, or from any part of
344 | it. (Additional permissions may be written to require their own
345 | removal in certain cases when you modify the work.) You may place
346 | additional permissions on material, added by you to a covered work,
347 | for which you have or can give appropriate copyright permission.
348 |
349 | Notwithstanding any other provision of this License, for material you
350 | add to a covered work, you may (if authorized by the copyright holders of
351 | that material) supplement the terms of this License with terms:
352 |
353 | a) Disclaiming warranty or limiting liability differently from the
354 | terms of sections 15 and 16 of this License; or
355 |
356 | b) Requiring preservation of specified reasonable legal notices or
357 | author attributions in that material or in the Appropriate Legal
358 | Notices displayed by works containing it; or
359 |
360 | c) Prohibiting misrepresentation of the origin of that material, or
361 | requiring that modified versions of such material be marked in
362 | reasonable ways as different from the original version; or
363 |
364 | d) Limiting the use for publicity purposes of names of licensors or
365 | authors of the material; or
366 |
367 | e) Declining to grant rights under trademark law for use of some
368 | trade names, trademarks, or service marks; or
369 |
370 | f) Requiring indemnification of licensors and authors of that
371 | material by anyone who conveys the material (or modified versions of
372 | it) with contractual assumptions of liability to the recipient, for
373 | any liability that these contractual assumptions directly impose on
374 | those licensors and authors.
375 |
376 | All other non-permissive additional terms are considered "further
377 | restrictions" within the meaning of section 10. If the Program as you
378 | received it, or any part of it, contains a notice stating that it is
379 | governed by this License along with a term that is a further
380 | restriction, you may remove that term. If a license document contains
381 | a further restriction but permits relicensing or conveying under this
382 | License, you may add to a covered work material governed by the terms
383 | of that license document, provided that the further restriction does
384 | not survive such relicensing or conveying.
385 |
386 | If you add terms to a covered work in accord with this section, you
387 | must place, in the relevant source files, a statement of the
388 | additional terms that apply to those files, or a notice indicating
389 | where to find the applicable terms.
390 |
391 | Additional terms, permissive or non-permissive, may be stated in the
392 | form of a separately written license, or stated as exceptions;
393 | the above requirements apply either way.
394 |
395 | 8. Termination.
396 |
397 | You may not propagate or modify a covered work except as expressly
398 | provided under this License. Any attempt otherwise to propagate or
399 | modify it is void, and will automatically terminate your rights under
400 | this License (including any patent licenses granted under the third
401 | paragraph of section 11).
402 |
403 | However, if you cease all violation of this License, then your
404 | license from a particular copyright holder is reinstated (a)
405 | provisionally, unless and until the copyright holder explicitly and
406 | finally terminates your license, and (b) permanently, if the copyright
407 | holder fails to notify you of the violation by some reasonable means
408 | prior to 60 days after the cessation.
409 |
410 | Moreover, your license from a particular copyright holder is
411 | reinstated permanently if the copyright holder notifies you of the
412 | violation by some reasonable means, this is the first time you have
413 | received notice of violation of this License (for any work) from that
414 | copyright holder, and you cure the violation prior to 30 days after
415 | your receipt of the notice.
416 |
417 | Termination of your rights under this section does not terminate the
418 | licenses of parties who have received copies or rights from you under
419 | this License. If your rights have been terminated and not permanently
420 | reinstated, you do not qualify to receive new licenses for the same
421 | material under section 10.
422 |
423 | 9. Acceptance Not Required for Having Copies.
424 |
425 | You are not required to accept this License in order to receive or
426 | run a copy of the Program. Ancillary propagation of a covered work
427 | occurring solely as a consequence of using peer-to-peer transmission
428 | to receive a copy likewise does not require acceptance. However,
429 | nothing other than this License grants you permission to propagate or
430 | modify any covered work. These actions infringe copyright if you do
431 | not accept this License. Therefore, by modifying or propagating a
432 | covered work, you indicate your acceptance of this License to do so.
433 |
434 | 10. Automatic Licensing of Downstream Recipients.
435 |
436 | Each time you convey a covered work, the recipient automatically
437 | receives a license from the original licensors, to run, modify and
438 | propagate that work, subject to this License. You are not responsible
439 | for enforcing compliance by third parties with this License.
440 |
441 | An "entity transaction" is a transaction transferring control of an
442 | organization, or substantially all assets of one, or subdividing an
443 | organization, or merging organizations. If propagation of a covered
444 | work results from an entity transaction, each party to that
445 | transaction who receives a copy of the work also receives whatever
446 | licenses to the work the party's predecessor in interest had or could
447 | give under the previous paragraph, plus a right to possession of the
448 | Corresponding Source of the work from the predecessor in interest, if
449 | the predecessor has it or can get it with reasonable efforts.
450 |
451 | You may not impose any further restrictions on the exercise of the
452 | rights granted or affirmed under this License. For example, you may
453 | not impose a license fee, royalty, or other charge for exercise of
454 | rights granted under this License, and you may not initiate litigation
455 | (including a cross-claim or counterclaim in a lawsuit) alleging that
456 | any patent claim is infringed by making, using, selling, offering for
457 | sale, or importing the Program or any portion of it.
458 |
459 | 11. Patents.
460 |
461 | A "contributor" is a copyright holder who authorizes use under this
462 | License of the Program or a work on which the Program is based. The
463 | work thus licensed is called the contributor's "contributor version".
464 |
465 | A contributor's "essential patent claims" are all patent claims
466 | owned or controlled by the contributor, whether already acquired or
467 | hereafter acquired, that would be infringed by some manner, permitted
468 | by this License, of making, using, or selling its contributor version,
469 | but do not include claims that would be infringed only as a
470 | consequence of further modification of the contributor version. For
471 | purposes of this definition, "control" includes the right to grant
472 | patent sublicenses in a manner consistent with the requirements of
473 | this License.
474 |
475 | Each contributor grants you a non-exclusive, worldwide, royalty-free
476 | patent license under the contributor's essential patent claims, to
477 | make, use, sell, offer for sale, import and otherwise run, modify and
478 | propagate the contents of its contributor version.
479 |
480 | In the following three paragraphs, a "patent license" is any express
481 | agreement or commitment, however denominated, not to enforce a patent
482 | (such as an express permission to practice a patent or covenant not to
483 | sue for patent infringement). To "grant" such a patent license to a
484 | party means to make such an agreement or commitment not to enforce a
485 | patent against the party.
486 |
487 | If you convey a covered work, knowingly relying on a patent license,
488 | and the Corresponding Source of the work is not available for anyone
489 | to copy, free of charge and under the terms of this License, through a
490 | publicly available network server or other readily accessible means,
491 | then you must either (1) cause the Corresponding Source to be so
492 | available, or (2) arrange to deprive yourself of the benefit of the
493 | patent license for this particular work, or (3) arrange, in a manner
494 | consistent with the requirements of this License, to extend the patent
495 | license to downstream recipients. "Knowingly relying" means you have
496 | actual knowledge that, but for the patent license, your conveying the
497 | covered work in a country, or your recipient's use of the covered work
498 | in a country, would infringe one or more identifiable patents in that
499 | country that you have reason to believe are valid.
500 |
501 | If, pursuant to or in connection with a single transaction or
502 | arrangement, you convey, or propagate by procuring conveyance of, a
503 | covered work, and grant a patent license to some of the parties
504 | receiving the covered work authorizing them to use, propagate, modify
505 | or convey a specific copy of the covered work, then the patent license
506 | you grant is automatically extended to all recipients of the covered
507 | work and works based on it.
508 |
509 | A patent license is "discriminatory" if it does not include within
510 | the scope of its coverage, prohibits the exercise of, or is
511 | conditioned on the non-exercise of one or more of the rights that are
512 | specifically granted under this License. You may not convey a covered
513 | work if you are a party to an arrangement with a third party that is
514 | in the business of distributing software, under which you make payment
515 | to the third party based on the extent of your activity of conveying
516 | the work, and under which the third party grants, to any of the
517 | parties who would receive the covered work from you, a discriminatory
518 | patent license (a) in connection with copies of the covered work
519 | conveyed by you (or copies made from those copies), or (b) primarily
520 | for and in connection with specific products or compilations that
521 | contain the covered work, unless you entered into that arrangement,
522 | or that patent license was granted, prior to 28 March 2007.
523 |
524 | Nothing in this License shall be construed as excluding or limiting
525 | any implied license or other defenses to infringement that may
526 | otherwise be available to you under applicable patent law.
527 |
528 | 12. No Surrender of Others' Freedom.
529 |
530 | If conditions are imposed on you (whether by court order, agreement or
531 | otherwise) that contradict the conditions of this License, they do not
532 | excuse you from the conditions of this License. If you cannot convey a
533 | covered work so as to satisfy simultaneously your obligations under this
534 | License and any other pertinent obligations, then as a consequence you may
535 | not convey it at all. For example, if you agree to terms that obligate you
536 | to collect a royalty for further conveying from those to whom you convey
537 | the Program, the only way you could satisfy both those terms and this
538 | License would be to refrain entirely from conveying the Program.
539 |
540 | 13. Remote Network Interaction; Use with the GNU General Public License.
541 |
542 | Notwithstanding any other provision of this License, if you modify the
543 | Program, your modified version must prominently offer all users
544 | interacting with it remotely through a computer network (if your version
545 | supports such interaction) an opportunity to receive the Corresponding
546 | Source of your version by providing access to the Corresponding Source
547 | from a network server at no charge, through some standard or customary
548 | means of facilitating copying of software. This Corresponding Source
549 | shall include the Corresponding Source for any work covered by version 3
550 | of the GNU General Public License that is incorporated pursuant to the
551 | following paragraph.
552 |
553 | Notwithstanding any other provision of this License, you have
554 | permission to link or combine any covered work with a work licensed
555 | under version 3 of the GNU General Public License into a single
556 | combined work, and to convey the resulting work. The terms of this
557 | License will continue to apply to the part which is the covered work,
558 | but the work with which it is combined will remain governed by version
559 | 3 of the GNU General Public License.
560 |
561 | 14. Revised Versions of this License.
562 |
563 | The Free Software Foundation may publish revised and/or new versions of
564 | the GNU Affero General Public License from time to time. Such new versions
565 | will be similar in spirit to the present version, but may differ in detail to
566 | address new problems or concerns.
567 |
568 | Each version is given a distinguishing version number. If the
569 | Program specifies that a certain numbered version of the GNU Affero General
570 | Public License "or any later version" applies to it, you have the
571 | option of following the terms and conditions either of that numbered
572 | version or of any later version published by the Free Software
573 | Foundation. If the Program does not specify a version number of the
574 | GNU Affero General Public License, you may choose any version ever published
575 | by the Free Software Foundation.
576 |
577 | If the Program specifies that a proxy can decide which future
578 | versions of the GNU Affero General Public License can be used, that proxy's
579 | public statement of acceptance of a version permanently authorizes you
580 | to choose that version for the Program.
581 |
582 | Later license versions may give you additional or different
583 | permissions. However, no additional obligations are imposed on any
584 | author or copyright holder as a result of your choosing to follow a
585 | later version.
586 |
587 | 15. Disclaimer of Warranty.
588 |
589 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
590 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
591 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
592 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
593 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
594 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
595 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
596 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
597 |
598 | 16. Limitation of Liability.
599 |
600 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
601 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
602 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
603 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
604 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
605 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
606 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
607 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
608 | SUCH DAMAGES.
609 |
610 | 17. Interpretation of Sections 15 and 16.
611 |
612 | If the disclaimer of warranty and limitation of liability provided
613 | above cannot be given local legal effect according to their terms,
614 | reviewing courts shall apply local law that most closely approximates
615 | an absolute waiver of all civil liability in connection with the
616 | Program, unless a warranty or assumption of liability accompanies a
617 | copy of the Program in return for a fee.
618 |
619 | END OF TERMS AND CONDITIONS
620 |
621 | How to Apply These Terms to Your New Programs
622 |
623 | If you develop a new program, and you want it to be of the greatest
624 | possible use to the public, the best way to achieve this is to make it
625 | free software which everyone can redistribute and change under these terms.
626 |
627 | To do so, attach the following notices to the program. It is safest
628 | to attach them to the start of each source file to most effectively
629 | state the exclusion of warranty; and each file should have at least
630 | the "copyright" line and a pointer to where the full notice is found.
631 |
632 |
633 | Copyright (C)
634 |
635 | This program is free software: you can redistribute it and/or modify
636 | it under the terms of the GNU Affero General Public License as published
637 | by the Free Software Foundation, either version 3 of the License, or
638 | (at your option) any later version.
639 |
640 | This program is distributed in the hope that it will be useful,
641 | but WITHOUT ANY WARRANTY; without even the implied warranty of
642 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
643 | GNU Affero General Public License for more details.
644 |
645 | You should have received a copy of the GNU Affero General Public License
646 | along with this program. If not, see .
647 |
648 | Also add information on how to contact you by electronic and paper mail.
649 |
650 | If your software can interact with users remotely through a computer
651 | network, you should also make sure that it provides a way for users to
652 | get its source. For example, if your program is a web application, its
653 | interface could display a "Source" link that leads users to an archive
654 | of the code. There are many ways you could offer source, and different
655 | solutions will be better for different programs; see section 13 for the
656 | specific requirements.
657 |
658 | You should also get your employer (if you work as a programmer) or school,
659 | if any, to sign a "copyright disclaimer" for the program, if necessary.
660 | For more information on this, and how to apply and follow the GNU AGPL, see
661 | .
662 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ### This project is no longer maintained. Check out our new project below!
2 |
3 | ## Furnace – Resource Pack Conversion Tool
4 |
5 | ### How to Use
6 |
7 | - Join our Discord [here](https://discord.gg/4jvpVGpeBE).
8 | - Upload your Java resource pack to the designated support channel.
9 | - Furnace bot automatically processes the file and converts it to a Geyser-compatible format.
10 | - Download and use the converted pack in Minecraft Bedrock via Geyser.
11 |
12 | ### Contact & Support
13 |
14 | - Join our Discord: [Furnace Discord](https://discord.gg/4jvpVGpeBE) for updates and assistance.
15 | - Community Discussions: Share feedback, report issues, and suggest improvements directly on our server.
16 |
17 | ### Todo-List
18 | - Support Custom Block (Ready for test and use)
19 | - Fix shield
20 | - Support custom gui and skip font. Example code for file to make it:
21 | ```
22 | [
23 | "\uE200":{
24 | "skip": true
25 | },
26 | "0xE201":{
27 | "skip": true,
28 | "gui": [0, 6]
29 | },
30 | "":{
31 | "skip": false,
32 | "gui": [0, 16]
33 | }
34 | // if skip is not set and gui is set, then the font will skip and the gui will be executed
35 | ]
36 | ```
37 | ## Usage
38 |
39 | **Please disable itemadder protection unzip**
40 |
41 | ### Donate
42 |
43 | [](https://paypal.me/LZ5509)
44 |
45 | ### Local
46 |
47 | To run, simply:
48 | ```
49 | ./converter.sh MyResourcePack.zip
50 | ```
51 |
52 | To run without settings prompts, use flags:
53 | - `-w (true|false)` whether or not to show the warning prompt
54 | - `-m (pack_to_merge.mcpack)` filename of Bedrock Edition resource pack in the same diretory to merge with result of the conversion
55 | - `-a (attachable_material)` material to use for attachables written by the script
56 | - `-b (block_material)` material to use for blocks written by the script
57 | - `-f (https://somesite.com/fallback_pack.zip|null)` URL of a Java Edition resource to use for fallback textures before the default pack
58 | - `-v (default_asset_version)` version of Minecraft Java Edition for which to pull default assets
59 |
60 | For example:
61 |
62 | ```
63 | ./converter.sh MyResourcePack.zip -w "false" -m "MyBedrock.mcpack" -a "entity_alphatest_one_sided" -b "alpha_test" -f "null" -v "1.18.2"
64 | ```
65 |
66 | ### Item Icons
67 |
68 | If you prepare 2D sprites for your 3D models, you can provide the converter with mappings for these sprites to be incorporated into item_texture.json and the exported Geyser mappings. To do so, simply include a file called `sprites.json` in the root of your Java resource pack. The format of this file is as follows:
69 | ```json
70 | {
71 | "leather": [
72 | {
73 | "custom_model_data": 1,
74 | "sprite": "textures/path/to/texture_in_bedrock_rp/texture1"
75 | },
76 | {
77 | "custom_model_data": 2,
78 | "sprite": "textures/path/to/texture_in_bedrock_rp/texture2"
79 | }
80 | ],
81 | "diamond_axe": [
82 | {
83 | "damage_predicate": 2,
84 | "unbreakable": true,
85 | "sprite": "textures/path/to/texture_in_bedrock_rp/texture3"
86 | }
87 | ]
88 | }
89 | ```
90 |
91 | When utilizing this feature, you should also use the merge feature to combine the converted pack with an existing Bedrock resource pack containing the specified sprite textures. If using the Github Actions based converter, simply provide a direct download URL of said Bedrock resource pack as done for the Java pack.
92 |
93 | ### Github Actions
94 |
95 | You may also run the converter through Github Actions in this repository by creating an issue with the [Pack Conversion](https://github.com/Kas-tle/java2bedrock.sh/issues/new?assignees=&labels=conversion&template=pack-conversion.yml&title=%5BPack%5D%3A+) template. You are only required to enter the link to the Java pack, though the options described above may also be configured. Your pack will then be queued for conversion by Github Actions. After conversion is complete, the Github Actions bot will reply to your issue with a link to download your converted pack and associated mappings file. Included in the bundle is a behavior pack and addon to view the models in single player, as well as a configuration file containing the paths to the models converted from the Java resource pack and their corresponding identifiers in the Bedrock resource pack.
96 |
97 | ## About
98 |
99 | **NOTICE:** Due to [MCPE-152191](https://bugs.mojang.com/browse/MCPE-152191), any blocks that are larger than 1.9 blocks will not load. This is only relavent to those using the preview pack to display converted models in single player.
100 |
101 | The script has been updated to handle parent models and 2D items. It will generate multiple sprite sheets for 3D models without repeating the inclusion of any given texture. 2D item textures will be copied over individually. Note that sprites for 3D items must be added manually.
102 |
103 | Your script and resource pack zip file must be in the same directory. Ensure that this zip file is properly setup. It should not have a root directory. Your resource pack must also be formatted correctly, to vanilla specifications. By default, this script will download the default assets in order to generate texture atlases in cases in which you have utilized those. If you wish to use different default assets, you may specify this at the beginning. The default pack will then be downloaded after your specified assets, with your specified assets taking precedence. As long as you provide valid JSON, the script should output something you can use.
104 |
105 | You may also specify an input bedrock pack to merge with the output assets produced by the converter. This should be in the same directory as the script and your input Java pack. Like the Java pack, ensure that it is compressed with no root folder. When prompted, type the file name of the input file, such as `example_rp.mcpack`. Merging of behavior packs is not currently supported.
106 |
107 | The packs generated by this script can currently only be used in Bedrock Edition 1.16.210.59 and above. Please be sure to enable the experimental setting "Holiday Creator Features" on world generation. You'll probably also want to be in creative mode as that will be the only way to give yourself the blocks generated by the script. Here are the commands to obtain one of the items or place them in your head slot:
108 | ```
109 | /give @p geysercmd:gmdl_xxxxxxx
110 | /replaceitem entity @p slot.armor.head 0 geysercmd:gmdl_xxxxxxx
111 | ```
112 | The `xxxxxxx` term corresponds to the short hash assigned to the model. These are written to config.json, which can be found in the target directory, along with packaged and non-packaged versions of the output assets. This will specify the corresponding item and nbt for each input predicate. The short hash is constructed by combining the predicate entry's item, custom model data, damage, and damaged predicates, taking the md5 hash of this string, and keeping only the first 7 characters. As a result, this hash value will remain the same across conversions.
113 |
114 | Also note that this script requires:
115 | - [jq](https://stedolan.github.io/jq/download/) (1.6+)
116 | - [sponge](https://joeyh.name/code/moreutils/)
117 | - [imagemagick](https://imagemagick.org/script/download.php) (6+)
118 | - [nodejs](https://nodejs.org/en/)
119 | - [spritesheet-js](https://www.npmjs.com/package/spritesheet-js)
120 |
121 | It will exit if you fail to meet these dependencies. While the ultimate intention here is to import these via Geyser, the script currently generates a behavior pack so that you may view your converted models in Bedrock Edition. It also generates a mappings file compliant with Geyser's custom item mappings system.
122 |
123 | Should you have any complaints about getting this to run because you "only use windows", do note that I was able to run this perfectly fine on a Mac running Parallels to run Windows to run WSL to run Ubuntu 20. Therefore, I am sure it is perfectly possible for you to get this working, regardless of your OS. I will gladly take such criticism only if you are willing to help develop this into a proper cross platform program.
124 |
125 | ## Dependency Installation
126 |
127 | ### Debian, Ubuntu, & Mint
128 | ```sh
129 | sudo apt-get install moreutils jq imagemagick unzip zip nodejs uuid-runtime
130 | npm i -g spritesheet-js
131 | ```
132 |
133 | ### MacOS
134 | ```sh
135 | brew install moreutils jq imagemagick unzip zip nodejs uuid-runtime
136 | npm i -g spritesheet-js
137 | ```
138 |
139 | ### RHEL, Fedora, & Centos
140 | ```sh
141 | sudo yum install moreutils jq imagemagick unzip zip nodejs uuid-runtime
142 | npm i -g spritesheet-js
143 | ```
144 |
145 | ### Arch Linux
146 | ```sh
147 | sudo pacman -S moreutils jq imagemagick unzip zip nodejs uuid-runtime
148 | npm i -g spritesheet-js
149 | ```
150 |
151 | ### Windows
152 | Impossible; consider [WSL](https://docs.microsoft.com/en-us/windows/wsl/install-win10).
153 |
154 | #### Special Notes for WSL (Ubuntu)
155 |
156 | In general, packages on WSL seem to be a little wonky, and sometimes jq-1.5 will be installed, which will not work. To manually install jq-1.6 on WSL, at least for Ubuntu:
157 | ```sh
158 | wget https://github.com/stedolan/jq/releases/download/jq-1.6/jq-linux64 && sudo chmod +x jq-linux64 && sudo mv jq-linux64 /usr/bin/jq
159 | ```
160 |
161 | If you install spritesheet-js globally, but the script fails due to missing the dependency, ensure that the folder containing your global node modules is added to your path. If, after installing, `which spritesheet-js` returns no output, you may add global node modules to your path by:
162 | ```sh
163 | echo "export PATH=$PATH:$(npm config --global get prefix)/bin" >> ~/.bashrc && source ~/.bashrc
164 | ```
165 |
--------------------------------------------------------------------------------
/armor.py:
--------------------------------------------------------------------------------
1 | import os
2 | import json
3 | import shutil
4 | import glob
5 | from jproperties import Properties
6 |
7 | optifine = Properties()
8 | i = 0
9 | item_type = ["leather_helmet", "leather_chestplate", "leather_leggings", "leather_boots"]
10 |
11 | def write_armor(file, gmdl, layer, i):
12 | if i == 0:
13 | type = "helmet"
14 | elif i == 1:
15 | type = "chestplate"
16 | elif i == 2:
17 | type = "leggings"
18 | elif i == 3:
19 | type = "boots"
20 | ajson = {
21 | "format_version": "1.10.0",
22 | "minecraft:attachable": {
23 | "description": {
24 | "identifier": f"geyser_custom:{gmdl}.player",
25 | "item": { f"geyser_custom:{gmdl}": "query.owner_identifier == 'minecraft:player'" },
26 | "materials": {
27 | "default": "armor_leather",
28 | "enchanted": "armor_leather_enchanted"
29 | },
30 | "textures": {
31 | "default": f"textures/armor_layer/{layer}",
32 | "enchanted": "textures/misc/enchanted_item_glint"
33 | },
34 | "geometry": {
35 | "default": f"geometry.player.armor.{type}"
36 | },
37 | "scripts": {
38 | "parent_setup": "variable.helmet_layer_visible = 0.0;"
39 | },
40 | "render_controllers": ["controller.render.armor"]
41 | }
42 | }
43 | }
44 | with open(file, "w") as f:
45 | f.write(json.dumps(ajson))
46 |
47 | while i < 4:
48 | try:
49 | with open(f"pack/assets/minecraft/models/item/{item_type[i]}.json", "r") as f:
50 | data = json.load(f)
51 | except:
52 | i += 1
53 | continue
54 | for override in data["overrides"]:
55 | custom_model_data = override["predicate"]["custom_model_data"]
56 | model = override["model"]
57 | namespace = model.split(":")[0]
58 | item = model.split("/")[-1]
59 | if item in item_type:
60 | continue
61 | else:
62 | try:
63 | path = model.split(":")[1]
64 | optifine_file = f"{namespace}_{item}"
65 | with open(f"pack/assets/minecraft/optifine/cit/ia_generated_armors/{optifine_file}.properties", "rb") as f:
66 | optifine.load(f)
67 | if i == 2:
68 | layer = optifine.get("texture.leather_layer_2").data.split(".")[0]
69 | else:
70 | layer = optifine.get("texture.leather_layer_1").data.split(".")[0]
71 | if not os.path.exists("staging/target/rp/textures/armor_layer"):
72 | os.mkdir("staging/target/rp/textures/armor_layer")
73 | if not os.path.exists(f"staging/target/rp/textures/armor_layer/{layer}.png"):
74 | shutil.copy(f"pack/assets/minecraft/optifine/cit/ia_generated_armors/{layer}.png", "staging/target/rp/textures/armor_layer")
75 | with open(f"pack/assets/{namespace}/models/{path}.json", "r") as f :
76 | texture = json.load(f)["textures"]["layer1"]
77 | tpath = texture.split(":")[1]
78 | try:
79 | shutil.copy(f"pack/assets/{namespace}/textures/{tpath}.png", f"staging/target/rp/textures/{namespace}/{path}.png")
80 | except Exception as e:
81 | print(e)
82 | afile = glob.glob(f"staging/target/rp/attachables/{namespace}/{path}*.json")
83 | with open(afile[0], "r") as f:
84 | da = json.load(f)["minecraft:attachable"]
85 | gmdl = da["description"]["identifier"].split(":")[1]
86 | pfile = afile[0].replace(".json", ".player.json")
87 | write_armor(pfile, gmdl, layer, i)
88 | except Exception as e:
89 | print(e)
90 | print("Item not found of ...")
91 | continue
92 | i += 1
93 |
--------------------------------------------------------------------------------
/blank256.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AZPixel-Team/Java2Bedrock/ffe3f128db5ef251b267bd5ae7f9ff7f4315fd3e/blank256.png
--------------------------------------------------------------------------------
/blocks.py:
--------------------------------------------------------------------------------
1 | import json
2 | import glob
3 | import os
4 | import blocks_util
5 |
6 | #Not Support For Fire
7 | files = glob.glob("pack/assets/minecraft/blockstates/*.json")
8 | if files != []:
9 | blocks_util.write_animated_cube()
10 | blocks_util.write_geometry_cube()
11 | for file in files:
12 | file = file.replace("\\", "/")
13 | block = (file.split("/")[-1]).replace(".json", "")
14 | if (block == "fire"): continue
15 | block_material = os.getenv("BLOCK_MATERIAL")
16 | blocks_util.write_mapping_block(block)
17 | with open(file, "r") as f:
18 | data = json.load(f)["variants"]
19 | for k, v in data.items():
20 | if not("block/original" in v["model"] or "block/tripwire_attached_n" in v["model"]):
21 | print(v["model"])
22 | am = blocks_util.get_am_file(v["model"])
23 | if am == None: continue
24 | with open(am, "r") as f:
25 | data_am = json.load(f)
26 | gmdl = data_am["minecraft:attachable"]["description"]["identifier"].split(":")[1]
27 | geometry = blocks_util.get_geometry_block(v["model"])
28 | texture = blocks_util.create_terrain_texture(gmdl, data_am["minecraft:attachable"]["description"]["textures"]["default"])
29 | if geometry == "geometry.cube":
30 | with open(am, "w") as f:
31 | data_am["minecraft:attachable"]["description"]["geometry"]["default"] = "geometry.cube"
32 | data_am["minecraft:attachable"]["description"]["animations"] = {"thirdperson_main_hand":"animation.geo_cube.thirdperson_main_hand","thirdperson_off_hand":"animation.geo_cube.thirdperson_off_hand","thirdperson_head":"animation.geo_cube.head","firstperson_main_hand":"animation.geo_cube.firstperson_main_hand","firstperson_off_hand":"animation.geo_cube.firstperson_off_hand","firstperson_head":"animation.geyser_custom.disable"}
33 | json.dump(data_am, f)
34 | if block == "tripwire":
35 | sstate = k.split(",")
36 | k = f"{sstate[0]},{sstate[4]},{sstate[1]},{sstate[2]},{sstate[6]},{sstate[3]},{sstate[5]}"
37 | blocks_util.regsister_block(block, gmdl, k, texture, block_material, geometry)
38 |
--------------------------------------------------------------------------------
/blocks_util.py:
--------------------------------------------------------------------------------
1 | import json
2 | import glob
3 | import os
4 |
5 | def get_am_file(model):
6 | namespace = model.split(":")[0]
7 | path = model.split(":")[1]
8 | files = glob.glob(f"staging/target/rp/attachables/{namespace}/{path}*.json")
9 | for fa in files:
10 | if f"{path.split('/')[-1]}." in fa:
11 | return fa
12 | def write_animated_cube():
13 | #Created by: ofunny, contact: https://ofunny.world/, repository: https://github.com/ofunny/ofunnysBedrockExamples/
14 | #file from ofunny
15 | data = {"format_version":"1.8.0","animations":{"animation.geo_cube.thirdperson_main_hand":{"loop":True,"bones":{"block":{"rotation":[-20,145,-10],"position":[0,14,-6],"scale":[0.375,0.375,0.375]}}},"animation.geo_cube.thirdperson_off_hand":{"loop":True,"bones":{"block":{"rotation":[20,40,20],"position":[0,13,-6],"scale":[0.375,0.375,0.375]}}},"animation.geo_cube.head":{"loop":True,"bones":{"block":{"position":[0,19.9,0],"scale":0.625}}},"animation.geo_cube.firstperson_main_hand":{"loop":True,"bones":{"block":{"rotation":[140,45,15],"position":[-1,17,0],"scale":[0.52,0.52,0.52]}}},"animation.geo_cube.firstperson_off_hand":{"loop":True,"bones":{"block":{"rotation":[-5,45,-5],"position":[-17.5,17.5,15],"scale":[0.52,0.52,0.52]}}}}}
16 | with open("staging/target/rp/animations/cube.json", "w") as f:
17 | json.dump(data, f)
18 | def write_geometry_cube():
19 | #Created by: ofunny, contact: https://ofunny.world/, repository: https://github.com/ofunny/ofunnysBedrockExamples/
20 | #file from ofunny
21 | data = {"format_version":"1.19.40","minecraft:geometry":[{"description":{"identifier":"geometry.cube","texture_width":16,"texture_height":16,"visible_bounds_width":2,"visible_bounds_height":2.5,"visible_bounds_offset":[0,0.75,0]},"bones":[{"name":"block","binding":"c.item_slot == 'head' ? 'head' : q.item_slot_to_bone_name(c.item_slot)","pivot":[0,8,0],"cubes":[{"origin":[-8,0,-8],"size":[16,16,16],"uv":{"north":{"uv":[0,0],"uv_size":[16,16]},"east":{"uv":[0,0],"uv_size":[16,16]},"south":{"uv":[0,0],"uv_size":[16,16]},"west":{"uv":[0,0],"uv_size":[16,16]},"up":{"uv":[16,16],"uv_size":[-16,-16]},"down":{"uv":[16,16],"uv_size":[-16,-16]}}}]}]}]}
22 | with open("staging/target/rp/models/blocks/cube.json", "w") as f:
23 | json.dump(data, f)
24 | def write_mapping_block(block: str):
25 | #Created by: ofunny, contact: https://ofunny.world/, repository: https://github.com/ofunny/ofunnysBedrockExamples/
26 | #file from ofunny
27 | data = {"format_version":1,"blocks":{f"minecraft:{block}":{"name":f"{block}","geometry":"geometry.cube","included_in_creative_inventory":False,"only_override_states":True,"place_air":True,"state_overrides":{}}}}
28 | with open(f"staging/target/geyser_block_{block}_mappings.json", "w") as f:
29 | json.dump(data, f, indent=4)
30 | def regsister_block(block: str, gmdl: str, state: str, texture: str, block_material: str, geometry: str):
31 | with open(f"staging/target/geyser_block_{block}_mappings.json", "r") as f:
32 | data = json.load(f)
33 | with open(f"staging/target/geyser_block_{block}_mappings.json", "w") as f:
34 | data["blocks"][f"minecraft:{block}"]["state_overrides"][state] = {"name":f"block_{gmdl}","display_name":f"block_{gmdl}","geometry":geometry,"material_instances":{"*":{"texture":texture,"render_method":block_material,"face_dimming":True,"ambient_occlusion":True}}}
35 | json.dump(data, f, indent=4)
36 | def create_terrain_texture(gmdl: str, texture_file: str):
37 | with open("staging/target/rp/textures/terrain_texture.json", "r") as f:
38 | data = json.load(f)
39 | with open("staging/target/rp/textures/terrain_texture.json", "w") as f:
40 | data["texture_data"][f"block_{gmdl}"] = {"textures": texture_file}
41 | json.dump(data, f, indent=4)
42 | return f"block_{gmdl}"
43 | def get_geometry_block(model: str):
44 | namespace = model.split(":")[0]
45 | path = model.split(":")[1]
46 | geometry_file = glob.glob(f"staging/target/rp/models/blocks/{namespace}/{path}.json")[0]
47 | if geometry_file != None:
48 | with open(geometry_file, "r") as f:
49 | geo_data = f.read()
50 | if geo_data == "":
51 | os.remove(geometry_file)
52 | return "geometry.cube"
53 | else:
54 | data = json.loads(geo_data)
55 | return data["minecraft:geometry"][0]["description"]["identifier"]
56 | else: return "geometry.cube"
57 |
--------------------------------------------------------------------------------
/bow.py:
--------------------------------------------------------------------------------
1 | import os
2 | import json
3 | import glob
4 | from bow_util import Bow_Util
5 |
6 | if os.path.exists("pack/assets/minecraft/models/item/bow.json"):
7 | with open("pack/assets/minecraft/models/item/bow.json") as f:
8 | data = json.load(f)
9 | predicate = [d["predicate"] for d in data["overrides"]]
10 | model = [d["model"] for d in data["overrides"]]
11 | for m, p in zip(model, predicate):
12 | if m in ["item/bow", "item/bow_pulling_0", "item/bow_pulling_1", "item/bow_pulling_2"] or not "custom_model_data" in p:
13 | continue
14 | i = 0
15 | try:
16 | if p["pulling"] == 1:
17 | i = 1
18 | if p["pull"] <= 0.65:
19 | i = 2
20 | elif p["pull"] > 0.65:
21 | i = 3
22 | except:
23 | pass
24 | fpath = (f"cache/bow/{p['custom_model_data']}.json")
25 | if not os.path.exists(fpath):
26 | os.makedirs(os.path.dirname(fpath), exist_ok=True)
27 | with open(fpath, "w") as f:
28 | f.write("{}")
29 | with open(fpath, "r") as f:
30 | data = json.load(f)
31 | with open(fpath, "w") as f:
32 | if "check" in data:
33 | data["check"] = data["check"] + 1
34 | else:
35 | data["check"] = 1
36 | data[f'texture_{i}'] = m
37 | json.dump(data, f, indent=2)
38 |
39 | files = glob.glob("cache/bow/*.json")
40 | Bow_Util.animation()
41 | Bow_Util.rendercontrollers()
42 | gmdllist = []
43 | for file in files:
44 | try:
45 | with open(file, "r") as f:
46 | data = json.load(f)
47 | if data["check"] == 4:
48 | textures = []
49 | geometry = []
50 | for i in range(4):
51 | namespace = data[f"texture_{i}"].split(":")[0]
52 | path = data[f"texture_{i}"].split(":")[1]
53 | files = glob.glob(f"staging/target/rp/attachables/{namespace}/{path}*.json")
54 | for fa in files:
55 | if f"{path.split('/')[-1]}." in fa:
56 | break
57 | with open(fa, "r") as f:
58 | dataA = json.load(f)
59 | f.close()
60 | textures.append(dataA["minecraft:attachable"]["description"]["textures"]["default"])
61 | is2Dbow = Bow_Util.is2Dbow(glob.glob(f"staging/target/rp/models/blocks/{namespace}/{path}.json")[0])
62 | if is2Dbow:
63 | if i == 0: geometry.append("geometry.bow_standby")
64 | else: geometry.append(f"geometry.bow_pulling_{i-1}")
65 | else: geometry.append(dataA["minecraft:attachable"]["description"]["geometry"]["default"])
66 | if i == 0:
67 | if is2Dbow:
68 | animate = [{"wield":"c.is_first_person"},{"third_person":"!c.is_first_person"},{"wield_first_person_pull":"query.main_hand_item_use_duration > 0.0f && c.is_first_person"}]
69 | pre_animation = ["v.charge_amount = math.clamp((q.main_hand_item_max_duration - (q.main_hand_item_use_duration - q.frame_alpha + 1.0)) / 10.0, 0.0, 1.0f);","v.total_frames = 3;","v.step = v.total_frames / 60;","v.frame = query.is_using_item ? math.clamp((v.frame ?? 0) + v.step, 1, v.total_frames) : 0;"]
70 | else:
71 | animate = [{"thirdperson_main_hand":"v.main_hand && !c.is_first_person"},{"thirdperson_off_hand":"v.off_hand && !c.is_first_person"},{"thirdperson_head":"v.head && !c.is_first_person"},{"firstperson_main_hand":"v.main_hand && c.is_first_person"},{"firstperson_off_hand":"v.off_hand && c.is_first_person"},{"firstperson_head":"c.is_first_person && v.head"}]
72 | pre_animation = ["v.charge_amount = math.clamp((q.main_hand_item_max_duration - (q.main_hand_item_use_duration - q.frame_alpha + 1.0)) / 10.0, 0.0, 1.0f);","v.total_frames = 3;","v.step = v.total_frames / 60;","v.frame = query.is_using_item ? math.clamp((v.frame ?? 0) + v.step, 1, v.total_frames) : 0;","v.main_hand = c.item_slot == 'main_hand';","v.off_hand = c.item_slot == 'off_hand';","v.head = c.item_slot == 'head';"]
73 | mfile = fa
74 | mdefault = dataA["minecraft:attachable"]["description"]["materials"]["default"]
75 | menchanted = dataA["minecraft:attachable"]["description"]["materials"]["enchanted"]
76 | gmdl = dataA["minecraft:attachable"]["description"]["identifier"].split(":")[1]
77 | animations = dataA["minecraft:attachable"]["description"]["animations"]
78 | animations["wield"] = "animation.player.bow_custom.first_person"
79 | animations["third_person"] = "animation.player.bow_custom"
80 | animations["wield_first_person_pull"] = "animation.bow.wield_first_person_pull"
81 | gmdllist.append(f"geyser_custom:{gmdl}")
82 | Bow_Util.item_texture(gmdl, textures[0])
83 | else:
84 | os.remove(fa)
85 | Bow_Util.write(mfile, gmdl, textures, geometry, mdefault, menchanted, animations, animate, pre_animation)
86 | except Exception as e:
87 | print(e)
88 | Bow_Util.acontroller(gmdllist)
89 |
--------------------------------------------------------------------------------
/bow_util.py:
--------------------------------------------------------------------------------
1 | import json
2 | import os
3 |
4 | class Bow_Util:
5 | def write(file, gmdl, textures, geometry, mdefault, menchanted, animations, animate, pre_animation):
6 | with open(file, "w") as f:
7 | data = {
8 | "format_version": "1.10.0",
9 | "minecraft:attachable": {
10 | "description": {
11 | "identifier": f"geyser_custom:{gmdl}",
12 | "materials": {
13 | "default": f"{mdefault}",
14 | "enchanted": f"{menchanted}"
15 | },
16 | "textures": {
17 | "default": f"{textures[0]}",
18 | "bow_pulling_0": f"{textures[1]}",
19 | "bow_pulling_1": f"{textures[2]}",
20 | "bow_pulling_2": f"{textures[3]}",
21 | "enchanted": "textures/misc/enchanted_item_glint"
22 | },
23 | "geometry": {
24 | "default": f"{geometry[0]}",
25 | "bow_pulling_0": f"{geometry[1]}",
26 | "bow_pulling_1": f"{geometry[2]}",
27 | "bow_pulling_2": f"{geometry[3]}"
28 | },
29 | "animations": animations,
30 | "scripts": {
31 | "pre_animation": pre_animation,
32 | "animate": animate,
33 | },
34 | "render_controllers": ["controller.render.bow_custom"]
35 | }
36 | }
37 | }
38 | json.dump(data, f)
39 | def rendercontrollers():
40 | file = "staging/target/rp/render_controllers/bow_custom.render_controllers.json"
41 | os.makedirs(os.path.dirname(file), exist_ok=True)
42 | with open(file, "w") as f:
43 | data = {
44 | "format_version": "1.10",
45 | "render_controllers": {
46 | "controller.render.bow_custom": {
47 | "arrays": {
48 | "textures": {
49 | "array.bow_texture_frames": [
50 | "texture.default",
51 | "texture.bow_pulling_0",
52 | "texture.bow_pulling_1",
53 | "texture.bow_pulling_2"
54 | ]
55 | },
56 | "geometries": {
57 | "array.bow_geo_frames": [
58 | "geometry.default",
59 | "geometry.bow_pulling_0",
60 | "geometry.bow_pulling_1",
61 | "geometry.bow_pulling_2"
62 | ]
63 | }
64 | },
65 | "geometry": "array.bow_geo_frames[math.floor(v.frame)]",
66 | "materials": [ { "*": "variable.is_enchanted ? material.enchanted : material.default" } ],
67 | "textures": [ "array.bow_texture_frames[math.floor(v.frame)]", "texture.enchanted" ]
68 | }
69 | }
70 | }
71 | json.dump(data, f)
72 | def item_texture(gmdl, texture):
73 | with open("staging/target/rp/textures/item_texture.json", "r") as f:
74 | data = json.load(f)
75 | if gmdl in data["texture_data"]:
76 | with open("staging/target/rp/textures/item_texture.json", "w") as f:
77 | data["texture_data"][gmdl]["textures"] = texture
78 | json.dump(data,f, indent=4)
79 | def animation():
80 | with open("staging/target/rp/animations/bow_custom.animation.json","w") as f:
81 | data = {
82 | "format_version": "1.8.0",
83 | "animations": {
84 | "animation.player.bow_custom.first_person": {
85 | "loop": True,
86 | "bones": {
87 | "rightitem": {
88 | "rotation": [ "c.is_first_person ? 30 : 0", "c.is_first_person ? -120 : 0", "c.is_first_person ? -60 : 0" ],
89 | "position": [ " c.is_first_person ? -6 : 0", "c.is_first_person ? -5 : 0", "c.is_first_person ? -2 : 0" ]
90 | }
91 | }
92 | },
93 | "animation.player.bow_custom": {
94 | "loop": True,
95 | "bones": {
96 | "rightitem": {
97 | "position": [ 0.5, -2, 0 ]
98 | }
99 | }
100 | }
101 | }
102 | }
103 | json.dump(data,f)
104 | def is2Dbow(file):
105 | with open(file, "r") as f:
106 | try:
107 | modelbone = json.load(f)["minecraft:geometry"][0]["bones"]
108 | except:
109 | modelbone = []
110 | if modelbone == [{"name":"geyser_custom","binding":"c.item_slot == 'head' ? 'head' : q.item_slot_to_bone_name(c.item_slot)","pivot":[0,8,0]},{"name":"geyser_custom_x","parent":"geyser_custom","pivot":[0,8,0]},{"name":"geyser_custom_y","parent":"geyser_custom_x","pivot":[0,8,0]},{"name":"geyser_custom_z","parent":"geyser_custom_y","pivot":[0,8,0],"texture_meshes":[{"texture":"default","position":[0,8,0],"rotation":[90,0,-180],"local_pivot":[8,0.5,8]}]}]:
111 | return True
112 | else:
113 | return False
114 | def acontroller(gmdllist):
115 | strlist = str(gmdllist)
116 | strlist = strlist.replace("[", "").replace("]", "")
117 | file = "staging/target/rp/animation_controllers/player.animation_controllers.json"
118 | os.makedirs(os.path.dirname(file), exist_ok=True)
119 | with open(file, "w") as f:
120 | data = {
121 | "format_version" : "1.10.0",
122 | "animation_controllers" : {
123 | "controller.animation.player.root" : {
124 | "initial_state" : "first_person",
125 | "states" : {
126 | "first_person" : {
127 | "animations" : [
128 | {
129 | "first_person_swap_item": "!query.blocking"
130 | },
131 | {
132 | "first_person_shield_block": "query.blocking"
133 | },
134 | {
135 | "first_person_attack_controller" : "variable.attack_time > 0.0f && query.get_equipped_item_name != 'filled_map'"
136 | },
137 | "first_person_base_pose",
138 | {
139 | "first_person_empty_hand" : "query.get_equipped_item_name(0, 1) != 'filled_map'"
140 | },
141 | {
142 | "first_person_walk" : "variable.bob_animation"
143 | },
144 | {
145 | "first_person_map_controller" : "(query.get_equipped_item_name(0, 1) == 'filled_map' || query.get_equipped_item_name('off_hand') == 'filled_map')"
146 | },
147 | {
148 | "first_person_crossbow_equipped": "query.get_equipped_item_name == 'crossbow' && (variable.item_use_normalized > 0 && variable.item_use_normalized < 1.0)"
149 | },
150 | {
151 | "first_person_breathing_bob": "variable.attack_time <= 0.0"
152 | }
153 | ],
154 | "transitions" : [
155 | {
156 | "paperdoll" : "variable.is_paperdoll"
157 | },
158 | {
159 | "map_player" : "variable.map_face_icon"
160 | },
161 | {
162 | "third_person" : "!variable.is_first_person"
163 | }
164 | ]
165 | },
166 | "map_player" : {
167 | "transitions" : [
168 | {
169 | "paperdoll" : "variable.is_paperdoll"
170 | },
171 | {
172 | "first_person" : "variable.is_first_person"
173 | },
174 | {
175 | "third_person" : "!variable.map_face_icon && !variable.is_first_person"
176 | }
177 | ]
178 | },
179 | "paperdoll" : {
180 | "animations" : [ "humanoid_base_pose", "look_at_target_ui", "move.arms", "move.legs", "cape" ],
181 | "transitions" : [
182 | {
183 | "first_person" : "!variable.is_paperdoll && variable.is_first_person"
184 | },
185 | {
186 | "map_player" : "variable.map_face_icon"
187 | },
188 | {
189 | "third_person" : "!variable.is_paperdoll && !variable.is_first_person"
190 | }
191 | ]
192 | },
193 | "third_person" : {
194 | "animations" : [
195 | "humanoid_base_pose",
196 | {
197 | "look_at_target" : "!query.is_sleeping && !query.is_emoting"
198 | },
199 | "move.arms",
200 | "move.legs",
201 | "cape",
202 | {
203 | "riding.arms" : "query.is_riding"
204 | },
205 | {
206 | "riding.legs" : "query.is_riding"
207 | },
208 | "holding",
209 | {
210 | "brandish_spear" : "variable.is_brandishing_spear"
211 | },
212 | {
213 | "holding_spyglass": "variable.is_holding_spyglass"
214 | },
215 | {
216 | "charging" : "query.is_charging"
217 | },
218 | {
219 | "sneaking" : "query.is_sneaking && !query.is_sleeping"
220 | },
221 | {
222 | "bob": "!variable.is_holding_spyglass && !variable.is_tooting_goat_horn"
223 | },
224 | {
225 | "damage_nearby_mobs" : "variable.damage_nearby_mobs"
226 | },
227 | {
228 | "swimming" : "variable.swim_amount > 0.0"
229 | },
230 | {
231 | "swimming.legs" : "variable.swim_amount > 0.0"
232 | },
233 | {
234 | "use_item_progress": f"( variable.use_item_interval_progress > 0.0 ) || ( variable.use_item_startup_progress > 0.0 ) && !variable.is_brandishing_spear && !variable.is_holding_spyglass && !variable.is_tooting_goat_horn && !query.is_item_name_any('slot.weapon.mainhand', 'minecraft:bow', {strlist})"
235 | },
236 | {
237 | "sleeping" : "query.is_sleeping && query.is_alive"
238 | },
239 | {
240 | "attack.positions" : "variable.attack_time >= 0.0"
241 | },
242 | {
243 | "attack.rotations" : "variable.attack_time >= 0.0"
244 | },
245 | {
246 | "shield_block_main_hand" : "query.blocking && query.get_equipped_item_name('off_hand') != 'shield' && query.get_equipped_item_name == 'shield'"
247 | },
248 | {
249 | "shield_block_off_hand" : "query.blocking && query.get_equipped_item_name('off_hand') == 'shield'"
250 | },
251 | {
252 | "crossbow_controller" : "query.get_equipped_item_name == 'crossbow'"
253 | },
254 | {
255 | "third_person_bow_equipped" : f"query.is_item_name_any('slot.weapon.mainhand', 0, 'minecraft:bow', {strlist}) && (q.is_using_item)"
256 | },
257 | {
258 | "tooting_goat_horn": "variable.is_tooting_goat_horn"
259 | }
260 | ],
261 | "transitions" : [
262 | {
263 | "paperdoll" : "variable.is_paperdoll"
264 | },
265 | {
266 | "first_person" : "variable.is_first_person"
267 | },
268 | {
269 | "map_player" : "variable.map_face_icon"
270 | }
271 | ]
272 | }
273 | }
274 | }
275 | }
276 | }
277 | json.dump(data, f)
--------------------------------------------------------------------------------
/converter.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | : ${1?'Please specify an input resource pack in the same directory as the script (e.g. ./converter.sh MyResourcePack.zip)'}
3 |
4 | # define color placeholders
5 | C_RED='\e[31m'
6 | C_GREEN='\e[32m'
7 | C_YELLOW='\e[33m'
8 | C_BLUE='\e[36m'
9 | C_GRAY='\e[37m'
10 | C_CLOSE='\e[m'
11 |
12 | # status message function depending on message type
13 | # usage: status
14 | status_message () {
15 | case $1 in
16 | "completion")
17 | printf "${C_GREEN}[+] ${C_GRAY}${2}${C_CLOSE}\n"
18 | ;;
19 | "process")
20 | printf "${C_YELLOW}[•] ${C_GRAY}${2}${C_CLOSE}\n"
21 | ;;
22 | "critical")
23 | printf "${C_RED}[X] ${C_GRAY}${2}${C_CLOSE}\n"
24 | ;;
25 | "error")
26 | printf "${C_RED}[ERROR] ${C_GRAY}${2}${C_CLOSE}\n"
27 | ;;
28 | "info")
29 | printf "${C_BLUE}${2}${C_CLOSE}\n"
30 | ;;
31 | "plain")
32 | printf "${C_GRAY}${2}${C_CLOSE}\n"
33 | ;;
34 | esac
35 | }
36 |
37 | # dependency check function ensures important required programs are installed
38 | # usage: dependency_check
39 | dependency_check () {
40 | if command ${3} 2>/dev/null | grep -q "${4}"; then
41 | status_message completion "Dependency ${1} satisfied"
42 | else
43 | status_message error "Dependency ${1} must be installed to proceed\nSee ${2}\nExiting script..."
44 | exit 1
45 | fi
46 | }
47 |
48 | # user input function to prompt user for info when needed
49 | # usage: user_input
50 | user_input () {
51 | if [[ -z "${!1}" ]]; then
52 | status_message plain "${2} ${C_YELLOW}[${3}]\n"
53 | read -p "${4}: " ${1}
54 | echo
55 | fi
56 | }
57 |
58 | # wait for jobs function prevents the next job from starting until there is a free CPU thread
59 | wait_for_jobs () {
60 | while test $(jobs -p | wc -w) -ge "$((2*$(nproc)))"; do wait -n; done
61 | }
62 |
63 | # ensure input pack exists
64 | if ! test -f "${1}"; then
65 | status_message error "Input resource pack ${1} is not in this directory"
66 | exit 1
67 | else
68 | status_message process "Input file ${1} detected"
69 | fi
70 |
71 | # get user defined start flags
72 | while getopts w:m:a:b:f:v:r:s:u: flag "${@:2}"
73 | do
74 | case "${flag}" in
75 | w) warn=${OPTARG};;
76 | m) merge_input=${OPTARG};;
77 | a) attachable_material=${OPTARG};;
78 | b) block_material=${OPTARG};;
79 | f) fallback_pack=${OPTARG};;
80 | v) default_asset_version=${OPTARG};;
81 | r) rename_model_files=${OPTARG};;
82 | s) save_scratch=${OPTARG};;
83 | u) disable_ulimit=${OPTARG};;
84 | esac
85 | done
86 |
87 | if [[ ${disable_ulimit} == "true" ]]
88 | then
89 | getconf ARG_MAX
90 | ulimit -s unlimited
91 | status_message info "Changed ulimit settings for script:"
92 | ulimit -a
93 | echo | xargs --show-limits
94 | getconf ARG_MAX
95 |
96 | fi
97 |
98 | # warn user about limitations of the script
99 | printf '\e[1;31m%-6s\e[m\n' "
100 | ███████████████████████████████████████████████████████████████████████████████
101 | ████████████████████████ # # W A R N I N G # # ████████████████████████
102 | ███████████████████████████████████████████████████████████████████████████████
103 | ███ This script has been provided as is. If your resource pack does not ███
104 | ███ entirely conform the vanilla resource specification, including but not ███
105 | ███ limited to, missing textures, improper parenting, improperly defined ███
106 | ███ predicates, and malformed JSON files, among other problems, there is a ███
107 | ███ strong possibility this script will fail. Please remedy any potential ███
108 | ███ resource pack formatting errors before attempting to make use of this ███
109 | ███ converter. You have been warned. ███
110 | ███████████████████████████████████████████████████████████████████████████████
111 | ███████████████████████████████████████████████████████████████████████████████
112 | ███████████████████████████████████████████████████████████████████████████████
113 | "
114 |
115 | if [[ ${warn} != "false" ]]; then
116 | read -p $'\e[37mTo acknowledge and continue, press enter. To exit, press Ctrl+C.:\e[0m
117 |
118 | '
119 | fi
120 |
121 | # ensure we have all the required dependencies
122 | dependency_check "jq" "https://stedolan.github.io/jq/download/" "jq --version" "1.6\|1.7"
123 | dependency_check "sponge" "https://joeyh.name/code/moreutils/" "-v sponge" ""
124 | dependency_check "imagemagick" "https://imagemagick.org/script/download.php" "convert --version" ""
125 | dependency_check "spritesheet-js" "https://www.npmjs.com/package/spritesheet-js" "-v spritesheet-js" ""
126 | status_message completion "All dependencies have been satisfied\n"
127 |
128 | # prompt user for initial configuration
129 | status_message info "This script will now ask some configuration questions. Default values are yellow. Simply press enter to use the defaults.\n"
130 | user_input merge_input "Is there an existing bedrock pack in this directory with which you would like the output merged? (e.g. input.mcpack)" "null" "Input pack to merge"
131 | user_input attachable_material "What material should we use for the attachables?" "entity_alphatest_one_sided" "Attachable material"
132 | user_input block_material "What material should we use for the blocks?" "alpha_test" "Block material"
133 | user_input fallback_pack "From what URL should we download the fallback resource pack? (must be a direct link)\n Use 'none' if default resources are not needed." "null" "Fallback pack URL"
134 |
135 | # print initial configuration for user and set default values if none were specified
136 | status_message plain "
137 | Generating Bedrock 3D resource pack with settings:
138 | ${C_GRAY}Input pack to merge: ${C_BLUE}${merge_input:=null}
139 | ${C_GRAY}Attachable material: ${C_BLUE}${attachable_material:=entity_alphatest_one_sided}
140 | ${C_GRAY}Block material: ${C_BLUE}${block_material:=alpha_test}
141 | ${C_GRAY}Fallback pack URL: ${C_BLUE}${fallback_pack:=null}
142 | "
143 |
144 | # decompress our input pack
145 | status_message process "Decompressing input pack"
146 | unzip -n -q "${1}"
147 | status_message completion "Input pack decompressed"
148 |
149 | # exit the script if no input pack exists by checking for a pack.mcmeta file
150 | if [ ! -f pack.mcmeta ]
151 | then
152 | status_message error "Invalid resource pack! The pack.mcmeta file does not exist. Is the resource pack improperly compressed in an enclosing folder?"
153 | exit 1
154 | fi
155 |
156 | # ensure the directory that would contain predicate definitions exists
157 | if test -d "./assets/minecraft/models/item"
158 | then
159 | status_message completion "Minecraft namespace item folder found."
160 | else
161 | # create our initial directories for bp & rp
162 | status_message process "Generating initial directory strucutre for our bedrock packs"
163 | mkdir -p ./target/rp/models/blocks && mkdir -p ./target/rp/textures && mkdir -p ./target/rp/attachables && mkdir -p ./target/rp/animations && mkdir -p ./target/bp/blocks && mkdir -p ./target/bp/items
164 |
165 | # copy over our pack.png if we have one
166 | if test -f "./pack.png"; then
167 | cp ./pack.png ./target/rp/pack_icon.png && cp ./pack.png ./target/bp/pack_icon.png
168 | fi
169 |
170 | # generate uuids for our manifests
171 | uuid1=($(uuidgen))
172 | uuid2=($(uuidgen))
173 | uuid3=($(uuidgen))
174 | uuid4=($(uuidgen))
175 |
176 | # get pack description if we have one
177 | pack_desc="$(jq -r '(.pack.description // "Geyser 3D Items Resource Pack")' ./pack.mcmeta)"
178 |
179 | # generate rp manifest.json
180 | status_message process "Generating resource pack manifest"
181 | jq -c --arg pack_desc "${pack_desc}" --arg uuid1 "${uuid1}" --arg uuid2 "${uuid2}" -n '
182 | {
183 | "format_version": 2,
184 | "header": {
185 | "description": "Adds 3D items for use with a Geyser proxy",
186 | "name": $pack_desc,
187 | "uuid": ($uuid1 | ascii_downcase),
188 | "version": [1, 0, 0],
189 | "min_engine_version": [1, 18, 3]
190 | },
191 | "modules": [
192 | {
193 | "description": "Adds 3D items for use with a Geyser proxy",
194 | "type": "resources",
195 | "uuid": ($uuid2 | ascii_downcase),
196 | "version": [1, 0, 0]
197 | }
198 | ]
199 | }
200 | ' | sponge ./target/rp/manifest.json
201 |
202 | # generate bp manifest.json
203 | status_message process "Generating behavior pack manifest"
204 | jq -c --arg pack_desc "${pack_desc}" --arg uuid1 "${uuid1}" --arg uuid3 "${uuid3}" --arg uuid4 "${uuid4}" -n '
205 | {
206 | "format_version": 2,
207 | "header": {
208 | "description": "Adds 3D items for use with a Geyser proxy",
209 | "name": $pack_desc,
210 | "uuid": ($uuid3 | ascii_downcase),
211 | "version": [1, 0, 0],
212 | "min_engine_version": [ 1, 18, 3]
213 | },
214 | "modules": [
215 | {
216 | "description": "Adds 3D items for use with a Geyser proxy",
217 | "type": "data",
218 | "uuid": ($uuid4 | ascii_downcase),
219 | "version": [1, 0, 0]
220 | }
221 | ],
222 | "dependencies": [
223 | {
224 | "uuid": ($uuid1 | ascii_downcase),
225 | "version": [1, 0, 0]
226 | }
227 | ]
228 | }
229 | ' | sponge ./target/bp/manifest.json
230 |
231 | # generate rp terrain_texture.json
232 | status_message process "Generating resource pack terrain texture definition"
233 | jq -nc '
234 | {
235 | "resource_pack_name": "geyser_custom",
236 | "texture_name": "atlas.terrain",
237 | "texture_data": {
238 | }
239 | }
240 | ' | sponge ./target/rp/textures/terrain_texture.json
241 |
242 | # generate rp item_texture.json
243 | status_message process "Generating resource pack item texture definition"
244 | jq -nc '
245 | {
246 | "resource_pack_name": "geyser_custom",
247 | "texture_name": "atlas.items",
248 | "texture_data": {}
249 | }
250 | ' | sponge ./target/rp/textures/item_texture.json
251 |
252 | status_message process "Generating resource pack disabling animation"
253 | # generate our disabling animation
254 | jq -nc '
255 | {
256 | "format_version": "1.8.0",
257 | "animations": {
258 | "animation.geyser_custom.disable": {
259 | "loop": true,
260 | "override_previous_animation": true,
261 | "bones": {
262 | "geyser_custom": {
263 | "scale": 0
264 | }
265 | }
266 | }
267 | }
268 | }
269 | ' | sponge ./target/rp/animations/animation.geyser_custom.disable.json
270 | cd -
271 | python manager.py
272 | cd ./staging
273 | # cleanup
274 | rm -rf assets && rm -f pack.mcmeta && rm -f pack.png
275 | if [[ ${save_scratch} != "true" ]]
276 | then
277 | rm -rf scratch_files
278 | status_message critical "Deleted scratch files"
279 | else
280 | cd ./scratch_files > /dev/null && zip -rq8 scratch_files.zip . -x "*/.*" && cd .. > /dev/null && mv ./scratch_files/scratch_files.zip ./target/scratch_files.zip
281 | status_message completion "Archived scratch files\n"
282 | fi
283 |
284 | status_message process "Compressing output packs"
285 | mkdir ./target/packaged
286 | cd ./target/rp > /dev/null && zip -rq8 geyser_resources_preview.mcpack . -x "*/.*" && cd ../.. > /dev/null && mv ./target/rp/geyser_resources_preview.mcpack ./target/packaged/geyser_resources_preview.mcpack
287 | cd ./target/bp > /dev/null && zip -rq8 geyser_behaviors_preview.mcpack . -x "*/.*" && cd ../.. > /dev/null && mv ./target/bp/geyser_behaviors_preview.mcpack ./target/packaged/geyser_behaviors_preview.mcpack
288 | cd ./target/packaged > /dev/null && zip -rq8 geyser_addon.mcaddon . -i "*_preview.mcpack" && cd ../.. > /dev/null
289 | jq 'delpaths([paths | select(.[-1] | strings | startswith("gmdl_atlas_"))])' ./target/rp/textures/terrain_texture.json | sponge ./target/rp/textures/terrain_texture.json
290 | cd ./target/rp > /dev/null && zip -rq8 geyser_resources.mcpack . -x "*/.*" && cd ../.. > /dev/null && mv ./target/rp/geyser_resources.mcpack ./target/packaged/geyser_resources.mcpack
291 | mkdir ./target/unpackaged
292 | mv ./target/rp ./target/unpackaged/rp && mv ./target/bp ./target/unpackaged/bp
293 |
294 | exit
295 | fi
296 |
297 | # Download geyser mappings
298 | status_message process "Downloading the latest geyser item mappings"
299 | mkdir -p ./scratch_files
300 | printf "\e[3m\e[37m"
301 | echo
302 | COLUMNS=$COLUMNS-1 curl --no-styled-output -#L -o scratch_files/item_mappings.json https://raw.githubusercontent.com/GeyserMC/mappings/master/items.json
303 | echo
304 | COLUMNS=$COLUMNS-1 curl --no-styled-output -#L -o scratch_files/item_texture.json https://raw.githubusercontent.com/Kas-tle/java2bedrockMappings/main/item_texture.json
305 | echo
306 | printf "${C_CLOSE}"
307 |
308 | # setup our initial config by iterating over all json files in the block and item folders
309 | # technically we only need to iterate over actual item models that contain overrides, but the constraints of bash would likely make such an approach less efficent
310 | status_message process "Iterating through all vanilla associated model JSONs to generate initial predicate config\nOn a large pack, this may take some time...\n"
311 |
312 | jq --slurpfile item_texture scratch_files/item_texture.json --slurpfile item_mappings scratch_files/item_mappings.json -n '
313 | [inputs | {(input_filename | sub("(.+)/(?.*?).json"; .itemname)): .overrides?[]?}] |
314 |
315 | def maxdur($input):
316 | ($item_mappings[] |
317 | [to_entries | map(.key as $key | .value | .java_identifer = $key) | .[] | select(.max_damage)]
318 | | map({(.java_identifer | split(":") | .[1]): (.max_damage)})
319 | | add
320 | | .[$input] // 1)
321 | ;
322 |
323 | def bedrocktexture($input):
324 | ($item_texture[] | .[$input] // {"icon": "camera", "frame": 0})
325 | ;
326 |
327 | def namespace:
328 | if contains(":") then sub("\\:(.+)"; "") else "minecraft" end
329 | ;
330 |
331 | [.[] | to_entries | map( select((.value.predicate.damage != null) or (.value.predicate.damaged != null) or (.value.predicate.custom_model_data != null)) |
332 | (if .value.predicate.damage then (.value.predicate.damage * maxdur(.key) | ceil) else null end) as $damage
333 | | (if .value.predicate.damaged == 0 then true else null end) as $unbreakable
334 | | (if .value.predicate.custom_model_data then .value.predicate.custom_model_data else null end) as $custom_model_data |
335 | {
336 | "item": .key,
337 | "bedrock_icon": bedrocktexture(.key),
338 | "nbt": ({
339 | "Damage": $damage,
340 | "Unbreakable": $unbreakable,
341 | "CustomModelData": $custom_model_data
342 | }),
343 | "path": ("./assets/" + (.value.model | namespace) + "/models/" + (.value.model | sub("(.*?)\\:"; "")) + ".json"),
344 | "namespace": (.value.model | namespace),
345 | "model_path": ((.value.model | sub("(.*?)\\:"; "")) | split("/")[:-1] | map(. + "/") | add[:-1] // ""),
346 | "model_name": ((.value.model | sub("(.*?)\\:"; "")) | split("/")[-1]),
347 | "generated": false
348 |
349 | }) | .[]]
350 | | walk(if type == "object" then with_entries(select(.value != null)) else . end)
351 | | to_entries | map( ((.value.geyserID = "gmdl_\(1+.key)") | .value))
352 | | INDEX(.geyserID)
353 |
354 | ' ./assets/minecraft/models/item/*.json > config.json || { status_message error "Invalid JSON exists in block or item folder! See above log."; exit 1; }
355 | status_message completion "Initial predicate config generated"
356 |
357 | # get a bash array of all model json files in our resource pack
358 | status_message process "Generating an array of all model JSON files to crosscheck with our predicate config"
359 | json_dir=($(find ./assets/**/models -type f -name '*.json'))
360 |
361 | # ensure all our reference files in config.json exist, and delete the entry if they do not
362 | status_message critical "Removing config entries that do not have an associated JSON file in the pack"
363 | jq '
364 |
365 | def real_file($input):
366 | ($ARGS.positional | index($input) // null);
367 |
368 | map_values(if real_file(.path) != null then . else empty end)
369 |
370 | ' config.json --args ${json_dir[@]} | sponge config.json
371 |
372 | # get a bash array of all our input models
373 | status_message process "Creating a bash array for remaing models in our predicate config"
374 | model_array=($(jq -r '[.[].path] | unique | .[]' config.json))
375 |
376 | # find initial parental information
377 | status_message process "Doing an initial sweep for level 1 parentals"
378 | jq -n '
379 |
380 | [def namespace: if contains(":") then sub("\\:(.+)"; "") else "minecraft" end;
381 |
382 | inputs | {
383 | "path": (input_filename),
384 | "parent": ("./assets/" + (.parent | namespace) + "/models/" + ((.parent? // empty) | sub("(.*?)\\:"; "")) + ".json")
385 | }
386 | ]
387 |
388 | ' ${model_array[@]} | sponge scratch_files/parents.json
389 |
390 | # add initial parental information to config.json
391 | status_message critical "Removing config entries with non-supported parentals\n"
392 | jq -s '
393 |
394 | . as $global |
395 |
396 | def intest($input_i): ($global | .[0] | map({(.path): .parent}) | add | .[$input_i]? // null);
397 |
398 | def gtest($input_g):
399 | [
400 | "./assets/minecraft/models/block/block.json",
401 | "./assets/minecraft/models/block/cube.json",
402 | "./assets/minecraft/models/block/cube_column.json",
403 | "./assets/minecraft/models/block/cube_directional.json",
404 | "./assets/minecraft/models/block/cube_mirrored.json",
405 | "./assets/minecraft/models/block/observer.json",
406 | "./assets/minecraft/models/block/orientable_with_bottom.json",
407 | "./assets/minecraft/models/block/piston_extended.json",
408 | "./assets/minecraft/models/block/redstone_dust_side.json",
409 | "./assets/minecraft/models/block/redstone_dust_side_alt.json",
410 | "./assets/minecraft/models/block/template_single_face.json",
411 | "./assets/minecraft/models/block/thin_block.json",
412 | "./assets/minecraft/models/builtin/entity.json"
413 | ]
414 | | index($input_g) // null;
415 |
416 | .[1] | map_values(. + ({"parent": (intest(.path) // null)} | if gtest(.parent) == null then . else empty end))
417 | | walk(if type == "object" then with_entries(select(.value != null)) else . end)
418 |
419 | ' scratch_files/parents.json config.json | sponge config.json
420 |
421 | # obtain hashes of all model predicate info to ensure consistent model naming
422 | jq -r '.[] | [.geyserID, (.item + "_c" + (.nbt.CustomModelData | tostring) + "_d" + (.nbt.Damage | tostring) + "_u" + (.nbt.Unbreakable | tostring)), .path] | @tsv | gsub("\\t";",")' config.json > scratch_files/paths.csv
423 |
424 | function write_hash () {
425 | local entry_hash=$(echo -n "${1}" | md5sum | head -c 7)
426 | local path_hash=$(echo -n "${2}" | md5sum | head -c 7)
427 | echo "${3},${entry_hash},${path_hash}" >> "${4}"
428 | }
429 |
430 | while IFS=, read -r gid predicate path
431 | do write_hash "${predicate}" "${path}" "${gid}" "scratch_files/hashes.csv"
432 | done < scratch_files/paths.csv > /dev/null
433 |
434 | jq -cR 'split(",")' scratch_files/hashes.csv | jq -s 'map({(.[0]): [.[1], .[2]]}) | add' > scratch_files/hashmap.json
435 |
436 | jq --slurpfile hashmap scratch_files/hashmap.json '
437 | map_values(
438 | .geyserID as $gid
439 | | . += {
440 | "path_hash": ("gmdl_" + ($hashmap[] | .[($gid)] | .[0])),
441 | "geometry": ("geo_" + ($hashmap[] | .[($gid)] | .[1]))
442 | }
443 | )
444 | ' config.json | sponge config.json
445 |
446 | # create our initial directories for bp & rp
447 | status_message process "Generating initial directory strucutre for our bedrock packs"
448 | mkdir -p ./target/rp/models/blocks && mkdir -p ./target/rp/textures && mkdir -p ./target/rp/attachables && mkdir -p ./target/rp/animations && mkdir -p ./target/bp/blocks && mkdir -p ./target/bp/items
449 |
450 | # copy over our pack.png if we have one
451 | if test -f "./pack.png"; then
452 | cp ./pack.png ./target/rp/pack_icon.png && cp ./pack.png ./target/bp/pack_icon.png
453 | fi
454 |
455 | # generate uuids for our manifests
456 | uuid1=($(uuidgen))
457 | uuid2=($(uuidgen))
458 | uuid3=($(uuidgen))
459 | uuid4=($(uuidgen))
460 |
461 | # get pack description if we have one
462 | pack_desc="$(jq -r '(.pack.description // "Geyser 3D Items Resource Pack")' ./pack.mcmeta)"
463 |
464 | # generate rp manifest.json
465 | status_message process "Generating resource pack manifest"
466 | jq -c --arg pack_desc "${pack_desc}" --arg uuid1 "${uuid1}" --arg uuid2 "${uuid2}" -n '
467 | {
468 | "format_version": 2,
469 | "header": {
470 | "description": "Adds 3D items for use with a Geyser proxy",
471 | "name": $pack_desc,
472 | "uuid": ($uuid1 | ascii_downcase),
473 | "version": [1, 0, 0],
474 | "min_engine_version": [1, 18, 3]
475 | },
476 | "modules": [
477 | {
478 | "description": "Adds 3D items for use with a Geyser proxy",
479 | "type": "resources",
480 | "uuid": ($uuid2 | ascii_downcase),
481 | "version": [1, 0, 0]
482 | }
483 | ]
484 | }
485 | ' | sponge ./target/rp/manifest.json
486 |
487 | # generate bp manifest.json
488 | status_message process "Generating behavior pack manifest"
489 | jq -c --arg pack_desc "${pack_desc}" --arg uuid1 "${uuid1}" --arg uuid3 "${uuid3}" --arg uuid4 "${uuid4}" -n '
490 | {
491 | "format_version": 2,
492 | "header": {
493 | "description": "Adds 3D items for use with a Geyser proxy",
494 | "name": $pack_desc,
495 | "uuid": ($uuid3 | ascii_downcase),
496 | "version": [1, 0, 0],
497 | "min_engine_version": [ 1, 18, 3]
498 | },
499 | "modules": [
500 | {
501 | "description": "Adds 3D items for use with a Geyser proxy",
502 | "type": "data",
503 | "uuid": ($uuid4 | ascii_downcase),
504 | "version": [1, 0, 0]
505 | }
506 | ],
507 | "dependencies": [
508 | {
509 | "uuid": ($uuid1 | ascii_downcase),
510 | "version": [1, 0, 0]
511 | }
512 | ]
513 | }
514 | ' | sponge ./target/bp/manifest.json
515 |
516 | # generate rp terrain_texture.json
517 | status_message process "Generating resource pack terrain texture definition"
518 | jq -nc '
519 | {
520 | "resource_pack_name": "geyser_custom",
521 | "texture_name": "atlas.terrain",
522 | "texture_data": {
523 | }
524 | }
525 | ' | sponge ./target/rp/textures/terrain_texture.json
526 |
527 | # generate rp item_texture.json
528 | status_message process "Generating resource pack item texture definition"
529 | jq -nc '
530 | {
531 | "resource_pack_name": "geyser_custom",
532 | "texture_name": "atlas.items",
533 | "texture_data": {}
534 | }
535 | ' | sponge ./target/rp/textures/item_texture.json
536 |
537 | status_message process "Generating resource pack disabling animation"
538 | # generate our disabling animation
539 | jq -nc '
540 | {
541 | "format_version": "1.8.0",
542 | "animations": {
543 | "animation.geyser_custom.disable": {
544 | "loop": true,
545 | "override_previous_animation": true,
546 | "bones": {
547 | "geyser_custom": {
548 | "scale": 0
549 | }
550 | }
551 | }
552 | }
553 | }
554 | ' | sponge ./target/rp/animations/animation.geyser_custom.disable.json
555 |
556 | # DO DEFAULT ASSETS HERE!!
557 | # get the current default textures and merge them with our rp
558 | if [[ ${fallback_pack} != none ]] && [[ ! -f default_assets.zip ]]
559 | then
560 | status_message process "Now downloading the fallback resource pack:"
561 | printf "\e[3m\e[37m"
562 | echo
563 | COLUMNS=$COLUMNS-1 curl --no-styled-output -#L -o default_assets.zip https://github.com/InventivetalentDev/minecraft-assets/zipball/refs/tags/${default_asset_version:=1.19.2}
564 | echo
565 | printf "${C_CLOSE}"
566 | status_message completion "Fallback resources downloaded"
567 | fi
568 |
569 | if [[ ${fallback_pack} != null && ${fallback_pack} != none ]]
570 | then
571 | printf "\e[3m\e[37m"
572 | echo
573 | COLUMNS=$COLUMNS-1 curl --no-styled-output -#L -o provided_assets.zip "${fallback_pack}"
574 | echo
575 | printf "${C_CLOSE}"
576 | status_message completion "Provided resources downloaded"
577 | mkdir ./providedassetholding
578 | unzip -n -q -d ./providedassetholding provided_assets.zip "assets/**"
579 | status_message completion "Provided resources decompressed"
580 | cp -n -r "./providedassetholding/assets"/** './assets/'
581 | status_message completion "Provided resources merged with target pack"
582 | fi
583 |
584 | if [[ ${fallback_pack} != none ]]
585 | then
586 | root_folder=($(unzip -Z -1 default_assets.zip | head -1))
587 | mkdir ./defaultassetholding
588 | unzip -n -q -d ./defaultassetholding default_assets.zip "${root_folder}assets/minecraft/textures/**/*"
589 | unzip -n -q -d ./defaultassetholding default_assets.zip "${root_folder}assets/minecraft/models/**/*"
590 | status_message completion "Fallback resources decompressed"
591 | mkdir -p './assets/minecraft/textures/'
592 | cp -n -r "./defaultassetholding/${root_folder}assets/minecraft/textures"/* './assets/minecraft/textures/'
593 | cp -n -r "./defaultassetholding/${root_folder}assets/minecraft/models"/* './assets/minecraft/models/'
594 | status_message completion "Fallback resources merged with target pack"
595 | rm -rf defaultassetholding
596 | #rm -f default_assets.zip
597 | status_message critical "Extraneous fallback resources deleted\n"
598 | fi
599 |
600 | # generate a fallback texture
601 | convert -size 16x16 xc:\#FFFFFF ./assets/minecraft/textures/0.png
602 |
603 | # make sure we crop all mcmeta associated png files
604 | status_message process "Cropping animated textures"
605 | for i in $(find ./assets/**/textures -type f -name "*.mcmeta" | sed 's/\.mcmeta//'); do
606 | convert ${i} -set option:distort:viewport "%[fx:min(w,h)]x%[fx:min(w,h)]" -distort affine "0,0 0,0" -define png:format=png8 -clamp ${i} 2> /dev/null
607 | done
608 |
609 | status_message completion "Initial pack setup complete\n"
610 |
611 | jq -r '.[] | select(.parent != null) | [.path, .geyserID, .parent, .namespace, .model_path, .model_name, .path_hash] | @tsv | gsub("\\t";",")' config.json | sponge scratch_files/pa.csv
612 |
613 | _start=1
614 | _end="$(jq -r '(. | length) + ([.[] | select(.parent != null)] | length)' config.json)"
615 | cur_pos=0
616 |
617 | function ProgressBar {
618 | let _progress=(${1}*100/${2}*100)/100
619 | let _done=(${_progress}*6)/10
620 | let _left=60-$_done
621 | _fill=$(printf "%${_done}s")
622 | _empty=$(printf "%${_left}s")
623 | printf "\r\e[37m█\e[m \e[37m${_fill// /█}\e[m\e[37m${_empty// /•}\e[m \e[37m█\e[m \e[33m${_progress}%\e[m\n"
624 | }
625 |
626 | # first, deal with parented models
627 | while IFS=, read -r file gid parental namespace model_path model_name path_hash
628 | do
629 | resolve_parental () {
630 | local file=${1}
631 | local gid=${2}
632 | local parental=${3}
633 | local namespace=${4}
634 | local model_path=${5}
635 | local model_name=${6}
636 | local path_hash=${7}
637 |
638 | local elements="$(jq -rc '.elements' ${file} | tee scratch_files/${gid}.elements.temp)"
639 | local element_parent=${file}
640 | local textures="$(jq -rc '.textures' ${file} | tee scratch_files/${gid}.textures.temp)"
641 | local display="$(jq -rc '.display' ${file} | tee scratch_files/${gid}.display.temp)"
642 | status_message process "Locating parental info for child model with GeyserID ${gid}"
643 |
644 | # itterate through parented models until they all have geometry, display, and textures
645 | until [[ ${elements} != null && ${textures} != null && ${display} != null ]] || [[ ${parental} = "./assets/minecraft/models/builtin/generated.json" ]] || [[ ${parental} = null ]]
646 | do
647 | if [[ ${elements} = null ]]
648 | then
649 | local elements="$(jq -rc '.elements' ${parental} 2> /dev/null | tee scratch_files/${gid}.elements.temp || (echo && echo null))"
650 | local element_parent=${parental}
651 | fi
652 | if [[ ${textures} = null ]]
653 | then
654 | local textures="$(jq -rc '.textures' ${parental} 2> /dev/null | tee scratch_files/${gid}.textures.temp || (echo && echo null))"
655 | fi
656 | if [[ ${display} = null ]]
657 | then
658 | local display="$(jq -rc '.display' ${parental} 2> /dev/null | tee scratch_files/${gid}.display.temp || (echo && echo null))"
659 | fi
660 | local parental="$(jq -rc 'def namespace: if contains(":") then sub("\\:(.+)"; "") else "minecraft" end; ("./assets/" + (.parent? | namespace) + "/models/" + ((.parent? // empty) | sub("(.*?)\\:"; "")) + ".json") // "null"' ${parental} 2> /dev/null || (echo && echo null))"
661 | local texture_0="$(jq -rc 'def namespace: if contains(":") then sub("\\:(.+)"; "") else "minecraft" end; ("./assets/" + ([.[]][0]? | namespace) + "/textures/" + (([.[]][0]? // empty) | sub("(.*?)\\:"; "")) + ".png") // "null"' scratch_files/${gid}.textures.temp)"
662 | done
663 |
664 | # if we can, generate a model now
665 | if [[ ${elements} != null && ${textures} != null ]]
666 | then
667 | jq -n --slurpfile jelements scratch_files/${gid}.elements.temp --slurpfile jtextures scratch_files/${gid}.textures.temp --slurpfile jdisplay scratch_files/${gid}.display.temp '
668 | {
669 | "textures": ($jtextures[]),
670 | "elements": ($jelements[])
671 | } + (if $jdisplay then ({"display": ($jdisplay[])}) else {} end)
672 | ' | sponge ${file}
673 | echo >> scratch_files/count.csv
674 | local tot_pos=$(wc -l < scratch_files/count.csv)
675 | status_message completion "Located all parental info for Child ${gid}\n$(ProgressBar ${tot_pos} ${_end})"
676 | echo
677 | # check if this is a 2d item dervived from ./assets/minecraft/models/builtin/generated
678 | elif [[ ${textures} != null && ${parental} = "./assets/minecraft/models/builtin/generated.json" && -f "${texture_0}" ]]
679 | then
680 | jq -n --slurpfile jelements scratch_files/${gid}.elements.temp --slurpfile jtextures scratch_files/${gid}.textures.temp --slurpfile jdisplay scratch_files/${gid}.display.temp '
681 | {
682 | "textures": ([$jtextures[]][0])
683 | } + (if $jdisplay then ({"display": ($jdisplay[])}) else {} end)
684 | ' | sponge ${file}
685 | # copy texture directly to the rp
686 | mkdir -p "./target/rp/textures/${namespace}/${model_path}"
687 | cp "${texture_0}" "./target/rp/textures/${namespace}/${model_path}/${model_name}.png"
688 | # add texture to item atlas
689 | echo "${path_hash},textures/${namespace}/${model_path}/${model_name}" >> scratch_files/icons.csv
690 | echo "${gid}" >> scratch_files/generated.csv
691 | echo >> scratch_files/count.csv
692 | local tot_pos=$(wc -l < scratch_files/count.csv)
693 | status_message completion "Located all parental info for 2D Child ${gid}\n$(ProgressBar ${tot_pos} ${_end})"
694 | echo
695 | # otherwise, remove it from our config
696 | else
697 | echo "${gid}" >> scratch_files/deleted.csv
698 | echo >> scratch_files/count.csv
699 | local tot_pos=$(wc -l < scratch_files/count.csv)
700 | status_message critical "Deleting ${gid} from config as no suitable parent information was found\n$(ProgressBar ${tot_pos} ${_end})"
701 | echo
702 | fi
703 | rm -f scratch_files/${gid}.elements.temp scratch_files/${gid}.textures.temp scratch_files/${gid}.display.temp
704 | }
705 | wait_for_jobs
706 | resolve_parental "${file}" "${gid}" "${parental}" "${namespace}" "${model_path}" "${model_name}" "${path_hash}" &
707 |
708 | done < scratch_files/pa.csv
709 | wait # wait for all the jobs to finish
710 |
711 | # update generated models in config
712 | if [[ -f scratch_files/generated.csv ]]
713 | then
714 | jq -cR 'split(",")' scratch_files/generated.csv | jq -s 'map({(.[0]): true}) | add' > scratch_files/generated.json
715 | jq -s '
716 | .[0] as $generated_models
717 | | .[1]
718 | | map_values(
719 | .geyserID as $gid
720 | | .generated = ($generated_models[($gid)] // false)
721 | )
722 | ' scratch_files/generated.json config.json | sponge config.json
723 | fi
724 |
725 | # add icon textures to item atlas
726 | if [[ -f scratch_files/icons.csv ]]
727 | then
728 | jq -cR 'split(",")' scratch_files/icons.csv | jq -s 'map({(.[0]): {"textures": (.[1] | gsub("//"; "/"))}}) | add' > scratch_files/icons.json
729 | jq -s '
730 | .[0] as $icons
731 | | .[1]
732 | | .texture_data += $icons
733 | ' scratch_files/icons.json ./target/rp/textures/item_texture.json | sponge ./target/rp/textures/item_texture.json
734 | fi
735 |
736 | # delete unsuitable models
737 | if [[ -f scratch_files/deleted.csv ]]
738 | then
739 | jq -cR 'split(",")' scratch_files/deleted.csv | jq -s '.' > scratch_files/deleted.json
740 | jq -s '.[0] as $deleted | .[1] | delpaths($deleted)' scratch_files/deleted.json config.json | sponge config.json
741 | fi
742 |
743 | status_message process "Compiling final model list"
744 | # get our final 3d model list from the config
745 | model_list=( $(jq -r '.[] | select(.generated == false) | .path' config.json) )
746 |
747 | # get our final texture list to be atlased
748 | # get a bash array of all texture files in our resource pack
749 | status_message process "Generating an array of all model PNG files to crosscheck with our atlas"
750 | jq -n '$ARGS.positional' --args $(find ./assets/**/textures -type f -name '*.png') | sponge scratch_files/all_textures.temp
751 | # get bash array of all texture files listed in our models
752 | status_message process "Generating union atlas arrays for all model textures"
753 | jq -s '
754 | def namespace:
755 | if contains(":") then sub("\\:(.+)"; "") else "minecraft" end;
756 | [.[]| [.textures[]?] | unique]
757 | | map(map("./assets/" + (. | namespace) + "/textures/" + (. | sub("(.*?)\\:"; "")) + ".png"))
758 | ' ${model_list[@]} | sponge scratch_files/union_atlas.temp
759 | jq '
760 | def intersects(a;b): any(a[]; . as $x | any(b[]; . == $x));
761 |
762 | def mapatlas(set):
763 | (set | unique) as $unique_set
764 | | (map(if intersects(.; $unique_set) then . else empty end) | add + $unique_set | unique) as $new_set
765 | | map(if intersects(.; $new_set) then empty else . end) + [$new_set];
766 |
767 | [["./assets/minecraft/textures/0.png"]] +
768 | reduce .[] as $entry ([]; mapatlas($entry))
769 | ' scratch_files/union_atlas.temp | sponge scratch_files/union_atlas.temp
770 | total_union_atlas=($(jq -r 'length - 1' scratch_files/union_atlas.temp))
771 |
772 | mkdir -p scratch_files/spritesheet
773 | status_message process "Generating $((1+${total_union_atlas})) sprite sheets..."
774 | for i in $(seq 0 ${total_union_atlas})
775 | do
776 | generate_atlas () {
777 | # find the union of all texture files listed in this atlas and all texture files in our resource pack
778 | local texture_list=( $(jq -s --arg index "${1}" -r '(.[1][($index | tonumber)] - .[0] | length > 0) as $fallback_needed | ((.[1][($index | tonumber)] - (.[1][($index | tonumber)] - .[0])) + (if $fallback_needed then ["./assets/minecraft/textures/0.png"] else [] end)) | .[]' scratch_files/all_textures.temp scratch_files/union_atlas.temp) )
779 | status_message process "Generating sprite sheet ${1} of ${total_union_atlas}"
780 | spritesheet-js -f json --name scratch_files/spritesheet/${1} --fullpath ${texture_list[@]} 1> /dev/null
781 | echo ${1} >> scratch_files/atlases.csv
782 | }
783 | wait_for_jobs
784 | generate_atlas "${i}" &
785 | done
786 | wait # wait for all the jobs to finish
787 |
788 | # generate terrain texture atlas
789 | jq -cR 'split(",")' scratch_files/atlases.csv | jq -s 'map({("gmdl_atlas_" + .[0]): {"textures": ("textures/" + .[0])}}) | add' > scratch_files/atlases.json
790 | jq -s '
791 | .[0] as $atlases
792 | | .[1]
793 | | .texture_data += $atlases
794 | ' scratch_files/atlases.json ./target/rp/textures/terrain_texture.json | sponge ./target/rp/textures/terrain_texture.json
795 |
796 | status_message completion "All sprite sheets generated"
797 | mv scratch_files/spritesheet/*.png ./target/rp/textures
798 |
799 | # begin conversion
800 | jq -r '.[] | [.path, .geyserID, .generated, .namespace, .model_path, .model_name, .path_hash, .geometry] | @tsv | gsub("\\t";",")' config.json | sponge scratch_files/all.csv
801 |
802 | while IFS=, read -r file gid generated namespace model_path model_name path_hash geometry
803 | do
804 | convert_model () {
805 | local file="${1}"
806 | local gid="${2}"
807 | local generated="${3}"
808 | local namespace="${4}"
809 | local model_path="${5}"
810 | local model_name="${6}"
811 | local path_hash="${7}"
812 | local geometry="${8}"
813 |
814 | # find which texture atlas we will be using if not generated
815 | if [[ ${generated} = "false" ]]
816 | then
817 | local atlas_index=$(jq -r -s 'def namespace: if contains(":") then sub("\\:(.+)"; "") else "minecraft" end; def intersects(a;b): any(a[]; . as $x | any(b[]; . == $x)); (.[0] | [.textures[]] | map("./assets/" + (. | namespace) + "/textures/" + (. | sub("(.*?)\\:"; "")) + ".png")) as $inp | [(.[1] | (map(if intersects(.;$inp) then . else empty end)[])) as $entry | .[1] | to_entries[] | select(.value == $entry).key][0] // 0' ${file} scratch_files/union_atlas.temp)
818 | else
819 | local atlas_index=0
820 | fi
821 |
822 | status_message process "Starting conversion of model with GeyserID ${gid}"
823 | mkdir -p ./target/rp/models/blocks/${namespace}/${model_path}
824 | jq --slurpfile atlas scratch_files/spritesheet/${atlas_index}.json --arg generated "${generated}" --arg binding "c.item_slot == 'head' ? 'head' : q.item_slot_to_bone_name(c.item_slot)" --arg geometry "${geometry}" -c '
825 | .textures as $texture_list |
826 | def namespace: if contains(":") then sub("\\:(.+)"; "") else "minecraft" end;
827 | def tobool: if .=="true" then true elif .=="false" then false else null end;
828 | def totexture($input): ($texture_list[($input[1:])]? // ([$texture_list[]][0]));
829 | def topath($input): ("./assets/" + ($input | namespace) + "/textures/" + ($input | sub("(.*?)\\:"; "")) + ".png");
830 | def texturedata($input): $atlas[] | .frames | (.[topath(totexture($input))] // ."./assets/minecraft/textures/0.png");
831 | def roundit: (.*10000 | round) / 10000;
832 | def element_array:
833 | if .elements then (.elements | map({
834 | "origin": [((-.to[0] + 8) | roundit), ((.from[1]) | roundit), ((.from[2] - 8) | roundit)],
835 | "size": [((.to[0] - .from[0]) | roundit), ((.to[1] - .from[1]) | roundit), ((.to[2] - .from[2]) | roundit)],
836 | "rotation": (if (.rotation.axis) == "x" then [(.rotation.angle | tonumber * -1), 0, 0] elif (.rotation.axis) == "y" then [0, (.rotation.angle | tonumber * -1), 0] elif (.rotation.axis) == "z" then [0, 0, (.rotation.angle | tonumber)] else null end),
837 | "pivot": (if .rotation.origin then [((- .rotation.origin[0] + 8) | roundit), (.rotation.origin[1] | roundit), ((.rotation.origin[2] - 8) | roundit)] else null end),
838 | "uv": (
839 | def uv_calc($input):
840 | (if (.faces | .[$input]) then
841 | (.faces | .[$input].texture) as $input_n
842 | | ( (((((.faces | .[$input].uv[0]) * (texturedata($input_n) | .frame.w) * 0.0625) + (texturedata($input_n) | .frame.x)) * (16 / ($atlas[] | .meta.size.w))) ) ) as $fn0
843 | | ( (((((.faces | .[$input].uv[1]) * (texturedata($input_n) | .frame.h) * 0.0625) + (texturedata($input_n) | .frame.y)) * (16 / ($atlas[] | .meta.size.h))) ) ) as $fn1
844 | | ( (((((.faces | .[$input].uv[2]) * (texturedata($input_n) | .frame.w) * 0.0625) + (texturedata($input_n) | .frame.x)) * (16 / ($atlas[] | .meta.size.w))) ) ) as $fn2
845 | | ( (((((.faces | .[$input].uv[3]) * (texturedata($input_n) | .frame.h) * 0.0625) + (texturedata($input_n) | .frame.y)) * (16 / ($atlas[] | .meta.size.h))) ) ) as $fn3
846 | | (($fn2 - $fn0) as $num | [([-1, $num] | max), 1] | min) as $x_sign
847 | | (($fn3 - $fn1) as $num | [([-1, $num] | max), 1] | min) as $y_sign |
848 | (if ($input == "up" or $input == "down") then {
849 | "uv": [(($fn2 - (0.016 * $x_sign)) | roundit), (($fn3 - (0.016 * $y_sign)) | roundit)],
850 | "uv_size": [((($fn0 - $fn2) + (0.016 * $x_sign)) | roundit), ((($fn1 - $fn3) + (0.016 * $y_sign)) | roundit)]
851 | } else {
852 | "uv": [(($fn0 + (0.016 * $x_sign)) | roundit), (($fn1 + (0.016 * $y_sign)) | roundit)],
853 | "uv_size": [((($fn2 - $fn0) - (0.016 * $x_sign)) | roundit), ((($fn3 - $fn1) - (0.016 * $y_sign)) | roundit)]
854 | } end) else null end);
855 | {
856 | "north": uv_calc("north"),
857 | "south": uv_calc("south"),
858 | "east": uv_calc("east"),
859 | "west": uv_calc("west"),
860 | "up": uv_calc("up"),
861 | "down": uv_calc("down")
862 | })
863 | }) | walk( if type == "object" then with_entries(select(.value != null)) else . end)) else {} end
864 | ;
865 | def pivot_groups:
866 | if .elements then ((element_array) as $element_array |
867 | [[.elements[].rotation] | unique | .[] | select (.!=null)]
868 | | map((
869 | [((- .origin[0] + 8) | roundit), (.origin[1] | roundit), ((.origin[2] - 8) | roundit)] as $i_piv |
870 | (if (.axis) == "x" then [(.angle | tonumber * -1), 0, 0] elif (.axis) == "y" then [0, (.angle | tonumber * -1), 0] else [0, 0, (.angle | tonumber)] end) as $i_rot |
871 | {
872 | "parent": "geyser_custom_z",
873 | "pivot": ($i_piv),
874 | "rotation": ($i_rot),
875 | "cubes": [($element_array | .[] | select(.rotation == $i_rot and .pivot == $i_piv))]
876 | }))) else {} end
877 | ;
878 | {
879 | "format_version": "1.16.0",
880 | "minecraft:geometry": [{
881 | "description": {
882 | "identifier": ( "geometry.geyser_custom." + ($geometry)),
883 | "texture_width": 16,
884 | "texture_height": 16,
885 | "visible_bounds_width": 4,
886 | "visible_bounds_height": 4.5,
887 | "visible_bounds_offset": [0, 0.75, 0]
888 | },
889 | "bones": ([{
890 | "name": "geyser_custom",
891 | "binding": $binding,
892 | "pivot": [0, 8, 0]
893 | }, {
894 | "name": "geyser_custom_x",
895 | "parent": "geyser_custom",
896 | "pivot": [0, 8, 0]
897 | }, {
898 | "name": "geyser_custom_y",
899 | "parent": "geyser_custom_x",
900 | "pivot": [0, 8, 0]
901 | },
902 | if ($generated | tobool) == true then ({
903 | "name": "geyser_custom_z",
904 | "parent": "geyser_custom_y",
905 | "pivot": [0, 8, 0],
906 | "texture_meshes": ([{"texture": "default", "position": [0, 8, 0], "rotation": [90, 0, -180], "local_pivot": [8, 0.5, 8]}])
907 | }) else ({
908 | "name": "geyser_custom_z",
909 | "parent": "geyser_custom_y",
910 | "pivot": [0, 8, 0],
911 | "cubes": ([(element_array | .[] | select(.rotation == null))])
912 | }) end] + (pivot_groups | map(del(.cubes[].rotation)) | to_entries | map( (.value.name = "rot_\(1+.key)" ) | .value)))
913 | }]
914 | }
915 | ' ${file} | sponge ./target/rp/models/blocks/${namespace}/${model_path}/${model_name}.json
916 |
917 | # generate our rp animations via display settings
918 | mkdir -p ./target/rp/animations/${namespace}/${model_path}
919 | jq -c --arg geometry "${geometry}" '
920 |
921 | {
922 | "format_version": "1.8.0",
923 | "animations": {
924 | ("animation.geyser_custom." + ($geometry) + ".thirdperson_main_hand"): {
925 | "loop": true,
926 | "bones": {
927 | "geyser_custom_x": (if .display.thirdperson_righthand then {
928 | "rotation": (if .display.thirdperson_righthand.rotation then [(- .display.thirdperson_righthand.rotation[0]), 0, 0] else null end),
929 | "position": (if .display.thirdperson_righthand.translation then [(- .display.thirdperson_righthand.translation[0]), (.display.thirdperson_righthand.translation[1]), (.display.thirdperson_righthand.translation[2])] else null end),
930 | "scale": (if .display.thirdperson_righthand.scale then [(.display.thirdperson_righthand.scale[0]), (.display.thirdperson_righthand.scale[1]), (.display.thirdperson_righthand.scale[2])] else null end)
931 | } else null end),
932 | "geyser_custom_y": (if .display.thirdperson_righthand.rotation then {
933 | "rotation": (if .display.thirdperson_righthand.rotation then [0, (- .display.thirdperson_righthand.rotation[1]), 0] else null end)
934 | } else null end),
935 | "geyser_custom_z": (if .display.thirdperson_righthand.rotation then {
936 | "rotation": [0, 0, (.display.thirdperson_righthand.rotation[2])]
937 | } else null end),
938 | "geyser_custom": {
939 | "rotation": [90, 0, 0],
940 | "position": [0, 13, -3]
941 | }
942 | }
943 | },
944 | ("animation.geyser_custom." + ($geometry) + ".thirdperson_off_hand"): {
945 | "loop": true,
946 | "bones": {
947 | "geyser_custom_x": (if .display.thirdperson_lefthand then {
948 | "rotation": (if .display.thirdperson_lefthand.rotation then [(- .display.thirdperson_lefthand.rotation[0]), 0, 0] else null end),
949 | "position": (if .display.thirdperson_lefthand.translation then [(.display.thirdperson_lefthand.translation[0]), (.display.thirdperson_lefthand.translation[1]), (.display.thirdperson_lefthand.translation[2])] else null end),
950 | "scale": (if .display.thirdperson_lefthand.scale then [(.display.thirdperson_lefthand.scale[0]), (.display.thirdperson_lefthand.scale[1]), (.display.thirdperson_lefthand.scale[2])] else null end)
951 | } else null end),
952 | "geyser_custom_y": (if .display.thirdperson_lefthand.rotation then {
953 | "rotation": (if .display.thirdperson_lefthand.rotation then [0, (- .display.thirdperson_lefthand.rotation[1]), 0] else null end)
954 | } else null end),
955 | "geyser_custom_z": (if .display.thirdperson_lefthand.rotation then {
956 | "rotation": [0, 0, (.display.thirdperson_lefthand.rotation[2])]
957 | } else null end),
958 | "geyser_custom": {
959 | "rotation": [90, 0, 0],
960 | "position": [0, 13, -3]
961 | }
962 | }
963 | },
964 | ("animation.geyser_custom." + ($geometry) + ".head"): {
965 | "loop": true,
966 | "bones": {
967 | "geyser_custom_x": {
968 | "rotation": (if .display.head.rotation then [(- .display.head.rotation[0]), 0, 0] else null end),
969 | "position": (if .display.head.translation then [(- .display.head.translation[0] * 0.625), (.display.head.translation[1] * 0.625), (.display.head.translation[2] * 0.625)] else null end),
970 | "scale": (if .display.head.scale then (.display.head.scale | map(. * 0.625)) else 0.625 end)
971 | },
972 | "geyser_custom_y": (if .display.head.rotation then {
973 | "rotation": [0, (- .display.head.rotation[1]), 0]
974 | } else null end),
975 | "geyser_custom_z": (if .display.head.rotation then {
976 | "rotation": [0, 0, (.display.head.rotation[2])]
977 | } else null end),
978 | "geyser_custom": {
979 | "position": [0, 19.9, 0]
980 | }
981 | }
982 | },
983 | ("animation.geyser_custom." + ($geometry) + ".firstperson_main_hand"): {
984 | "loop": true,
985 | "bones": {
986 | "geyser_custom": {
987 | "rotation": [90, 60, -40],
988 | "position": [4, 10, 4],
989 | "scale": 1.5
990 | },
991 | "geyser_custom_x": {
992 | "position": (if .display.firstperson_righthand.translation then [(- .display.firstperson_righthand.translation[0]), (.display.firstperson_righthand.translation[1]), (- .display.firstperson_righthand.translation[2])] else null end),
993 | "rotation": (if .display.firstperson_righthand.rotation then [(- .display.firstperson_righthand.rotation[0]), 0, 0] else [0.1, 0.1, 0.1] end),
994 | "scale": (if .display.firstperson_righthand.scale then (.display.firstperson_righthand.scale) else null end)
995 | },
996 | "geyser_custom_y": (if .display.firstperson_righthand.rotation then {
997 | "rotation": [0, (- .display.firstperson_righthand.rotation[1]), 0]
998 | } else null end),
999 | "geyser_custom_z": (if .display.firstperson_righthand.rotation then {
1000 | "rotation": [0, 0, (.display.firstperson_righthand.rotation[2])]
1001 | } else null end)
1002 | }
1003 | },
1004 | ("animation.geyser_custom." + ($geometry) + ".firstperson_off_hand"): {
1005 | "loop": true,
1006 | "bones": {
1007 | "geyser_custom": {
1008 | "rotation": [90, 60, -40],
1009 | "position": [4, 10, 4],
1010 | "scale": 1.5
1011 | },
1012 | "geyser_custom_x": {
1013 | "position": (if .display.firstperson_lefthand.translation then [(.display.firstperson_lefthand.translation[0]), (.display.firstperson_lefthand.translation[1]), (- .display.firstperson_lefthand.translation[2])] else null end),
1014 | "rotation": (if .display.firstperson_lefthand.rotation then [(- .display.firstperson_lefthand.rotation[0]), 0, 0] else [0.1, 0.1, 0.1] end),
1015 | "scale": (if .display.firstperson_lefthand.scale then (.display.firstperson_lefthand.scale) else null end)
1016 | },
1017 | "geyser_custom_y": (if .display.firstperson_lefthand.rotation then {
1018 | "rotation": [0, (- .display.firstperson_lefthand.rotation[1]), 0]
1019 | } else null end),
1020 | "geyser_custom_z": (if .display.firstperson_lefthand.rotation then {
1021 | "rotation": [0, 0, (.display.firstperson_lefthand.rotation[2])]
1022 | } else null end)
1023 | }
1024 | }
1025 | }
1026 | } | walk( if type == "object" then with_entries(select(.value != null)) else . end)
1027 |
1028 | ' ${file} | sponge ./target/rp/animations/${namespace}/${model_path}/animation.${model_name}.json
1029 |
1030 | # generate our bp block definition if this is a 3D item
1031 | if [[ ${generated} = false ]]
1032 | then
1033 | mkdir -p ./target/bp/blocks/${namespace}/${model_path}
1034 | jq -c -n --arg atlas_index "${atlas_index}" --arg block_material "${block_material}" --arg path_hash "${path_hash}" --arg geometry "${geometry}" '
1035 | {
1036 | "format_version": "1.16.100",
1037 | "minecraft:block": {
1038 | "description": {
1039 | "identifier": ("geyser_custom:" + $path_hash)
1040 | },
1041 | "components": {
1042 | "minecraft:material_instances": {
1043 | "*": {
1044 | "texture": ("gmdl_atlas_" + $atlas_index),
1045 | "render_method": $block_material,
1046 | "face_dimming": false,
1047 | "ambient_occlusion": false
1048 | }
1049 | },
1050 | "minecraft:geometry": ("geometry.geyser_custom." + $geometry),
1051 | "minecraft:placement_filter": {
1052 | "conditions": [
1053 | {
1054 | "allowed_faces": [
1055 | ],
1056 | "block_filter": [
1057 | ]
1058 | }
1059 | ]
1060 | }
1061 | }
1062 | }
1063 | }
1064 | ' | sponge ./target/bp/blocks/${namespace}/${model_path}/${model_name}.json
1065 | # generate our bp item definition if this is a 2D item
1066 | else
1067 | mkdir -p ./target/bp/items/${namespace}/${model_path}
1068 | jq -c -n --arg path_hash "${path_hash}" '
1069 | {
1070 | "format_version": "1.16.100",
1071 | "minecraft:item": {
1072 | "description": {
1073 | "identifier": ("geyser_custom:" + $path_hash),
1074 | "category": "items"
1075 | },
1076 | "components": {
1077 | "minecraft:icon": {
1078 | "texture": $path_hash
1079 | }
1080 | }
1081 | }
1082 | }
1083 | ' | sponge ./target/bp/items/${namespace}/${model_path}/${model_name}.${path_hash}.json
1084 | fi
1085 |
1086 | # generate our rp attachable definition
1087 | mkdir -p ./target/rp/attachables/${namespace}/${model_path}
1088 | jq -c -n --arg generated "${generated}" --arg atlas_index "${atlas_index}" --arg attachable_material "${attachable_material}" --arg v_main "v.main_hand = c.item_slot == 'main_hand';" --arg v_off "v.off_hand = c.item_slot == 'off_hand';" --arg v_head "v.head = c.item_slot == 'head';" --arg path_hash "${path_hash}" --arg namespace "${namespace}" --arg model_path "${model_path}" --arg model_name "${model_name}" --arg geometry "${geometry}" '
1089 | def tobool: if .=="true" then true elif .=="false" then false else null end;
1090 | {
1091 | "format_version": "1.10.0",
1092 | "minecraft:attachable": {
1093 | "description": {
1094 | "identifier": ("geyser_custom:" + $path_hash),
1095 | "materials": {
1096 | "default": $attachable_material,
1097 | "enchanted": $attachable_material
1098 | },
1099 | "textures": {
1100 | "default": (if ($generated | tobool) == true then ("textures/" + $namespace + "/" + $model_path + "/" + $model_name) else ("textures/" + $atlas_index) end),
1101 | "enchanted": "textures/misc/enchanted_item_glint"
1102 | },
1103 | "geometry": {
1104 | "default": ("geometry.geyser_custom." + $geometry)
1105 | },
1106 | "scripts": {
1107 | "pre_animation": [$v_main, $v_off, $v_head],
1108 | "animate": [
1109 | {"thirdperson_main_hand": "v.main_hand && !c.is_first_person"},
1110 | {"thirdperson_off_hand": "v.off_hand && !c.is_first_person"},
1111 | {"thirdperson_head": "v.head && !c.is_first_person"},
1112 | {"firstperson_main_hand": "v.main_hand && c.is_first_person"},
1113 | {"firstperson_off_hand": "v.off_hand && c.is_first_person"},
1114 | {"firstperson_head": "c.is_first_person && v.head"}
1115 | ]
1116 | },
1117 | "animations": {
1118 | "thirdperson_main_hand": ("animation.geyser_custom." + $geometry + ".thirdperson_main_hand"),
1119 | "thirdperson_off_hand": ("animation.geyser_custom." + $geometry + ".thirdperson_off_hand"),
1120 | "thirdperson_head": ("animation.geyser_custom." + $geometry + ".head"),
1121 | "firstperson_main_hand": ("animation.geyser_custom." + $geometry + ".firstperson_main_hand"),
1122 | "firstperson_off_hand": ("animation.geyser_custom." + $geometry + ".firstperson_off_hand"),
1123 | "firstperson_head": "animation.geyser_custom.disable"
1124 | },
1125 | "render_controllers": [ "controller.render.item_default" ]
1126 | }
1127 | }
1128 | }
1129 |
1130 | ' | sponge ./target/rp/attachables/${namespace}/${model_path}/${model_name}.${path_hash}.attachable.json
1131 |
1132 | # progress
1133 | echo >> scratch_files/count.csv
1134 | local tot_pos=$((cur_pos + $(wc -l < scratch_files/count.csv)))
1135 | status_message completion "${gid} converted\n$(ProgressBar ${tot_pos} ${_end})"
1136 | echo
1137 | }
1138 | wait_for_jobs
1139 | convert_model "${file}" "${gid}" "${generated}" "${namespace}" "${model_path}" "${model_name}" "${path_hash}" "${geometry}" &
1140 |
1141 | done < scratch_files/all.csv
1142 | wait # wait for all the jobs to finish
1143 |
1144 | # write lang file US
1145 | status_message process "Writing en_US and en_GB lang files"
1146 | mkdir ./target/rp/texts
1147 | jq -r '
1148 |
1149 | def format: (.[0:1] | ascii_upcase ) + (.[1:] | gsub( "_(?[a-z])"; (" " + .a) | ascii_upcase));
1150 | .[]|"\("item.geyser_custom:" + .path_hash + ".name")=\(.item | format)"
1151 |
1152 | ' config.json | sponge ./target/rp/texts/en_US.lang
1153 |
1154 | # copy US lang to GB
1155 | cp ./target/rp/texts/en_US.lang ./target/rp/texts/en_GB.lang
1156 |
1157 | # write supported languages file
1158 | jq -n '["en_US","en_GB"]' | sponge ./target/rp/texts/languages.json
1159 | status_message completion "en_US and en_GB lang files written\n"
1160 |
1161 | # Ensure images are in the correct color space
1162 | status_message process "Setting all images to png8"
1163 | find ./target/rp/textures -name '*.png' -exec mogrify -define png:format=png8 {} +
1164 | status_message completion "All images set to png8"
1165 |
1166 | if [[ ${rename_model_files} == "true" ]]
1167 | then
1168 | status_message process "Consolidating model files"
1169 | function consolidate_files () {
1170 | ## Get a list of all files
1171 | list=$(find ${1} -mindepth 2 -type f -print)
1172 | nr=1
1173 |
1174 | ## Move all files that are unique
1175 | find ${1} -mindepth 2 -type f -print0 | while IFS= read -r -d '' file; do
1176 | mv -n "$file" ${1}/
1177 | done
1178 | list=$(find ${1} -mindepth 2 -type f -print)
1179 |
1180 | ## Checking which files need to be renamed
1181 | while [[ $list != '' ]] ; do
1182 | ##Remaming the un-moved files to unique names and move the renamed files
1183 | find ${1} -mindepth 2 -type f -print0 | while IFS= read -r -d '' file; do
1184 | current_file=$(basename "$file")
1185 | mv -n "$file" "./${nr}${current_file}"
1186 | done
1187 | ## Incrementing counter to prefix to file name
1188 | nr=$((nr+1))
1189 | list=$(find ${1} -mindepth 2 -type f -print)
1190 | done
1191 | }
1192 | consolidate_files './target/rp/animations'
1193 | rm -rf ./target/rp/animations/*/
1194 | consolidate_files './target/rp/models/blocks'
1195 | rm -rf ./target/rp/models/blocks/*/
1196 | consolidate_files './target/rp/attachables'
1197 | rm -rf rm -rf ./target/rp/attachables/*/
1198 | fi
1199 |
1200 | # attempt to merge with existing pack if input was provided
1201 | if test -f ${merge_input}; then
1202 | mkdir inputbedrockpack
1203 | status_message process "Decompressing input bedrock pack"
1204 | unzip -q ${merge_input} -d ./inputbedrockpack
1205 | status_message process "Merging input bedrock pack with generated bedrock assets"
1206 | cp -n -r "./inputbedrockpack"/* './target/rp/'
1207 | if test -f ./inputbedrockpack/textures/terrain_texture.json; then
1208 | status_message process "Merging terrain texture files"
1209 | jq -s '
1210 | {
1211 | "resource_pack_name": "geyser_custom",
1212 | "texture_name": "atlas.terrain",
1213 | "texture_data": (.[1].texture_data + .[0].texture_data)
1214 | }
1215 | ' ./target/rp/textures/terrain_texture.json ./inputbedrockpack/textures/terrain_texture.json | sponge ./target/rp/textures/terrain_texture.json
1216 | fi
1217 | if test -f ./inputbedrockpack/textures/item_texture.json; then
1218 | status_message process "Merging item texture files"
1219 | jq -s '
1220 | {
1221 | "resource_pack_name": "geyser_custom",
1222 | "texture_name": "atlas.items",
1223 | "texture_data": (.[1].texture_data + .[0].texture_data)
1224 | }
1225 | ' ./target/rp/textures/item_texture.json ./inputbedrockpack/textures/item_texture.json | sponge ./target/rp/textures/item_texture.json
1226 | fi
1227 | if test -f ./inputbedrockpack/texts/languages.json; then
1228 | status_message process "Merging languages file"
1229 | jq -s '.[0] + .[1] | unique' | sponge ./target/rp/texts/languages.json
1230 | fi
1231 | if test -f ./inputbedrockpack/texts/en_US.lang; then
1232 | status_message process "Merging en_US lang file"
1233 | cat ./inputbedrockpack/texts/en_US.lang >> ./target/rp/texts/en_US.lang
1234 | fi
1235 | if test -f ./inputbedrockpack/texts/en_GB.lang; then
1236 | status_message process "Merging en_GB lang file"
1237 | cat ./inputbedrockpack/texts/en_GB.lang >> ./target/rp/texts/en_GB.lang
1238 | fi
1239 | status_message critical "Deleting input bedrock pack scratch direcotry"
1240 | rm -rf inputbedrockpack
1241 | status_message completion "Input bedrock pack merged with generated assets\n"
1242 | fi
1243 |
1244 | status_message process "Creating Geyser mappings in target directory"
1245 | echo
1246 | jq '
1247 | ([map(
1248 | {
1249 | ("minecraft:" + .item): [
1250 | {
1251 | "name": .path_hash,
1252 | "allow_offhand": true,
1253 | "icon": (if .generated == true then .path_hash else .bedrock_icon.icon end)
1254 | }
1255 | + (if (.generated == false) then {"frame": (.bedrock_icon.frame)} else {} end)
1256 | + (if .nbt.CustomModelData then {"custom_model_data": (.nbt.CustomModelData)} else {} end)
1257 | + (if .nbt.Damage then {"damage_predicate": (.nbt.Damage)} else {} end)
1258 | + (if .nbt.Unbreakable then {"unbreakable": (.nbt.Unbreakable)} else {} end)
1259 | ]
1260 | }
1261 | )
1262 | | map(to_entries[])
1263 | | group_by(.key)[]
1264 | | {(.[0].key) : map(.value) | add}] | add) as $mappings
1265 | | {
1266 | "format_version": "1",
1267 | "items": $mappings
1268 | }
1269 | ' config.json | sponge ./target/geyser_mappings.json
1270 |
1271 | # Add sprites if sprites.json exists in the root pack
1272 | if [ -f sprites.json ]; then
1273 | status_message process "Adding provided sprite paths from sprites.json"
1274 | jq -r '
1275 | to_entries
1276 | | map(.key as $item | .value | map(. += {"item": $item}))
1277 | | add[]
1278 | | [((.item | split(":")[-1]) + "_c" + (.custom_model_data | tostring) + "_d" + (.damage_predicate | tostring) + "_u" + (.unbreakable | tostring)), .sprite]
1279 | | @tsv
1280 | | gsub("\\t";",")
1281 | ' sprites.json > scratch_files/sprites.csv
1282 |
1283 | function write_id_hash () {
1284 | local entry_hash=$(echo -n "${1}" | md5sum | head -c 7)
1285 | echo "${2},${entry_hash}" >> "${3}"
1286 | }
1287 |
1288 | while IFS=, read -r predicate icon
1289 | do write_id_hash "${predicate}" "${icon}" "scratch_files/sprite_hashes.csv" &
1290 | done < scratch_files/sprites.csv > /dev/null
1291 |
1292 | jq -cR 'split(",")' scratch_files/sprite_hashes.csv | jq -s 'map({("gmdl_" + .[1]): {"textures": .[0]}}) | add' > scratch_files/sprite_hashmap.json
1293 |
1294 | jq -s '
1295 | .[0] as $icon_sprites
1296 | | .[1]
1297 | | .texture_data += $icon_sprites
1298 | ' scratch_files/sprite_hashmap.json ./target/rp/textures/item_texture.json | sponge ./target/rp/textures/item_texture.json
1299 |
1300 | jq -s '
1301 | {
1302 | "format_version": "1",
1303 | "items":
1304 | ((.[0] | keys | map({(.): (.)}) | add) as $sprites | .[1].items | to_entries | map(
1305 | (.key | split(":")[1]) as $item
1306 | | .value | {("minecraft:" + $item): (map(
1307 | .name as $name
1308 | | .icon as $icon
1309 | | .icon = ($sprites[($name)] // $icon)
1310 | ))}
1311 | ) | add)
1312 | }
1313 | ' scratch_files/sprite_hashmap.json ./target/geyser_mappings.json | sponge ./target/geyser_mappings.json
1314 |
1315 | fi
1316 |
1317 | cd -
1318 | python manager.py
1319 | cd ./staging
1320 |
1321 | # cleanup
1322 | rm -rf assets && rm -f pack.mcmeta && rm -f pack.png
1323 | if [[ ${save_scratch} != "true" ]]
1324 | then
1325 | rm -rf scratch_files
1326 | status_message critical "Deleted scratch files"
1327 | else
1328 | cd ./scratch_files > /dev/null && zip -rq8 scratch_files.zip . -x "*/.*" && cd .. > /dev/null && mv ./scratch_files/scratch_files.zip ./target/scratch_files.zip
1329 | status_message completion "Archived scratch files\n"
1330 | fi
1331 |
1332 | status_message process "Compressing output packs"
1333 | mkdir ./target/packaged
1334 | cd ./target/rp > /dev/null && zip -rq8 geyser_resources_preview.mcpack . -x "*/.*" && cd ../.. > /dev/null && mv ./target/rp/geyser_resources_preview.mcpack ./target/packaged/geyser_resources_preview.mcpack
1335 | cd ./target/bp > /dev/null && zip -rq8 geyser_behaviors_preview.mcpack . -x "*/.*" && cd ../.. > /dev/null && mv ./target/bp/geyser_behaviors_preview.mcpack ./target/packaged/geyser_behaviors_preview.mcpack
1336 | cd ./target/packaged > /dev/null && zip -rq8 geyser_addon.mcaddon . -i "*_preview.mcpack" && cd ../.. > /dev/null
1337 | jq 'delpaths([paths | select(.[-1] | strings | startswith("gmdl_atlas_"))])' ./target/rp/textures/terrain_texture.json | sponge ./target/rp/textures/terrain_texture.json
1338 | cd ./target/rp > /dev/null && zip -rq8 geyser_resources.mcpack . -x "*/.*" && cd ../.. > /dev/null && mv ./target/rp/geyser_resources.mcpack ./target/packaged/geyser_resources.mcpack
1339 | mkdir ./target/unpackaged
1340 | mv ./target/rp ./target/unpackaged/rp && mv ./target/bp ./target/unpackaged/bp
1341 |
1342 | echo
1343 | printf "\e[32m[+]\e[m \e[1m\e[37mConversion Process Complete\e[m\n\n\e[37mExiting...\e[m\n\n"
1344 |
--------------------------------------------------------------------------------
/font.py:
--------------------------------------------------------------------------------
1 | from PIL import Image
2 | from font_sprite import sprite
3 | from io import BytesIO
4 | import glob, os, json
5 |
6 | lines = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, "a", "b", "c", "d", "e", "f"]
7 | try:
8 | with open("pack/assets/minecraft/font/default.json", "r") as f:
9 | data = json.load(f)
10 | except Exception as e:
11 | print("[FONT ERROR]")
12 | print(e)
13 | symbols = []
14 | paths = []
15 | heights = []
16 | ascents = []
17 | for d in data['providers']:
18 | try:
19 | symbols.append(d['chars'])
20 | paths.append(d['file'])
21 | heights.append(d['height'])
22 | ascents.append(d['ascent'])
23 | except:
24 | continue
25 |
26 | def createfolder(glyph):
27 | os.makedirs(f"images/{glyph}", exist_ok = True)
28 | os.makedirs(f"export/{glyph}", exist_ok = True)
29 | os.makedirs(f"font/", exist_ok = True)
30 |
31 | def create_empty(glyph, blankimg):
32 | for line in lines:
33 | for linee in lines:
34 | if linee != lines:
35 | name = f"{line}{linee}"
36 | if os.path.isfile(f"images/{glyph}/0x{glyph}{name}.png"):
37 | continue
38 | else:
39 | imagesus = Image.open(blankimg)
40 | image = imagesus.copy()
41 | image.save(f"images/{glyph}/0x{glyph}{name}.png", "PNG")
42 | for line in lines:
43 | name = f"{line}{line}"
44 | if os.path.isfile(f"images/{glyph}/0x{glyph}{name}.png"):
45 | continue
46 | else:
47 | imagesus = Image.open(blankimg)
48 | image = imagesus.copy()
49 | image.save(f"images/{glyph}/0x{glyph}{name}.png", "PNG")
50 |
51 | def imagetoexport(glyph, blankimg):
52 | filelist = [file for file in os.listdir(f'images/{glyph}') if file.endswith('.png')]
53 | for img in filelist:
54 | image = Image.open(blankimg)
55 | logo = Image.open(f'images/{glyph}/{img}')
56 | image_copy = image.copy()
57 | w, h = image.size
58 | wl, hl = logo.size
59 | for height, symboll in zip(heights, symbols):
60 | symbolbe = ''.join(symboll)
61 | symbolbehex = (hex(ord(symbolbe)))
62 | if len(symbolbehex) == 6:
63 | symbol = symbolbehex[4:]
64 | elif len(symbolbehex) == 5:
65 | symbolbehex = symbolbehex[:2] + "0" + symbolbehex[2:]
66 | symbol = symbolbehex[4:]
67 | name = f"0x{glyph}{symbol}"
68 | imgname = f"0x{glyph}{img}"
69 | if name == imgname:
70 | if height >= 1 and height < w and height < h:
71 | size = (height, height)
72 | logo.thumbnail(size,Image.ANTIALIAS)
73 | if wl > (w/2) and hl > (h/2):
74 | position = (0, 0)
75 | image_copy.paste(logo, position)
76 | image_copy.save(f"export/{glyph}/{img}")
77 | else:
78 | position = (0, (h//2) - (hl//2))
79 | image_copy.paste(logo, position)
80 | image_copy.save(f"export/{glyph}/{img}")
81 |
82 |
83 | glyphs = []
84 | for i in symbols:
85 | if i not in glyphs:
86 | try:
87 | symbolbe = ''.join(i)
88 | sbh = (hex(ord(symbolbe)))
89 | a = sbh[2:]
90 | ab = a[:2]
91 | glyphs.append(ab.upper())
92 | except:
93 | print(f"Symbol Error: {symbolbe}")
94 | symbols.remove(i)
95 | continue
96 | glyphs = list(dict.fromkeys(glyphs))
97 | print("[FONT FILE]")
98 | print(glyphs)
99 |
100 | listglyphdone = []
101 | def converterpack(glyph):
102 | createfolder(glyph)
103 | if len(symbols) == len(paths):
104 | maxsw, maxsh = 0, 0
105 | for symboll, path in zip(symbols, paths):
106 | symbolbe = ''.join(symboll)
107 | symbolbehex = (hex(ord(symbolbe)))
108 | if glyph in listglyphdone:
109 | return False
110 | if len(symbolbehex) == 6:
111 | symbol = symbolbehex[4:]
112 | symbolac = symbolbehex[2:]
113 | symbolcheck = symbolac[:2]
114 | elif len(symbolbehex) == 5:
115 | symbolbehex = symbolbehex[:2] + "0" + symbolbehex[2:]
116 | symbol = symbolbehex[4:]
117 | symbolac = symbolbehex[2:]
118 | symbolcheck = symbolac[:2]
119 | glyphs.append(symbolcheck.upper())
120 | if (symbolcheck.upper()) == (glyph.upper()):
121 | if ":" in path:
122 | try:
123 | namespace = path.split(":")[0]
124 | pathnew = path.split(":")[1]
125 | imagefont = Image.open(f"pack/assets/{namespace}/textures/{pathnew}")
126 | image = imagefont.copy()
127 | image.save(f"images/{glyph}/0x{glyph}{symbol}.png", "PNG")
128 | except Exception as e:
129 | print(e)
130 | continue
131 | else:
132 | try:
133 | imagefont = Image.open(f"pack/assets/minecraft/textures/{path}")
134 | image = imagefont.copy()
135 | image.save(f"images/{glyph}/0x{glyph}{symbol}.png", "PNG")
136 | except Exception as e:
137 | print(e)
138 | continue
139 | else:
140 | continue
141 | else:
142 | files = glob.glob(f"images/{glyph}/*.png")
143 | for file in files:
144 | image = Image.open(file)
145 | sw, sh = image.size
146 | maxsw, maxsh = (max(maxsw, sw), max(maxsh, sh))
147 | if maxsw == maxsh:
148 | size = (int(maxsw + 1), int(maxsw + 1))
149 | elif maxsw > maxsh:
150 | size = (int(maxsw + 1), int(maxsw + 1))
151 | elif maxsh > maxsw:
152 | size = (int(maxsh + 1), int(maxsh + 1))
153 | if size == (0, 0):
154 | pass
155 | else:
156 | glyphsize = size * 16
157 | img = Image.open("blank256.png")
158 | imgre = img.resize(size)
159 | imgre.save("blankimg.png")
160 | blankimg = "blankimg.png"
161 | create_empty(glyph, blankimg)
162 | imagetoexport(glyph, blankimg)
163 | sprite(glyph, glyphsize, size)
164 | listglyphdone.append(glyph)
165 |
166 | for glyph in glyphs:
167 | converterpack(glyph)
168 |
--------------------------------------------------------------------------------
/font_sprite.py:
--------------------------------------------------------------------------------
1 | def sprite(glyph, spritesheet = None, tile = None):
2 | from PIL import Image
3 | import os, math, time
4 | max_frames_row = 16.0
5 | frames = []
6 |
7 | tile_width = None
8 | tile_height = None
9 | spritesheet_width = None
10 | spritesheet_height = None
11 | if tile_width or tile_height or spritesheet_width or spritesheet_height == None:
12 | tile_width = 256
13 | tile_height = 256
14 | spritesheet_width = 4096
15 | spritesheet_height = 4096
16 | else:
17 | tile_width = tile
18 | tile_height = tile
19 | spritesheet_width = spritesheet
20 | spritesheet_height = spritesheet
21 |
22 | files = []
23 |
24 | files = os.listdir(f"export/{glyph}")
25 | files.sort()
26 |
27 | for current_file in files:
28 | try:
29 | with Image.open(f"export/{glyph}/{current_file}") as im:
30 | frames.append(im.getdata())
31 | except:
32 | print(current_file + " is not a valid image")
33 | tile_width = frames[0].size[0]
34 | tile_height = frames[0].size[1]
35 |
36 | if len(frames) > max_frames_row :
37 | spritesheet_width = tile_width * max_frames_row
38 | required_rows = math.ceil(len(frames)/max_frames_row)
39 | spritesheet_height = tile_height * required_rows
40 | else:
41 | spritesheet_width = tile_width*len(frames)
42 | spritesheet_height = tile_height
43 |
44 | print(spritesheet_height)
45 | print(spritesheet_width)
46 |
47 | spritesheet = Image.new("RGBA",(int(spritesheet_width), int(spritesheet_height)))
48 |
49 | for current_frame in frames :
50 | top = tile_height * math.floor((frames.index(current_frame))/max_frames_row)
51 | left = tile_width * (frames.index(current_frame) % max_frames_row)
52 | bottom = top + tile_height
53 | right = left + tile_width
54 |
55 | box = (left,top,right,bottom)
56 | box = [int(i) for i in box]
57 | cut_frame = current_frame.crop((0,0,tile_width,tile_height))
58 |
59 | spritesheet.paste(cut_frame, box)
60 | os.makedirs("staging/target/rp/font", exist_ok = True)
61 | spritesheet.save(f"staging/target/rp/font/glyph_{glyph}.png", "PNG")
62 |
--------------------------------------------------------------------------------
/manager.py:
--------------------------------------------------------------------------------
1 | import zipfile, os
2 |
3 | with zipfile.ZipFile("staging/input_pack.zip", "r") as file:
4 | file.extractall("pack/")
5 |
6 | try:
7 | if os.getenv("SOUNDS_CONVERSION") == "true": import sound
8 | except Exception as e: print(e)
9 | try:
10 | if os.getenv("MEG3_FIX") == "true": import meg3
11 | except Exception as e: print(e)
12 | try:
13 | if os.getenv("ARMOR_CONVERSION") == "true": import armor
14 | except Exception as e: print(e)
15 | try:
16 | if os.getenv("FONT_CONVERSION") == "true": import font
17 | except Exception as e: print(e)
18 | try:
19 | if os.getenv("BOW_CONVERSION") == "true": import bow
20 | except Exception as e: print(e)
21 | try:
22 | if os.getenv("SHIELD_CONVERSION") == "true": import shield
23 | except Exception as e: print(e)
24 | try:
25 | if os.getenv("BLOCK_CONVERSION") == "true": import blocks
26 | except Exception as e: print(e)
27 |
--------------------------------------------------------------------------------
/meg3.py:
--------------------------------------------------------------------------------
1 | from PIL import Image
2 | import json
3 | import glob
4 | import os
5 | files = glob.glob("staging/target/rp/attachables/modelengine/**/*.json")
6 | texture_done = []
7 | for file in files:
8 | try:
9 | with open(file, "r") as f:
10 | data = json.load(f)
11 | texture_file = data["minecraft:attachable"]["description"]["textures"]["default"]
12 | texture = f"staging/target/rp/{texture_file}.png"
13 | if not os.getenv("ATTACHABLE_MATERIAL") == "entity_emissive_alpha_one_sided":
14 | with open(file, "w") as f:
15 | data["minecraft:attachable"]["description"]["materials"]["default"] = "entity_emissive_alpha_one_sided"
16 | data["minecraft:attachable"]["description"]["materials"]["enchanted"] = "entity_emissive_alpha_one_sided"
17 | json.dump(data, f)
18 | if texture_file in texture_done: continue
19 | im = Image.open(texture).convert("RGBA")
20 | im.putalpha(51)
21 | pixels = im.load()
22 | for x in range(im.width):
23 | for y in range(im.height):
24 | if pixels[x,y] == (0,0,0,51):
25 | pixels[x,y] = (0,0,0,0)
26 | im.save(texture)
27 | texture_done.append(texture_file)
28 | except Exception as e:
29 | print(e)
30 | print("Error texture:" + texture)
31 | print(texture_done)
32 |
--------------------------------------------------------------------------------
/shield.py:
--------------------------------------------------------------------------------
1 | import os
2 | import json
3 | import glob
4 |
5 | if os.path.exists("pack/assets/minecraft/models/item/shield.json"):
6 | with open("pack/assets/minecraft/models/item/shield.json") as f:
7 | data = json.load(f)
8 | predicate = [d["predicate"] for d in data["overrides"]]
9 | model = [d["model"] for d in data["overrides"]]
10 | for m, p in zip(model, predicate):
11 | if m == "item/shield" or "custom_model_data" not in p: continue
12 | try:
13 | fpath = (f"cache/shield/{p['custom_model_data']}.json")
14 | if not os.path.exists(fpath):
15 | os.makedirs(os.path.dirname(fpath), exist_ok=True)
16 | with open(fpath, "w") as f:
17 | f.write("{}")
18 | with open(fpath, "r") as f:
19 | data = json.load(f)
20 | with open(fpath, "w") as f:
21 | if ("blocking" in p): data["blocking"] = m
22 | else: data["default"] = m
23 | if "check" in data: data["check"] = data["check"] + 1
24 | else: data["check"] = 1
25 | json.dump(data, f, indent=2)
26 | except Exception as e:
27 | print(e)
28 | pass
29 |
30 | for file in glob.glob("cache/shield/*.json"):
31 | with open(file, "r") as f:
32 | data = json.load(f)
33 | if data["check"] == 2:
34 | animation = {}
35 | for i in ["default", "blocking"]:
36 | namespace = data[i].split(":")[0]
37 | path = data[i].split(":")[1]
38 | files = glob.glob(f"staging/target/rp/attachables/{namespace}/{path}*.json")
39 | for fa in files:
40 | if f"{path.split('/')[-1]}." in fa:
41 | break
42 | with open(fa, "r") as f:
43 | dataA = json.load(f)
44 | animationitem = dataA["minecraft:attachable"]["description"]["animations"]
45 | gmdl = dataA["minecraft:attachable"]["description"]["identifier"]
46 | if i == "default":
47 | saf = fa
48 | adata = dataA
49 | animation["mainhand.first_person"] = animationitem["firstperson_main_hand"]
50 | animation["mainhand.thierd_person"] = animationitem["thirdperson_main_hand"]
51 | animation["offhand.first_person"] = animationitem["firstperson_off_hand"]
52 | animation["offhand.thierd_person"] = animationitem["thirdperson_off_hand"]
53 | animate = [
54 | {"mainhand.thierd_person.block": f"!c.is_first_person && c.item_slot == 'main_hand' && q.is_item_name_any('slot.weapon.mainhand', '{gmdl}') && query.is_sneaking"},
55 | {"mainhand.first_person.block": f"c.is_first_person && c.item_slot == 'main_hand' && q.is_item_name_any('slot.weapon.mainhand', '{gmdl}') && query.is_sneaking"},
56 | {"mainhand.first_person": f"c.is_first_person && c.item_slot == 'main_hand' && q.is_item_name_any('slot.weapon.mainhand', '{gmdl}') && !query.is_sneaking"},
57 | {"mainhand.thierd_person": f"!c.is_first_person && c.item_slot == 'main_hand' && q.is_item_name_any('slot.weapon.mainhand', '{gmdl}') && !query.is_sneaking"},
58 |
59 | {"offhand.thierd_person.block": f"!c.is_first_person && c.item_slot == 'off_hand' && q.is_item_name_any('slot.weapon.offhand', '{gmdl}') && query.is_sneaking"},
60 | {"offhand.first_person.block": f"c.is_first_person && c.item_slot == 'off_hand' && q.is_item_name_any('slot.weapon.offhand', '{gmdl}') && query.is_sneaking"},
61 | {"offhand.first_person": f"c.is_first_person && c.item_slot == 'off_hand' && q.is_item_name_any('slot.weapon.offhand', '{gmdl}') && !query.is_sneaking"},
62 | {"offhand.thierd_person": f"!c.is_first_person && c.item_slot == 'off_hand' && q.is_item_name_any('slot.weapon.offhand', '{gmdl}') && !query.is_sneaking"}
63 | ]
64 | else:
65 | animation["mainhand.first_person.block"] = animationitem["firstperson_main_hand"]
66 | animation["mainhand.thierd_person.block"] = animationitem["thirdperson_main_hand"]
67 | animation["offhand.first_person.block"] = animationitem["firstperson_off_hand"]
68 | animation["offhand.thierd_person.block"] = animationitem["thirdperson_off_hand"]
69 | os.remove(fa)
70 | with open(saf, "w") as f:
71 | adata["minecraft:attachable"]["description"]["animations"] = animation
72 | adata["minecraft:attachable"]["description"]["scripts"]["animate"] = animate
73 | json.dump(adata, f)
--------------------------------------------------------------------------------
/sound.py:
--------------------------------------------------------------------------------
1 | import json, glob, os, shutil
2 |
3 | files = glob.glob("pack/assets/**/sounds.json")
4 | print(f"Sounds Files: {files}")
5 | os.makedirs("staging/target/rp/sounds", exist_ok=True)
6 | with open("staging/target/rp/sounds/sound_definitions.json", "w") as f:
7 | f.write('{"format_version": "1.14.0", "sound_definitions": {}}')
8 | for file in files:
9 | with open(file, "r") as f:
10 | data = json.load(f)
11 | namespace = file.split(os.sep)[1]
12 | names = [d for d in data]
13 | with open("staging/target/rp/sounds/sound_definitions.json", "r") as f:
14 | dj = json.load(f)
15 | for name in names:
16 | dj['sound_definitions'][f"{namespace}:{name}"] = {}
17 | with open("staging/target/rp/sounds/sound_definitions.json", "w") as f:
18 | try:
19 | dj['sound_definitions'][f"{namespace}:{name}"]["category"] = data[name]["category"]
20 | except:
21 | dj['sound_definitions'][f"{namespace}:{name}"]["category"] = "neutral"
22 | sounds = data[name]["sounds"]
23 | listsound = []
24 | for sound in sounds:
25 | if type(sound).__name__ == "dict":
26 | sound["name"]
27 | b = (sound["name"].split(":")[-1] + ".ogg").split((sound['name'].split(':')[-1] + ".ogg").split("/")[-1])[0]
28 | sound["name"] = "sounds/" + sound["name"].split(":")[-1]
29 | os.makedirs("staging/target/rp/sounds/" + b, exist_ok=True)
30 | shutil.copyfile(f"pack/assets/minecraft/{sound['name'].split(':')[-1]}.ogg", f"staging/target/rp/{sound['name'].split(':')[-1]}.ogg")
31 | listsound.append(sound)
32 | else:
33 | b = (sound.split(":")[-1] + ".ogg").split((sound.split(':')[-1] + ".ogg").split("/")[-1])[0]
34 | os.makedirs("staging/target/rp/sounds/" + b, exist_ok=True)
35 | shutil.copyfile(f"pack/assets/minecraft/sounds/{sound.split(':')[-1]}.ogg", f"staging/target/rp/sounds/{sound.split(':')[-1]}.ogg")
36 | a = "sounds/" + sound.split(":")[-1]
37 | listsound.append(a)
38 | dj["sound_definitions"][f"{namespace}:{name}"]["sounds"] = listsound
39 | json.dump(dj, f, indent=2)
40 |
--------------------------------------------------------------------------------