-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
37ce2ce
commit 219f01f
Showing
13 changed files
with
123 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
src/main/java/heyblack/repeatersound/mixin/DaylightDetectorBlockMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package heyblack.repeatersound.mixin; | ||
|
||
import heyblack.repeatersound.RepeaterSound; | ||
import heyblack.repeatersound.config.Config; | ||
import net.fabricmc.api.EnvType; | ||
import net.fabricmc.api.Environment; | ||
import net.minecraft.block.BlockState; | ||
import net.minecraft.block.DaylightDetectorBlock; | ||
import net.minecraft.entity.player.PlayerEntity; | ||
import net.minecraft.sound.SoundCategory; | ||
import net.minecraft.state.property.BooleanProperty; | ||
import net.minecraft.util.ActionResult; | ||
import net.minecraft.util.Hand; | ||
import net.minecraft.util.hit.BlockHitResult; | ||
import net.minecraft.util.math.BlockPos; | ||
import net.minecraft.world.World; | ||
import org.spongepowered.asm.mixin.Final; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
|
||
@Environment(value= EnvType.CLIENT) | ||
@Mixin(DaylightDetectorBlock.class) | ||
public class DaylightDetectorBlockMixin | ||
{ | ||
@Shadow @Final public static BooleanProperty INVERTED; | ||
|
||
@Inject(method = "onUse", at = @At("HEAD")) | ||
public void playSound(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit, CallbackInfoReturnable<ActionResult> cir) | ||
{ | ||
Config config = RepeaterSound.getConfig(); | ||
float basePitch = config.getBasePitch(); | ||
float pitch = config.getRandomPitch() ? | ||
(float) (basePitch + (Math.random() - 0.5) * 0.25) : | ||
state.cycle(INVERTED).get(INVERTED) ? basePitch : basePitch + 0.05f; | ||
float volume = config.getVolume(); | ||
world.playSound(player, pos, RepeaterSound.BLOCK_DAYLIGHT_DETECTOR_CLICK, SoundCategory.BLOCKS, volume, pitch); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
{ | ||
"subtitles.repeatersound.repeater_click": "Repeater clicks", | ||
"subtitles.repeatersound.redstone_wire_click": "Redstone Wire clicks" | ||
"subtitles.repeatersound.redstone_wire_click": "Redstone Wire clicks", | ||
"subtitles.repeatersound.daylight_detector_click": "Daylight Detector clicks" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
{ | ||
"subtitles.repeatersound.repeater_click": "中继器:调节档位", | ||
"subtitles.repeatersound.redstone_wire_click": "红石线:改变形状" | ||
"subtitles.repeatersound.redstone_wire_click": "红石线:改变形状", | ||
"subtitles.repeatersound.daylight_detector_click": "阳光探测器:转换模式" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters