Skip to content

Commit 0628a78

Browse files
committed
Just gotta do a cloud save
1 parent f702180 commit 0628a78

33 files changed

+148
-14
lines changed

src/client/java/com/carsoncoder/gpws/gpwsElytraClient.java

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,34 @@
11
package com.carsoncoder.gpws;
22

3-
import org.joml.Matrix4f;
43
import org.slf4j.Logger;
54

65
import net.fabricmc.api.ClientModInitializer;
76
import net.fabricmc.fabric.api.client.rendering.v1.HudRenderCallback;
87
import net.minecraft.client.MinecraftClient;
9-
import net.minecraft.client.gui.DrawContext;
108
import net.minecraft.entity.Entity;
9+
import net.minecraft.registry.Registries;
10+
import net.minecraft.registry.Registry;
11+
import net.minecraft.sound.SoundEvent;
12+
import net.minecraft.util.Identifier;
1113
import nl.enjarai.cicada.api.conversation.ConversationManager;
1214
import nl.enjarai.cicada.api.util.CicadaEntrypoint;
1315
import nl.enjarai.cicada.api.util.JsonSource;
1416
import nl.enjarai.cicada.api.util.ProperLogger;
1517

16-
public class gpwsElytraClient implements ClientModInitializer, CicadaEntrypoint, HudRenderCallback {
18+
public class gpwsElytraClient implements ClientModInitializer, CicadaEntrypoint {
1719
public static final Logger LOGGER = ProperLogger.getLogger("gpws-elytra");
1820
public static gpwsElytraClient instance;
1921

22+
public static final Identifier MY_SOUND_ID = new Identifier("gpws-elytra:retard");
23+
public static SoundEvent RETARD = SoundEvent.of(MY_SOUND_ID);
24+
2025
private String gpwsState = "Loading";
2126

2227
@Override
2328
public void onInitializeClient() {
2429
instance = this;
2530
HudRenderCallback.EVENT.register(new gpwsHud(this));
31+
Registry.register(Registries.SOUND_EVENT, gpwsElytraClient.MY_SOUND_ID, RETARD);
2632
}
2733

2834
@Override
@@ -34,26 +40,21 @@ public void registerConversations(ConversationManager conversationManager) {
3440
);
3541
}
3642

37-
@Override
38-
public void onHudRender(DrawContext drawContext, float tickDelta) {
39-
Matrix4f matrix = MinecraftClient.getInstance().gameRenderer.getBasicProjectionMatrix(MinecraftClient.getInstance().options.getFov().getValue());
40-
}
41-
4243
public void tick()
4344
{
4445
LOGGER.debug("ticked");
4546
gpwsState = "";
4647
}
4748

4849
private String StateLogic() {
49-
int StallAngle = -70;
50+
int StallAngle = -50;
5051

5152
Entity cam = MinecraftClient.getInstance().getCameraEntity();
5253
float Pitch = cam.getPitch();
5354
LOGGER.info(String.valueOf(Pitch));
5455

5556
if (Pitch < StallAngle) {
56-
return "Stall";
57+
return "Bank Angle";
5758
}
5859

5960
return "";

src/client/java/com/carsoncoder/gpws/gpwsHud.java

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,26 @@
77
import net.minecraft.client.MinecraftClient;
88
import net.minecraft.client.font.TextRenderer;
99
import net.minecraft.client.gui.DrawContext;
10+
import net.minecraft.client.sound.EntityTrackingSoundInstance;
1011
import net.minecraft.client.util.math.MatrixStack;
12+
import net.minecraft.sound.SoundCategory;
13+
import net.minecraft.sound.SoundEvent;
1114
import net.minecraft.text.MutableText;
1215
import net.minecraft.text.Text;
1316
import net.minecraft.util.Formatting;
17+
import net.minecraft.util.math.random.Random;
1418
import nl.enjarai.cicada.api.util.ProperLogger;
1519

1620
public class gpwsHud implements HudRenderCallback {
1721
public static final Logger LOGGER = ProperLogger.getLogger("gpws-elytra");
1822

1923
TextRenderer renderer;
2024

25+
int repeatTime = 3;
26+
27+
String prevstate = "";
28+
float lastPlayedSoundTime = 0;
29+
2130
class Color {
2231
public int R;
2332
public int G;
@@ -75,6 +84,25 @@ public void renderText(DrawContext ctx, Text text, Color color, int x, int y) {
7584
stack.pop();
7685
}
7786

87+
private void PlaySound(SoundEvent sound) {
88+
MinecraftClient.getInstance().getSoundManager().play(new EntityTrackingSoundInstance(
89+
gpwsElytraClient.RETARD,
90+
SoundCategory.BLOCKS,
91+
1f,
92+
1f,
93+
MinecraftClient.getInstance().player,
94+
Random.create().nextLong()));
95+
// if (MinecraftClient.getInstance().player == null) {return;}
96+
// MinecraftClient.getInstance().world.playSound(
97+
// MinecraftClient.getInstance().player, // Player - if non-null, will play sound for every nearby player *except* the specified player
98+
// MinecraftClient.getInstance().player.getBlockPos(), // The position of where the sound will come from
99+
// SoundEvents.BLOCK_FENCE_GATE_OPEN, // The sound that will play
100+
// SoundCategory.BLOCKS, // This determines which of the volume sliders affect this sound
101+
// 1f, //Volume multiplier, 1 is normal, 0.5 is half volume, etc
102+
// 1f // Pitch multiplier, 1 is normal, 0.5 is half pitch, etc
103+
// );
104+
}
105+
78106
@Override
79107
public void onHudRender(DrawContext drawContext, float tickDelta) {
80108
if (!client.isFallFlying()) {
@@ -86,13 +114,19 @@ public void onHudRender(DrawContext drawContext, float tickDelta) {
86114
renderer = MinecraftClient.getInstance().textRenderer;
87115
}
88116

117+
String state = client.GetState();
118+
119+
if (state != prevstate) {
120+
PlaySound(gpwsElytraClient.RETARD);
121+
}
122+
89123
// Render Bold Underlined Hello In the center of the screen
90124
Text gpwsText = newText(
91125
client.GetState(),
92126
false,
93127
false,
94128
false,
95-
true,
129+
false,
96130
false
97131
);
98132

@@ -103,5 +137,7 @@ public void onHudRender(DrawContext drawContext, float tickDelta) {
103137
(MinecraftClient.getInstance().getWindow().getWidth() / 4 - renderer.getWidth(gpwsText)) / 2,
104138
10
105139
);
140+
141+
prevstate = state;
106142
}
107143
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package com.carsoncoder.gpws;
2+
3+
import net.minecraft.registry.Registries;
4+
import net.minecraft.registry.Registry;
5+
import net.minecraft.sound.SoundEvent;
6+
import net.minecraft.util.Identifier;
7+
8+
public class gpwsSounds {
9+
10+
public enum Sounds {
11+
RETARD, PULL_UP, BANK_ANGLE, Y2500, Y500, Y400, Y300, Y200, Y100, Y70, Y60, Y50, Y40, Y30, Y20
12+
}
13+
14+
public static final Identifier RETARD_ID = new Identifier("gpws-elytra:retard");
15+
public static SoundEvent RETARD = SoundEvent.of(RETARD_ID);
16+
17+
public static final Identifier BANK_ANGLE_ID = new Identifier("gpws-elytra:retard");
18+
public static SoundEvent BANK_ANGLE = SoundEvent.of(BANK_ANGLE_ID);
19+
20+
public static final Identifier PULL_UP_ID = new Identifier("gpws-elytra:retard");
21+
public static SoundEvent PULL_UP = SoundEvent.of(PULL_UP_ID);
22+
23+
void init() {
24+
Registry.register(Registries.SOUND_EVENT, RETARD_ID, RETARD);
25+
Registry.register(Registries.SOUND_EVENT, BANK_ANGLE_ID, BANK_ANGLE);
26+
Registry.register(Registries.SOUND_EVENT, PULL_UP_ID, PULL_UP);
27+
}
28+
}

src/client/java/com/carsoncoder/gpws/mixin/client/gpwsElytraClientMixin.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@
1111

1212
@Mixin(MinecraftClient.class)
1313
public class gpwsElytraClientMixin {
14-
// @Inject(at = @At("HEAD"), method = "doItemUse")
15-
// private void doItemUse(CallbackInfo info) {
16-
// }
1714
@Inject(at = @At("HEAD"), method = "tick")
1815
private void tick(CallbackInfo info) {
1916
gpwsElytraClient.instance.tick();

src/client/resources/Sounds/100.mp3

-19.5 KB
Binary file not shown.

src/client/resources/Sounds/20.mp3

-14.3 KB
Binary file not shown.

src/client/resources/Sounds/200.mp3

-21.8 KB
Binary file not shown.

src/client/resources/Sounds/2500.mp3

-38.3 KB
Binary file not shown.

src/client/resources/Sounds/30.mp3

-12.8 KB
Binary file not shown.

src/client/resources/Sounds/300.mp3

-23.3 KB
Binary file not shown.

0 commit comments

Comments
 (0)