Skip to content

Commit

Permalink
update: 1.20.5
Browse files Browse the repository at this point in the history
Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
  • Loading branch information
Octol1ttle committed Aug 22, 2024
1 parent d696ee2 commit 1aa7d1e
Show file tree
Hide file tree
Showing 10 changed files with 85 additions and 32 deletions.
1 change: 0 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ jobs:
matrix:
# Use these Java versions
java: [
17, # Current Java LTS & minimum supported by Minecraft
21, # Current Java LTS
]
runs-on: ubuntu-22.04
Expand Down
10 changes: 5 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,13 @@ dependencies {
// Required: Fabric API for callbacks
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fapi_version}+${project.minecraft_version}"
// Required: YACL for config storage and screen
modImplementation "dev.isxander.yacl:yet-another-config-lib-fabric:${project.yacl_version}+${project.minecraft_version}"
modImplementation "dev.isxander:yet-another-config-lib:${project.yacl_version}+${project.minecraft_version}-fabric"
// 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"
// Optional: Do a Barrel Roll to control roll via RollController
modApi "nl.enjarai:do-a-barrel-roll:${project.dabr_version}+${project.minecraft_version}-fabric"
modApi "nl.enjarai:do-a-barrel-roll:${project.dabr_version}-fabric"
}

processResources {
Expand All @@ -89,7 +89,7 @@ yamlang {
}

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

java {
Expand All @@ -98,8 +98,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
24 changes: 12 additions & 12 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,26 @@ org.gradle.parallel=true

# Fabric Properties
# check these on https://fabricmc.net/develop
minecraft_version=1.20.4
yarn_mappings=1.20.4+build.3
floader_version=0.15.3
minecraft_version=1.20.5
yarn_mappings=1.20.5+build.1
floader_version=0.15.10

# Mod Properties
mod_version=2.3.4
maven_group=ru.octol1ttle.flightassistant
archives_base_name=flightassistant

# Dependencies
ahrc_version=1.20.x-0.1.3
fapi_version=0.96.4
yacl_version=3.3.1
modmenu_version=9.0.0
immediatelyfast_version=1.2.8
dabr_version=3.3.8
ahrc_version=1.20.5-1.0.0
fapi_version=0.97.5
yacl_version=3.4.0
modmenu_version=10.0.0-beta.1
immediatelyfast_version=1.2.12
dabr_version=3.5.7+1.20.6
# Publish Properties
publish_target_min=1.20
publish_target_max=1.20.4
publish_target_min=1.20.5
publish_target_max=1.20.6
mod_modrinth=CWqLEOPt
mod_curseforge=972881
mod_github=Octol1ttle/FlightAssistant
git_branch=dev
git_branch=1.20.5/dev
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package ru.octol1ttle.flightassistant.computers.impl;

import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.block.BlockState;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.network.ClientPlayerEntity;
Expand All @@ -20,13 +19,14 @@
import net.minecraft.world.World;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.joml.Matrix3f;
import org.joml.Matrix4f;
import ru.octol1ttle.flightassistant.DrawHelper;
import ru.octol1ttle.flightassistant.FAMathHelper;
import ru.octol1ttle.flightassistant.computers.api.ITickableComputer;
import ru.octol1ttle.flightassistant.config.ComputerConfig;
import ru.octol1ttle.flightassistant.config.FAConfig;
import ru.octol1ttle.flightassistant.config.IndicatorConfig;
import ru.octol1ttle.flightassistant.util.events.RollMatrixCallback;

import static net.minecraft.SharedConstants.TICKS_PER_SECOND;

Expand All @@ -44,13 +44,13 @@ public class AirDataComputer implements ITickableComputer {

public AirDataComputer(MinecraftClient mc) {
this.mc = mc;
RollMatrixCallback.EVENT.register(matrix4f -> roll = computeRoll(matrix4f));
}

@Override
public void tick() {
velocity = player().getVelocity().multiply(TICKS_PER_SECOND);
forwardVelocity = computeForwardVelocity();
roll = computeRoll(RenderSystem.getInverseViewRotationMatrix().invert());
isCurrentChunkLoaded = isCurrentChunkLoaded();
groundLevel = computeGroundLevel();
flightPitch = computeFlightPitch(velocity, pitch());
Expand Down Expand Up @@ -93,7 +93,7 @@ private Vec3d computeForwardVelocity() {
return new Vec3d(Math.max(0.0, lookVelocity.x), Math.max(0.0, lookVelocity.y), Math.max(0.0, lookVelocity.z));
}

private float computeRoll(Matrix3f matrix) {
private float computeRoll(Matrix4f matrix) {
return validate(FAMathHelper.toDegrees(Math.atan2(-matrix.m10(), matrix.m11())), -180.0f, 180.0f);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package ru.octol1ttle.flightassistant.computers.impl.autoflight;

import net.minecraft.client.MinecraftClient;
import net.minecraft.component.DataComponentTypes;
import net.minecraft.component.type.FireworksComponent;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.item.FireworkRocketItem;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.nbt.NbtElement;
import net.minecraft.util.Hand;
import ru.octol1ttle.flightassistant.computers.api.IThrustHandler;
import ru.octol1ttle.flightassistant.computers.api.ITickableComputer;
Expand Down Expand Up @@ -129,8 +129,12 @@ public boolean isFireworkSafe(ItemStack stack) {
if (data.isInvulnerable()) {
return true;
}
NbtCompound nbtCompound = stack.getSubNbt("Fireworks");
return nbtCompound == null || nbtCompound.getList("Explosions", NbtElement.COMPOUND_TYPE).isEmpty();

FireworksComponent component = stack.getComponents().get(DataComponentTypes.FIREWORKS);
if (component == null) {
throw new IllegalStateException();
}
return component.explosions().isEmpty();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public static IndicatorConfig indicator() {
}

if (!client.player.getAbilities().allowFlying) {
for (ItemStack stack : client.player.getItemsEquipped()) {
for (ItemStack stack : client.player.getEquippedItems()) {
if (Items.ELYTRA.equals(stack.getItem())) {
return INDICATORS_STORAGE_HANDLER.instance().notFlyingHasElytra;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package ru.octol1ttle.flightassistant.mixin;

import com.llamalad7.mixinextras.sugar.Local;
import net.minecraft.client.render.GameRenderer;
import org.joml.Matrix4f;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import ru.octol1ttle.flightassistant.util.events.RollMatrixCallback;

@Mixin(GameRenderer.class)
public class GameRendererMixin {
@Inject(
method = "renderWorld",
at = @At(
value = "INVOKE_ASSIGN",
target = "Lorg/joml/Matrix4f;rotationXYZ(FFF)Lorg/joml/Matrix4f;",
ordinal = 0,
remap = false
)
)
public void updateRoll(float tickDelta, long limitTime, CallbackInfo ci, @Local(ordinal = 1) Matrix4f matrix4f2) {
RollMatrixCallback.EVENT.invoker().onMatrixUpdate(matrix4f2);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package ru.octol1ttle.flightassistant.util.events;

import net.fabricmc.fabric.api.event.Event;
import net.fabricmc.fabric.api.event.EventFactory;
import org.joml.Matrix4f;

public interface RollMatrixCallback {
Event<RollMatrixCallback> EVENT = EventFactory.createArrayBacked(
RollMatrixCallback.class,
(listeners) -> (matrix4f) -> {
for (RollMatrixCallback event : listeners) {
event.onMatrixUpdate(matrix4f);
}
}
);

/**
* Called after the roll matrix has been updated
*
* @param matrix4f the roll matrix
*/
void onMatrixUpdate(Matrix4f matrix4f);
}
6 changes: 3 additions & 3 deletions src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@
"flightassistant.mixins.json"
],
"depends": {
"fabricloader": ">=0.15.3",
"fabricloader": ">=0.15.10",
"fabric-api": "*",
"minecraft": ">=1.20.0 <1.20.5",
"java": ">=17",
"minecraft": ">=1.20.5 <1.21",
"java": ">=21",
"yet_another_config_lib_v3": "*"
},
"recommends": {
Expand Down
5 changes: 3 additions & 2 deletions src/main/resources/flightassistant.mixins.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
{
"required": true,
"package": "ru.octol1ttle.flightassistant.mixin",
"compatibilityLevel": "JAVA_17",
"compatibilityLevel": "JAVA_21",
"mixins": [],
"client": [
"EntityMixin",
"FireworkRocketEntityMixin",
"GameRendererInvoker"
"GameRendererInvoker",
"GameRendererMixin"
],
"injectors": {
"defaultRequire": 1
Expand Down

0 comments on commit 1aa7d1e

Please sign in to comment.