Andrzej Zebrowski

make a mod that while in combat you can only use youre elytra for 2.5 seconds and a 10 second coldown

Kodari AI
KodariOct 30 at 1:41 pm 1
ElytraCombatLimiter
A Minecraft Fabric mod that restricts elytra usage during combat. When a player enters combat, they can only fly with their elytra for 2.5 seconds before it becomes disabled. After the elytra is disabled, a 10-second cooldown begins before the player can use the elytra again. The mod tracks combat status based on taking or dealing damage, displays visual feedback for the remaining flight time and cooldown duration, and automatically re-enables elytra flight once the cooldown expires. Compatible with Fabric 26.2 and designed for PvP and PvE scenarios to prevent infinite elytra kiting during fights.

Plan:

  1. Mark combat when a player attacks or takes damage.

  2. In server ticks, cap combat elytra flight at 2.5 seconds and enforce a 10-second cooldown.

  3. Create the Fabric 26.2 project files and mod metadata.

Created the Fabric 26.2 mod. Attacking or taking damage starts combat; while combat is active, elytra flight is limited to 2.5 seconds, followed by a 10-second cooldown. Outside combat, elytra use remains unrestricted.

Andrzej Zebrowski

can you make it that you can see the coldown and how moch you have time left on youre rlytraa

Kodari AI
KodariOct 30 at 1:57 pm 1
  1. Synchronize combat and elytra timers from server to client.

  2. Show remaining flight time or cooldown in an in-game HUD.

  3. Register the client entrypoint and bundle owo-lib.

Added a HUD indicator showing your elytra time remaining during combat, the cooldown after flight, and whether combat elytra is ready. The timer updates from server-synced status.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
gradle.properties
manifest.kod
settings.gradle
Code
8 259
src/client/java/dev/kodari/combat_elytra/CombatElytraClient.java
package dev.kodari.combat_elytra;

import io.wispforest.owo.ui.component.LabelComponent;
import io.wispforest.owo.ui.component.UIComponents;
import io.wispforest.owo.ui.container.FlowLayout;
import io.wispforest.owo.ui.container.UIContainers;
import io.wispforest.owo.ui.core.Insets;
import io.wispforest.owo.ui.core.Positioning;
import io.wispforest.owo.ui.core.Sizing;
import io.wispforest.owo.ui.core.Surface;
import io.wispforest.owo.ui.hud.Hud;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.Identifier;

import java.util.Locale;

public class CombatElytraClient implements ClientModInitializer {
	private static final Identifier HUD_ID = Identifier.fromNamespaceAndPath("combat_elytra", "status_hud");
	private static LabelComponent statusLabel;

	@Override
	public void onInitializeClient() {
		Hud.add(HUD_ID, () -> {
			statusLabel = UIComponents.label(Component.literal("Combat Elytra: Not in combat"));
			FlowLayout panel = UIContainers.verticalFlow(Sizing.content(), Sizing.content());
			panel.child(statusLabel);
			panel.padding(Insets.of(4));
			panel.surface(Surface.DARK_PANEL);
			panel.margins(Insets.of(5));
			panel.positioning(Positioning.relative(0, 0));
			return panel;
		});

		ClientPlayNetworking.registerGlobalReceiver(CombatElytraStatusPayload.TYPE, (payload, context) ->
				updateStatus(payload.combatTicks(), payload.flightTicks(), payload.cooldownTicks(), payload.limitedFlight())
		);
	}

	private static void updateStatus(int combatTicks, int flightTicks, int cooldownTicks, boolean limitedFlight) {
		if (statusLabel == null) {
			return;
		}

		String text;
		if (combatTicks <= 0) {
			text = "Combat Elytra: Not in combat";
		} else if (limitedFlight && flightTicks > 0) {
			text = String.format(Locale.ROOT, "Elytra: %.1fs remaining", flightTicks / 20.0);
		} else if (cooldownTicks > 0) {
			text = String.format(Locale.ROOT, "Elytra cooldown: %.1fs", cooldownTicks / 20.0);
		} else {
			text = "Elytra: Ready";
		}

		if (!statusLabel.text().getString().equals(text)) {
			statusLabel.text(Component.literal(text));
		}
	}
}