Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add Chinese translate #143

Merged
merged 7 commits into from
Sep 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 66 additions & 0 deletions README-zh-cn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Structura
[![Github All Releases](https://img.shields.io/github/downloads/RavinMaddHatter/Structura/total.svg)]()

简体中文丨[**English**](https://github.com//Wulian233/Structura/blob/main/README.md)
(此md文档由捂脸翻译)

这个工具的灵感来自Litematica模组。它是一个可以用.mcstructure文件生成资源包的工具。在这个资源包中,盔甲架模型被修改为被投影的方块。它会把结构文件中的所有方块作为模型中的骨骼。然后投影出“幽灵块”用于向用户显示原本方块的位置。

[![介绍视频](https://img.youtube.com/vi/IdKT925LKMM/0.jpg)](https://www.youtube.com/watch?v=IdKT925LKMM)

## 生成.mcstructure文件

首先,你必须获得一个结构方块。但它需要在启用作弊的存档中完成,只需在聊天栏输入`/give @s structure_block`即可获得一个结构方块。
![alt text](https://github.com/RavinMaddHatter/Structura/blob/main/docs/give_structure.png?raw=true)
接下来使用GUI配置结构,选择你希望在盔甲架中投影的范围 。请注意,单个支持的最大尺寸为 64x64x64(无需编辑世界NBT数据)
![alt text](https://github.com/RavinMaddHatter/Structura/blob/main/docs/select_structure.PNG?raw=true)
接下来单击底部的导出按钮以生成保存文件。将其命名为您想要的任何名称,而不是位置,稍后您将需要它。
![alt text](https://github.com/RavinMaddHatter/Structura/blob/main/docs/export_structure.PNG?raw=true)

## 将结构转换为 .mcpack 文件
首先,你需要下载当前版本的Structura工具。解压zip文件,然后启动可执行文件。启动后,您应该会看到类似于下图的内容。
![alt text](https://github.com/RavinMaddHatter/Structura/blob/main/docs/launch_structura.PNG?raw=true)
接下来使用浏览按钮打开之前导出的结构,或手动输入路径。
![alt text](https://github.com/RavinMaddHatter/Structura/blob/main/docs/browse_file.PNG?raw=true)
输入生成后资源包的名称。
![alt text](https://github.com/RavinMaddHatter/Structura/blob/main/docs/name.PNG?raw=true)
** 如果你错误地将两个文件名重复,它会在下面显示重命名的提示。
![alt text](https://github.com/RavinMaddHatter/Structura/blob/main/docs/already_exists.PNG?raw=true)
如果一切正常,您现在应该有一个mcpack文件。
![alt text](https://github.com/RavinMaddHatter/Structura/blob/main/docs/pack_made.PNG?raw=true)

## 使用资源包
这个包就像任何纹理包一样。要使用它,你必须确保它处于激活状态,以便在全局资源中启用它。
![alt text](https://github.com/RavinMaddHatter/Structura/blob/main/docs/make_pack_active.PNG?raw=true)
该结构将出现在您加载的世界中的每个盔甲架周围。这就是我们能够使其在任何世界上工作的方式。所以拿出一个盔甲架,把它放下来看看你的结构。
![alt text](https://github.com/RavinMaddHatter/Structura/blob/main/docs/example_full.png?raw=true)
如果你愿意,可以通过右击盔甲架来逐层浏览结构。这将最小化除“活动”层之外的所有层。然而对于大型结构,它一次会显示多层(相隔12个方块)
![alt text](https://github.com/RavinMaddHatter/Structura/blob/main/docs/example_layer.png?raw=true)


## Linux

首先,你肯定得安装python3-tk。

选择适合你的方法:

Debian/Ubuntu:
```bash
sudo apt-get install python3.7-tk
```
Fedora:
```bash
sudo dnf install python3-tkinter
```
Arch:
```bash
yay -S python37 # yay or any other AUR component
```
要运行程序,请允许需要的模块,不过运行start.sh可以自动帮你安装:
```bash
chmod +x start.sh && sh start.sh
```

## 更新方块
从1.3版本开始,你可以手动更新方块并贡献回本项目。
[这是一篇关于它如何工作的文章](docs/Editing%20Blocks.md)
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# Structura
[![Github All Releases](https://img.shields.io/github/downloads/RavinMaddHatter/Structura/total.svg)]()

English丨[**简体中文**](https://github.com//Wulian233/Structura/blob/main/README-zh-cn.md)

This tool is inspired by Litematica. It is a tool that generates Resource packs from .mcstructure files. In this resource pack the armor stands were modified to render when off screen, and have all the blocks from your structure file as bones in their model. then "ghost blocks" are used to show the user where to place the real blocks.

Expand Down
62 changes: 21 additions & 41 deletions structura.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,11 @@
from turtle import color
import armor_stand_geo_class_2 as asgc
import armor_stand_class
import structure_reader
import animation_class
import armor_stand_class ,structure_reader ,animation_class ,manifest ,os ,glob ,json ,shutil ,updater
import render_controller_class as rcc
import manifest
from shutil import copyfile
import os
from zipfile import ZipFile
import glob
import shutil
import ntpath
import json
import updater
from zipfile import ZIP_DEFLATED, ZipFile

debug=False
debug=True

with open("lookups/nbt_defs.json") as f:
nbt_def = json.load(f)
Expand All @@ -25,7 +17,7 @@ def process_block(x,y,z,block):
data=0
skip=False
variant="Default"

for key in nbt_def.keys():
if nbt_def[key]== "variant" and key in block["states"].keys():
variant = [key,block["states"][key]]
Expand All @@ -41,7 +33,7 @@ def process_block(x,y,z,block):
open_bit = bool(block["states"][key])
if nbt_def[key]== "data" and key in block["states"].keys():
data = int(block["states"][key])

if "wood_type" in block["states"].keys():
variant = ["wood_type",block["states"]["wood_type"]]
if block["name"] == "minecraft:wood":
Expand All @@ -54,35 +46,28 @@ def process_block(x,y,z,block):
return [rot, top, variant, open_bit, data, skip]





def generate_pack(pack_name,models_object={},makeMaterialsList=False, icon="lookups/pack_icon.png"):
"""
This is the funciton that makes a structura pack:
pack_name : the name of the pack, this will be stored the the manafest.JSON as well as the name of the mcpack file
models : 'NAME_TAG': {offsets: [x, y, z],opacity: percent,structure: file.mcstructure},
makeMaterialsList : sets wether a material list shall be output.
"""


visual_name=pack_name
if len("".join(list(models_object.keys())))>1:
fileName="{} Nametags.txt".format(pack_name)
with open(fileName,"w+") as text_file:
text_file.write("These are the nametags used in this file\n")
for name in models_object.keys():

text_file.write("{}\n".format(name))



## makes a render controller class that we will use to hide models
rc=rcc.render_controller()
##makes a armor stand entity class that we will use to add models
armorstand_entity = armor_stand_class.armorstand()
##manifest is mostly hard coded in this function.
manifest.export(visual_name)

## repeate for each structure after you get it to work
#creats a base animation controller for us to put pose changes into
animation = animation_class.animations()
Expand All @@ -99,7 +84,7 @@ def generate_pack(pack_name,models_object={},makeMaterialsList=False, icon="look
struct2make = structure_reader.process_structure(models_object[model_name]["structure"])
#creates a base armorstand class for us to insert blocks
armorstand = asgc.armorstandgeo(model_name,alpha = models_object[model_name]['opacity'],offsets=models_object[model_name]['offsets'])

#gets the shape for looping
[xlen, ylen, zlen] = struct2make.get_size()
if ylen > longestY:
Expand Down Expand Up @@ -149,31 +134,31 @@ def generate_pack(pack_name,models_object={},makeMaterialsList=False, icon="look
for name in allBlocks.keys():
commonName = name.replace("minecraft:","")
text_file.write("{}: {}\n".format(commonName,allBlocks[name]))

# call export fuctions
armorstand.export(pack_name)
animation.export(pack_name)

##export the armorstand class
armorstand_entity.export(pack_name)

# Copy my icons in
copyfile(icon, "{}/pack_icon.png".format(pack_name))
# Adds to zip file a modified armor stand geometry to enlarge the render area of the entity
larger_render = "lookups/armor_stand.larger_render.geo.json"
larger_render_path = "{}/models/entity/{}".format(pack_name, "armor_stand.larger_render.geo.json")
copyfile(larger_render, larger_render_path)
# the base render controller is hard coded and just copied in


rc.export(pack_name)
## get all files
file_paths = []
for directory,_,_ in os.walk(pack_name):
file_paths.extend(glob.glob(os.path.join(directory, "*.*")))

## add all files to the mcpack file
with ZipFile("{}.mcpack".format(pack_name), 'x') as zip:
with ZipFile("{}.mcpack".format(pack_name), 'x',ZIP_DEFLATED) as zip:
# writing each file one by one

for file in file_paths:
Expand All @@ -187,13 +172,10 @@ def generate_pack(pack_name,models_object={},makeMaterialsList=False, icon="look
if __name__=="__main__":
## this is all the gui stuff that is not needed if you are calling this as a CLI

from tkinter import ttk
from tkinter import filedialog
from tkinter import messagebox
from tkinter import ttk,filedialog,messagebox
from tkinter import StringVar, Button, Label, Entry, Tk, Checkbutton, END, ACTIVE
from tkinter import filedialog, Scale,DoubleVar,HORIZONTAL,IntVar,Listbox, ANCHOR


def browseStruct():
#browse for a structure file.
FileGUI.set(filedialog.askopenfilename(filetypes=(
Expand All @@ -219,7 +201,7 @@ def box_checked():
icon_entry.grid(row=r, column=1)
IconButton.grid(row=r, column=2)
r += 1

packName_lb.grid(row=r, column=0)
packName_entry.grid(row=r, column=1)
r += 1
Expand Down Expand Up @@ -274,9 +256,6 @@ def add_model():
if len(FileGUI.get()) == 0:
valid=False
messagebox.showinfo("Error", "You need to browse for a structure file!")
## if len(model_name_var.get()) == 0:
## valid=False
## messagebox.showinfo("Error", "You need a name for the Name Tag!")
if model_name_var.get() in list(models.keys()):
messagebox.showinfo("Error", "The Name Tag mut be unique")
valid=False
Expand Down Expand Up @@ -337,8 +316,6 @@ def runFromGui():
makeMaterialsList=(export_list.get()==1),
icon=pack_icon)



offsets={}
root = Tk()
root.title("Structura")
Expand Down Expand Up @@ -371,6 +348,8 @@ def runFromGui():
IconButton = Button(root, text="Browse", command=browseIcon)
file_lb = Label(root, text="Structure file")
packName_lb = Label(root, text="Pack Name")
if debug:
debug_lb = Label(root, text="Debug Mode",fg='Red').place(x=285,y=70)
packButton = Button(root, text="Browse", command=browseStruct)
advanced_check = Checkbutton(root, text="advanced", variable=check_var, onvalue=1, offvalue=0, command=box_checked)
export_check = Checkbutton(root, text="make lists", variable=export_list, onvalue=1, offvalue=0)
Expand All @@ -385,5 +364,6 @@ def runFromGui():

box_checked()

root.resizable(0,0)
root.mainloop()
root.quit()
root.quit()