diff options
author | Maximusbarcz <maxim.baranek@gmail.com> | 2023-01-17 20:16:11 +0100 |
---|---|---|
committer | Maximusbarcz <maxim.baranek@gmail.com> | 2023-01-17 20:16:11 +0100 |
commit | 531bb27e7eb07e08e1e423d0cf01c297fef890f6 (patch) | |
tree | 15368a17e2cd41ba4c17d7f9c6fa719d7befabfa /src/main/java/dev/mayaqq/ygasi/mixin/PlayerEntityMixin.java | |
parent | c940f1261b74e83c135703fa0c35d3f8e5605761 (diff) | |
download | ygasi-531bb27e7eb07e08e1e423d0cf01c297fef890f6.tar.gz ygasi-531bb27e7eb07e08e1e423d0cf01c297fef890f6.tar.bz2 ygasi-531bb27e7eb07e08e1e423d0cf01c297fef890f6.zip |
Made the first offence1 ability work, the next is offence2! (Wish me luck)
Diffstat (limited to 'src/main/java/dev/mayaqq/ygasi/mixin/PlayerEntityMixin.java')
-rw-r--r-- | src/main/java/dev/mayaqq/ygasi/mixin/PlayerEntityMixin.java | 34 |
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 |