Skip to content

Commit

Permalink
Fix item breaking function "breaking" items immediately in Forge with…
Browse files Browse the repository at this point in the history
… 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 <[email protected]>
  • Loading branch information
AndyNoob and bibi-reden authored Nov 9, 2024
1 parent a1a33fe commit a3ae2a3
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 16 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/audit-pr-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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/
13 changes: 3 additions & 10 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
## 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.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 <T extends LivingEntity> void preventBreak(int amount, T entity, Consumer<T> 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)) {
Expand Down

0 comments on commit a3ae2a3

Please sign in to comment.