Skip to content

Commit

Permalink
Added movement util, updated CI
Browse files Browse the repository at this point in the history
  • Loading branch information
Faboslav committed Sep 24, 2024
1 parent ca23714 commit 3f27c5f
Show file tree
Hide file tree
Showing 10 changed files with 172 additions and 189 deletions.
3 changes: 1 addition & 2 deletions .github/scripts/generate-publish-matrix.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ modrinth_forge_project_id=$5
IFS=',' read -r -a allowed_mod_loaders_array <<< "${allowed_mod_loaders//[\[\]\']/}"
matrix_content="{\"include\":["
enabled_platforms=$(awk -F= '/enabled_platforms/{print $2}' gradle.properties | tr -d ' ')
minecraft_version=$(awk -F= '/minecraft_version/{print $2; exit}' gradle.properties | tr -d ' ')

for platform in $(echo $enabled_platforms | tr ',' ' '); do
if [[ " ${allowed_mod_loaders_array[@]} " =~ " ${platform} " ]]; then
Expand All @@ -27,7 +26,7 @@ for platform in $(echo $enabled_platforms | tr ',' ' '); do
modrinth_project_id="$modrinth_forge_project_id"
fi

matrix_entry="{\"mod_loader\":\"$platform\",\"minecraft_version\":\"$minecraft_version\",\"supported_mod_loaders\":[$supported_mod_loaders],\"curseforge_project_id\":\"$curseforge_project_id\",\"modrinth_project_id\":\"$modrinth_project_id\"},"
matrix_entry="{\"mod_loader\":\"$platform\",\"supported_mod_loaders\":[$supported_mod_loaders],\"curseforge_project_id\":\"$curseforge_project_id\",\"modrinth_project_id\":\"$modrinth_project_id\"},"
matrix_content+="$matrix_entry"
fi
done
Expand Down
123 changes: 123 additions & 0 deletions .github/workflows/publish-branch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
name: "Publish branch"

on:
workflow_call:
inputs:
mod_loaders:
description: 'List of mod loaders to be published'
required: true
type: string
branch:
description: "Branch to be published"
required: true
type: string

jobs:
build:
runs-on: ubuntu-latest
name: Build ${{ inputs.branch }}
timeout-minutes: 30
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}

steps:
- name: "Checkout repository"
uses: actions/checkout@v4
with:
ref: ${{ inputs.branch }}
fetch-depth: 0

- name: "Parse gradle properties"
id: gradle-properties
run: ./.github/scripts/parse-gradle-properties.sh

- name: "Parse changelog"
run: ./.github/scripts/parse-changelog.sh ${{ steps.gradle-properties.outputs.MOD_VERSION }}

- name: "Create github release"
continue-on-error: true
uses: ncipollo/release-action@v1
with:
skipIfReleaseExists: true
allowUpdates: true
omitNameDuringUpdate: true
omitBodyDuringUpdate: true
tag: mc${{ steps.gradle-properties.outputs.MINECRAFT_VERSION }}-${{ steps.gradle-properties.outputs.MOD_VERSION }}
commit: ${{ inputs.branch }}
name: ${{ steps.gradle-properties.outputs.MOD_NAME }} ${{ steps.gradle-properties.outputs.MOD_VERSION }} for Minecraft ${{ steps.gradle-properties.outputs.MINECRAFT_VERSION }}
bodyFile: RELEASE_CHANGELOG.md

- name: "Set up JDK"
uses: actions/setup-java@v4
with:
java-version: ${{ steps.gradle-properties.outputs.MOD_JAVA_VERSION }}
distribution: temurin

- name: "Setup Gradle and run build"
uses: gradle/actions/setup-gradle@v3
with:
cache-read-only: false
generate-job-summary: false
gradle-version: wrapper
arguments: build

