Skip to content

Commit

Permalink
update: 1.21.2
Browse files Browse the repository at this point in the history
Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
  • Loading branch information
Octol1ttle committed Oct 24, 2024
1 parent 781d3f7 commit d2c66d4
Show file tree
Hide file tree
Showing 20 changed files with 44 additions and 119 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ dependencies {
// Optional: Mod Menu to access the YACL config screen
modApi "com.terraformersmc:modmenu:${project.modmenu_version}"
// Optional: ImmediatelyFast for batching support to increase rendering performance
modApi "maven.modrinth:immediatelyfast:${project.immediatelyfast_version}+${project.minecraft_version}-fabric"
//modApi "maven.modrinth:immediatelyfast:${project.immediatelyfast_version}+1.21.3-fabric"
// Optional: Do a Barrel Roll to control roll via RollController
modApi "nl.enjarai:do-a-barrel-roll:${project.dabr_version}+${project.minecraft_version}-fabric"
}
Expand Down
20 changes: 10 additions & 10 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ org.gradle.parallel=true

# Fabric Properties
# check these on https://fabricmc.net/develop
minecraft_version=1.21
yarn_mappings=1.21+build.2
minecraft_version=1.21.2
yarn_mappings=1.21.2+build.1
floader_version=0.15.10

# Mod Properties
Expand All @@ -15,15 +15,15 @@ archives_base_name=flightassistant

# Dependencies
ahrc_version=1.20.5-1.0.0
fapi_version=0.100.1
yacl_version=3.5.0
modmenu_version=11.0.0
immediatelyfast_version=1.2.18
dabr_version=3.6.1
fapi_version=0.106.1
yacl_version=3.6.0
modmenu_version=12.0.0-beta.1
immediatelyfast_version=1.3.0
dabr_version=3.8.0
# Publish Properties
publish_target_min=1.21
publish_target_max=1.21.1
publish_target_min=1.21.2
publish_target_max=1.21.3
mod_modrinth=CWqLEOPt
mod_curseforge=972881
mod_github=Octol1ttle/FlightAssistant
git_branch=1.21/dev
git_branch=1.21.2/dev
6 changes: 3 additions & 3 deletions src/main/java/ru/octol1ttle/flightassistant/DrawHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import net.minecraft.text.MutableText;
import net.minecraft.text.Text;
import net.minecraft.util.math.Vec3d;
import ru.octol1ttle.flightassistant.compatibility.immediatelyfast.HUDBatching;
import ru.octol1ttle.flightassistant.util.ScreenSpaceRendering;

