Explosion Resistance API#7828
Conversation
|
No idea why the tests are failing, the code works fine with runDev, may need some help figuring out the issue. |
the CI shows errors with test for testBlastResistance. |
I know that much, but the values it is returning is correct, so the tests should be passing, but they don't. I have never worked with tests before, so I don't really know how to resolve it. |
|
See the DummyServer class |
|
I think part of the reality is that those methods kinda shouldn't be on the Server itself, idk where they'd really be best suited though |
I agree, however putting them directly in the Material class is not really an option, and it didn't make sense to add a new singleton just for managing explosion resistance. |
|
The test probably is not even needed anymore as all we are doing is comparing if the function is returning the very same variable we are comparing against. |
|
Also what should be done about the switch statement I commented out, should I leave it commented out, or just remove it? |
|
Rebased for 1.19 |
|
Fixed the issue with the test, was caused by DummyServer not having an implementation for |
|
Rebased |
electronicboy
left a comment
There was a problem hiding this comment.
Generally looks fine, I'm somewhat iffy on methods being added to Bukkit for this, but, as said, there is no real general place for this stuff outside of Unsafe...
|
Rebased |
|
Rebased for 1.19.1 |
|
Rebased |
|
Thank you for your contribution, however, generally api like this is tricky as this is mutating data that really isn't expected to be mutated at all. Being able to modify a part of a block like this without notifying the client is a bit iffy. And in general, being able to change properties like this is something that we want to better support in the future. For now, it's better that these hard coded values stay immutable for the time being. If you want something like this it's most likely better to do this in your own fork. |
Adds API functions to
Bukkit,Server, andMaterialto allow changing the explosion resistance of blocks without using NMS or Reflection which is the current method used to acomplish this.As
Materialdoes not have a CraftBukkit implementation the functions to alter the resistance is part ofServer, these functions are aliased inBukkitandMaterialfor easy access.The existing
getBlastResistancefunction has been deprecated as the name "explosion resistance" is used by Mojang Mappings. The function also previously used a switch statement to define the explosion resistance which has been commented out in favor of using the actually values.A
defaultExplosionResistancehas been added to BlockBehaviour which stores the initial value, allowing a plugin to reset the explosion resistance to the value specified by vanilla minecraft.