-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathnew_block.py
98 lines (73 loc) · 2.82 KB
/
new_block.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# written in 3 seconds cause i hate making 500 files just to make a block don't judge my code
import json
MODID = "nyakomod"
def color(code):
return f"\033[0;{code}m"
def main():
block_name = input(f"{color('37;1;4')}Enter the name of the block (ex. Diamond Launcher):\n{color('31;1')}> {color('0')}")
block_id = input(f"{color('37;1;4')}Enter the ID of the block (ex. diamond_launcher):\n{color('31;1')}> {color('0')}")
block_class = input(f"{color('37;1;4')}Enter the class name of the block (ex. DiamondLauncherBlock):\n{color('31;1')}> {color('0')}")
print(f"{color('37;1;4;6')}Nice block")
with open(f"src/main/resources/assets/{MODID}/lang/en_us.json", encoding="utf-8") as f:
data = json.load(f)
data[f"block.{MODID}.{block_id}"] = block_name
with open(f"src/main/resources/assets/{MODID}/lang/en_us.json", "w", encoding="utf-8") as write_file:
json.dump(data, write_file, sort_keys=True, indent=4)
with open(f"src/main/resources/assets/{MODID}/blockstates/{block_id}.json", "x") as file:
file.write(
"""{
\"variants\": {
\"\": { "model": \"""" + MODID +""":block/""" + block_id + """\" }
}
}""")
print(f"{color('0')}src/main/resources/assets/{MODID}/blockstates/{block_id}.json")
with open(f"src/main/resources/assets/{MODID}/models/block/{block_id}.json", "x") as file:
file.write(
"""{
\"parent\": \"block/cube_all\",
\"textures\": {
\"\": { "all": \"""" + MODID +""":block/""" + block_id + """\" }
}
}""")
print(f"src/main/resources/assets/{MODID}/models/block/{block_id}.json")
with open(f"src/main/resources/assets/{MODID}/models/item/{block_id}.json", "x") as file:
file.write(
"""{
"parent": \"""" + MODID +""":block/""" + block_id + """\"
}""")
print(f"src/main/resources/assets/{MODID}/models/item/{block_id}.json")
with open(f"src/main/resources/data/{MODID}/loot_tables/blocks/{block_id}.json", "x") as file:
file.write(
"""{
"type": "minecraft:block",
"pools": [
{
"rolls": 1,
"entries": [
{
"type": "minecraft:item",
"name": \"""" + MODID + """:""" + block_id + """"
}
],
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
]
}
]
}""")
print(f"src/main/resources/data/{MODID}/loot_tables/blocks/{block_id}.json")
with open(f"src/main/java/gay/nyako/{MODID}/block/{block_class}.java", "x") as file:
file.write(
f"""package gay.nyako.nyakomod.block;
import net.minecraft.block.Block;
public class {block_class} extends Block {{
public {block_class}(Settings settings) {{
super(settings);
}}
}}""")
print(f"src/main/java/gay/nyako/{MODID}/{block_class}.java")
print(f"{color('0')}it has been done and congratulation")
if __name__ == "__main__":
main()