Skip to content

Commit 87db857

Browse files
committed
Implement combination step sounds
1 parent ab68ab0 commit 87db857

File tree

5 files changed

+71
-14
lines changed

5 files changed

+71
-14
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ buildscript {
1818
apply plugin: 'net.minecraftforge.gradle.forge'
1919
apply plugin: 'org.spongepowered.mixin'
2020

21-
version = '1.12.2-1.4.0'
21+
version = '1.12.2-1.4.1'
2222
group = 'mod.acgaming.extrasounds'
2323
archivesBaseName = 'ExtraSounds'
2424

src/main/java/mod/acgaming/extrasounds/ExtraSounds.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public class ExtraSounds
2121
{
2222
public static final String MODID = "extrasounds";
2323
public static final String NAME = "Extra Sounds";
24-
public static final String VERSION = "1.12.2-1.4.0";
24+
public static final String VERSION = "1.12.2-1.4.1";
2525
public static final String DEPENDENCIES = "required-after:mixinbooter;after:assetmover;after:jei;after:asmc;after:dsurround";
2626
public static final Logger LOGGER = LogManager.getLogger(NAME);
2727
public static boolean asmc = false;

src/main/java/mod/acgaming/extrasounds/config/ESConfig.java

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -122,18 +122,27 @@ public static class SoundToggles
122122
@Config.Name("Potion Sound")
123123
@Config.Comment("Play a sound when potion effects get added or removed from the player")
124124
public boolean esPotionSound = false;
125+
126+
@Config.Name("Combination Step Sound")
127+
@Config.Comment
128+
({
129+
"Recreates the combination step sound introduced in snapshot 23w12a",
130+
"Plays an additional muffled step sound for blocks beneath carpets and snow"
131+
})
132+
public boolean esCombinationStepSound = true;
125133
}
126134

127135
public static class SoundCategories
128136
{
129137
@Config.Name("Pick/Place Sounds")
130-
@Config.Comment({
131-
"Categories of sounds when picking and placing items in GUIs",
132-
"Available categories: dirt, dust, gem, grass, gravel, ingot, nugget, sand, snow, stone, wood, wool",
133-
"Syntax: CATEGORY;REGISTRY_NAME",
134-
"Use * for ore dictionary wildcards",
135-
"Examples | ingot;ore:example_ore | gem;mod_id:example_item"
136-
})
138+
@Config.Comment
139+
({
140+
"Categories of sounds when picking and placing items in GUIs",
141+
"Available categories: dirt, dust, gem, grass, gravel, ingot, nugget, sand, snow, stone, wood, wool",
142+
"Syntax: CATEGORY;REGISTRY_NAME",
143+
"Use * for ore dictionary wildcards",
144+
"Examples | ingot;ore:example_ore | gem;mod_id:example_item"
145+
})
137146
public String[] soundArray = new String[]
138147
{
139148
"dust;ore:dust*",
@@ -173,10 +182,11 @@ public static class SoundCategories
173182
public static class MiscSettings
174183
{
175184
@Config.Name("Increase Sound Channels")
176-
@Config.Comment({
177-
"Increase sound channels to improve audio playback",
178-
"Disable this if you're facing sound issues or have another mod installed handling this"
179-
})
185+
@Config.Comment
186+
({
187+
"Increase sound channels to improve audio playback",
188+
"Disable this if you're facing sound issues or have another mod installed handling this"
189+
})
180190
public boolean esSoundChannels = true;
181191
}
182192

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
package mod.acgaming.extrasounds.mixin;
2+
3+
import net.minecraft.block.Block;
4+
import net.minecraft.block.SoundType;
5+
import net.minecraft.entity.Entity;
6+
import net.minecraft.init.Blocks;
7+
import net.minecraft.util.SoundEvent;
8+
import net.minecraft.util.math.BlockPos;
9+
import net.minecraft.world.World;
10+
11+
import mod.acgaming.extrasounds.config.ESConfig;
12+
import org.spongepowered.asm.mixin.Mixin;
13+
import org.spongepowered.asm.mixin.Shadow;
14+
import org.spongepowered.asm.mixin.injection.At;
15+
import org.spongepowered.asm.mixin.injection.Inject;
16+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
17+
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
18+
19+
@Mixin(Entity.class)
20+
public abstract class EntityMixin
21+
{
22+
@Shadow
23+
public World world;
24+
25+
@Shadow
26+
public abstract void playSound(SoundEvent soundIn, float volume, float pitch);
27+
28+
@Inject(method = "playStepSound", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/Block;getSoundType()Lnet/minecraft/block/SoundType;"), locals = LocalCapture.CAPTURE_FAILSOFT)
29+
public void esPlayStepSoundSnow(BlockPos pos, Block blockIn, CallbackInfo ci, SoundType soundtype)
30+
{
31+
if (!ESConfig.soundToggles.esCombinationStepSound) return;
32+
this.playSound(soundtype.getStepSound(), soundtype.getVolume() * 0.08F, soundtype.getPitch() - 0.3F);
33+
}
34+
35+
@Inject(method = "playStepSound", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;getBlockState(Lnet/minecraft/util/math/BlockPos;)Lnet/minecraft/block/state/IBlockState;", ordinal = 1), locals = LocalCapture.CAPTURE_FAILSOFT, cancellable = true)
36+
public void esPlayStepSoundCarpet(BlockPos pos, Block blockIn, CallbackInfo ci, SoundType soundtype)
37+
{
38+
if (!ESConfig.soundToggles.esCombinationStepSound) return;
39+
if (this.world.getBlockState(pos.up()).getBlock() == Blocks.CARPET)
40+
{
41+
this.playSound(soundtype.getStepSound(), soundtype.getVolume() * 0.08F, soundtype.getPitch() - 0.3F);
42+
SoundType soundtypeCarpet = Blocks.CARPET.getSoundType();
43+
this.playSound(soundtypeCarpet.getStepSound(), soundtypeCarpet.getVolume() * 0.15F, soundtypeCarpet.getPitch());
44+
ci.cancel();
45+
}
46+
}
47+
}

src/main/resources/extrasounds.server.mixins.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
"refmap": "extrasounds.refmap.json",
44
"minVersion": "0.8",
55
"compatibilityLevel": "JAVA_8",
6-
"mixins": ["BlockFlowerPotMixin", "BlockJukeboxMixin", "BlockPortalMixin", "EntityEnderPearlMixin", "EntityPlayerMixin", "InventoryPlayerMixin", "ItemBoatMixin", "ItemBowMixin", "ItemMinecartMixin", "ItemMonsterPlacerMixin", "ItemSeedsMixin", "MobSpawnerBaseLogicMixin", "SlotCraftingMixin", "TileEntityBeaconMixin"]
6+
"mixins": ["BlockFlowerPotMixin", "BlockJukeboxMixin", "BlockPortalMixin", "EntityEnderPearlMixin", "EntityMixin", "EntityPlayerMixin", "InventoryPlayerMixin", "ItemBoatMixin", "ItemBowMixin", "ItemMinecartMixin", "ItemMonsterPlacerMixin", "ItemSeedsMixin", "MobSpawnerBaseLogicMixin", "SlotCraftingMixin", "TileEntityBeaconMixin"]
77
}

0 commit comments

Comments
 (0)