From 3eb3a1b106c8ebdb9bfd8b86c5b4d99b678a66e6 Mon Sep 17 00:00:00 2001 From: paul07iq <127239640+paul07iq@users.noreply.github.com> Date: Sun, 19 May 2024 13:43:55 +0200 Subject: [PATCH 1/4] Added clear_effect Added clear_effect --- mcproto/entity.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mcproto/entity.py b/mcproto/entity.py index 6d10407..f2d8036 100644 --- a/mcproto/entity.py +++ b/mcproto/entity.py @@ -126,6 +126,9 @@ def giveEffect( pbool = str(not bool(particles)).lower() self.runCommand(f"effect give @s {effect} {int(seconds)} {amplifier} {pbool}") + def clear_effect(self, effect: str = "") -> None: + 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}") From 3092c4dd3fb71b663a1c7955d157f5c513e1f2ab Mon Sep 17 00:00:00 2001 From: paul07iq <127239640+paul07iq@users.noreply.github.com> Date: Sun, 19 May 2024 14:07:32 +0200 Subject: [PATCH 2/4] Added effects to _types.py Added effects to _types.py --- mcproto/_types.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/mcproto/_types.py b/mcproto/_types.py index 12c7836..52f5338 100644 --- a/mcproto/_types.py +++ b/mcproto/_types.py @@ -23,3 +23,35 @@ "red", "black", ] + +EFFECTE: TypeAlias = Literal[ + "speed", + "slowness", + "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" +] From 2b61b831f4070aeced5d874b1ffd1e48b5b16839 Mon Sep 17 00:00:00 2001 From: paul07iq <127239640+paul07iq@users.noreply.github.com> Date: Sun, 19 May 2024 14:09:56 +0200 Subject: [PATCH 3/4] Used effect list from _types.py Used effect list from _types.py --- mcproto/entity.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mcproto/entity.py b/mcproto/entity.py index f2d8036..994f1f5 100644 --- a/mcproto/entity.py +++ b/mcproto/entity.py @@ -4,7 +4,7 @@ from functools import partial from ._base import HasStub, _EntityProvider -from ._types import COLOR +from ._types import COLOR, EFFECT from ._util import ThreadSafeCachedKeyBasedFactory from .colors import color_codes from .exception import raise_on_error @@ -121,12 +121,12 @@ 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: + def clear_effect(self, EFFECT: str = "") -> None: self.runCommand(f'effect clear @s {effect}') def replaceItem(self, where: str, item: str, amount: int = 1, nbt: NBT | None = None) -> None: From dce8750027bff6587daf72195481491db343b4a5 Mon Sep 17 00:00:00 2001 From: paul07iq <127239640+paul07iq@users.noreply.github.com> Date: Sun, 19 May 2024 14:34:36 +0200 Subject: [PATCH 4/4] Update _types.py Update _types.py --- mcproto/_types.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mcproto/_types.py b/mcproto/_types.py index 52f5338..d183317 100644 --- a/mcproto/_types.py +++ b/mcproto/_types.py @@ -27,7 +27,8 @@ EFFECTE: TypeAlias = Literal[ "speed", "slowness", - "haste", "mining_fatigue", + "haste", + "mining_fatigue", "strength", "instant_health", "instant_damage",