commit e82f1f5cc830a919ebf1817eb072a09fdd4c7c0b Author: ChaoticByte Date: Tue Jul 23 19:38:54 2024 +0200 Add project files diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e35d885 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +_build diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..920dc4f --- /dev/null +++ b/LICENSE @@ -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. diff --git a/README.md b/README.md new file mode 100644 index 0000000..76c1860 --- /dev/null +++ b/README.md @@ -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. diff --git a/build.py b/build.py new file mode 100755 index 0000000..1a8fbf2 --- /dev/null +++ b/build.py @@ -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) diff --git a/data/minecraft/tags/functions/load.json b/data/minecraft/tags/functions/load.json new file mode 100644 index 0000000..a9b826e --- /dev/null +++ b/data/minecraft/tags/functions/load.json @@ -0,0 +1,3 @@ +{ + "values": ["peaceful_enforced:set_peaceful"] +} \ No newline at end of file diff --git a/data/peaceful_enforced/functions/set_peaceful.mcfunction b/data/peaceful_enforced/functions/set_peaceful.mcfunction new file mode 100644 index 0000000..5402af8 --- /dev/null +++ b/data/peaceful_enforced/functions/set_peaceful.mcfunction @@ -0,0 +1 @@ +difficulty peaceful \ No newline at end of file diff --git a/fabric.mod.json b/fabric.mod.json new file mode 100644 index 0000000..1a03786 --- /dev/null +++ b/fabric.mod.json @@ -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": "*" + } +} \ No newline at end of file diff --git a/pack.mcmeta b/pack.mcmeta new file mode 100644 index 0000000..9526f09 --- /dev/null +++ b/pack.mcmeta @@ -0,0 +1,6 @@ +{ + "pack": { + "pack_format": 15, + "description": "Enforces the peaceful difficulty" + } +}