From 023c852181c4969dfab859423885bd8bf200e853 Mon Sep 17 00:00:00 2001 From: IThundxr Date: Fri, 21 Jun 2024 18:44:26 -0400 Subject: [PATCH 1/5] redo workflow to match porting lib --- .github/workflows/build.yml | 88 +++++++++++++++++++------------------ 1 file changed, 46 insertions(+), 42 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1b8e899261..7a22756821 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,52 +1,56 @@ -name: build +name: Build on: - workflow_dispatch: - inputs: - publish: - description: Publish to Modrinth and CurseForge - required: true - default: "false" - patch: - description: Patch number, 0 for first (ex. Create 1.19.2 v0.5.0.g Patch N) - required: true - pull_request: push: + pull_request: + workflow_dispatch: + inputs: + publish: + description: Publish to Modrinth and CurseForge + required: true + default: "false" + patch: + description: Patch number, 0 for first (ex. Create 1.19.2 v0.5.0.g Patch N) + required: true jobs: - build: - runs-on: ubuntu-latest - env: - PUBLISH_SUFFIX: snapshots - MAVEN_USER: ${{ secrets.MAVEN_USER }} - MAVEN_PASS: ${{ secrets.MAVEN_PASS }} - MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }} - CURSEFORGE_TOKEN: ${{ secrets.CURSEFORGE_TOKEN }} - PATCH_NUMBER: ${{ github.event.inputs.patch }} - PUBLISHING: ${{ github.event.inputs.publish }} - steps: + build: + runs-on: ubuntu-latest + env: + PUBLISH_SUFFIX: snapshots + MAVEN_USER: ${{ secrets.MAVEN_USER }} + MAVEN_PASS: ${{ secrets.MAVEN_PASS }} + MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }} + CURSEFORGE_TOKEN: ${{ secrets.CURSEFORGE_TOKEN }} + PATCH_NUMBER: ${{ github.event.inputs.patch }} + PUBLISHING: ${{ github.event.inputs.publish }} + steps: + - name: Setup Java + run: echo "JAVA_HOME=$JAVA_HOME_17_X64" >> "$GITHUB_ENV" - - name: checkout repository - uses: actions/checkout@v4 + - name: Loom Cache + uses: actions/cache@v4 + with: + path: "**/.gradle/loom-cache" + key: "${{ runner.os }}-gradle-${{ hashFiles('**/libs.versions.*', '**/*.gradle*', '**/gradle-wrapper.properties') }}" + restore-keys: "${{ runner.os }}-gradle-" - - name: make gradle wrapper executable - run: chmod +x ./gradlew + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v3 + with: + gradle-home-cache-cleanup: true - - name: setup Java - uses: actions/setup-java@v4 - with: - distribution: temurin - java-version: 17 - cache: gradle + - name: Validate Gradle Wrapper Integrity + uses: gradle/wrapper-validation-action@v2 - - name: build - run: ./gradlew buildOrPublish + - name: Build + run: ./gradlew buildOrPublish - - name: capture build artifacts - uses: actions/upload-artifact@v4 - with: - name: Artifacts - path: build/libs/ + - name: Capture build artifacts + uses: actions/upload-artifact@v4 + with: + name: Artifacts + path: build/libs/ - - name: publish to Modrinth and CurseForge - if: ${{ github.event.inputs.publish }} - run: ./gradlew publishMod + - name: Publish to Modrinth and CurseForge + if: ${{ github.event.inputs.publish }} + run: ./gradlew publishMod From 620479710f0cf1bae245b05de01d6b9d4e4f9180 Mon Sep 17 00:00:00 2001 From: IThundxr Date: Fri, 21 Jun 2024 18:49:49 -0400 Subject: [PATCH 2/5] fix workflow --- .github/workflows/build.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7a22756821..90d3f3af99 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -24,6 +24,9 @@ jobs: PATCH_NUMBER: ${{ github.event.inputs.patch }} PUBLISHING: ${{ github.event.inputs.publish }} steps: + - name: Checkout Repository + uses: actions/checkout@v4 + - name: Setup Java run: echo "JAVA_HOME=$JAVA_HOME_17_X64" >> "$GITHUB_ENV" From 4324156545737030afa6537e9adaba73e64c7ad9 Mon Sep 17 00:00:00 2001 From: IThundxr Date: Thu, 27 Jun 2024 13:19:28 -0400 Subject: [PATCH 3/5] no more separate module for stub mod --- build.gradle | 43 +++++++++++++++++-- settings.gradle | 2 - stubMod/build.gradle | 16 ------- .../{src/main/resources => }/fabric.mod.json | 0 4 files changed, 40 insertions(+), 21 deletions(-) delete mode 100644 stubMod/build.gradle rename stubMod/{src/main/resources => }/fabric.mod.json (100%) diff --git a/build.gradle b/build.gradle index e9abedc275..faa8fdef91 100644 --- a/build.gradle +++ b/build.gradle @@ -1,3 +1,6 @@ +import java.util.jar.JarEntry +import java.util.jar.JarOutputStream + //file:noinspection GrMethodMayBeStatic plugins { id "fabric-loom" version "1.5.+" @@ -62,9 +65,6 @@ def dependencies(DependencyHandler deps) { exclude(group: "io.github.fabricators_of_create") // avoid duplicate Porting Lib } - // Stub mod to allow addons to depend on a constant version between sub-patches - deps.include(project(":stubMod")) - deps.modApi(deps.include("me.alphamode:ForgeTags:$forge_tags_version")) deps.modApi(deps.include("com.electronwill.night-config:core:$night_config_version")) deps.modApi(deps.include("com.electronwill.night-config:toml:$night_config_version")) @@ -231,6 +231,43 @@ jar { } } +tasks.register("createStubJar") { + outputs.upToDateWhen { false } + + ByteArrayOutputStream byteStream = new ByteArrayOutputStream() + JarOutputStream jarStream = new JarOutputStream(byteStream) + + try { + File fabricModJson = file("$projectDir/stubMod/fabric.mod.json") + if (fabricModJson.exists()) { + String content = fabricModJson.text.replace('${version}', mod_version) + jarStream.putNextEntry(new JarEntry("fabric.mod.json")) + jarStream.write(content.bytes) + jarStream.closeEntry() + } else { + throw new FileNotFoundException("Warning: fabric.mod.json not found at ${fabricModJson.path}") + } + } finally { + jarStream.close() + } + + File baseDir = file("$projectDir/build/stub") + baseDir.mkdirs() + File outputFile = file("$baseDir/create-stub-${mod_version}.jar") + outputFile.withOutputStream { os -> + byteStream.writeTo(os) + } + + outputs.file(outputFile) + + println "Stub jar created at: ${outputFile.path}" +} + +tasks.remapJar.configure { + dependsOn tasks.createStubJar + tasks.remapJar.nestedJars.from(createStubJar.outputs) +} + // see gradle/publishing.gradle for publishing apply from: "gradle/publishing/publishing.gradle" apply from: "gradle/compat/compat.gradle" diff --git a/settings.gradle b/settings.gradle index 6e095df8f9..049598aa09 100644 --- a/settings.gradle +++ b/settings.gradle @@ -5,5 +5,3 @@ pluginManagement { gradlePluginPortal() } } - -include "stubMod" diff --git a/stubMod/build.gradle b/stubMod/build.gradle deleted file mode 100644 index ede41dc866..0000000000 --- a/stubMod/build.gradle +++ /dev/null @@ -1,16 +0,0 @@ -plugins { - id("java") -} - -group = maven_group -archivesBaseName = "create-fabric-stub" - -version = mod_version - -processResources { - filesMatching("fabric.mod.json") { - expand "version": mod_version - } - - duplicatesStrategy = DuplicatesStrategy.WARN -} diff --git a/stubMod/src/main/resources/fabric.mod.json b/stubMod/fabric.mod.json similarity index 100% rename from stubMod/src/main/resources/fabric.mod.json rename to stubMod/fabric.mod.json From 0043eb03c27dadd6e9d145575d4059407fe6d551 Mon Sep 17 00:00:00 2001 From: sno_and_petals <62764868+snoandpetals@users.noreply.github.com> Date: Sun, 16 Jun 2024 08:33:55 -0400 Subject: [PATCH 4/5] Re-add events and methods for the Extendo Grip's durability usage --- .../extendoGrip/ExtendoGripItem.java | 30 ++++++++----------- .../foundation/events/CommonEvents.java | 2 ++ 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/src/main/java/com/simibubi/create/content/equipment/extendoGrip/ExtendoGripItem.java b/src/main/java/com/simibubi/create/content/equipment/extendoGrip/ExtendoGripItem.java index c38e561bf9..0592640a5a 100644 --- a/src/main/java/com/simibubi/create/content/equipment/extendoGrip/ExtendoGripItem.java +++ b/src/main/java/com/simibubi/create/content/equipment/extendoGrip/ExtendoGripItem.java @@ -19,6 +19,7 @@ import net.fabricmc.api.Environment; import net.minecraft.client.Minecraft; import net.minecraft.client.player.LocalPlayer; +import net.minecraft.core.BlockPos; import net.minecraft.nbt.CompoundTag; import net.minecraft.world.InteractionHand; import net.minecraft.world.damagesource.DamageSource; @@ -31,6 +32,10 @@ import net.minecraft.world.entity.projectile.ProjectileUtil; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.context.BlockPlaceContext; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.EntityHitResult; @@ -158,23 +163,6 @@ public static void dontMissEntitiesWhenYouHaveHighReachDistance(/*ClickInputEven } } -// @SubscribeEvent(priority = EventPriority.LOWEST) -// public static void consumeDurabilityOnBlockBreak(BreakEvent event) { -// findAndDamageExtendoGrip(event.getPlayer()); -// } -// -// @SubscribeEvent(priority = EventPriority.LOWEST) -// public static void consumeDurabilityOnPlace(EntityPlaceEvent event) { -// Entity entity = event.getEntity(); -// if (entity instanceof Player) -// findAndDamageExtendoGrip((Player) entity); -// } - -// @SubscribeEvent(priority = EventPriority.LOWEST) -// public static void consumeDurabilityOnPlace(PlayerInteractEvent event) { -// findAndDamageExtendoGrip(event.getPlayer()); -// } - private static void findAndDamageExtendoGrip(Player player) { if (player == null) return; @@ -289,6 +277,14 @@ public static boolean isHoldingExtendoGrip(Player player) { return holdingGrip; } + public static void consumeDurabilityOnBreak(Level level, Player player, BlockPos blockPos, BlockState blockState, BlockEntity blockEntity) { + findAndDamageExtendoGrip(player); + } + + public static void consumeDurabilityOnPlace(BlockPlaceContext blockPlaceContext, BlockPos blockPos, BlockState blockState) { + findAndDamageExtendoGrip(blockPlaceContext.getPlayer()); + } + // @Override // @Environment(EnvType.CLIENT) // public void initializeClient(Consumer consumer) { diff --git a/src/main/java/com/simibubi/create/foundation/events/CommonEvents.java b/src/main/java/com/simibubi/create/foundation/events/CommonEvents.java index 32b41418db..8df58ef3ce 100644 --- a/src/main/java/com/simibubi/create/foundation/events/CommonEvents.java +++ b/src/main/java/com/simibubi/create/foundation/events/CommonEvents.java @@ -310,5 +310,7 @@ public static void register() { MinecartEvents.WRITE.register(AbstractMinecartExtensions::minecartWrite); MinecartEvents.REMOVE.register(AbstractMinecartExtensions::minecartRemove); PlayerBlockBreakEvents.BEFORE.register(SymmetryHandler::onBlockDestroyed); + PlayerBlockBreakEvents.AFTER.register(ExtendoGripItem::consumeDurabilityOnBreak); + BlockEvents.POST_PROCESS_PLACE.register(ExtendoGripItem::consumeDurabilityOnPlace); } } From 8e0b03f7370780bb1b937ede1c485919599815f8 Mon Sep 17 00:00:00 2001 From: IThundxr Date: Tue, 9 Jul 2024 12:26:00 -0400 Subject: [PATCH 5/5] fix: cleanup PR --- .../equipment/extendoGrip/ExtendoGripItem.java | 16 ++++++++-------- .../create/foundation/events/CommonEvents.java | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/simibubi/create/content/equipment/extendoGrip/ExtendoGripItem.java b/src/main/java/com/simibubi/create/content/equipment/extendoGrip/ExtendoGripItem.java index 0592640a5a..8fc714b926 100644 --- a/src/main/java/com/simibubi/create/content/equipment/extendoGrip/ExtendoGripItem.java +++ b/src/main/java/com/simibubi/create/content/equipment/extendoGrip/ExtendoGripItem.java @@ -163,6 +163,14 @@ public static void dontMissEntitiesWhenYouHaveHighReachDistance(/*ClickInputEven } } + public static void consumeDurabilityOnBlockBreak(Level level, Player player, BlockPos blockPos, BlockState blockState, BlockEntity blockEntity) { + findAndDamageExtendoGrip(player); + } + + public static void consumeDurabilityOnPlace(BlockPlaceContext blockPlaceContext, BlockPos blockPos, BlockState blockState) { + findAndDamageExtendoGrip(blockPlaceContext.getPlayer()); + } + private static void findAndDamageExtendoGrip(Player player) { if (player == null) return; @@ -277,14 +285,6 @@ public static boolean isHoldingExtendoGrip(Player player) { return holdingGrip; } - public static void consumeDurabilityOnBreak(Level level, Player player, BlockPos blockPos, BlockState blockState, BlockEntity blockEntity) { - findAndDamageExtendoGrip(player); - } - - public static void consumeDurabilityOnPlace(BlockPlaceContext blockPlaceContext, BlockPos blockPos, BlockState blockState) { - findAndDamageExtendoGrip(blockPlaceContext.getPlayer()); - } - // @Override // @Environment(EnvType.CLIENT) // public void initializeClient(Consumer consumer) { diff --git a/src/main/java/com/simibubi/create/foundation/events/CommonEvents.java b/src/main/java/com/simibubi/create/foundation/events/CommonEvents.java index 8df58ef3ce..4bcec752b4 100644 --- a/src/main/java/com/simibubi/create/foundation/events/CommonEvents.java +++ b/src/main/java/com/simibubi/create/foundation/events/CommonEvents.java @@ -310,7 +310,7 @@ public static void register() { MinecartEvents.WRITE.register(AbstractMinecartExtensions::minecartWrite); MinecartEvents.REMOVE.register(AbstractMinecartExtensions::minecartRemove); PlayerBlockBreakEvents.BEFORE.register(SymmetryHandler::onBlockDestroyed); - PlayerBlockBreakEvents.AFTER.register(ExtendoGripItem::consumeDurabilityOnBreak); + PlayerBlockBreakEvents.AFTER.register(ExtendoGripItem::consumeDurabilityOnBlockBreak); BlockEvents.POST_PROCESS_PLACE.register(ExtendoGripItem::consumeDurabilityOnPlace); } }