Add project files
This commit is contained in:
commit
e82f1f5cc8
8 changed files with 108 additions and 0 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
_build
|
21
LICENSE
Normal file
21
LICENSE
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2024 Julian Müller (ChaoticByte)
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
4
README.md
Normal file
4
README.md
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
# Peaceful Enforced
|
||||||
|
|
||||||
|
This mod for **Minecraft 1.20.1** w/ **Fabric** sets the difficulty to peaceful when it is loaded.
|
||||||
|
Useful for modpack developers.
|
52
build.py
Executable file
52
build.py
Executable file
|
@ -0,0 +1,52 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
from json import load
|
||||||
|
from os import chdir
|
||||||
|
from pathlib import Path
|
||||||
|
from shutil import copy
|
||||||
|
from shutil import copytree
|
||||||
|
from shutil import make_archive
|
||||||
|
from shutil import rmtree
|
||||||
|
|
||||||
|
|
||||||
|
project_dir = Path(".").resolve()
|
||||||
|
build_root_dir = project_dir / "_build"
|
||||||
|
|
||||||
|
fabric_mod_json_path = project_dir / "fabric.mod.json"
|
||||||
|
source_files = [
|
||||||
|
fabric_mod_json_path,
|
||||||
|
project_dir / "pack.mcmeta",
|
||||||
|
project_dir / "data"
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
def get_build_name(mod_info: dict) -> str:
|
||||||
|
return f"{mod_info['id'].replace('_', '-')}-{mod_info['version']}-mc{mod_info['depends']['minecraft']}"
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
# load mod info
|
||||||
|
with fabric_mod_json_path.open("r") as f:
|
||||||
|
mod_info = load(f)
|
||||||
|
# get build name
|
||||||
|
build_name = get_build_name(mod_info)
|
||||||
|
# clear/create required directories
|
||||||
|
build_tmp_dir = build_root_dir / build_name
|
||||||
|
if build_tmp_dir.exists():
|
||||||
|
rmtree(build_tmp_dir)
|
||||||
|
build_tmp_dir.mkdir(parents=True)
|
||||||
|
# copy source files
|
||||||
|
for s in source_files:
|
||||||
|
if s.is_dir():
|
||||||
|
copytree(s, build_tmp_dir / s.name)
|
||||||
|
else:
|
||||||
|
copy(s, build_tmp_dir / s.name)
|
||||||
|
# create jar archive
|
||||||
|
chdir(build_root_dir)
|
||||||
|
make_archive(build_name, "zip", build_tmp_dir.name)
|
||||||
|
output_file = Path(build_name + ".zip").rename(build_name + ".jar").resolve()
|
||||||
|
chdir(project_dir)
|
||||||
|
# cleanup
|
||||||
|
rmtree(build_tmp_dir)
|
||||||
|
# done
|
||||||
|
print("Done. The resulting jar file is at", output_file)
|
3
data/minecraft/tags/functions/load.json
Normal file
3
data/minecraft/tags/functions/load.json
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
"values": ["peaceful_enforced:set_peaceful"]
|
||||||
|
}
|
1
data/peaceful_enforced/functions/set_peaceful.mcfunction
Normal file
1
data/peaceful_enforced/functions/set_peaceful.mcfunction
Normal file
|
@ -0,0 +1 @@
|
||||||
|
difficulty peaceful
|
20
fabric.mod.json
Normal file
20
fabric.mod.json
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
{
|
||||||
|
"schemaVersion": 1,
|
||||||
|
"id": "peaceful_enforced",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"name": "Peaceful Enforced",
|
||||||
|
"description": "Enforces the peaceful difficulty",
|
||||||
|
"authors": [
|
||||||
|
"ChaoticByte"
|
||||||
|
],
|
||||||
|
"contact": {
|
||||||
|
"sources": "https://github.com/ChaoticByte/peaceful-enforced",
|
||||||
|
"issues": "https://github.com/ChaoticByte/peaceful-enforced/issues"
|
||||||
|
},
|
||||||
|
"license": "MIT",
|
||||||
|
"environment": "*",
|
||||||
|
"depends": {
|
||||||
|
"minecraft": "1.20.1",
|
||||||
|
"fabric-resource-loader-v0": "*"
|
||||||
|
}
|
||||||
|
}
|
6
pack.mcmeta
Normal file
6
pack.mcmeta
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"pack": {
|
||||||
|
"pack_format": 15,
|
||||||
|
"description": "Enforces the peaceful difficulty"
|
||||||
|
}
|
||||||
|
}
|
Reference in a new issue