Skip to content

Commit

Permalink
Fixed description and added more sounds
Browse files Browse the repository at this point in the history
  • Loading branch information
Pedro270707 committed Jul 5, 2023
1 parent 3c8928d commit 584f257
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,22 +74,22 @@ public void renderGameOverlay(float partialTicks, boolean flag, int mouseX, int
width - (longestStringWidth / 2) - (fontrenderer.getStringWidth(stringToDraw) / 2) - sp - arrowWidth / 2,
height - 34 - (subtitleLines * lineHeight) - sp,
Color.intToIntARGB(
(int) (Math.min(60.0f, Subtitles.soundsPlaying.get(string)) * 255.0f / 60f), 255,
(int) (Math.min(60.0f, 20.0f + Subtitles.soundsPlaying.get(string)) * 255.0f / 70.0f), 255,
255, 255));

if (angleDegrees <= 325 && 215 <= angleDegrees) {
fontrenderer.drawString(">",
width - 6 - sp,
height - 34 - (subtitleLines * lineHeight) - sp,
Color.intToIntARGB(
(int) (Math.min(60.0f, Subtitles.soundsPlaying.get(string)) * 255.0f / 60f), 255,
(int) (Math.min(60.0f, 10.0f + Subtitles.soundsPlaying.get(string)) * 255.0f / 70.0f), 255,
255, 255));
} else if (angleDegrees >= 35 && 145 >= angleDegrees) {
fontrenderer.drawString("<",
width - longestStringWidth - sp - arrowWidth,
height - 34 - (subtitleLines * lineHeight) - sp,
Color.intToIntARGB(
(int) (Math.min(60.0f, Subtitles.soundsPlaying.get(string)) * 255.0f / 60f), 255,
(int) (Math.min(60.0f, 20.0f + Subtitles.soundsPlaying.get(string)) * 255.0f / 70.0f), 255,
255, 255));
}
} else {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package net.pedroricardo.subtitles.mixin;

import net.minecraft.client.Minecraft;
import net.minecraft.src.SoundManager;
import net.minecraft.src.SoundPoolEntry;
import net.pedroricardo.subtitles.Subtitles;
Expand All @@ -23,13 +24,11 @@
public class SoundPoolMixin {
@Inject(method = "playSound", at = @At(value = "INVOKE", target = "Lpaulscode/sound/SoundSystem;newSource(ZLjava/lang/String;Ljava/net/URL;Ljava/lang/String;ZFFFIF)V"), locals = LocalCapture.CAPTURE_FAILHARD)
public void playSound(String s, float x, float y, float z, float f3, float f4, CallbackInfo ci,
SoundPoolEntry soundpoolentry, String s1, float f5) throws IOException,
UnsupportedAudioFileException {
SoundPoolEntry soundpoolentry, String s1, float f5) throws IOException {
File file = new File(soundpoolentry.soundUrl.getPath());
double soundDuration = 0.0f;
if (file.getName().endsWith(".ogg")) {
soundDuration = calculateDuration(file);
Subtitles.soundsPlaying.put(s, 60.0f + (float)soundDuration / 15.0f);
double soundDuration = calculateDuration(file);
Subtitles.soundsPlaying.put(s, 60.0f + (float)soundDuration / 50.0f);
} else {
Subtitles.soundsPlaying.put(s, 150.0f);
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"version": "${version}",

"name": "Subtitles",
"description": "This mod",
"description": "This mod adds modern subtitles to the game.",
"authors": [
"Pedro Ricardo"
],
Expand Down
15 changes: 14 additions & 1 deletion src/main/resources/lang/subtitles/en_US.lang
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,17 @@ subtitles.mob.creeper=Creeper hurts
subtitles.null=Something
subtitles.random.glass=Glass shatters
subtitles.liquid.splash=Splashing
subtitles.liquid.water=Water flows
subtitles.liquid.water=Water flows
subtitles.tile.piston.out=Piston extends
subtitles.tile.piston.in=Piston retracts
subtitles.ambient.weather.rain=Rain falls
subtitles.ambient.weather.thunder=Thunder roars
subtitles.ambient.cave.cave=Eerie noise
subtitles.note.bass=Note Block plays
subtitles.note.bassattack=Note Block plays
subtitles.note.bd=Note Block plays
subtitles.note.harp=Note Block plays
subtitles.note.hat=Note Block plays
subtitles.note.pling=Note Block plays
subtitles.note.snare=Note Block plays
subtitles.portal.trigger=Portal noise intensifies

0 comments on commit 584f257

Please sign in to comment.