Every KILL has it's ULTRA

- Jhon Ultrakill
This commit is contained in:
YuRaNnNzZZ 2023-02-27 20:06:03 +03:00
parent 0d33ce228a
commit de68575848
Signed by: YuRaNnNzZZ
GPG Key ID: 5F71738C85A6006D
5 changed files with 44 additions and 1 deletions

View File

@ -34,6 +34,11 @@ class SoundDataProvider(event: GatherDataEvent) : SoundDefinitionsProvider(event
add(MSoundEvents.ANDROID_SHOCKWAVE,
definition().subtitle("otm.sound.android.shockwave")
.with(SoundDefinition.Sound.sound(modLocation("android/shockwave"), SoundDefinition.SoundType.SOUND)))
add(MSoundEvents.ANDROID_PROJ_PARRY,
definition().subtitle("otm.sound.android.projectile_parry")
.with(SoundDefinition.Sound.sound(modLocation("android/punch_projectile"), SoundDefinition.SoundType.SOUND))
)
}
private inline fun add(value: SoundEvent, block: SoundDefinition.() -> Unit) {

View File

@ -0,0 +1,36 @@
package ru.dbotthepony.mc.otm.mixin;
import net.minecraft.sounds.SoundSource;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.projectile.AbstractHurtingProjectile;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import ru.dbotthepony.mc.otm.capability.MatteryCapability;
import ru.dbotthepony.mc.otm.registry.MSoundEvents;
@Mixin(AbstractHurtingProjectile.class)
public class MixinAbstractHurtingProjectile {
@Inject(
method = "hurt(Lnet/minecraft/world/damagesource/DamageSource;F)Z",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/world/entity/projectile/AbstractHurtingProjectile;markHurt()V",
ordinal = 0
)
)
public void onProjectileHit(DamageSource pSource, float pAmount, CallbackInfoReturnable<Boolean> cir) {
Entity entity = pSource.getEntity();
if (entity == null) return;
entity.getCapability(MatteryCapability.MATTERY_PLAYER).ifPresent(cap -> {
AbstractHurtingProjectile proj = (AbstractHurtingProjectile)(Object)this;
if (cap.isAndroid() && proj.getOwner() != entity) {
entity.level.playSound(entity, proj.blockPosition(), MSoundEvents.INSTANCE.getANDROID_PROJ_PARRY(), SoundSource.PLAYERS, 1.0f, 0.95f + entity.level.random.nextFloat() * 0.1f);
}
});
}
}

View File

@ -23,6 +23,7 @@ object MSoundEvents {
val ANDROID_JUMP_BOOST: SoundEvent by make("android.jump_boost")
val ANDROID_SHOCKWAVE: SoundEvent by make("android.shockwave")
val ANDROID_PROJ_PARRY: SoundEvent by make("android.projectile_parry")
internal fun register(bus: IEventBus) {
registry.register(bus)

View File

@ -8,6 +8,7 @@
"mixins": [
"MixinPatchProjectileFinder",
"MixinLivingEntity",
"MixinAnvilBlock"
"MixinAnvilBlock",
"MixinAbstractHurtingProjectile"
]
}