Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'fabric-loom' version '1.6-SNAPSHOT'
id 'fabric-loom' version '1.15-SNAPSHOT'
id 'maven-publish'
}

Expand Down Expand Up @@ -70,7 +70,7 @@ processResources {
}

tasks.withType(JavaCompile).configureEach {
it.options.release = 17
it.options.release = 21
}

java {
Expand All @@ -79,8 +79,8 @@ java {
// If you remove this line, sources will not be generated.
withSourcesJar()

sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
}

jar {
Expand Down
15 changes: 8 additions & 7 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,18 @@ org.gradle.parallel=true

# Fabric Properties
# check these on https://fabricmc.net/develop
minecraft_version=1.21
yarn_mappings=1.21+build.2
loader_version=0.15.11
minecraft_version=1.21.8
yarn_mappings=1.21.8+build.1
loader_version=0.18.4
loom_version=1.15-SNAPSHOT

# Mod Properties
mod_version=5.0.1
maven_group=io.github.autoinfelytra
archives_base_name=autoinfelytra

# Dependencies
fabric_version=0.100.1+1.21
clientarguments=1.9
yacl=3.5.0+1.21-fabric
modmenu = 11.0.0-beta.1
fabric_version=0.136.1+1.21.8
clientarguments=1.11.4
yacl=3.8.1+1.21.6-fabric
modmenu = 15.0.2
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.0-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@
import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
import net.fabricmc.fabric.api.client.rendering.v1.HudRenderCallback;
import net.fabricmc.fabric.api.client.rendering.v1.hud.HudElementRegistry;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.option.KeyBinding;
import net.minecraft.client.util.InputUtil;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.Vec3d;
import org.lwjgl.glfw.GLFW;
import org.slf4j.Logger;
Expand Down Expand Up @@ -99,7 +100,10 @@ public void onInitializeClient() {
if(autoFlight && AutomaticElytraConfig.HANDLER.instance().play_music) MusicPlayer.playMusic(minecraftClient.player);
else if(MusicPlayer.isPlayingMusic()) MusicPlayer.stopAllMusic();
});
HudRenderCallback.EVENT.register(HUD::drawHUD);
HudElementRegistry.addLast(
Identifier.of("autoinfelytra", "hud"),
(drawContext, tickCounter) -> HUD.drawHUD(drawContext, tickCounter)
);

AutomaticInfiniteElytraClient.instance = this;
LOGGER.info("I believe I can fly...");
Expand All @@ -115,12 +119,12 @@ public static void rotatePlayer(MinecraftClient minecraftClient){
minecraftClient.player.sendMessage(Text.literal("Taking evasive action! ").formatted(Formatting.RED), true);
autoFlight = false;
rotationStage++;
minecraftClient.player.stopFallFlying();
minecraftClient.player.stopGliding();
}
if(rotationStage >= CollisionDetectionUtil.scanAheadTicks){
rotating = false;
rotationStage = 0;
if(minecraftClient.player.checkFallFlying()) minecraftClient.player.startFallFlying();
if(minecraftClient.player.checkGliding()) minecraftClient.player.startGliding();
}
}

