Commit Graph

65 Commits

Author SHA1 Message Date
bf44edd179 Constify a bunch of NBT keys, pass 1 2022-12-18 22:12:15 +00:00
1d4b6dc66e Only reduce durability when armor reduced damage. (#5444)
https://minecraft.fandom.com/wiki/Durability#Armor_durability
2022-12-05 21:10:36 +00:00
d476a4c1aa Implement a Living::getDisplayName() (#5384) 2022-11-27 19:48:55 +00:00
6ae7cb288e Merge remote-tracking branch 'origin/stable' into next-minor 2022-10-11 21:59:40 +01:00
cd4bb91676 Living: alter eye height so the player doesn't drown on the surface of water when swimming
fixes #4989
2022-09-29 00:15:07 +01:00
bda0ca23b4 Living: deprecated hasLineOfSight() 2022-09-28 17:34:51 +01:00
5e5661de75 Play burp sound when consuming a FoodSource (#5158) 2022-09-27 17:21:55 +01:00
38d6284671 Use PHP-CS-Fixer to enforce file header presence 2022-06-04 17:34:49 +01:00
39b8daeeec Living: fixed a usage of hardcoded numeric ID 2022-05-25 22:23:14 +01:00
fc53f3721a Avoid direct mutations of Entity->location 2022-01-20 21:49:14 +00:00
8f525ab399 Replace disallowed operators in src/entity/ 2022-01-20 19:14:28 +00:00
d41f933e7b Implement swimming/gliding including AABB recalculation (#4446)
- The following events have been added:
  - PlayerToggleGlideEvent
  - PlayerToggleSwimEvent
- The following API methods have been added:
  - Entity->getSize()
  - Living->isSwimming()
  - Living->setSwimming()
  - Living->isGliding()
  - Living->setSwimming()
  - Player->toggleSwim()
  - Player->toggleGlide()
2021-12-19 17:10:41 +00:00
b9b1ba9526 Include eye height in Living->lookAt() calculation (#4440) 2021-09-08 21:54:32 +01:00
ded778f422 Implemented bed bouncing 2021-09-05 20:11:49 +01:00
d4d00a9b80 Living: added calculateFallDamage()
to clean up the way that fall damage is handled for flying players; also, onHitGround() isn't only doing fall damage things these days.
2021-09-05 14:36:58 +01:00
6b7e671794 Living: use Vector3->down() instead of subtract(). 2021-09-05 14:12:04 +01:00
17dfd2cc52 Living: Trigger fall sounds on the nearest collidable block below
we can't have landed on it unless it actually has a collision box - otherwise, we only landed _in_ it.
This assumes, of course, that no blocks have bounding boxes >= 2 blocks tall, which currently none do.
2021-09-05 14:10:54 +01:00
8be1f34736 Entity: Rename fall() to onHitGround(), and make it protected
this had no business being exposed to public API in the first place.
2021-09-05 13:36:40 +01:00
6ecad153ea Entity: remove fallDistance parameter from fall() 2021-09-05 13:34:43 +01:00
77138c5c06 Living: changed bad parameter name 2021-07-22 15:46:08 +01:00
e803ca0e06 Living: Limit vertical knockback to 0.4 by default
this will break non-standard use cases with large forces, but they only have to stick a 'null' at the end of the parameter list.
Since this function should be primarily used for vanilla knockback, it makes more sense to keep the default as vanilla, but allow people to change it if they want to.

closes #4106 (this is close to #4106 anyway, but small enough that it was easier to recreate it than pull and modify it)
closes #2707
2021-07-22 14:27:20 +01:00
2312511be6 Living: remove unnecessary double CompoundTag::getTag() call 2021-06-29 23:54:52 +01:00
5a14c1cb89 Entity: don't rebuild metadata every tick unless an associated property changed
this should improve performance back to PM3 levels.
2021-05-17 20:05:52 +01:00
e53b57732b Entity: replace separate height/width/eyeHeight fields with an EntitySizeInfo structure
this will make it easier to implement stuff like sleeping (properly), swimming and gliding without needing to duplicate all the fields.
2021-01-08 00:11:01 +00:00
d76883a5f8 Merge branch 'stable' 2020-12-29 18:00:09 +00:00
bcc3e87730 Timings: rename core timers to remove 'timer' from the names
this makes them shorter and more consistent.
2020-12-23 17:52:25 +00:00
341d8747b7 Living: wipe out effect add/remove hooks onDispose() 2020-12-01 18:27:10 +00:00
8be0c0da0d Implemented a silent property on entities and Entity->broadcastSound()
fixes #3516
2020-10-31 16:07:18 +00:00
3f254bd49c Separated effects' MCPE ID registration from VanillaEffects 2020-10-24 18:52:20 +01:00
a01c086481 Introduced VanillaEnchantments registry 2020-10-23 20:48:19 +01:00
7b02cc3efd Implemented #3836: Replace setCancelled() in events with cancel() and uncancel()
The motivation for this is to prevent passing a dynamic argument to cancellation, which in almost all cases is a bug in user code. This same mistake also appears in a few places in the PM core (as seen in this commit), but in those cases the mistakes were mostly harmless since they were taking place before the event was actually called.
closes #3836
2020-09-26 14:31:56 +01:00
db7fb25196 Avoid more Vector3 mutations using withComponents() 2020-09-25 18:40:13 +01:00
279abb871d Remove all usages of CompoundTag->hasTag()
in pretty much every case, these usages really wanted to read the tag's contents anyway, which can be combined with a getTag() and instanceof call for more concise and static analysis friendly code.
In the few cases where the tag contents wasn't needed, it still wanted to check the type, which, again, can be done in a more static analysis friendly way by just using getTag() and instanceof.
2020-07-10 21:01:43 +01:00
d585081c22 Separate consumable item interfaces from general consumable interfaces (#3595)
I wonder if there's a way to generalise item consuming beyond just eating/drinking. Stuff like lava bucket in a furnace needs the same kind of "leftover" logic.
2020-06-28 17:53:03 +01:00
1f0ea0c2c7 Living: stop mutating Vector3 2020-06-27 21:51:42 +01:00
7e331c590d Use static-analysis-friendly method for getting effects from EffectManager
fixes 5 phpstan level 8 errors
2020-06-27 13:09:05 +01:00
9e6f1c9a5a Living: check if damager is null before trying to use it 2020-06-27 13:09:05 +01:00
b58c425189 Merge branch 'next-minor'
# Conflicts:
#	changelogs/3.12.md
#	resources/vanilla
#	src/VersionInfo.php
2020-06-03 13:11:30 +01:00
2bf73c7a4a Merge commit '8c5a81cf5'
# Conflicts:
#	resources/vanilla
2020-06-03 12:50:09 +01:00
c72937a4af Merge commit '5dadf1237'
# Conflicts:
#	resources/vanilla
2020-06-03 12:46:06 +01:00
6257f717b1 Entity: make networkProperties private
this reduces the temptation to use it in high-level code, as well as making syncNetworkData() more useful (now it can export to many data collections, which means we can start to think about having a property cache per network session, which is more flexible)
2020-05-21 20:29:06 +01:00
1aa92bd6a8 Living: Do not rely on attribute map for moveSpeed attribute access 2020-05-21 20:13:24 +01:00
f77eea8c44 Living: set SPRINTING flag when it's needed, close #3521 2020-05-21 20:01:37 +01:00
ec8ee29291 moving sneak & sprint properties to Living 2020-05-21 19:55:58 +01:00
74e1f6320a Store attributes as local vars, reduce usage of AttributeMap
ideally we want attribute map to only be used for properties that need synchronization.
2020-05-21 19:18:00 +01:00
7aca41a530 Living: do not loop downwards searching for collision block, closes #3517 2020-05-20 20:33:25 +01:00
45ec4645d2 Merge commit '089180fef4534b383a31a9d560a76bfaf0d16c6b'
# Conflicts:
#	resources/vanilla
#	src/entity/Living.php
2020-05-19 21:14:54 +01:00
22425551ed separate default attribute creation from Attribute into AttributeMap 2020-05-18 18:12:04 +01:00
4437756987 Inventory: reduce API duplication by using a Set for viewers 2020-05-14 14:13:28 +01:00
8682ea35f7 Introduce some (not great) API for entity animations
while this API is a bit yucky, it's a step forward for protocol isolation and offers the possibility of controlling animations by adding events.
2020-05-01 13:57:26 +01:00