Fixupboy
Some checks are pending
build / build (push) Waiting to run

This commit is contained in:
Soph :3 2025-10-06 23:48:03 +03:00
parent b500cde68c
commit a35950fc0b
3 changed files with 18 additions and 10 deletions

View file

@ -1,7 +1,9 @@
# FORK!
This is a forked version of https://modrinth.com/mod/powered-jetpacks
which was originally for 1.20.1. I've ported the mod to 1.21.8, but
there's still a major bug, which is if you're using a
there's still a major bug, which is if you're using the powered jetback in quirk armor,
it won't show it on your player model.
# Powered Jetpacks
A simple fabric mod about jetpacks powered with E energy.

View file

@ -8,6 +8,8 @@ import net.fabricmc.fabric.api.client.item.v1.ItemTooltipCallback;
import net.fabricmc.fabric.api.client.rendering.v1.EntityModelLayerRegistry;
import net.fabricmc.fabric.api.client.rendering.v1.HudRenderCallback;
import net.fabricmc.fabric.api.client.rendering.v1.LivingEntityFeatureRendererRegistrationCallback;
import net.fabricmc.fabric.api.client.rendering.v1.hud.HudElementRegistry;
import net.fabricmc.fabric.api.client.rendering.v1.hud.VanillaHudElements;
import net.minecraft.client.render.entity.feature.FeatureRendererContext;
import net.minecraft.client.render.entity.model.EntityModel;
import net.minecraft.entity.EntityType;
@ -19,16 +21,17 @@ public class PoweredJetpacksClient implements ClientModInitializer {
@Override
public void onInitializeClient() {
ItemTooltipCallback.EVENT.register(new StackToolTipHandler());
HudRenderCallback.EVENT.register(new JetpackHUD());
LivingEntityFeatureRendererRegistrationCallback.EVENT.register(
(entityType, entityRenderer, registrationHelper, context) -> {
if (entityRenderer != null && entityType == EntityType.PLAYER) {
// Construct your feature renderer with the context
// Need to get the PlayerEntity somehow here
//TODO: Need to get the PlayerEntity somehow here, for Trinkets
registrationHelper.register(new JetpackRenderer(entityRenderer));
}
}
);
HudElementRegistry.addLast(Identifier.of(PoweredJetpacks.MOD_ID, "hud"), new JetpackHUD());
}
}

View file

@ -2,7 +2,9 @@ package konhaiii.powered_jetpacks.hud;
import konhaiii.powered_jetpacks.PoweredJetpacks;
import konhaiii.powered_jetpacks.item.special.JetpackItem;
import net.fabricmc.fabric.api.client.rendering.v1.HudRenderCallback;
import net.fabricmc.fabric.api.client.rendering.v1.hud.HudElement;
import net.fabricmc.fabric.api.client.rendering.v1.hud.HudElementRegistry;
import net.fabricmc.fabric.api.client.rendering.v1.hud.VanillaHudElements;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.gui.DrawContext;
@ -10,25 +12,26 @@ import net.minecraft.client.render.RenderTickCounter;
import net.minecraft.entity.EquipmentSlot;
import net.minecraft.entity.LivingEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Identifier;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import static net.minecraft.client.resource.language.I18n.translate;
public class JetpackHUD implements HudRenderCallback {
private boolean isValidJetpack(ItemStack stack) {
public class JetpackHUD implements HudElement {
private static boolean isValidJetpack(ItemStack stack) {
return stack.getItem() instanceof JetpackItem;
}
private int percentage(double CurrentValue, double MaxValue) {
private static int percentage(double CurrentValue, double MaxValue) {
if (CurrentValue == 0)
return 0;
return (int) ((CurrentValue * 100.0f) / MaxValue);
}
@Override
public void onHudRender(DrawContext drawContext, RenderTickCounter renderTickCounter) {
public void render(DrawContext drawContext, RenderTickCounter renderTickCounter) {
MinecraftClient client = MinecraftClient.getInstance();
if (client.player == null) return;
@ -57,7 +60,7 @@ public class JetpackHUD implements HudRenderCallback {
int percentage = percentage(energy, maxEnergy);
String energyText = translate("hud.powered_jetpacks.jetpack_power").concat(String.valueOf(percentage)).concat("%");
drawContext.drawTextWithShadow(textRenderer, energyText, 10, 10, 0xFFFFFF);
drawContext.drawTextWithShadow(textRenderer, energyText, 10, 10, 0xFFFFFFFF);
}
}
}