generated from QuiltMC/quilt-template-mod
-
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.
Get the music cooldown and put it on the music screen
Signed-off-by: Rina Mary Shaw <[email protected]>
- Loading branch information
Showing
30 changed files
with
156 additions
and
47 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
5 changes: 5 additions & 0 deletions
5
projects/kitten-heart/src/main/java/net/pixaurora/kitten_heart/impl/service/MusicCompat.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,5 @@ | ||
package net.pixaurora.kitten_heart.impl.service; | ||
|
||
public interface MusicCompat { | ||
long millisToNextSong(); | ||
} |
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
29 changes: 29 additions & 0 deletions
29
...c/main/java/net/pixaurora/kitten_heart/impl/ui/widget/progress/MusicCooldownProgress.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,29 @@ | ||
package net.pixaurora.kitten_heart.impl.ui.widget.progress; | ||
|
||
import java.time.Duration; | ||
|
||
import net.pixaurora.kitten_heart.impl.KitTunes; | ||
|
||
public class MusicCooldownProgress implements ProgressProvider { | ||
private final long startingCooldown; | ||
|
||
public MusicCooldownProgress() { | ||
this.startingCooldown = KitTunes.MUSIC_LAYER.millisToNextSong(); | ||
} | ||
|
||
@Override | ||
public double percentComplete() { | ||
return (double) KitTunes.MUSIC_LAYER.millisToNextSong() / this.startingCooldown; | ||
} | ||
|
||
@Override | ||
public Duration playedDuration() { | ||
return Duration.ofMillis(KitTunes.MUSIC_LAYER.millisToNextSong()); | ||
} | ||
|
||
@Override | ||
public Duration totalDuration() { | ||
return Duration.ofMillis(startingCooldown); | ||
} | ||
|
||
} |
12 changes: 12 additions & 0 deletions
12
...ds/r1.17.0/src/main/java/net/pixaurora/kitten_sounds/impl/mixin/MusicManagerAccessor.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,12 @@ | ||
package net.pixaurora.kitten_sounds.impl.mixin; | ||
|
||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.gen.Accessor; | ||
|
||
import net.minecraft.client.sounds.MusicManager; | ||
|
||
@Mixin(MusicManager.class) | ||
public interface MusicManagerAccessor { | ||
@Accessor | ||
public int getNextSongDelay(); | ||
} |
17 changes: 17 additions & 0 deletions
17
...ounds/r1.17.0/src/main/java/net/pixaurora/kitten_sounds/impl/service/MusicCompatImpl.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,17 @@ | ||
package net.pixaurora.kitten_sounds.impl.service; | ||
|
||
import net.minecraft.client.Minecraft; | ||
import net.pixaurora.kitten_heart.impl.service.MusicCompat; | ||
import net.pixaurora.kitten_sounds.impl.mixin.MusicManagerAccessor; | ||
|
||
public class MusicCompatImpl implements MusicCompat { | ||
private static final long MILLIS_PER_TICK = 50; | ||
|
||
private final Minecraft client = Minecraft.getInstance(); | ||
|
||
@Override | ||
public long millisToNextSong() { | ||
long nextSongDelay = ((MusicManagerAccessor) this.client.getMusicManager()).getNextSongDelay(); | ||
return MILLIS_PER_TICK * nextSongDelay; | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
.../src/main/resources/META-INF/services/net.pixaurora.kitten_heart.impl.service.MusicCompat
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 @@ | ||
net.pixaurora.kitten_sounds.impl.service.MusicCompatImpl |
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
12 changes: 12 additions & 0 deletions
12
...ds/r1.20.3/src/main/java/net/pixaurora/kitten_sounds/impl/mixin/MusicManagerAccessor.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,12 @@ | ||
package net.pixaurora.kitten_sounds.impl.mixin; | ||
|
||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.gen.Accessor; | ||
|
||
import net.minecraft.client.sounds.MusicManager; | ||
|
||
@Mixin(MusicManager.class) | ||
public interface MusicManagerAccessor { | ||
@Accessor | ||
public int getNextSongDelay(); | ||
} |
17 changes: 17 additions & 0 deletions
17
...ounds/r1.20.3/src/main/java/net/pixaurora/kitten_sounds/impl/service/MusicCompatImpl.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,17 @@ | ||
package net.pixaurora.kitten_sounds.impl.service; | ||
|
||
import net.minecraft.client.Minecraft; | ||
import net.pixaurora.kitten_heart.impl.service.MusicCompat; | ||
import net.pixaurora.kitten_sounds.impl.mixin.MusicManagerAccessor; | ||
|
||
public class MusicCompatImpl implements MusicCompat { | ||
private static final long MILLIS_PER_TICK = 50; | ||
|
||
private final Minecraft client = Minecraft.getInstance(); | ||
|
||
@Override | ||
public long millisToNextSong() { | ||
long nextSongDelay = ((MusicManagerAccessor) this.client.getMusicManager()).getNextSongDelay(); | ||
return MILLIS_PER_TICK * nextSongDelay; | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
.../src/main/resources/META-INF/services/net.pixaurora.kitten_heart.impl.service.MusicCompat
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 @@ | ||
net.pixaurora.kitten_sounds.impl.service.MusicCompatImpl |
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
File renamed without changes.
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
File renamed without changes.
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
File renamed without changes.
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
File renamed without changes.
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
File renamed without changes.
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
File renamed without changes.
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
File renamed without changes.
Oops, something went wrong.