Skip to content

Commit 638c266

Browse files
committed
add more types, and auto-updating for frequently changing types
1 parent d0efe4c commit 638c266

14 files changed

Lines changed: 1822 additions & 252 deletions

File tree

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
on:
2+
schedule:
3+
- cron: "0 0 * * *"
4+
5+
jobs:
6+
update:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- name: Checkout
10+
uses: actions/checkout@v3
11+
with:
12+
fetch-depth: "1"
13+
- name: Setup Python
14+
uses: actions/setup-python@v4
15+
with:
16+
python-version: "3.10"
17+
- name: Install and configure Poetry
18+
uses: snok/install-poetry@v1
19+
- name: Install dependencies
20+
run: "poetry install"
21+
- name: Run script
22+
id: script
23+
run: "poetry run python tools/update_specific_types.py"
24+
- name: Push
25+
if: ${{ steps.script.outputs.release }} == true
26+
uses: stefanzweifel/git-auto-commit-action@v4
27+
- name: "Get Previous tag"
28+
if: ${{ steps.script.outputs.release }} == true
29+
id: previoustag
30+
uses: "WyriHaximus/github-action-get-previous-tag@v1"
31+
- name: "Get next minor version"
32+
if: ${{ steps.script.outputs.release }} == true
33+
id: semvers
34+
uses: "WyriHaximus/github-action-next-semvers@v1"
35+
with:
36+
version: ${{ steps.previoustag.outputs.tag }}
37+
- name: Create Release
38+
if: ${{ steps.script.outputs.release }} == true
39+
id: create_release
40+
uses: actions/create-release@latest
41+
env:
42+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
43+
with:
44+
tag_name: ${{ steps.semvers.outputs.patch }}
45+
release_name: Release ${{ github.ref }}
46+
body: "This automated release was created, because there are new things in Minecraft."
47+
draft: false
48+
prerelease: false

poetry.lock

Lines changed: 60 additions & 118 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pymcfunction/commands/execute.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ def atEntity(self, target: str):
1414
self.currentQuery += f"at {target} "
1515
return self
1616

17-
def ifBlock(self, coord: str, block: str):
18-
self.currentQuery += f"if block {coord} {block} "
17+
def ifBlock(self, coord: str, block: Block):
18+
self.currentQuery += f"if block {coord} {block.value} "
1919
return self
2020

2121
def ifBlocks(self, coord1: str, coord2: str, matchcoord: str, masked: bool = True):
@@ -50,8 +50,8 @@ def ifScoreCompared(
5050
self.currentQuery += f"if score {selector1} {scoreboard1.name} {operator} {selector2} {scoreboard2.name} "
5151
return self
5252

53-
def unlessBlock(self, coord: str, block: str):
54-
self.currentQuery += f"unless block {coord} {block} "
53+
def unlessBlock(self, coord: str, block: Block):
54+
self.currentQuery += f"unless block {coord} {block.value} "
5555
return self
5656

5757
def unlessBlocks(

pymcfunction/commands/item.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
from pymcfunction.types import ContainerType
2+
from pymcfunction.update_specific_types.block import Block
3+
from pymcfunction.update_specific_types.item import Item
24

35

46
class item:
@@ -11,11 +13,11 @@ def modifyEntity(self, target: str, slot: str, modifier: str):
1113
def modifyBlock(self, coord: str, slot: str, modifier: str):
1214
return f"item modify block {coord} {slot} {modifier}"
1315

14-
def replaceEntity(self, target: str, slot: str, item: str, count: int = 1):
15-
return f"item replace entity {target} {slot} with {item} {count}"
16+
def replaceEntity(self, target: str, slot: str, item: Item | Block, count: int = 1):
17+
return f"item replace entity {target} {slot} with {item.vale} {count}"
1618

17-
def replaceBlock(self, coord: str, slot: str, item: str, count: int = 1):
18-
return f"item replace block {coord} {slot} with {item} {count}"
19+
def replaceBlock(self, coord: str, slot: str, item: Item | Block, count: int = 1):
20+
return f"item replace block {coord} {slot} with {item.value} {count}"
1921

2022
def copy(
2123
self,

pymcfunction/commands/simple.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
from types import NoneType
22
from pymcfunction.types import BanListType, Difficultiy, Gamemode, Weather
3+
from pymcfunction.update_specific_types.block import Block
4+
from pymcfunction.update_specific_types.entity import Entity
5+
from pymcfunction.update_specific_types.item import Item
36
from pymcfunction.util import _dictToMcKeyVal
47

58

@@ -52,8 +55,8 @@ def setidletimeout(minutes: int):
5255
return "setidletimeout " + str(minutes)
5356

5457

55-
def give(target: str, item: str, count: int = 1):
56-
return f"give {target} {count}"
58+
def give(target: str, item: Item | Block, count: int = 1):
59+
return f"give {target} {item.value} {count}"
5760

5861

5962
def kill(target: str):
@@ -111,8 +114,8 @@ def banlist(_type: BanListType):
111114
return "banlist " + _type.value
112115

113116

114-
def summon(entity: str, pos: str = "~ ~ ~", nbt: dict | str = None):
115-
return f"summon {entity} {pos}" + (
117+
def summon(entity: Entity, pos: str = "~ ~ ~", nbt: dict | str = None):
118+
return f"summon {entity.value} {pos}" + (
116119
((" " + (_dictToMcKeyVal(nbt)) if type(nbt) == dict else nbt)) if nbt else ""
117120
)
118121

0 commit comments

Comments
 (0)