aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/dev/mayaqq/ygasi/mixin/StatusEffectMixin.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/dev/mayaqq/ygasi/mixin/StatusEffectMixin.java')
-rw-r--r--src/main/java/dev/mayaqq/ygasi/mixin/StatusEffectMixin.java42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/main/java/dev/mayaqq/ygasi/mixin/StatusEffectMixin.java b/src/main/java/dev/mayaqq/ygasi/mixin/StatusEffectMixin.java
new file mode 100644
index 0000000..e2df799
--- /dev/null
+++ b/src/main/java/dev/mayaqq/ygasi/mixin/StatusEffectMixin.java
@@ -0,0 +1,42 @@
+package dev.mayaqq.ygasi.mixin;
+
+import dev.mayaqq.ygasi.util.AdvUtils;
+import dev.mayaqq.ygasi.util.Multithreading;
+import net.minecraft.entity.LivingEntity;
+import net.minecraft.entity.attribute.AttributeContainer;
+import net.minecraft.entity.effect.StatusEffect;
+import net.minecraft.entity.effect.StatusEffects;
+import net.minecraft.server.network.ServerPlayerEntity;
+import net.minecraft.sound.SoundCategory;
+import net.minecraft.sound.SoundEvent;
+import net.minecraft.sound.SoundEvents;
+import net.minecraft.text.Text;
+import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.Shadow;
+import org.spongepowered.asm.mixin.injection.At;
+import org.spongepowered.asm.mixin.injection.Inject;
+import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
+
+import java.util.concurrent.TimeUnit;
+
+import static dev.mayaqq.ygasi.Ygasi.LOGGER;
+import static dev.mayaqq.ygasi.abilities.mercenary.Offence1.attackList;
+
+@Mixin(StatusEffect.class)
+public abstract class StatusEffectMixin {
+
+ @Shadow public abstract Text getName();
+
+ @Inject(method = "onRemoved", at = @At("HEAD"))
+ public void onUpdateStatusEffect(LivingEntity entity, AttributeContainer attributes, int amplifier, CallbackInfo ci) {
+ LOGGER.info("onRemovedTick");
+ if (entity.isPlayer()) {
+ ServerPlayerEntity player = (ServerPlayerEntity) entity;
+ if (this.getName() != null && this.getName().equals(StatusEffects.STRENGTH.getName()) && AdvUtils.getAdvancementProgress(player, "minecraft", "ygasi/offence1")) {
+ Multithreading.schedule(() -> {
+ attackList.entrySet().removeIf(entry -> entry.getKey().startsWith(player.getUuidAsString()));
+ },4, TimeUnit.SECONDS);
+ }
+ }
+ }
+}