Skip to content

Commit

Permalink
Item breaking mechanics (#29)
Browse files Browse the repository at this point in the history
* Basic implementation

* Merge duplicate ItemStackMixin

* Make armour not provide defense when broken

* Add 'Broken' tooltip to broken items

* Remove more attributes when broken

* Use item tag to detect what items should be 'unbreakable'

* Make items render blackened when broken

* [partial-feat] add `itemBreakingEnabled`

* [chore] adjust `itemBreakingEnabled` to `true` by default

* [feat] hopefully integrate `itemBreakingEnabled`

* [chore] set on workflow dispatch

* Bump version to beta.5 and update changelog

Closes #25 

---------

Co-authored-by: Bibi Reden <[email protected]>
  • Loading branch information
naomieow and bibi-reden authored Aug 30, 2024
1 parent 5bed9a6 commit 8469019
Show file tree
Hide file tree
Showing 14 changed files with 421 additions and 144 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
## Changes 🌽
- Reconciled connector based issue where old player data did not transfer over to a new player.
- Updated the modded datapack to apply some attributes properly to scale.
- Added "Item Breaking" mechanic
- Added config option for Item Breaking
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.4
mod_version=4.0.0+1.20.1-beta.5
maven_group=com.bibireden.playerex
archives_base_name=playerex-directors-cut

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.bibireden.playerex.mixin;

import com.bibireden.playerex.util.PlayerEXUtil;
import net.minecraft.client.renderer.entity.ItemRenderer;
import net.minecraft.world.item.ItemDisplayContext;
import net.minecraft.world.item.ItemStack;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.ModifyVariable;

@Mixin(ItemRenderer.class)
abstract class ItemRendererMixin {
@ModifyVariable(
method = "render",
at = @At(value = "HEAD"), index = 6, argsOnly = true
)
public int renderBlackWhenBroken(int value, ItemStack stack, ItemDisplayContext ctx) {
if (PlayerEXUtil.isBroken(stack) && ctx == ItemDisplayContext.GUI) {
return 15;
}
return value;
}
}
134 changes: 0 additions & 134 deletions src/client/java/com/bibireden/playerex/mixin/ItemStackMixin.java

This file was deleted.

7 changes: 3 additions & 4 deletions src/client/resources/playerex.client.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@
"compatibilityLevel": "JAVA_17",
"client": [
"EntityRendererMixin",
"LocalPlayerMixin"
"LocalPlayerMixin",
"ItemRendererMixin"
],
"injectors": {
"defaultRequire": 1
},
"mixins": [
"ItemStackMixin"
]
"mixins": []
}
Loading

0 comments on commit 8469019

Please sign in to comment.