use of dev.hypnotic.event.events.EventVisualCooldown in project Hypnotic-Client by Hypnotic-Development.
the class HeldItemRendererMixin method updateHeldItems1.
@Inject(method = "updateHeldItems", at = @At("HEAD"), cancellable = true)
public void updateHeldItems1(CallbackInfo ci) {
EventVisualCooldown event = new EventVisualCooldown();
event.call();
if (ModuleManager.INSTANCE.getModule(OldBlock.class).isEnabled())
event.setCancelled(true);
if (event.isCancelled()) {
ci.cancel();
this.prevEquipProgressMainHand = this.equipProgressMainHand;
this.prevEquipProgressOffHand = this.equipProgressOffHand;
ClientPlayerEntity clientPlayerEntity = this.client.player;
ItemStack itemStack = clientPlayerEntity.getMainHandStack();
ItemStack itemStack2 = clientPlayerEntity.getOffHandStack();
if (ItemStack.areEqual(this.mainHand, itemStack)) {
this.mainHand = itemStack;
}
if (ItemStack.areEqual(this.offHand, itemStack2)) {
this.offHand = itemStack2;
}
if (clientPlayerEntity.isRiding()) {
this.equipProgressMainHand = MathHelper.clamp(this.equipProgressMainHand - 0.4F, 0.0F, 1.0F);
this.equipProgressOffHand = MathHelper.clamp(this.equipProgressOffHand - 0.4F, 0.0F, 1.0F);
} else {
// \/ This part here is what changed, it used to calculate with attack progress
this.equipProgressMainHand += MathHelper.clamp((this.mainHand == itemStack ? 1 : 0.0F) - this.equipProgressMainHand, -0.4F, 0.4F);
this.equipProgressOffHand += MathHelper.clamp((float) (this.offHand == itemStack2 ? 1 : 0) - this.equipProgressOffHand, -0.4F, 0.4F);
}
if (this.equipProgressMainHand < 0.1F) {
this.mainHand = itemStack;
}
if (this.equipProgressOffHand < 0.1F) {
this.offHand = itemStack2;
}
}
}
Aggregations