From a3ae2a3f671370dc15826ceb68a9c0ef6e8e7652 Mon Sep 17 00:00:00 2001 From: AndyNoob <69229995+AndyNoob@users.noreply.github.com> Date: Fri, 8 Nov 2024 22:31:29 -0800 Subject: [PATCH] Fix item breaking function "breaking" items immediately in Forge with Connector (#53) * Change ItemStackMixin#preventBreak to target ItemStack#shrink * [fix] update github build action * [chore] add changelog entry & `beta.12` --------- Co-authored-by: Bibi Reden --- .github/workflows/audit-pr-build.yml | 6 +++--- CHANGELOG.md | 13 +++---------- gradle.properties | 2 +- .../bibireden/playerex/mixin/ItemStackMixin.java | 3 +-- 4 files changed, 8 insertions(+), 16 deletions(-) diff --git a/.github/workflows/audit-pr-build.yml b/.github/workflows/audit-pr-build.yml index 35c8a840..32e6eeb9 100644 --- a/.github/workflows/audit-pr-build.yml +++ b/.github/workflows/audit-pr-build.yml @@ -12,11 +12,11 @@ jobs: runs-on: ${{ matrix.os }} steps: - name: checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: validate gradle wrapper uses: gradle/wrapper-validation-action@v1 - name: setup jdk ${{ matrix.java }} - uses: actions/setup-java@v1 + uses: actions/setup-java@v3 with: java-version: ${{ matrix.java }} - name: make gradle wrapper executable @@ -26,7 +26,7 @@ jobs: run: ./gradlew build - name: capture build artifacts if: ${{ runner.os == 'Linux' && matrix.java == '17' }} # Only upload artifacts built from latest java on one OS - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 with: name: Artifacts path: build/libs/ diff --git a/CHANGELOG.md b/CHANGELOG.md index b3638c51..00590ceb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,3 @@ -**Ensure you back up your playerex config before updating to this version and using it!** - -## Additions 💖 -- Added a `LifecycleConfig` enum on the playerex config: `ON_TICK` | `ON_EVERY_SECOND`. - - This has been applied to Health Regeneration, and you can adjust it in the config. Default is `ON_EVERY_SECOND`. - -## Changes 🌽 -- Rearranged the config in its entirety. -- Everything is nested and opened by default. -- Everything labeled in `AdvancedSettings` has been adjusted to reflect better in their respective components internally. \ No newline at end of file +## Fixes 🌽 +- Resolved a mixin target for Forge users (on Sinytra) that caused items to break immediately. + - Thank you **`AndyNoob` https://github.com/AndyNoob** for this contribution. \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 0e65b829..3194e9f4 100644 --- a/gradle.properties +++ b/gradle.properties @@ -17,7 +17,7 @@ parchment_version=1.20.1:2023.09.03 quilt_mappings_version=23 # Mod Properties -mod_version=4.0.0+1.20.1-beta.11 +mod_version=4.0.0+1.20.1-beta.12 maven_group=com.bibireden.playerex archives_base_name=playerex-directors-cut diff --git a/src/main/java/com/bibireden/playerex/mixin/ItemStackMixin.java b/src/main/java/com/bibireden/playerex/mixin/ItemStackMixin.java index 84d9a257..b0258fec 100644 --- a/src/main/java/com/bibireden/playerex/mixin/ItemStackMixin.java +++ b/src/main/java/com/bibireden/playerex/mixin/ItemStackMixin.java @@ -80,10 +80,9 @@ public void preventDamage(int amount, RandomSource random, ServerPlayer user, Ca } } - @Inject(method = "hurtAndBreak(ILnet/minecraft/world/entity/LivingEntity;Ljava/util/function/Consumer;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/item/ItemStack;getItem()Lnet/minecraft/world/item/Item;"), cancellable = true) + @Inject(method = "hurtAndBreak(ILnet/minecraft/world/entity/LivingEntity;Ljava/util/function/Consumer;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/item/ItemStack;shrink(I)V"), cancellable = true) public void preventBreak(int amount, T entity, Consumer onBroken, CallbackInfo ci) { if (!PlayerEX.CONFIG.getFeatureSettings().getItemBreakingEnabled()) return; - ItemStack stack = (ItemStack)(Object)this; if (stack.getItem().builtInRegistryHolder().is(PlayerEXTags.UNBREAKABLE_ITEMS)) { if (!PlayerEXUtil.isBroken(stack)) {