Expand All @@ -129,7 +133,7 @@ private static void onTick() {
if (minecraftClient.player != null) {
rotatePlayer(minecraftClient);
if (minecraftClient == null) minecraftClient = MinecraftClient.getInstance();
if (minecraftClient.player.isFallFlying()) showHud = true;
if (minecraftClient.player.isGliding()) showHud = true;
else {
showHud = false;
autoFlight = false;
Expand All @@ -138,7 +142,7 @@ private static void onTick() {
showHud = false;

if (!lastPressed && keyBinding.isPressed()) {
if (minecraftClient.player.isFallFlying()) {
if (minecraftClient.player.isGliding()) {
// If the player is flying an elytra, we start the auto flight
autoFlight = !autoFlight;
if (autoFlight) isDescending = true;
Expand Down
16 changes: 8 additions & 8 deletions src/main/java/io/github/autoinfelytra/Commands.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ private static void SetLastDestinationCommand(CommandDispatcher<FabricClientComm
if(AutomaticInfiniteElytraClient.autoFlight) {
Autopilot.initNewFlight(pos, false);
TraverseArea.stop();
context.getSource().getPlayer().sendMessage(Text.literal("Autopilot is set to coordinates " + pos.getX() + " " + pos.getZ()).formatted(Formatting.GREEN));
context.getSource().getPlayer().sendMessage(Text.literal("Autopilot is set to coordinates " + pos.getX() + " " + pos.getZ()).formatted(Formatting.GREEN), true);
}
else context.getSource().getPlayer().sendMessage(Text.literal("You need to be flying and have Automatic Flight Mode enabled.").formatted(Formatting.RED));
else context.getSource().getPlayer().sendMessage(Text.literal("You need to be flying and have Automatic Flight Mode enabled.").formatted(Formatting.RED), true);
}
else context.getSource().getPlayer().sendMessage(Text.literal("Previous destination is null").formatted(Formatting.RED));
else context.getSource().getPlayer().sendMessage(Text.literal("Previous destination is null").formatted(Formatting.RED), true);
return 1;
}));
}
Expand All @@ -60,11 +60,11 @@ private static void SetDestinationCommand(CommandDispatcher<FabricClientCommandS
if(AutomaticInfiniteElytraClient.autoFlight) {
Autopilot.initNewFlight(pos, false);
TraverseArea.stop();
context.getSource().getPlayer().sendMessage(Text.literal("Autopilot is set to coordinates " + pos.getX() + " " + pos.getZ()).formatted(Formatting.GREEN));
context.getSource().getPlayer().sendMessage(Text.literal("Autopilot is set to coordinates " + pos.getX() + " " + pos.getZ()).formatted(Formatting.GREEN), true);
}
else context.getSource().getPlayer().sendMessage(Text.literal("You need to be flying and have Automatic Flight Mode enabled.").formatted(Formatting.RED));
else context.getSource().getPlayer().sendMessage(Text.literal("You need to be flying and have Automatic Flight Mode enabled.").formatted(Formatting.RED), true);
}
else context.getSource().getPlayer().sendMessage(Text.literal("Autopilot is disabled. Please enable it in the Config.").formatted(Formatting.RED));
else context.getSource().getPlayer().sendMessage(Text.literal("Autopilot is disabled. Please enable it in the Config.").formatted(Formatting.RED), true);
return 1;
})));
}
Expand All @@ -89,9 +89,9 @@ private static void traverseAreaCommand(CommandDispatcher<FabricClientCommandSou
ColumnPos ending = CColumnPosArgument.getColumnPos(context, "ending");
if(AutomaticInfiniteElytraClient.autoFlight) {
TraverseArea.init(starting, ending);
context.getSource().getPlayer().sendMessage(Text.literal("Area traversal in progress").formatted(Formatting.GREEN));
context.getSource().getPlayer().sendMessage(Text.literal("Area traversal in progress").formatted(Formatting.GREEN), true);
}
else context.getSource().getPlayer().sendMessage(Text.literal("You need to be flying and have Automatic Flight Mode enabled.").formatted(Formatting.RED));
else context.getSource().getPlayer().sendMessage(Text.literal("You need to be flying and have Automatic Flight Mode enabled.").formatted(Formatting.RED), true);
return 1;
}))));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public static void target() {
}

