aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/dev/mayaqq/ygasi/mixin/PlayerEntityMixin.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/dev/mayaqq/ygasi/mixin/PlayerEntityMixin.java')
-rw-r--r--src/main/java/dev/mayaqq/ygasi/mixin/PlayerEntityMixin.java34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/main/java/dev/mayaqq/ygasi/mixin/PlayerEntityMixin.java b/src/main/java/dev/mayaqq/ygasi/mixin/PlayerEntityMixin.java
new file mode 100644
index 0000000..5eeea63
--- /dev/null
+++ b/src/main/java/dev/mayaqq/ygasi/mixin/PlayerEntityMixin.java
@@ -0,0 +1,34 @@
+package dev.mayaqq.ygasi.mixin;
+
+import dev.mayaqq.ygasi.util.AdvUtils;
+import net.minecraft.entity.Entity;
+import net.minecraft.entity.effect.StatusEffectInstance;
+import net.minecraft.entity.effect.StatusEffects;
+import net.minecraft.entity.player.PlayerEntity;
+import net.minecraft.server.network.ServerPlayerEntity;
+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 static dev.mayaqq.ygasi.abilities.mercenary.Offence1.attackList;
+
+@Mixin(PlayerEntity.class)
+public abstract class PlayerEntityMixin {
+ @Shadow public abstract boolean isPlayer();
+
+ @Inject(method = "attack", at = @At("HEAD"))
+ public void onAttack(Entity target, CallbackInfo ci) {
+ if (this.isPlayer()) {
+ ServerPlayerEntity player = (ServerPlayerEntity) (Object) this;
+ if (!attackList.containsKey(player.getUuidAsString() + target.getUuidAsString()) && AdvUtils.getAdvancementProgress(player, "minecraft", "ygasi/offence1")) {
+ attackList.put(player.getUuidAsString() + target.getUuidAsString(), true);
+ StatusEffectInstance currentEffect = player.getStatusEffect(StatusEffects.STRENGTH);
+ int currentLevel = currentEffect != null ? currentEffect.getAmplifier() : 0;
+ int currentTime = currentEffect != null ? currentEffect.getDuration() : 0;
+ player.addStatusEffect(new StatusEffectInstance(StatusEffects.STRENGTH, currentTime + 2 * 20, currentLevel, false, false, true));
+ }
+ }
+ }
+} \ No newline at end of file