|
| 1 | +package dev.isxander.debugify.client.mixins.basic.mc188359; |
| 2 | + |
| 3 | +import dev.isxander.debugify.fixes.BugFix; |
| 4 | +import dev.isxander.debugify.fixes.FixCategory; |
| 5 | +import net.minecraft.core.Holder; |
| 6 | +import net.minecraft.sounds.SoundEvent; |
| 7 | +import net.minecraft.sounds.SoundEvents; |
| 8 | +import net.minecraft.sounds.SoundSource; |
| 9 | +import net.minecraft.util.Mth; |
| 10 | +import net.minecraft.world.entity.LivingEntity; |
| 11 | +import net.minecraft.world.item.ItemStack; |
| 12 | +import net.minecraft.world.item.component.Consumable; |
| 13 | +import net.minecraft.world.level.Level; |
| 14 | +import org.spongepowered.asm.mixin.Final; |
| 15 | +import org.spongepowered.asm.mixin.Mixin; |
| 16 | +import org.spongepowered.asm.mixin.Shadow; |
| 17 | +import org.spongepowered.asm.mixin.injection.At; |
| 18 | +import org.spongepowered.asm.mixin.injection.Inject; |
| 19 | +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; |
| 20 | + |
| 21 | +@BugFix(id = "MC-188359", category = FixCategory.BASIC, env = BugFix.Env.CLIENT, description = "Burp sound does not play after drinking or after eating cake") |
| 22 | +@Mixin(Consumable.class) |
| 23 | +public class ConsumableMixin { |
| 24 | + @Shadow |
| 25 | + @Final |
| 26 | + private Holder<SoundEvent> sound; |
| 27 | + |
| 28 | + @Inject(method = "onConsume", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/item/ItemStack;consume(ILnet/minecraft/world/entity/LivingEntity;)V")) |
| 29 | + private void addBurpSound(Level level, LivingEntity livingEntity, ItemStack itemStack, CallbackInfoReturnable<ItemStack> cir) { |
| 30 | + if (this.sound.is(SoundEvents.GENERIC_DRINK) && livingEntity.isAlwaysTicking()) { |
| 31 | + level.playLocalSound(livingEntity.getX(), livingEntity.getY(), livingEntity.getZ(), SoundEvents.PLAYER_BURP, SoundSource.PLAYERS, 0.5F, Mth.randomBetween(livingEntity.getRandom(), 0.9F, 1.0F), false); |
| 32 | + } |
| 33 | + } |
| 34 | +} |
0 commit comments