Skip to content

Commit

Permalink
Added function commands and fixed docs in PackManager.DataPack.__init__
Browse files Browse the repository at this point in the history
  • Loading branch information
DoubleF3lix committed Oct 21, 2021
1 parent b537d13 commit 023a7ca
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
13 changes: 13 additions & 0 deletions onyx/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -1502,6 +1502,19 @@ def fill(
f"fill {translate(corner1)} {translate(corner2)} {translate(block)} {translate(mode) if mode else ''} {translate(replace_block) if replace_block else ''}"
)

@staticmethod
def function(function: Union["Function", str]) -> str:
"""
function - Executes a function
Args:
function (Union[Function, str]): The function to execute. An alternative to ``function <FunctionObj>`` is just ``<FunctionObj()>``.
Returns:
str: Command
"""
return Commands.push(f"function {translate(function)}")

@staticmethod
def gamemode(mode: gamemode, players: Selector) -> str:
"""
Expand Down
5 changes: 4 additions & 1 deletion onyx/pack_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def generate(
only_generate_zip_object: bool = False,
print_output_path: bool = True,
print_generation_time: bool = True,
) -> None:
) -> dict:
"""
generate - Generates the data pack
Expand All @@ -58,6 +58,9 @@ def generate(
only_generate_zip_object (bool, optional): If set, only returns a ``ZipFile`` object instead of generating a file/folder. Defaults to False.
print_output_path (bool, optional): Whether to print the output path of the data pack. Defaults to True.
print_generation_time (bool): Whether the generation time should be printed to the console. Defaults to False.
Returns:
dict: A dictionary containing the output path of the data pack, the generation time, and the ``ZipFile`` object if ``only_generate_zip_object`` is ``True``.
"""
# Generate the initialization function file (make sure it has any commands in it, otherwise don't bother)
if self.init_contents:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name="onyx-mclib",
version="2.1.0",
version="2.1.1",
description="A python library to create minecraft data packs",
long_description=long_description,
long_description_content_type="text/markdown",
Expand Down

0 comments on commit 023a7ca

Please sign in to comment.