Skip to content

Commit 64602fe

Browse files
committed
Finished and Config
1 parent ac8ee50 commit 64602fe

File tree

8 files changed

+78
-26
lines changed

8 files changed

+78
-26
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,5 @@ hs_err_*.log
3838
replay_*.log
3939
*.hprof
4040
*.jfr
41+
42+
.history/

build.gradle

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ repositories {
1818
// for more information about repositories.
1919
maven { url = "https://maven.enjarai.nl/mirrors" }
2020
maven { url = "https://maven.enjarai.nl/releases" }
21-
maven {
22-
name 'Xander Maven'
23-
url 'https://maven.isxander.dev/releases'
24-
}
21+
maven { url 'https://maven.isxander.dev/releases' }
22+
maven { url = "https://maven.quiltmc.org/repository/release/" }
23+
maven { url "https://maven.terraformersmc.com/releases" }
24+
maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
2525
}
2626

2727
loom {
@@ -54,6 +54,7 @@ dependencies {
5454
}
5555

5656
modImplementation 'dev.isxander.yacl:yet-another-config-lib-fabric:3.1.0+1.20'
57+
modApi "com.terraformersmc:modmenu:7.1.0"
5758
}
5859

5960
processResources {
Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,49 @@
11
package com.carsoncoder.gpws;
22

3-
import dev.isxander.yacl.api.ConfigCategory;
4-
import dev.isxander.yacl.api.Option;
5-
import dev.isxander.yacl.api.OptionGroup;
6-
import dev.isxander.yacl.api.YetAnotherConfigLib;
7-
import dev.isxander.yacl.gui.controllers.TickBoxController;
3+
import dev.isxander.yacl3.api.ConfigCategory;
4+
import dev.isxander.yacl3.api.Option;
5+
import dev.isxander.yacl3.api.OptionDescription;
6+
import dev.isxander.yacl3.api.OptionGroup;
7+
import dev.isxander.yacl3.api.YetAnotherConfigLib;
8+
import dev.isxander.yacl3.api.controller.IntegerSliderControllerBuilder;
9+
import net.minecraft.client.gui.screen.Screen;
810
import net.minecraft.text.Text;
911

1012
public class gpwsConfig {
1113
int PullUpRange = 50;
1214
int BankAngleAngle = -50;
13-
int Volume = 100;
15+
float Volume = 1.0f;
1416
int SoundDelay = 30;
1517

1618
boolean test = false;
1719

18-
public gpwsConfig() {
20+
public static Screen create(Screen screen) {
21+
gpwsElytraClient.LOGGER.info("Building Config");
1922
YetAnotherConfigLib thing = YetAnotherConfigLib.createBuilder()
2023
.title(Text.literal("Used for narration. Could be used to render a title in the future."))
2124
.category(ConfigCategory.createBuilder()
22-
.name(Text.literal("Name of the category"))
23-
.tooltip(Text.literal("This text will appear as a tooltip when you hover or focus the button with Tab. There is no need to add \n to wrap as YACL will do it for you."))
25+
.name(Text.literal("Settings"))
26+
.tooltip(Text.literal("The main settings for elytra GPWS"))
2427
.group(OptionGroup.createBuilder()
25-
.name(Text.literal("Name of the group"))
26-
.tooltip(Text.literal("This text will appear when you hover over the name or focus on the collapse button with Tab."))
27-
.option(Option.createBuilder(boolean.class)
28-
.name(Text.literal("Boolean Option"))
29-
.tooltip(Text.literal("This text will appear as a tooltip when you hover over the option."))
30-
.binding(true, () -> this.test, newVal -> this.test = newVal)
31-
.controller(TickBoxController::new)
28+
.name(Text.literal("Sounds"))
29+
.option(Option.createBuilder(int.class)
30+
.name(Text.literal("Volume"))
31+
.description(OptionDescription.createBuilder()
32+
.text(Text.literal("The volume of sounds"))
33+
.build())
34+
.binding(50, () -> {return Math.round(gpwsElytraClient.CONFIG.Volume*100);}, newVal -> gpwsElytraClient.CONFIG.Volume = newVal/100)
35+
.controller(opt -> IntegerSliderControllerBuilder.create(opt)
36+
.range(0, 100)
37+
.step(1)
38+
.valueFormatter(val -> Text.literal(val + "%"))
39+
)
3240
.build())
3341
.build())
3442
.build())
3543
.build();
44+
45+
return thing.generateScreen(screen);
46+
47+
//MinecraftClient.getInstance().setScreen(thing.generateScreen(MinecraftClient.getInstance().currentScreen));
3648
}
3749
}

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import nl.enjarai.cicada.api.util.ProperLogger;
1919

2020
public class gpwsElytraClient implements ClientModInitializer, CicadaEntrypoint {
21-
public static gpwsConfig config = new gpwsConfig();
21+
public static gpwsConfig CONFIG = new gpwsConfig();
2222
public static final Logger LOGGER = ProperLogger.getLogger("gpws-elytra");
2323
public static gpwsElytraClient instance;
2424
public static final gpwsSounds SOUNDS_MANAGER = new gpwsSounds();
@@ -30,7 +30,7 @@ public void onInitializeClient() {
3030
instance = this;
3131
SOUNDS_MANAGER.init();
3232
HudRenderCallback.EVENT.register(new gpwsHud(this));
33-
}
33+
}
3434

3535
@Override
3636
public void registerConversations(ConversationManager conversationManager) {
@@ -86,7 +86,7 @@ private boolean PullUp(float delta) {
8686
}
8787

8888
private String StateLogic(float delta) {
89-
int StallAngle = config.BankAngleAngle;
89+
int StallAngle = CONFIG.BankAngleAngle;
9090

9191
Entity cam = MinecraftClient.getInstance().getCameraEntity();
9292
BlockPos pos = MinecraftClient.getInstance().player.getBlockPos();
@@ -97,7 +97,7 @@ private String StateLogic(float delta) {
9797
double DownVel = MinecraftClient.getInstance().player.getVelocity().y;
9898
float Pitch = cam.getPitch();
9999

100-
LOGGER.info(String.valueOf(heightmap.get(Math.max(Math.min(pos.getX() - chunk.getPos().getStartX(), 15), 0), Math.max(Math.min(pos.getX() - chunk.getPos().getStartZ(), 15), 0))));
100+
// LOGGER.info(String.valueOf(heightmap.get(Math.max(Math.min(pos.getX() - chunk.getPos().getStartX(), 15), 0), Math.max(Math.min(pos.getX() - chunk.getPos().getStartZ(), 15), 0))));
101101

102102
if (Pitch < StallAngle) {
103103
return "Bank Angle";
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package com.carsoncoder.gpws;
2+
3+
import com.terraformersmc.modmenu.api.ConfigScreenFactory;
4+
import com.terraformersmc.modmenu.api.ModMenuApi;
5+
6+
public class gpwsModScreen implements ModMenuApi {
7+
@Override
8+
public ConfigScreenFactory<?> getModConfigScreenFactory() {
9+
return gpwsConfig::create;
10+
}
11+
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public static HitResult raycastInDirection(MinecraftClient client, float tickDel
4141
return null;
4242
}
4343

44-
double reachDistance = gpwsElytraClient.config.PullUpRange; //Change this to extend the reach
44+
double reachDistance = gpwsElytraClient.CONFIG.PullUpRange; //Change this to extend the reach
4545
HitResult target = raycast(entity, reachDistance, tickDelta, false, direction);
4646
boolean tooFar = false;
4747
double extendedReach = reachDistance;

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

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,29 @@ void init() {
5050
}
5151
}
5252

53+
public void PlaySound(SoundEvent sound) {
54+
MinecraftClient.getInstance().getSoundManager().play(new EntityTrackingSoundInstance(
55+
sound,
56+
SoundCategory.VOICE,
57+
gpwsElytraClient.CONFIG.Volume,
58+
1f,
59+
MinecraftClient.getInstance().player,
60+
Random.create().nextLong()));
61+
// if (MinecraftClient.getInstance().player == null) {return;}
62+
// MinecraftClient.getInstance().world.playSound(
63+
// MinecraftClient.getInstance().player, // Player - if non-null, will play sound for every nearby player *except* the specified player
64+
// MinecraftClient.getInstance().player.getBlockPos(), // The position of where the sound will come from
65+
// SoundEvents.BLOCK_FENCE_GATE_OPEN, // The sound that will play
66+
// SoundCategory.BLOCKS, // This determines which of the volume sliders affect this sound
67+
// 1f, //Volume multiplier, 1 is normal, 0.5 is half volume, etc
68+
// 1f // Pitch multiplier, 1 is normal, 0.5 is half pitch, etc
69+
// );
70+
}
71+
72+
public void PlaySound(gpwsSounds.SOUNDS sound) {
73+
PlaySound(GetSound(sound));
74+
}
75+
5376
public SoundEvent GetSound(SOUNDS sound) {
5477
return SoundsDict.get(sound);
5578
}

src/main/resources/fabric.mod.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@
2020
],
2121
"client": [
2222
"com.carsoncoder.gpws.gpwsElytraClient"
23-
]
23+
],
24+
"modmenu": [
25+
"com.carsoncoder.gpws.gpwsModScreen"
26+
]
2427
},
2528
"mixins": [
2629
"gpws-elytra.mixins.json",

0 commit comments

Comments
 (0)