Skip to content

Commit 839357e

Browse files
committed
Closes #71
1 parent 7099f3a commit 839357e

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

common/src/main/java/org/infernalstudios/shieldexp/mixin/LivingEntityMixin.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import net.minecraft.world.entity.EntityType;
55
import net.minecraft.world.entity.LivingEntity;
66
import net.minecraft.world.item.ItemStack;
7+
import net.minecraft.world.item.UseAnim;
78
import net.minecraft.world.level.Level;
89
import org.spongepowered.asm.mixin.Mixin;
910
import org.spongepowered.asm.mixin.Shadow;
@@ -25,8 +26,13 @@ public LivingEntityMixin(EntityType<?> type, Level world) {
2526
super(type, world);
2627
}
2728

29+
@Shadow
30+
public abstract boolean isUsingItem();
31+
2832
@Inject(method = "isBlocking", at = @At(value = "RETURN", ordinal = 1), cancellable = true)
2933
private void shieldexp$isBlocking(CallbackInfoReturnable<Boolean> ci) {
30-
ci.setReturnValue(this.useItem.getItem().getUseDuration(this.useItem, (LivingEntity) (Object) this) - this.useItemRemaining >= 0);
34+
if (this.isUsingItem() && this.useItem.getUseAnimation() == UseAnim.BLOCK) {
35+
ci.setReturnValue(this.useItem.getItem().getUseDuration(this.useItem, (LivingEntity) (Object) this) - this.useItemRemaining >= 0);
36+
}
3137
}
3238
}

0 commit comments

Comments
 (0)