PocketMine-MP
PocketMine-MP copied to clipboard
Anvil Damage Implementation
Introduction
When a player or an entity has an anvil drop on them no damage is applied to same entity.
Relevant issues
Changes
API changes
No API Changes.
Behavioural changes
- Anvils now create falling damage at a max of 40HP. The damage is linked to the tick rate so odd behavior is limited.
- EntityDamageEvent has been updated to contain "CAUSE_FALLING_ANVIL"
- PlayerDeathEvent translation factory now has anvil death message.
Nathan was squashed by an anvil
Backwards compatibility
Unlikely to have any issues.
Follow-up
- Falling Block types could benefit to having an event to handle collisions for plugins.
- Sound when anvil finishes falling.
- Anvil functionality.
- Anvil piston behavior.
Requires translations:
Name | Value in eng.ini |
---|---|
death.attack.anvil |
{%a} was squashed by an anvil |
Tests
Game Implementation so no PHPUnit test used. I tested it by dropping anvils at various heights on me and all mobs implemented.
PHP CS Fixer is not working on my PHP Storm so for now I will try to fix manually.
Why does code style fail? on the actual php file its one line, on the log it shows + then -.
Also I made it so the autotranslation key is generated for the anvil death event. But now I get a generated code consistency error.
Why does code style fail? on the actual php file its one line, on the log it shows + then -.
You've left trailing whitespace on the line. Blank lines shouldn't have any indentation.
Also I made it so the autotranslation key is generated for the anvil death event. But now I get a generated code consistency error.
You haven't added the string to the language file.
You need to submit a pull request to the master branch of this repo to add the string to eng.ini
: https://github.com/pmmp/Language
Once that's done, the resources/locale
submodule should be updated and the translation APIs regenerated.
I added the PR. This PR should be good to go after that translation is merged.
Ideally I wanted to implement the damage code into the anvil class but having a falling block makes is a little more tricky. I put the code in the FallingBlock->onGround() method.
After debugging workspace I FINALLY got my checkers to all work now.
Strange, my coding checker didn't detect /** var */ as a problem and ill fix, regardless this PR cannot be merged until language/pmmp gets pulled so I recommend this be marked as on hold or whatever equivalent
You can pull it yourself, if you want to.
cd resources/locale
git checkout master
git pull
cd ../..
git add resources/locale
and then commit as you would normally.
Alright what about something like this then, fallable now has a method that is called when a falling entity hits the ground.
Wearing a helmet reduces the damage by 1⁄4, but this costs durability on the helmet
Idk if there is a BlockSolidifyEvent of some sorts, it would be useful to invoke it with the falling block's block and the resulting block being the damaged block, so plugins can cancel the breaking.
Plus anvil destruction https://minecraft.fandom.com/wiki/Anvil#Becoming_damaged
Wearing a helmet reduces the damage by 1⁄4, but this costs durability on the helmet
Idk if there is a BlockSolidifyEvent of some sorts, it would be useful to invoke it with the falling block's block and the resulting block being the damaged block, so plugins can cancel the breaking.
Plus anvil destruction https://minecraft.fandom.com/wiki/Anvil#Becoming_damaged
While adding the helmet damage makes sense I feel like the rest of the listed implementations here are unrelated to the PR.
Note: Latest change exposes Living::damageItem()
Closing due to lack of activity.