Skip to content
This repository has been archived by the owner on Oct 4, 2024. It is now read-only.

Commit

Permalink
added click sound to mass storage
Browse files Browse the repository at this point in the history
  • Loading branch information
Trinsdar committed Oct 24, 2023
1 parent 7b0b925 commit 6b7b0d1
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
import net.minecraft.core.Direction;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.sounds.SoundSource;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.player.Player;
Expand Down Expand Up @@ -87,6 +89,7 @@ public InteractionResult onInteractServer(BlockState state, Level world, BlockPo
if (leftover.getCount() < stack.getCount()) {
handler.insertItem(0, stack.copy(), false);
stack.shrink(stack.getCount() - leftover.getCount());
world.playSound(null, this.getBlockPos(), SoundEvents.UI_BUTTON_CLICK, SoundSource.PLAYERS, 1.0F, 1.0F);
return InteractionResult.SUCCESS;
}
} else {
Expand All @@ -101,7 +104,10 @@ public InteractionResult onInteractServer(BlockState state, Level world, BlockPo
if (inserted.getCount() > 0) break;
}
}
if (sucess) return InteractionResult.SUCCESS;
if (sucess) {
world.playSound(null, this.getBlockPos(), SoundEvents.UI_BUTTON_CLICK, SoundSource.PLAYERS, 1.0F, 1.0F);
return InteractionResult.SUCCESS;
}
}
}
}
Expand Down Expand Up @@ -129,6 +135,7 @@ public InteractionResult onInteractServer(BlockState state, Level world, BlockPo
}

handler.extractItem(0, extract, false);
world.playSound(null, this.getBlockPos(), SoundEvents.UI_BUTTON_CLICK, SoundSource.PLAYERS, 1.0F, 1.0F);
return InteractionResult.SUCCESS;
}
return InteractionResult.CONSUME;
Expand Down

0 comments on commit 6b7b0d1

Please sign in to comment.