Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Effect #2

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions mcproto/_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,36 @@
"red",
"black",
]

EFFECTE: TypeAlias = Literal[
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bitte Einzahl, also EFFECT anstelle von EFFECTE

"speed",
"slowness",
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Es fehlen drei Effekte: darkness, luck und unluck. Bitte diese noch hinzufügen.
Ich würde auch empfehlen, die Effekte im Literal alphabetisch zu sortieren!
Damit kann man viel leichter sehen, was man hat, was fehlt, auch wenn wir die Liste später updaten wollen 👍

"haste",
"mining_fatigue",
"strength",
"instant_health",
"instant_damage",
"jump_boost",
"nausea",
"regeneration",
"resistance",
"fire_resistance",
"water_breathing",
"invisibility",
"blindness",
"night_vision",
"hunger",
"weakness",
"poison",
"wither",
"health_boost",
"absorption",
"saturation",
"glowing",
"levitation",
"slow_falling",
"conduit_power",
"bad_omen",
"hero_of_the_village",
"dolphins_grace"
]
7 changes: 5 additions & 2 deletions mcproto/entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from functools import partial

from ._base import HasStub, _EntityProvider
from ._types import COLOR
from ._types import COLOR, EFFECT
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Konnte wegen Typo dieses Befehl nicht testen (in _types heißt der Typ EFFECTE, bitte dort ausbesser), im Moment ist das ein ImportError!

from ._util import ThreadSafeCachedKeyBasedFactory
from .colors import color_codes
from .exception import raise_on_error
Expand Down Expand Up @@ -121,11 +121,14 @@ def getEntitiesAround(
return [e for e in entities if e is not self]

def giveEffect(
self, effect: str, seconds: int = 30, amplifier: int = 0, particles: bool = True
self, effect: EFFECT, seconds: int = 30, amplifier: int = 0, particles: bool = True
) -> None:
pbool = str(not bool(particles)).lower()
self.runCommand(f"effect give @s {effect} {int(seconds)} {amplifier} {pbool}")

def clear_effect(self, EFFECT: str = "") -> None:
Copy link
Owner

@icezyclon icezyclon May 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bitte argument klein schreiben, und den richtigen Typen angeben: Also, (self, effect: EFFECT | None = None) und dann auf das None eingehen.
Und auch bitte CamelCase verwenden

self.runCommand(f'effect clear @s {effect}')

def replaceItem(self, where: str, item: str, amount: int = 1, nbt: NBT | None = None) -> None:
if nbt is None:
self.runCommand(f"item replace entity @s {where} with {item} {amount}")
Expand Down