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

Commit

Permalink
made data stick make click sound when right clicking a filter block
Browse files Browse the repository at this point in the history
  • Loading branch information
Trinsdar committed Aug 25, 2024
1 parent 230d099 commit 61d3191
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.nbt.CompoundTag;
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 @@ -67,11 +69,13 @@ public InteractionResult onInteractServer(BlockState state, Level world, BlockPo
i.getHandler(SlotType.DISPLAY_SETTABLE).serialize(displaySlots);
});
displaySlots.putString("machineType", this.getMachineType().getLoc().toString());
level.playSound(null, pos, SoundEvents.UI_BUTTON_CLICK, SoundSource.BLOCKS, 10.f, 1.0f);
return InteractionResult.SUCCESS;
} else {
CompoundTag displaySlots = stack.getTagElement("displaySlots");
if (!displaySlots.isEmpty() && displaySlots.getString("machineType").equals(this.getMachineType().getLoc().toString())){
this.itemHandler.ifPresent(i -> i.getHandler(SlotType.DISPLAY_SETTABLE).deserialize(displaySlots));
level.playSound(null, pos, SoundEvents.UI_BUTTON_CLICK, SoundSource.BLOCKS, 10.f, 1.0f);
return InteractionResult.SUCCESS;
}

Expand Down

0 comments on commit 61d3191

Please sign in to comment.