Merge pull request #6664 from NotSoEpic/mc1.18/dev

Encasing blocks plays a placing sound
This commit is contained in:
simibubi 2024-07-15 13:46:52 +02:00 committed by GitHub
commit 3f6efe5520
Failed to generate hash of commit

View file

@ -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);
}
}