public abstract class DrawHelper {
Expand Down Expand Up @@ -61,14 +60,15 @@ public static void drawMiddleAlignedText(TextRenderer textRenderer, DrawContext
}

public static int drawHighlightedText(TextRenderer textRenderer, DrawContext context, Text text, int x, int y, Color color, boolean highlight) {
HUDBatching.tryEnd();
if (highlight) {
DrawHelper.fill(context, x - 2, y - 1, x + textRenderer.getWidth(text) + 1, y + 8, color);
context.getMatrices().translate(0, 0, 100);
DrawHelper.drawText(textRenderer, context, text, x, y, getContrasting(color));
context.getMatrices().translate(0, 0, -100);
} else {
DrawHelper.drawText(textRenderer, context, text, x, y, color);
}
HUDBatching.tryBegin();

return SINGLE_LINE_DRAWN;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
import net.minecraft.entity.projectile.FireworkRocketEntity;
import net.minecraft.item.FireworkRocketItem;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.util.Pair;
import net.minecraft.util.TypedActionResult;
import net.minecraft.util.math.Direction;
import net.minecraft.util.math.RotationAxis;
import net.minecraft.world.World;
Expand Down Expand Up @@ -137,18 +137,18 @@ public Optional<Float> onPitchChange(Entity entity, float pitchDelta) {
}

@Override
public TypedActionResult<ItemStack> interact(PlayerEntity player, World world, Hand hand) {
public ActionResult interact(PlayerEntity player, World world, Hand hand) {
ItemStack stack = player.getStackInHand(hand);
AirDataComputer data = ComputerRegistry.resolve(AirDataComputer.class);
GroundProximityComputer gpws = ComputerRegistry.resolve(GroundProximityComputer.class);
FireworkController firework = ComputerRegistry.resolve(FireworkController.class);
TimeComputer time = ComputerRegistry.resolve(TimeComputer.class);

if (!world.isClient() || ComputerRegistry.isFaulted(FireworkController.class)) {
return TypedActionResult.pass(stack);
return ActionResult.PASS;
}
if (!data.isFlying() || !(stack.getItem() instanceof FireworkRocketItem)) {
return TypedActionResult.pass(stack);
return ActionResult.PASS;
}

boolean gpwsLocksFireworks = FAConfig.computer().lockFireworksFacingTerrain;
Expand All @@ -157,7 +157,7 @@ public TypedActionResult<ItemStack> interact(PlayerEntity player, World world, H
boolean unsafeFireworks = FAConfig.computer().lockUnsafeFireworks && !firework.isFireworkSafe(player.getStackInHand(hand));

if (!firework.activationInProgress && (unsafeFireworks || gpwsDanger)) {
return TypedActionResult.fail(stack);
return ActionResult.FAIL;
}

if (firework.fireworkResponded) {
Expand All @@ -168,7 +168,7 @@ public TypedActionResult<ItemStack> interact(PlayerEntity player, World world, H
firework.fireworkResponded = false;
}

return TypedActionResult.pass(stack);
return ActionResult.PASS;
}

@Override
Expand Down
10 changes: 0 additions & 10 deletions src/main/java/ru/octol1ttle/flightassistant/FAModMenuImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,6 @@ private ConfigCategory hud(Text name, HUDConfig config, HUDConfig defaults) {
return ConfigCategory.createBuilder()
.name(name)

.option(Option.<HUDConfig.BatchedRendering>createBuilder()
.name(Text.translatable("config.flightassistant.hud.batching"))
.available(FlightAssistant.canUseBatching())
.binding(defaults.batchedRendering, () -> FlightAssistant.canUseBatching()
? config.batchedRendering
: HUDConfig.BatchedRendering.NO_BATCHING
, o -> config.batchedRendering = o)
.controller(opt -> EnumControllerBuilder.create(opt).enumClass(HUDConfig.BatchedRendering.class))
.build()
)
.option(Option.<Float>createBuilder()
.name(Text.translatable("config.flightassistant.hud.scale"))
.binding(defaults.hudScale, () -> config.hudScale, o -> config.hudScale = o)
Expand Down
10 changes: 0 additions & 10 deletions src/main/java/ru/octol1ttle/flightassistant/FlightAssistant.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
package ru.octol1ttle.flightassistant;

import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.client.MinecraftClient;
import net.minecraft.util.Identifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import ru.octol1ttle.flightassistant.computers.ComputerHost;
import ru.octol1ttle.flightassistant.config.FAConfig;
import ru.octol1ttle.flightassistant.config.HUDConfig;
import ru.octol1ttle.flightassistant.hud.HudDisplayHost;

public class FlightAssistant implements ClientModInitializer {
Expand Down Expand Up @@ -54,12 +52,4 @@ public static ComputerHost getComputerHost() {
public static Identifier id(String path) {
return Identifier.of(FlightAssistant.MODID, path);
}

public static boolean isHUDBatched() {
return canUseBatching() && FAConfig.hud().batchedRendering != HUDConfig.BatchedRendering.NO_BATCHING;
}

public static boolean canUseBatching() {
return FabricLoader.getInstance().isModLoaded("immediatelyfast");
}
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import ru.octol1ttle.flightassistant.config.ComputerConfig;
import ru.octol1ttle.flightassistant.config.FAConfig;
import ru.octol1ttle.flightassistant.config.IndicatorConfig;
import ru.octol1ttle.flightassistant.mixin.EntityInvoker;
import ru.octol1ttle.flightassistant.util.events.RollMatrixCallback;

import static net.minecraft.SharedConstants.TICKS_PER_SECOND;
Expand Down Expand Up @@ -76,7 +77,7 @@ public boolean isInvulnerableTo(DamageSource source) {
if (!FAConfig.computer().considerInvulnerability) {
return false;
}
return player().isInvulnerableTo(source)
return ((EntityInvoker) player()).invokeIsAlwaysInvulnerableTo(source)
|| player().getAbilities().invulnerable && !source.isIn(DamageTypeTags.BYPASSES_INVULNERABILITY)
|| player().getAbilities().allowFlying && source.isIn(DamageTypeTags.IS_FALL);
}
Expand Down Expand Up @@ -167,7 +168,7 @@ public static float toHeading(float yawDegrees) {
}

public boolean isFlying() {
return player().isFallFlying();
return player().isGliding();
}

public Vec3d position() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public void tick() {
}

private boolean tickLanding(Vector2d target) {
Vec3d landPos = data.findGround(new Vec3d(target.x, data.world().getTopY(), target.y));
Vec3d landPos = data.findGround(new Vec3d(target.x, data.world().getTopYInclusive(), target.y));
if (landPos == null) {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public void tick() {

boolean soundChanged = false;
if (alert.soundInstance != null) {
soundChanged = data.sound() == null || !data.sound().getId().equals(alert.soundInstance.getId());
soundChanged = data.sound() == null || !data.sound().id().equals(alert.soundInstance.getId());
if (soundChanged || interrupt || alert.hidden) {
manager.stop(alert.soundInstance);
alert.soundInstance = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ private boolean positiveLessOrEquals(float time, float lessOrEquals) {
}

private BlockPos findHighest(BlockPos.Mutable at) {
while (at.getY() < data.world().getTopY()) {
while (at.getY() < data.world().getTopYInclusive()) {
if (!data.isGround(at.move(Direction.UP))) {
return at;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public static IndicatorConfig indicator() {
throw new IllegalStateException("Attempted to retrieve indicator settings when there is no player");
}

if (client.player.isFallFlying()) {
if (client.player.isGliding()) {
return INDICATORS_STORAGE_HANDLER.instance().flying;
}

Expand Down
16 changes: 0 additions & 16 deletions src/main/java/ru/octol1ttle/flightassistant/config/HUDConfig.java
Original file line number Diff line number Diff line change
@@ -1,28 +1,12 @@
package ru.octol1ttle.flightassistant.config;

import dev.isxander.yacl3.api.NameableEnum;
import dev.isxander.yacl3.config.v2.api.SerialEntry;
import java.util.Locale;
import net.minecraft.text.Text;

public class HUDConfig {
@SerialEntry
public BatchedRendering batchedRendering = BatchedRendering.SINGLE_BATCH;
@SerialEntry
public float hudScale = 1.0f;
@SerialEntry
public float frameWidth = 0.6f;
@SerialEntry
public float frameHeight = 0.6f;

public enum BatchedRendering implements NameableEnum {
NO_BATCHING,
PER_COMPONENT,
SINGLE_BATCH;

@Override
public Text getDisplayName() {
return Text.translatable("config.flightassistant.hud.batching." + name().toLowerCase(Locale.ROOT));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@
import net.minecraft.client.gui.DrawContext;
import net.minecraft.util.Identifier;
import ru.octol1ttle.flightassistant.Dimensions;
import ru.octol1ttle.flightassistant.FlightAssistant;
import ru.octol1ttle.flightassistant.compatibility.immediatelyfast.HUDBatching;
import ru.octol1ttle.flightassistant.config.FAConfig;
import ru.octol1ttle.flightassistant.config.HUDConfig;
import ru.octol1ttle.flightassistant.hud.api.IHudDisplay;
import ru.octol1ttle.flightassistant.hud.impl.AlertDisplay;
import ru.octol1ttle.flightassistant.hud.impl.AltitudeDisplay;
Expand Down Expand Up @@ -57,17 +54,13 @@ public void render(MinecraftClient mc, DrawContext context, float tickDelta) {
dim.update(context, renderer.invokeGetFov(mc.gameRenderer.getCamera(), tickDelta, true));

float hudScale = FAConfig.hud().hudScale;
boolean batchAll = FlightAssistant.canUseBatching() && FAConfig.hud().batchedRendering == HUDConfig.BatchedRendering.SINGLE_BATCH;

context.getMatrices().push();
context.getMatrices().scale(hudScale, hudScale, hudScale);
HUDBatching.tryBeginIf(batchAll);

for (Map.Entry<Identifier, IHudDisplay> entry : HudDisplayRegistry.getDisplays()) {
Identifier id = entry.getKey();
IHudDisplay display = entry.getValue();
boolean perComponent = FlightAssistant.canUseBatching() && FAConfig.hud().batchedRendering == HUDConfig.BatchedRendering.PER_COMPONENT;
HUDBatching.tryBeginIf(perComponent);
try {
if (!HudDisplayRegistry.isFaulted(id)) {
display.render(context, mc.textRenderer);
Expand All @@ -77,10 +70,8 @@ public void render(MinecraftClient mc, DrawContext context, float tickDelta) {
} catch (Throwable t) {
HudDisplayRegistry.markFaulted(id, t, "Exception rendering display with ID: %s".formatted(id));
}
HUDBatching.tryEndIf(perComponent);
}

HUDBatching.tryEndIf(batchAll);
context.getMatrices().pop();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package ru.octol1ttle.flightassistant.mixin;

import net.minecraft.entity.Entity;
import net.minecraft.entity.damage.DamageSource;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Invoker;

@Mixin(Entity.class)
public interface EntityInvoker {
@Invoker
boolean invokeIsAlwaysInvulnerableTo(DamageSource damageSource);
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
@Mixin(GameRenderer.class)
public interface GameRendererInvoker {
@Invoker
double invokeGetFov(Camera camera, float tickDelta, boolean changingFov);
float invokeGetFov(Camera camera, float tickDelta, boolean changingFov);
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class GameRendererMixin {
remap = false
)
)
public void updateRoll(RenderTickCounter tickCounter, CallbackInfo ci, @Local(ordinal = 1) Matrix4f matrix4f2) {
RollMatrixCallback.EVENT.invoker().onMatrixUpdate(matrix4f2);
public void updateRoll(RenderTickCounter tickCounter, CallbackInfo ci, @Local(ordinal = 2) Matrix4f matrix4f3) {
RollMatrixCallback.EVENT.invoker().onMatrixUpdate(matrix4f3);
}
}
2 changes: 1 addition & 1 deletion src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"depends": {
"fabricloader": ">=0.15.10",
"fabric-api": "*",
"minecraft": "^1.21",
"minecraft": ">=1.21.2 <1.22",
"java": ">=21",
"yet_another_config_lib_v3": "*"
},
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/flightassistant.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"compatibilityLevel": "JAVA_21",
"mixins": [],
"client": [
"EntityInvoker",
"EntityMixin",
"FireworkRocketEntityMixin",
"GameRendererInvoker",
Expand Down

0 comments on commit d2c66d4

Please sign in to comment.