diff --git a/src/main/java/com/mrcrayfish/guns/entity/EntityThrowableItem.java b/src/main/java/com/mrcrayfish/guns/entity/EntityThrowableItem.java index 2338fb837..269656451 100644 --- a/src/main/java/com/mrcrayfish/guns/entity/EntityThrowableItem.java +++ b/src/main/java/com/mrcrayfish/guns/entity/EntityThrowableItem.java @@ -1,5 +1,6 @@ package com.mrcrayfish.guns.entity; +import com.mrcrayfish.guns.init.ModSounds; import net.minecraft.block.BlockState; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityType; @@ -11,6 +12,7 @@ import net.minecraft.util.Direction; import net.minecraft.util.SoundCategory; import net.minecraft.util.SoundEvent; +import net.minecraft.util.SoundEvents; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockRayTraceResult; import net.minecraft.util.math.EntityRayTraceResult; @@ -106,7 +108,25 @@ protected void onImpact(RayTraceResult result) double speed = this.getMotion().length(); if(speed > 0.1) { - this.world.playSound(null, result.getHitVec().x, result.getHitVec().y, result.getHitVec().z, event, SoundCategory.AMBIENT, 1.0F, 1.0F); + float pitch = 1.4F + 0.2F * rand.nextFloat(); + boolean hitStone = event == SoundEvents.BLOCK_STONE_STEP; + if(hitStone || event == SoundEvents.BLOCK_METAL_STEP || event == SoundEvents.BLOCK_ANVIL_STEP) + { + event = ModSounds.ENTITY_STUN_GRENADE_HIT_STONE.get(); + if(!hitStone) + { + pitch += 0.5F; + } + } + else if(event == SoundEvents.BLOCK_GLASS_STEP) + { + event = ModSounds.ENTITY_STUN_GRENADE_HIT_GLASS.get(); + } + else if(event == SoundEvents.BLOCK_WOOD_STEP || event == SoundEvents.BLOCK_LADDER_STEP) + { + event = ModSounds.ENTITY_STUN_GRENADE_HIT_WOOD.get(); + } + this.world.playSound(null, result.getHitVec().x, result.getHitVec().y, result.getHitVec().z, event, SoundCategory.AMBIENT, (float) Math.min(1, speed), pitch); } Direction direction = blockResult.getFace(); switch(direction.getAxis()) diff --git a/src/main/java/com/mrcrayfish/guns/init/ModSounds.java b/src/main/java/com/mrcrayfish/guns/init/ModSounds.java index 7aa1b00d7..d5b7ea270 100644 --- a/src/main/java/com/mrcrayfish/guns/init/ModSounds.java +++ b/src/main/java/com/mrcrayfish/guns/init/ModSounds.java @@ -26,8 +26,11 @@ public class ModSounds public static final RegistryObject ITEM_MACHINE_PISTOL_FIRE = register("item.machine_pistol.fire"); public static final RegistryObject ITEM_MACHINE_PISTOL_SILENCED_FIRE = register("item.machine_pistol.silenced_fire"); public static final RegistryObject ITEM_GRENADE_PIN = register("item.grenade.pin"); - public static final RegistryObject ENTITY_STUN_GRENADE_EXPLOSION = register("entity.stun_grenade.explosion"); - public static final RegistryObject ENTITY_STUN_GRENADE_RING = register("entity.stun_grenade.ring"); + public static final RegistryObject ENTITY_STUN_GRENADE_EXPLOSION = register("entity.grenade.stun.explosion"); + public static final RegistryObject ENTITY_STUN_GRENADE_RING = register("entity.grenade.stun.ring"); + public static final RegistryObject ENTITY_STUN_GRENADE_HIT_GLASS = register("entity.grenade.hit_glass"); + public static final RegistryObject ENTITY_STUN_GRENADE_HIT_STONE = register("entity.grenade.hit_stone"); + public static final RegistryObject ENTITY_STUN_GRENADE_HIT_WOOD = register("entity.grenade.hit_wood"); public static final RegistryObject UI_WEAPON_ATTACH = register("ui.weapon.attach"); private static RegistryObject register(String key) diff --git a/src/main/resources/assets/cgm/lang/en_us.json b/src/main/resources/assets/cgm/lang/en_us.json index b435962e4..f2b0b840e 100644 --- a/src/main/resources/assets/cgm/lang/en_us.json +++ b/src/main/resources/assets/cgm/lang/en_us.json @@ -40,6 +40,7 @@ "effect.cgm.deafened": "Deafened", "subtitle.cgm.stun.explosion": "Stun grenade explosion", "subtitle.cgm.stun.ring": "Ringing", + "subtitle.cgm.grenade.hit": "Grenade hit hard surface", "subtitle.cgm.fire": "Gunfire", "subtitle.cgm.fire.silenced": "Silenced gunfire", "subtitle.cgm.reload": "Reloading", diff --git a/src/main/resources/assets/cgm/sounds.json b/src/main/resources/assets/cgm/sounds.json index 9c1ee1578..833d56659 100644 --- a/src/main/resources/assets/cgm/sounds.json +++ b/src/main/resources/assets/cgm/sounds.json @@ -13,8 +13,11 @@ "item.machine_pistol.fire": { "subtitle": "subtitle.cgm.fire", "sounds": [{ "name": "cgm:item/machine_pistol/fire" }]}, "item.machine_pistol.silenced_fire": { "subtitle": "subtitle.cgm.fire.silenced", "sounds": [{ "name": "cgm:item/machine_pistol/silenced_fire" }]}, "item.grenade.pin": { "subtitle": "subtitle.cgm.grenade.pin", "sounds": [{ "name": "cgm:item/grenade/pin" }]}, - "entity.stun_grenade.explosion": { "subtitle": "subtitle.cgm.stun.explosion", "sounds": [{ "name": "cgm:entity/stun_grenade/explosion" }]}, - "entity.stun_grenade.ring": { "subtitle": "subtitle.cgm.stun.ring", "sounds": [{ "name": "cgm:entity/stun_grenade/ring", "stream": true }]}, + "entity.grenade.stun.explosion": { "subtitle": "subtitle.cgm.stun.explosion", "sounds": [{ "name": "cgm:entity/grenade/stun/explosion" }]}, + "entity.grenade.stun.ring": { "subtitle": "subtitle.cgm.stun.ring", "sounds": [{ "name": "cgm:entity/grenade/stun/ring", "stream": true }]}, + "entity.grenade.hit_glass": { "subtitle": "subtitle.cgm.grenade.hit", "sounds": [{ "name": "cgm:entity/grenade/hit_glass" }]}, + "entity.grenade.hit_stone": { "subtitle": "subtitle.cgm.grenade.hit", "sounds": [{ "name": "cgm:entity/grenade/hit_stone" }]}, + "entity.grenade.hit_wood": { "subtitle": "subtitle.cgm.grenade.hit", "sounds": [{ "name": "cgm:entity/grenade/hit_wood" }]}, "ui.weapon.attach": { "subtitle": "subtitle.cgm.attach", "sounds": [{ "name": "cgm:ui/weapon/attach" }]} } \ No newline at end of file diff --git a/src/main/resources/assets/cgm/sounds/entity/grenade/hit_glass.ogg b/src/main/resources/assets/cgm/sounds/entity/grenade/hit_glass.ogg new file mode 100644 index 000000000..a4dafbcd6 Binary files /dev/null and b/src/main/resources/assets/cgm/sounds/entity/grenade/hit_glass.ogg differ diff --git a/src/main/resources/assets/cgm/sounds/entity/grenade/hit_stone.ogg b/src/main/resources/assets/cgm/sounds/entity/grenade/hit_stone.ogg new file mode 100644 index 000000000..7633baf7e Binary files /dev/null and b/src/main/resources/assets/cgm/sounds/entity/grenade/hit_stone.ogg differ diff --git a/src/main/resources/assets/cgm/sounds/entity/grenade/hit_wood.ogg b/src/main/resources/assets/cgm/sounds/entity/grenade/hit_wood.ogg new file mode 100644 index 000000000..fc03770b7 Binary files /dev/null and b/src/main/resources/assets/cgm/sounds/entity/grenade/hit_wood.ogg differ diff --git a/src/main/resources/assets/cgm/sounds/entity/stun_grenade/explosion.ogg b/src/main/resources/assets/cgm/sounds/entity/grenade/stun/explosion.ogg similarity index 100% rename from src/main/resources/assets/cgm/sounds/entity/stun_grenade/explosion.ogg rename to src/main/resources/assets/cgm/sounds/entity/grenade/stun/explosion.ogg diff --git a/src/main/resources/assets/cgm/sounds/entity/stun_grenade/ring.ogg b/src/main/resources/assets/cgm/sounds/entity/grenade/stun/ring.ogg similarity index 100% rename from src/main/resources/assets/cgm/sounds/entity/stun_grenade/ring.ogg rename to src/main/resources/assets/cgm/sounds/entity/grenade/stun/ring.ogg