Skip to content

Commit

Permalink
Fix no wolf armor updates sent to players
Browse files Browse the repository at this point in the history
  • Loading branch information
2No2Name committed May 16, 2024
1 parent 0ea402c commit 9a89b2a
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import org.jetbrains.annotations.Nullable;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
Expand All @@ -22,11 +23,16 @@
@Mixin(LivingEntity.class)
public abstract class LivingEntityMixin extends Entity implements EquipmentEntity {

private static final Predicate<ItemStack> DYNAMIC_EQUIPMENT = item -> item.isOf(Items.CROSSBOW);
@Unique
private static final Predicate<ItemStack> DYNAMIC_EQUIPMENT = item -> item.isOf(Items.CROSSBOW) || item.isOf(Items.WOLF_ARMOR);

@Shadow
public abstract ItemStack getEquippedStack(EquipmentSlot slot);

@Shadow
public abstract boolean isHolding(Predicate<ItemStack> predicate);

@Unique
private boolean equipmentChanged = true;

public LivingEntityMixin(EntityType<?> type, World world) {
Expand Down Expand Up @@ -59,7 +65,7 @@ private void skipSentEquipmentComparison(CallbackInfoReturnable<@Nullable Map<Eq
private void resetEquipmentChanged(CallbackInfo ci) {
//Not implemented for player entities and modded entities, fallback to never skipping inventory comparison
//Work around dynamic items that are changed while holding them (only crossbow in 1.19.2)
if (this instanceof EquipmentTrackingEntity && !this.isHolding(DYNAMIC_EQUIPMENT)) {
if (this instanceof EquipmentTrackingEntity && !this.isHolding(DYNAMIC_EQUIPMENT) && !DYNAMIC_EQUIPMENT.test(this.getEquippedStack(EquipmentSlot.BODY))) {
this.equipmentChanged = false;
}
}
Expand Down

0 comments on commit 9a89b2a

Please sign in to comment.