Skip to content

Commit

Permalink
Quick update for latest assets 2024 (#1)
Browse files Browse the repository at this point in the history
* Initial commit for fork

* Updated litematic-viewer for mid-2024

Atlas image for Minecraft 1.19, 1.20, and 1.21

Updated index.html so that the atlas image is directly fetched from mcmeta's updated atlas file instead of from outdated demo atlas.

Created a script to update assets JSON (inside assets.js)

Updated the main script to be similar to the js-compiled ts script on the deepslate repository's demo script (this chunk of the code https://github.com/misode/deepslate/blob/main/demo/main.ts#L65-L123).

* Update README

---------

Co-authored-by: blackrobe <>
Co-authored-by: Blackrobe <[email protected]>
  • Loading branch information
wendavid552 and Blackrobe authored Aug 1, 2024
1 parent 28ab1b8 commit 6fa34d8
Show file tree
Hide file tree
Showing 7 changed files with 481 additions and 313 deletions.
37 changes: 2 additions & 35 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,37 +1,4 @@
## Welcome to GitHub Pages
# EndingCredits' Litematic Viewer

You can use the [editor on GitHub](https://github.com/EndingCredits/litematic-viewer/edit/main/README.md) to maintain and preview the content for your website in Markdown files.
Powered by [DeepSlate](https://github.com/misode/deepslate)

Whenever you commit to this repository, GitHub Pages will run [Jekyll](https://jekyllrb.com/) to rebuild the pages in your site, from the content in your Markdown files.

### Markdown

Markdown is a lightweight and easy-to-use syntax for styling your writing. It includes conventions for

```markdown
Syntax highlighted code block

# Header 1
## Header 2
### Header 3

- Bulleted
- List

1. Numbered
2. List

**Bold** and _Italic_ and `Code` text

[Link](url) and ![Image](src)
```

For more details see [Basic writing and formatting syntax](https://docs.github.com/en/github/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax).

### Jekyll Themes

Your Pages site will use the layout and styles from the Jekyll theme you have selected in your [repository settings](https://github.com/EndingCredits/litematic-viewer/settings/pages). The name of this theme is saved in the Jekyll `_config.yml` configuration file.

### Support or Contact

Having trouble with Pages? Check out our [documentation](https://docs.github.com/categories/github-pages-basics/) or [contact support](https://support.github.com/contact) and we’ll help you sort it out.
39 changes: 39 additions & 0 deletions helper/assets_update.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# To use: change directory into this file's dir and run it with Python command line

import requests
import json


ASSETS_FILE_PATH = "../resource/assets.js"
ATLAS_FILE_PATH = "../resource/atlas.png"
BLOCK_DEF_URL = "https://raw.githubusercontent.com/misode/mcmeta/summary/assets/block_definition/data.min.json"
MODELS_URL = "https://raw.githubusercontent.com/misode/mcmeta/summary/assets/model/data.min.json"
ATLAS_MAPPING_URL = "https://raw.githubusercontent.com/misode/mcmeta/atlas/all/data.min.json"
ATLAS_IMAGE_URL = "https://raw.githubusercontent.com/misode/mcmeta/atlas/all/atlas.png"

result = dict()

print("Processing: blockstates")

result["blockstates"] = requests.get(BLOCK_DEF_URL).json()

print("Processing: models")

result["models"] = requests.get(MODELS_URL).json()

print("Processing: textures")

result["textures"] = requests.get(ATLAS_MAPPING_URL).json()

with open(ASSETS_FILE_PATH, 'w') as f:
f.write(f"""const assets = JSON.parse('{ json.dumps(result, sort_keys=True, separators=(',', ':')) }')""")

print("Written into:", ASSETS_FILE_PATH)

# with open("./assets_debug.json", 'w') as f:
# f.write(json.dumps(result, sort_keys=True, indent=2))

# print("Written into debug file")

with open(ATLAS_FILE_PATH, 'wb') as f:
f.write(requests.get(ATLAS_IMAGE_URL).content)
7 changes: 4 additions & 3 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
<title>Litematic Viewer</title>

<!-- Deepslate -->
<script src="https://unpkg.com/[email protected].0"></script>
<script src="https://unpkg.com/gl-matrix@3.3.0/gl-matrix-min.js"></script>
<script src="https://unpkg.com/[email protected].1"></script>
<script src="https://unpkg.com/gl-matrix@3.4.3/gl-matrix-min.js"></script>

<script src="resource/assets.js"></script>
<script src="resource/opaque.js"></script>
Expand Down Expand Up @@ -151,13 +151,14 @@ <h3>or paste a .litematic link:</h3>
<h5 class="header light">
Powered by <a href="https://github.com/misode/deepslate">DeepSlate <i class="fa fa-github fa-1x"></i></a>
</h5>
<p>Known issues: Cannot render Banner, Bed, Chest, Decorated Pot, Sign, Shulker box</p>
<p>Complain about this app <a href="https://discord.gg/GJckUsHsVB">here <i class="fab fa-discord"></i></a> (expect improvements soon)</p>
<p>Contribute to the project <a href="https://github.com/endingcredits/litematic-viewer/">here <i class="fa fa-github"></i></a></p>
</div>
</div>

<!-- Texture atlas -->
<img id="atlas" src="https://raw.githubusercontent.com/misode/deepslate-demo/main/atlas.png" alt="Texture atlas" crossorigin="anonymous" hidden>
<img id="atlas" src="resource/atlas.png" alt="Texture atlas" crossorigin="anonymous" hidden>

<script>
document.addEventListener("DOMContentLoaded", function(event) {
Expand Down
2 changes: 1 addition & 1 deletion resource/assets.js

Large diffs are not rendered by default.

Binary file modified resource/atlas.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 6fa34d8

Please sign in to comment.