public static void tick() {
if(player == null || player.getBlockPos() == null || destination == null || !player.isFallFlying()){
if(player == null || player.getBlockPos() == null || destination == null || !player.isGliding()){
destination = null;
targetYaw = Integer.MIN_VALUE;
lastDistanceToDestination = Integer.MAX_VALUE;
Expand All @@ -113,7 +113,7 @@ public static void tick() {
if (isAtDestination()) {
destination = null;
if(!TraverseArea.isTraversalInProgress()){
player.sendMessage(Text.literal("[Automatic Elytra Autopilot] You have arrived").formatted(Formatting.GREEN));
player.sendMessage(Text.literal("[Automatic Elytra Autopilot] You have arrived").formatted(Formatting.GREEN), true);
if(AutomaticElytraConfig.HANDLER.instance().record_analytics) {
FlightAnalytics.setTime((player.age - FlightAnalytics.getStartTime()) / 20);
FlightAnalytics.setDurability_lost(player.getEquippedStack(EquipmentSlot.CHEST).get(DataComponentTypes.DAMAGE) - FlightAnalytics.getStartDurability());
Expand All @@ -123,7 +123,7 @@ public static void tick() {
}

if(shouldLand()) {
player.sendMessage(Text.literal("[Automatic Elytra Autopilot] Initiating landing procedures").formatted(Formatting.GREEN));
player.sendMessage(Text.literal("[Automatic Elytra Autopilot] Initiating landing procedures").formatted(Formatting.GREEN), true);
landing = true;
initLanding();
}
Expand Down Expand Up @@ -152,7 +152,7 @@ public static boolean shouldLand(){
return AutomaticInfiniteElytraClient.autoFlight
&& AutomaticElytraConfig.HANDLER.instance().do_landing
&& doLanding
&& player.isFallFlying()
&& player.isGliding()
&& !player.isTouchingWater()
&& !player.isInLava();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public static void cancelFlightIfObstacleDetected(PlayerEntity player, World wor
BlockPos blockPos = new BlockPos(vec3i);
if (world.getBlockState(blockPos).isSolid()) {
player.sendMessage(Text.literal("[Collision Detection Utility] ").formatted(Formatting.AQUA).append(Text.literal("Flight aborted due to obstacle ahead!")), false); // Send a message to the player
player.sendMessage(Text.literal("Consider using fireworks to boost your height before enabling automatic flight"));
player.sendMessage(Text.literal("Consider using fireworks to boost your height before enabling automatic flight"), false);
AutomaticInfiniteElytraClient.rotating = true;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,13 @@ public static String getPresentableTime(int t){

public static void printAnalytics(PlayerEntity player){
int width = (int) Math.floor(MinecraftClient.getInstance().options.getChatWidth().getValue());
player.sendMessage(Text.literal(getSeperator(width, "-")));
player.sendMessage(Text.literal("Flight Analytics: ").formatted(Formatting.AQUA));
player.sendMessage(Text.literal("Distance Travelled: " + distance).formatted(Formatting.WHITE));
player.sendMessage(Text.literal("Time Taken: " + getPresentableTime(time)).formatted(Formatting.WHITE));
player.sendMessage(Text.literal("Average Speed: " + (distance/time) + " m/s").formatted(Formatting.WHITE));
player.sendMessage(Text.literal("Elytra Durability Used: " + durability_lost).formatted(Formatting.WHITE));
player.sendMessage(Text.literal(getSeperator(width, "-")));
player.sendMessage(Text.literal(getSeperator(width, "-")), false);
player.sendMessage(Text.literal("Flight Analytics: ").formatted(Formatting.AQUA), false);
player.sendMessage(Text.literal("Distance Travelled: " + distance).formatted(Formatting.WHITE), false);
player.sendMessage(Text.literal("Time Taken: " + getPresentableTime(time)).formatted(Formatting.WHITE), false);
player.sendMessage(Text.literal("Average Speed: " + (distance/time) + " m/s").formatted(Formatting.WHITE), false);
player.sendMessage(Text.literal("Elytra Durability Used: " + durability_lost).formatted(Formatting.WHITE), false);
player.sendMessage(Text.literal(getSeperator(width, "-")), false);

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ private static void next(){
current+=4;
if(current >= coordinates.size()){
stop();
MinecraftClient.getInstance().player.sendMessage(Text.of("Done"));
MinecraftClient.getInstance().player.sendMessage(Text.of("Done"), true);
return;
}
Autopilot.unsetLocation();
Expand Down
17 changes: 11 additions & 6 deletions src/main/java/io/github/autoinfelytra/hud/HUD.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@
@Environment(EnvType.CLIENT)
public class HUD {

public static final int RED_HUD_COLOR = Objects.requireNonNull(TextColor.fromFormatting(Formatting.RED)).getRgb();
public static final int YELLOW_HUD_COLOR = Objects.requireNonNull(TextColor.fromFormatting(Formatting.YELLOW)).getRgb();
public static final int GREEN_HUD_COLOR = Objects.requireNonNull(TextColor.fromFormatting(Formatting.GREEN)).getRgb();
// Hardcoding because easy
public static final int RED_HUD_COLOR = 0xFFFF5555;
public static final int YELLOW_HUD_COLOR = 0xFFFFFF55;
public static final int GREEN_HUD_COLOR = 0xFF55FF55;

public static ArrayList<String> hudArray;
public static int hudColor = RED_HUD_COLOR;
Expand All @@ -31,10 +32,14 @@ public static void tick(){
} else hudArray = null;
}
public static void drawHUD(DrawContext drawContext, RenderTickCounter renderTickCounter) {
drawContext.draw();
//drawContext.draw();

MinecraftClient client = MinecraftClient.getInstance();
int sw = client.getWindow().getScaledWidth();
int sh = client.getWindow().getScaledHeight();

int x = (MinecraftClient.getInstance().getWindow().getWidth() * AutomaticElytraConfig.HANDLER.instance().x_coordinates_of_hud)/2000;
int y = ((MinecraftClient.getInstance().getWindow().getHeight()) * AutomaticElytraConfig.HANDLER.instance().y_coordinates_of_hud)/2000;
int x = (sw * AutomaticElytraConfig.HANDLER.instance().x_coordinates_of_hud) / 2000;
int y = (sh * AutomaticElytraConfig.HANDLER.instance().y_coordinates_of_hud) / 2000;

//MinecraftClient.getInstance().player.sendMessage(Text.literal(String.valueOf((MinecraftClient.getInstance().getWindow().getHeight()))), true);

Expand Down
20 changes: 10 additions & 10 deletions src/main/java/io/github/autoinfelytra/music/MusicPlayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -108,15 +108,15 @@ public static void playMusic(PlayerEntity player){
incrementMusicNumberAndWrap();
}

isPlayingMusic = isSoundPlaying(EMBARK.getId(), MinecraftClient.getInstance().getSoundManager().soundSystem)
|| isSoundPlaying(SWEEPING_CLOUDS_SOUND.getId(), MinecraftClient.getInstance().getSoundManager().soundSystem)
|| isSoundPlaying(SUNSHINE.getId(), MinecraftClient.getInstance().getSoundManager().soundSystem)
isPlayingMusic = isSoundPlaying(EMBARK.id(), MinecraftClient.getInstance().getSoundManager().soundSystem)
|| isSoundPlaying(SWEEPING_CLOUDS_SOUND.id(), MinecraftClient.getInstance().getSoundManager().soundSystem)
|| isSoundPlaying(SUNSHINE.id(), MinecraftClient.getInstance().getSoundManager().soundSystem)
|| isSoundPlaying(SoundEvents.MUSIC_DISC_WAIT.registryKey().getValue(), MinecraftClient.getInstance().getSoundManager().soundSystem)
|| isSoundPlaying(SoundEvents.MUSIC_DISC_OTHERSIDE.registryKey().getValue(), MinecraftClient.getInstance().getSoundManager().soundSystem)
|| isSoundPlaying(SoundEvents.MUSIC_DISC_PIGSTEP.registryKey().getValue(), MinecraftClient.getInstance().getSoundManager().soundSystem)
|| isSoundPlaying(SoundEvents.MUSIC_DISC_MELLOHI.registryKey().getValue(), MinecraftClient.getInstance().getSoundManager().soundSystem)
|| isSoundPlaying(FEELING.getId(), MinecraftClient.getInstance().getSoundManager().soundSystem)
|| isSoundPlaying(HOMESICK.getId(), MinecraftClient.getInstance().getSoundManager().soundSystem);
|| isSoundPlaying(FEELING.id(), MinecraftClient.getInstance().getSoundManager().soundSystem)
|| isSoundPlaying(HOMESICK.id(), MinecraftClient.getInstance().getSoundManager().soundSystem);
}
else {
MinecraftClient.getInstance().player.sendMessage(Text.literal("Music cannot play; your master volume is 0%"), true);
Expand All @@ -125,14 +125,14 @@ public static void playMusic(PlayerEntity player){

public static void stopAllMusic(){
MinecraftClient.getInstance().getSoundManager().stopSounds(SoundEvents.MUSIC_DISC_WAIT.registryKey().getValue(), SoundCategory.MASTER);
MinecraftClient.getInstance().getSoundManager().stopSounds(EMBARK.getId(), SoundCategory.MASTER);
MinecraftClient.getInstance().getSoundManager().stopSounds(SWEEPING_CLOUDS_SOUND.getId(), SoundCategory.MASTER);
MinecraftClient.getInstance().getSoundManager().stopSounds(EMBARK.id(), SoundCategory.MASTER);
MinecraftClient.getInstance().getSoundManager().stopSounds(SWEEPING_CLOUDS_SOUND.id(), SoundCategory.MASTER);
MinecraftClient.getInstance().getSoundManager().stopSounds(SoundEvents.MUSIC_DISC_OTHERSIDE.registryKey().getValue(), SoundCategory.MASTER);
MinecraftClient.getInstance().getSoundManager().stopSounds(SUNSHINE.getId(), SoundCategory.MASTER);
MinecraftClient.getInstance().getSoundManager().stopSounds(SUNSHINE.id(), SoundCategory.MASTER);
MinecraftClient.getInstance().getSoundManager().stopSounds(SoundEvents.MUSIC_DISC_PIGSTEP.registryKey().getValue(), SoundCategory.MASTER);
MinecraftClient.getInstance().getSoundManager().stopSounds(SoundEvents.MUSIC_DISC_MELLOHI.registryKey().getValue(), SoundCategory.MASTER);
MinecraftClient.getInstance().getSoundManager().stopSounds(FEELING.getId(), SoundCategory.MASTER);
MinecraftClient.getInstance().getSoundManager().stopSounds(HOMESICK.getId(), SoundCategory.MASTER);
MinecraftClient.getInstance().getSoundManager().stopSounds(FEELING.id(), SoundCategory.MASTER);
MinecraftClient.getInstance().getSoundManager().stopSounds(HOMESICK.id(), SoundCategory.MASTER);
musicNumber = 1;

isPlayingMusic = false;
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@
"accessWidener": "automaticinfelytra.accesswidener",
"depends": {
"fabricloader": ">=0.15.0",
"minecraft": ">=1.21",
"minecraft": ">=1.21.8",
"java": ">=21",
"fabric-api": "*",
"yet_another_config_lib_v3": ">=3.2.1"
"yet_another_config_lib_v3": ">=3.8.1"
},
"suggests": {
"another-mod": "*"
Expand Down