Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Call axe disable timer in other situations #150

Open
swapmasterx opened this issue Aug 15, 2023 · 18 comments
Open

Call axe disable timer in other situations #150

swapmasterx opened this issue Aug 15, 2023 · 18 comments
Labels
bug Something isn't working

Comments

@swapmasterx
Copy link

How would I call the activation of the disable timer in cases outside just an axe. For example, calling it when the shield reaches a certain durability threshold.

@CringeStar
Copy link
Collaborator

the code to disable the shield is player.getItemCooldownManager().set((Item) shield, shield.getCoolDownTicks()); where player is the PlayerEntity and shield is the ActiveItem if it is a shield. I would assume you jusr run that when the durability is low.

@swapmasterx
Copy link
Author

swapmasterx commented Aug 16, 2023

Yep. I just got to modify the inventory tick method I'm using to check for it

@swapmasterx
Copy link
Author

swapmasterx commented Aug 16, 2023

Last thing, the two shield methods after item don't know where to go and I'm not finding the right symbol pathing for it

@CringeStar
Copy link
Collaborator

Yeah, that should be the shield item that you have trying to disable, not some class. Make sure to name variable that.

@swapmasterx
Copy link
Author

What should I initialize the class variable with? It auto fills to null but I don't think that would be right

@CringeStar
Copy link
Collaborator

It could either be Item, ActiveItem, ShieldItem, FabricShieldItem, or FabricBannerShieldItem, depending on the context. If you are trying to get the shield that the player has equipped, set it to equal player.getActiveItem().

@swapmasterx
Copy link
Author

swapmasterx commented Aug 16, 2023

So it works but it doesn't force the shield off being active. I can keep holding rightclick to keep the shield up even if it gets put on cooldown. Letting go the cooldown blocks it from being used as intended but it doesn't seem calling it this way forces you to stop using it

@CringeStar
Copy link
Collaborator

Try adding this line before it:
ShieldDisabledCallback.EVENT.invoker().disable(player, player.getActiveHand(), activeItemStack);

@swapmasterx
Copy link
Author

There's a brief fov change now when the cooldown is triggered but I can still keep the shield up. I'll post the block of code that calls it on a follow up post to see if one of the parts is messing with intended function.

@swapmasterx
Copy link
Author

@OverRide
public void inventoryTick(ItemStack stack, World world, Entity entity, int slot, boolean selected) {
if (entity instanceof PlayerEntity player && Math.max(0, stack.getMaxDamage() - stack.getDamage())
<= 5 && !player.getItemCooldownManager().isCoolingDown(this)) {
FabricShieldItem shield = this;
ShieldDisabledCallback.EVENT.invoker().disable(player, player.getActiveHand(), stack);
player.getItemCooldownManager().set((Item) shield, shield.getCoolDownTicks());
}

@swapmasterx
Copy link
Author

Is there anything else I can do here?

@CringeStar
Copy link
Collaborator

That code looks right to me, so I don't know what else to change. I will have tk test it myself when I have the time.

@swapmasterx
Copy link
Author

Alrighty. It at least does get called but doesn't properly cancel the input is my guess given the brief fov shift.

@swapmasterx
Copy link
Author

swapmasterx commented Aug 21, 2023

Still not having success over here fixing the bug on my end

@CringeStar
Copy link
Collaborator

hey im coming back to this issue as I'm trying to update the lib, can you explain the issue/bug again, our previous comments don't ring any bells.

@CringeStar CringeStar modified the milestone: 1.7.1 Sep 25, 2023
@CringeStar
Copy link
Collaborator

@swapmasterx do you still need help with this?

@swapmasterx
Copy link
Author

Sorry, been taking a large break from modding. Essentially the bug is that even when the cooldown is called via another means if you hold right click you can keep the shield up even when the item is visible on cooldown. Letting go of rightclick while on cooldown and you can't raise the shield again until the cooldown expires as expected.

@CringeStar CringeStar added this to the 1.7.3 milestone Jan 30, 2024
@CringeStar
Copy link
Collaborator

So calling the disable event starts the cool down but does not disable active shields? I'll have to look into how this event is structured.

@CringeStar CringeStar modified the milestones: 1.8, Backport 1.8 Jan 20, 2025
@CringeStar CringeStar added the bug Something isn't working label Jan 20, 2025
@CringeStar CringeStar added this to the Minor Important Tweaks milestone Jan 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants