Skip to content

Commit

Permalink
Only play trident noise for self
Browse files Browse the repository at this point in the history
  • Loading branch information
Aeltumn committed Aug 18, 2024
1 parent cc0a540 commit 70492f1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.noxcrew.noxesium.feature.entity.LivingEntityExtension;
import com.noxcrew.noxesium.feature.rule.ServerRules;
import net.minecraft.client.Minecraft;
import net.minecraft.core.Holder;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.sounds.SoundEvent;
Expand Down Expand Up @@ -155,6 +156,7 @@ public Collection<MobEffectInstance> getActiveEffects(Operation<Collection<MobEf
@Inject(method = "isAutoSpinAttack", at = @At(value = "HEAD"), cancellable = true)
private void isAutoSpinAttack(CallbackInfoReturnable<Boolean> cir) {
if (!ServerRules.ENABLE_SMOOTHER_CLIENT_TRIDENT.getValue()) return;
if (((Object) this) != Minecraft.getInstance().player) return;
cir.setReturnValue(this.autoSpinAttackTicks > 0);
}

Expand All @@ -164,6 +166,7 @@ private void isAutoSpinAttack(CallbackInfoReturnable<Boolean> cir) {
@Inject(method = "baseTick", at = @At(value = "TAIL"))
private void onTick(CallbackInfo ci) {
if (!ServerRules.ENABLE_SMOOTHER_CLIENT_TRIDENT.getValue()) return;
if (((Object) this) != Minecraft.getInstance().player) return;

// Reduce the use attempt ticks
if (noxesium$attemptUseTicks > 0) noxesium$attemptUseTicks--;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ private static boolean isTooDamagedToUse(ItemStack itemStack) {
@Inject(method = "releaseUsing", at = @At(value = "HEAD"))
public void coyoteTimeRelease(ItemStack itemStack, Level level, LivingEntity livingEntity, int remaining, CallbackInfo ci) {
if (!ServerRules.ENABLE_SMOOTHER_CLIENT_TRIDENT.getValue()) return;
if (livingEntity != Minecraft.getInstance().player) return;

if (livingEntity instanceof Player player) {
// Ignore non-riptide tridents!
Expand All @@ -56,6 +57,7 @@ public void coyoteTimeRelease(ItemStack itemStack, Level level, LivingEntity liv
@Redirect(method = "releaseUsing", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/Level;playSound(Lnet/minecraft/world/entity/player/Player;Lnet/minecraft/world/entity/Entity;Lnet/minecraft/sounds/SoundEvent;Lnet/minecraft/sounds/SoundSource;FF)V"))
public void playSound(Level instance, Player player, Entity entity, SoundEvent soundEvent, SoundSource soundSource, float volume, float pitch) {
if (!ServerRules.ENABLE_SMOOTHER_CLIENT_TRIDENT.getValue()) return;
if (entity != Minecraft.getInstance().player) return;

// Reset the coyote time as we've just activated the riptide.
if (entity instanceof LivingEntity livingEntity) {
Expand Down

0 comments on commit 70492f1

Please sign in to comment.