-
Notifications
You must be signed in to change notification settings - Fork 70
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
Sword blocking animation #769
Comments
Also cool side note, they fixed this bug: https://bugs.mojang.com/browse/MC-152728 |
This comment was marked as spam.
This comment was marked as spam.
This is currently difficult to achieve, ProtocolLib still can't be loaded on 1.21.4 server. I made a plugin to implement this animation just now. (but it can't reduce damage) src: |
That only seems to deal with the animation, but we use the shield because it genuinely does block damage, we just configure by how much. How could we ever tell if the damage was meant to be blocked or not otherwise? |
By checking if the current use item has consumable of type block & has the custom data field of whatever to check if it is a OCM blocking tool/is a sword? |
There is many ways to check if you are blocking as the consumable thing makes the sword act as a BLOCKING item like shield, so you should be able to do like "isBlocking" or whatever spigot/paper method is and do the custom reduced damage or whatever |
That's assuming the client sends packets with the blocking bit set. Also does this mean we have to modify all sword to have the animation property? Because OCM does not modify any items and this is deliberate, because it leads to a nightmare of tracking what items were changed when, and what happens if you uninstall the plugin. It's the same reason we don't edit the attack damage labels on the items directly. |
I think it should be on the server to provide players with consumable swords, OCM should just handle the functionality of halving damage if blocking with a sword. AFAIK the server will still register them as "using" the sword, and can be detected by OCM. |
When I asked Copilot in Windows 11 how to halve the damage when right-clicking with a sword, he suggested the following code. |
So uhm, I know you mentioned not wanting to add components to items cause of uninstalling the plugin But as of 25w04a, they added a shield component which would allow you to put the blocking logic entirely in the component.
|
Also the cool thing about this new component is you can finally remove the stupid hardcoded 5 tick delay when blocking! |
Hello ! I'm really interested in the new In the other hand, the But I understand that using components to mimic the sword blocking behavior is problematic because you're actually modifying the item, the behavior would stay even if the plugin is disabled. It would be great to add it behind a flag or a setting in the config.yml file. I'm not a good java developer so I don't know how it would impact performance, but I would use the onInventoryClick, onInventoryClose, onItemDrop, onPlayerDeath and onPlayerQuit events to remove the component from the item whenever it leaves the player's inventory or when the player disconnects, the component would be added when the player connects or craft/get a sword; thus the component would live only in the player's inventory and be removed whenever it leaves the inventory. |
Instead of modifying the actual item stack on the server, could we explore using packet manipulation? The server could intercept the packet that sends item information to the client and add the consumable property with the 'block' animation and a consume_seconds value (like 3600 for 1.8 blocking duration). This would allow the client to play the blocking animation without the server having to constantly modify the item itself, potentially improving performance. This also simplifies server-side logic, as the server only needs to check if the item is a sword when sending item data, without needing to validate if the item already has the consumable property. The server would still need to handle the actual damage blocking logic. |
When 1.21.5 comes out, don't use the consumable component for blocking anymore. Also packet manipulation could work, but on right click, wouldn't the item update clientside to remove it or no? Also anti cheat support |
If you listen to all the instances where item information is sent to the client and modify the itemstacks accordingly the client has no way of knowing the item is "not real". (Have to skip players on creative mode as creative will override the itemstack with the modified one and make it persistent) Some time ago I implemented a very basic tool to translate custom item stacks based on the player client language as a proof of concept. https://github.com/jorgetoh/DynamicLang/blob/main/src/main/java/me/jorgetoh/dynamiclang/managers/ItemStackRenamer.java Obviously, you could argue why having all this overhead when you can just modify the itemstack one time. |
Now that 1.21.2 has come out and split the food component into two, food and consumable. The consumable component has a field named animation which allows you to specify the animation played when using said item, one of those animations being "block". Currently tho in 1.21.2/3, it only shows the blocking animation in third person but I reported the first person animation missing as a bug (https://bugs.mojang.com/browse/MC-275917) and it has been fixed and the first person animation has been introduced into 24w44a.
Yall should add a option/abandon using the shield as the way of blocking and instead give the swords the new consumable component with the animation of "block" and consume seconds of 3600 (same time as it was hardcoded in 1.8)
The text was updated successfully, but these errors were encountered: