From ee41e0f04e365678c786eb82454761a714f5a88c Mon Sep 17 00:00:00 2001 From: NotSoEpic Date: Sat, 6 Jul 2024 08:41:41 +0800 Subject: [PATCH] Encasing blocks plays a placing sound --- .../content/decoration/encasing/EncasableBlock.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/main/java/com/simibubi/create/content/decoration/encasing/EncasableBlock.java b/src/main/java/com/simibubi/create/content/decoration/encasing/EncasableBlock.java index 6c31ae78c..d53cf9617 100644 --- a/src/main/java/com/simibubi/create/content/decoration/encasing/EncasableBlock.java +++ b/src/main/java/com/simibubi/create/content/decoration/encasing/EncasableBlock.java @@ -3,12 +3,14 @@ package com.simibubi.create.content.decoration.encasing; import java.util.List; import net.minecraft.core.BlockPos; +import net.minecraft.sounds.SoundSource; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.SoundType; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.phys.BlockHitResult; @@ -31,9 +33,16 @@ public interface EncasableBlock { return InteractionResult.SUCCESS; encased.handleEncasing(state, level, pos, heldItem, player, hand, ray); + playEncaseSound(level, pos); return InteractionResult.SUCCESS; } } return InteractionResult.PASS; } + + default void playEncaseSound(Level level, BlockPos pos) { + BlockState newState = level.getBlockState(pos); + SoundType soundType = newState.getSoundType(); + level.playSound(null, pos, soundType.getPlaceSound(), SoundSource.BLOCKS, (soundType.getVolume() + 1.0F) / 2.0F, soundType.getPitch() * 0.8F); + } }