- name: "Upload Built JARs"
uses: actions/upload-artifact@v4
with:
name: built-jars-${{ inputs.branch }}
if-no-files-found: error
path: |
./**/build/libs/*[0-9].jar
- name: "Generate matrix for the run job"
id: set-matrix
run: ./.github/scripts/generate-publish-matrix.sh "${{ inputs.mod_loaders }}" ${{ vars.CURSEFORGE_FABRIC_PROJECT_ID }} ${{ vars.CURSEFORGE_FORGE_PROJECT_ID }} ${{ vars.MODRINTH_FABRIC_PROJECT_ID }} ${{ vars.MODRINTH_FORGE_PROJECT_ID }}

publish:
runs-on: ubuntu-latest
needs: build
name: Publish ${{ inputs.branch }} ${{ matrix.mod_loader }}
timeout-minutes: 10
strategy:
fail-fast: false
matrix: ${{fromJson(needs.build.outputs.matrix)}}

steps:
- name: "Checkout repository"
uses: actions/checkout@v4
with:
ref: ${{ inputs.branch }}
fetch-depth: 0

- name: "Download Built JARs"
uses: actions/download-artifact@v4
with:
name: built-jars-${{ inputs.branch }}

- name: "Parse gradle properties"
id: gradle-properties
run: ./.github/scripts/parse-gradle-properties.sh

- name: "Parse changelog"
run: ./.github/scripts/parse-changelog.sh ${{ steps.gradle-properties.outputs.MOD_VERSION }}

- name: Publish ${{ matrix.mod_loader }}
uses: Kir-Antipov/[email protected]
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
github-tag: mc${{ steps.gradle-properties.outputs.MINECRAFT_VERSION }}-${{ steps.gradle-properties.outputs.MOD_VERSION }}
github-commitish: ${{ steps.gradle-properties.outputs.MINECRAFT_VERSION }}

#curseforge-id: ${{ matrix.curseforge_project_id }}
#curseforge-token: ${{ secrets.CURSEFORGE_RELEASE_TOKEN }}

#modrinth-id: ${{ matrix.modrinth_project_id }}
#modrinth-token: ${{ secrets.MODRINTH_RELEASE_TOKEN }}

name: ${{ steps.gradle-properties.outputs.MOD_NAME }} ${{ steps.gradle-properties.outputs.MOD_VERSION }}
version: ${{ matrix.mod_loader }}-mc${{ steps.gradle-properties.outputs.MINECRAFT_VERSION }}-${{ steps.gradle-properties.outputs.MOD_VERSION }}
loaders: ${{ join(matrix.supported_mod_loaders, ' ') }}
game-versions: "${{ steps.gradle-properties.outputs.MINECRAFT_VERSION }}\n${{ steps.gradle-properties.outputs.MIN_MINECRAFT_VERSION }}"
changelog-file: RELEASE_CHANGELOG.md
files: |
${{ matrix.mod_loader }}/build/libs/*[0-9].jar
116 changes: 7 additions & 109 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,116 +15,14 @@ on:
type: string

jobs:
build:
runs-on: ubuntu-latest
name: Build ${{ matrix.branch }}
timeout-minutes: 15
publish:
name: "Publish"
strategy:
fail-fast: false
matrix:
branch: ${{ fromJson(inputs.branches) }}
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}

steps:
- name: "Checkout repository"
uses: actions/checkout@v4
with:
ref: ${{ matrix.branch }}
fetch-depth: 0

- name: "Parse gradle properties"
id: gradle-properties
run: ./.github/scripts/parse-gradle-properties.sh

- name: "Parse changelog"
run: ./.github/scripts/parse-changelog.sh ${{ steps.gradle-properties.outputs.MOD_VERSION }}

- name: "Create github release"
continue-on-error: true
uses: ncipollo/release-action@v1
with:
skipIfReleaseExists: true
allowUpdates: true
omitNameDuringUpdate: true
omitBodyDuringUpdate: true
tag: mc${{ steps.gradle-properties.outputs.MINECRAFT_VERSION }}-${{ steps.gradle-properties.outputs.MOD_VERSION }}
commit: ${{ matrix.branch }}
name: ${{ steps.gradle-properties.outputs.MOD_NAME }} ${{ steps.gradle-properties.outputs.MOD_VERSION }} for Minecraft ${{ steps.gradle-properties.outputs.MINECRAFT_VERSION }}
bodyFile: RELEASE_CHANGELOG.md

- name: "Set up JDK"
uses: actions/setup-java@v4
with:
java-version: ${{ steps.gradle-properties.outputs.MOD_JAVA_VERSION }}
distribution: temurin

- name: "Setup Gradle and run build"
uses: gradle/actions/setup-gradle@v3
with:
cache-read-only: false
generate-job-summary: false
gradle-version: wrapper
arguments: build

- name: "Upload Built JARs"
uses: actions/upload-artifact@v4
with:
name: built-jars
if-no-files-found: error
path: |
./**/build/libs/*[0-9].jar
- name: "Generate matrix for the run job"
id: set-matrix
run: ./.github/scripts/generate-publish-matrix.sh "${{ inputs.mod_loaders }}" ${{ vars.CURSEFORGE_FABRIC_PROJECT_ID }} ${{ vars.CURSEFORGE_FORGE_PROJECT_ID }} ${{ vars.MODRINTH_FABRIC_PROJECT_ID }} ${{ vars.MODRINTH_FORGE_PROJECT_ID }}

publish:
runs-on: ubuntu-latest
needs: build
name: Publish ${{ matrix.mod_loader }}
timeout-minutes: 15
strategy:
fail-fast: false
matrix: ${{fromJson(needs.build.outputs.matrix)}}

steps:
- name: "Checkout repository"
uses: actions/checkout@v4
with:
ref: ${{ matrix.minecraft_version }}
fetch-depth: 0

- name: "Download Built JARs"
uses: actions/download-artifact@v4
with:
name: built-jars

- name: "Parse gradle properties"
id: gradle-properties
run: ./.github/scripts/parse-gradle-properties.sh

- name: "Parse changelog"
run: ./.github/scripts/parse-changelog.sh ${{ steps.gradle-properties.outputs.MOD_VERSION }}

- name: Publish ${{ matrix.mod_loader }}
uses: Kir-Antipov/[email protected]
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
github-tag: mc${{ steps.gradle-properties.outputs.MINECRAFT_VERSION }}-${{ steps.gradle-properties.outputs.MOD_VERSION }}
github-commitish: ${{ steps.gradle-properties.outputs.MINECRAFT_VERSION }}

#curseforge-id: ${{ matrix.curseforge_project_id }}
#curseforge-token: ${{ secrets.CURSEFORGE_RELEASE_TOKEN }}

#modrinth-id: ${{ matrix.modrinth_project_id }}
#modrinth-featured: true
#modrinth-token: ${{ secrets.MODRINTH_RELEASE_TOKEN }}

name: ${{ steps.gradle-properties.outputs.MOD_NAME }} ${{ steps.gradle-properties.outputs.MOD_VERSION }}
version: ${{ matrix.mod_loader }}-mc${{ steps.gradle-properties.outputs.MINECRAFT_VERSION }}-${{ steps.gradle-properties.outputs.MOD_VERSION }}
loaders: ${{ join(matrix.supported_mod_loaders, ' ') }}
game-versions: "${{ steps.gradle-properties.outputs.MINECRAFT_VERSION }}\n${{ steps.gradle-properties.outputs.MIN_MINECRAFT_VERSION }}"
changelog-file: RELEASE_CHANGELOG.md
files: |
${{ matrix.mod_loader }}/build/libs/*[0-9].jar
uses: ./.github/workflows/publish-branch.yml
with:
branch: ${{ matrix.branch }}
mod_loaders: ${{ inputs.mod_loaders }}
secrets: inherit
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import com.faboslav.friendsandfoes.common.init.FriendsAndFoesMemoryModuleTypes;
import com.faboslav.friendsandfoes.common.init.FriendsAndFoesSoundEvents;
import com.faboslav.friendsandfoes.common.tag.FriendsAndFoesTags;
import com.faboslav.friendsandfoes.common.util.MovementUtil;
import com.faboslav.friendsandfoes.common.util.particle.ParticleSpawner;
import com.mojang.serialization.Dynamic;
import net.minecraft.block.BlockState;
Expand Down Expand Up @@ -496,7 +497,7 @@ public void tick() {

if (this.isOxidized()) {
this.applyEntitySnapshot();
this.stopMovement();
MovementUtil.stopMovement(this);
return;
}

Expand Down Expand Up @@ -775,27 +776,6 @@ private void becomeEntity() {
CopperGolemBrain.setPressButtonCooldown(this);
}

public void stopMovement() {
this.getBrain().forget(MemoryModuleType.AVOID_TARGET);
this.getBrain().forget(MemoryModuleType.WALK_TARGET);
this.getBrain().forget(MemoryModuleType.LOOK_TARGET);

this.getNavigation().setSpeed(0);
this.getNavigation().stop();
this.getMoveControl().moveTo(this.getX(), this.getY(), this.getZ(), 0);
this.getMoveControl().tick();
this.getLookControl().lookAt(this.getLookControl().getLookX(), this.getLookControl().getLookY(), this.getLookControl().getLookZ());
this.getLookControl().lookAt(Vec3d.ZERO);
this.getLookControl().tick();

this.setJumping(false);
this.setMovementSpeed(0.0F);
this.prevHorizontalSpeed = 0.0F;
this.horizontalSpeed = 0.0F;
this.sidewaysSpeed = 0.0F;
this.upwardSpeed = 0.0F;
}

public boolean isWaxed() {
return this.dataTracker.get(IS_WAXED);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import com.faboslav.friendsandfoes.common.init.FriendsAndFoesMemoryModuleTypes;
import com.faboslav.friendsandfoes.common.init.FriendsAndFoesSoundEvents;
import com.faboslav.friendsandfoes.common.tag.FriendsAndFoesTags;
import com.faboslav.friendsandfoes.common.util.MovementUtil;
import com.faboslav.friendsandfoes.common.util.RandomGenerator;
import com.faboslav.friendsandfoes.common.util.particle.ParticleSpawner;
import com.mojang.serialization.Dynamic;
Expand Down Expand Up @@ -444,7 +445,7 @@ public ActionResult interactMob(
this.setSitting(!this.isSitting());

if (this.isSitting()) {
this.stopMovement();
MovementUtil.stopMovement(this);
}

return ActionResult.SUCCESS;
Expand Down Expand Up @@ -519,27 +520,6 @@ public void setSitting(boolean isSitting) {
super.setInSittingPose(isSitting);
}

public void stopMovement() {
this.getBrain().forget(MemoryModuleType.AVOID_TARGET);
this.getBrain().forget(MemoryModuleType.WALK_TARGET);
this.getBrain().forget(MemoryModuleType.LOOK_TARGET);

this.getNavigation().setSpeed(0);
this.getNavigation().stop();
this.getMoveControl().moveTo(this.getX(), this.getY(), this.getZ(), 0);
this.getMoveControl().tick();
this.getLookControl().lookAt(this.getLookControl().getLookX(), this.getLookControl().getLookY(), this.getLookControl().getLookZ());
this.getLookControl().lookAt(Vec3d.ZERO);
this.getLookControl().tick();

this.setJumping(false);
this.setMovementSpeed(0.0F);
this.prevHorizontalSpeed = 0.0F;
this.horizontalSpeed = 0.0F;
this.sidewaysSpeed = 0.0F;
this.upwardSpeed = 0.0F;
}

@Nullable
public GlobalPos getGlowBerriesPos() {
return this.getBrain().getOptionalMemory(FriendsAndFoesMemoryModuleTypes.GLARE_GLOW_BERRIES_POS.get()).orElse(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import com.faboslav.friendsandfoes.common.entity.animation.AnimatedEntity;
import com.faboslav.friendsandfoes.common.entity.pose.TuffGolemEntityPose;
import com.faboslav.friendsandfoes.common.init.FriendsAndFoesSoundEvents;
import com.faboslav.friendsandfoes.common.util.MovementUtil;
import com.faboslav.friendsandfoes.common.util.particle.ParticleSpawner;
import com.mojang.serialization.Dynamic;
import net.minecraft.block.Block;
Expand Down Expand Up @@ -439,7 +440,7 @@ private boolean tryToInteractMobWithItem(
return false;
}

this.stopMovement();
MovementUtil.stopMovement(this);

if (this.isHoldingItem()) {
if (!player.getAbilities().creativeMode) {
Expand Down Expand Up @@ -822,23 +823,6 @@ public void setSpawnYaw(float yaw) {
this.setHeadYaw(yaw);
}

public void stopMovement() {
this.getNavigation().setSpeed(0);
this.getNavigation().stop();
this.getMoveControl().moveTo(this.getX(), this.getY(), this.getZ(), 0);
this.getMoveControl().tick();
this.getLookControl().lookAt(this.getLookControl().getLookX(), this.getLookControl().getLookY(), this.getLookControl().getLookZ());
this.getLookControl().lookAt(Vec3d.ZERO);
this.getLookControl().tick();

this.setJumping(false);
this.setMovementSpeed(0.0F);
this.prevHorizontalSpeed = 0.0F;
this.horizontalSpeed = 0.0F;
this.sidewaysSpeed = 0.0F;
this.upwardSpeed = 0.0F;
}

public enum Color
{
RED("red"),
Expand Down
Loading

0 comments on commit 3f27c5f

Please sign in to comment.