Search in sources :

Example 1 with EventVisualCooldown

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;
        }
    }
}
Also used : OldBlock(dev.hypnotic.module.render.OldBlock) AbstractClientPlayerEntity(net.minecraft.client.network.AbstractClientPlayerEntity) ClientPlayerEntity(net.minecraft.client.network.ClientPlayerEntity) ItemStack(net.minecraft.item.ItemStack) EventVisualCooldown(dev.hypnotic.event.events.EventVisualCooldown) Inject(org.spongepowered.asm.mixin.injection.Inject)

Aggregations

EventVisualCooldown (dev.hypnotic.event.events.EventVisualCooldown)1 OldBlock (dev.hypnotic.module.render.OldBlock)1 AbstractClientPlayerEntity (net.minecraft.client.network.AbstractClientPlayerEntity)1 ClientPlayerEntity (net.minecraft.client.network.ClientPlayerEntity)1 ItemStack (net.minecraft.item.ItemStack)1 Inject (org.spongepowered.asm.mixin.injection.Inject)1