Commit Graph

241 Commits

Author SHA1 Message Date
Dylan K. Taylor
ee9f5e0044 Location: make __construct() parameters mandatory
I did consider allowing yaw/pitch to remain optional, but considering the implicit immutability of Location, it really doesn't make any sense to create a Location with default yaw/pitch - just create a Position in that case instead.
2021-10-29 15:40:58 +01:00
Dylan K. Taylor
04aedc6494 Updated BedrockProtocol 2021-10-23 23:54:49 +01:00
Dylan K. Taylor
c77829f4ad Migrate packet creation to use ::create() methods in all but one case
MovePlayerPacket doesn't yet have a ::create() due to a complication with fields that aren't always present.
2021-10-23 01:46:01 +01:00
Dylan K. Taylor
c773e43eda Updated BedrockProtocol to pmmp/BedrockProtocol@97fa88e9ef 2021-10-23 01:16:45 +01:00
Dylan K. Taylor
c70b80c273 ItemEntity: implement partial itemstack pickups in the dumbest way possible
Given the various limitations and flexibilities posed by EntityItemPickupEvent, I settled on this as the simplest way to deal with the problem.

- EntityItemPickupEvent may have its destination inventory changed, so we can't cache the result of getAddableItemQuantity() to use after the event.
- The item itself may have changed, so even if we thought we could add some items before the change, we might not be able to afterwards.

Considering the above facts, it's better to just give the whole itemstack to EntityItemPickupEvent, and let plugins use getAddableItemQuantity() on their own to decide if their chosen inventory can accommodate the item or not.
If it can't, then we'll just drop it on the ground.
This also fixes a potential issue where plugins changing the item to a custom one might end up with their items and the actual items both just vanishing if the target inventory was full.
closes #4499
2021-10-17 22:37:49 +01:00
Dylan K. Taylor
aa53dc6709 Entity: fixed network properties not updating when fireTicks changes
another bug that LBSG knew about, but didn't report. :/
2021-10-09 23:57:37 +01:00
Dylan K. Taylor
0ad663ff50 Merge remote-tracking branch 'origin/stable' 2021-10-05 01:17:59 +01:00
Dylan T
4111d92b98 Stop hardcoding chunk dimensions everywhere (#4443) 2021-09-10 16:13:25 +01:00
marshall
b9b1ba9526 Include eye height in Living->lookAt() calculation (#4440) 2021-09-08 21:54:32 +01:00
Dylan K. Taylor
931c3ed77d Entity: fixed current movement not being accounted for in fall height
this caused incorrect damage when falling from heights, as well as a bug in #4434.
2021-09-06 12:53:52 +01:00
Dylan K. Taylor
956780c6a6 Entity: add getters and setters for fallDistance 2021-09-05 23:59:04 +01:00
Dylan K. Taylor
ded778f422 Implemented bed bouncing 2021-09-05 20:11:49 +01:00
Dylan K. Taylor
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
Dylan K. Taylor
6b7e671794 Living: use Vector3->down() instead of subtract(). 2021-09-05 14:12:04 +01:00
Dylan K. Taylor
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
Dylan K. Taylor
d329bfb25d Entity: rename movX/movY/movZ to wantedX/wantedY/wantedZ
this makes the code much easier to understand.
2021-09-05 14:06:53 +01:00
Dylan K. Taylor
73cc841d0b Entity: rename checkBlockCollisions() to checkBlockIntersections() 2021-09-05 14:00:27 +01:00
Dylan K. Taylor
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
Dylan K. Taylor
6ecad153ea Entity: remove fallDistance parameter from fall() 2021-09-05 13:34:43 +01:00
Dylan K. Taylor
7e82cafdeb Entity: remove a bunch of commented code that no one cares about 2021-09-05 13:27:48 +01:00
Dylan K. Taylor
7d5b9295cb PoisonEffect should accept Translatable|string, like its parent
this doesn't really break anything, but someone will likely whine about consistency if it's not fixed now.
2021-09-03 21:33:55 +01:00
Dylan K. Taylor
0404298c74 Effect: get rid of runtimeIDs 2021-09-03 21:25:06 +01:00
Dylan K. Taylor
665f2473e1 Effect: stop using hardcoded translation keys for names 2021-09-03 20:39:02 +01:00
Dylan K. Taylor
8e58beef7f Effect: use promoted properties 2021-09-03 20:32:13 +01:00
Rush2929
c2558573e2 Fix offhand pickup (#4412) 2021-08-29 12:45:23 +01:00
marshall
6e68e99ec0 Added PlayerEntityInteractEvent (#4374) 2021-08-24 11:56:10 +01:00
SalmonDE
7fd712c1ff Refactor Block & Tile: getPos() to getPosition() (#4395)
this also changes the name of the class property 'pos' to 'position' as well as Block->getPosOffset() to Block->getPositionOffset()
2021-08-23 14:01:32 +01:00
Dylan K. Taylor
270ee5c085 Simplify registry method generation 2021-08-22 23:02:36 +01:00
Rush2929
1ce9474fce Picked up items can now be added to offhand slots. (#4360) 2021-08-22 20:36:12 +01:00
Rush2929
eb9188c309 Replace InventoryPickup*Event with EntityItemPickupEvent (#4384)
The rationale here is that inventories don't actually pick items up - their holders do.
It's especially misleading to say that an inventory is picking up an item in creative mode when the picked-up item can't actually be added to the target inventory in the first place.

This change allows a range of new functionality, such as:
- Allowing survival players to pick items up even when their inventories are full, similarly to creative players
- Changing the destination inventory of collected items (e.g. items could be redirected to the offhand or ender chest inventory, while still allowing other plugins to understand what's happening)

As an added bonus, this obsoletes one more use case for Inventory->getHolder(), bringing us one step closer to removing the cyclic reference nightmare from inventories.

The choice of naming (EntityItemPickup, instead of EntityPickupItem) is to be consistent with other events, where the word order is SubjectObjectActionEvent.
2021-08-20 22:59:35 +01:00
Dylan K. Taylor
83805a3406 Entity: use match in checkObstruction() 2021-08-17 20:44:49 +01:00
Dylan T
1afda04620 PrimedTNT: fixed fuse not getting updated client-side, closes #4333 2021-07-25 12:27:25 +01:00
Dylan K. Taylor
77138c5c06 Living: changed bad parameter name 2021-07-22 15:46:08 +01:00
Dylan K. Taylor
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
Dylan K. Taylor
91d54ff0ad Removed unnecessary and/or obsolete GC hacks
the intent of these hacks was to break cyclic references to avoid having objects lingering in memory. However, all of the stuff that's being removed in this commit no longer has any effect anyway, due to the fact that these things don't circularly reference each other anymore. Notably, Tile inventories now keep Position instead of a Tile ref.
2021-06-30 19:16:25 +01:00
Dylan K. Taylor
2312511be6 Living: remove unnecessary double CompoundTag::getTag() call 2021-06-29 23:54:52 +01:00
Dylan K. Taylor
444d902990 Fix CS 2021-06-21 20:45:31 +01:00
Dylan K. Taylor
5d6146a01f Register missing potion types 2021-06-19 21:53:08 +01:00
Dylan K. Taylor
5387456e44 Move potion types to enum 2021-06-19 21:39:23 +01:00
Dylan K. Taylor
c07f3f5e12 fix CS 2021-06-19 19:48:30 +01:00
Dylan K. Taylor
6fea09ded4 SplashPotion: Require potionId in constructor 2021-06-19 19:47:44 +01:00
Dylan K. Taylor
fc70b625b3 ExperienceOrb: Require providing XP value in constructor 2021-06-19 19:42:13 +01:00
Dylan K. Taylor
11b483f2dc Inline EntityDataHelper::createBaseNBT()
this is only used for saving entity data now, and its presence here is allowing plugin devs to keep abusing it.
2021-06-19 18:45:21 +01:00
Dylan K. Taylor
cc00b3e19b Merge remote-tracking branch 'origin/stable' 2021-06-13 15:27:29 +01:00
Jason
532d57eec7 Arrow: Save and load critical state (#4241)
Fixes #3596
2021-06-09 14:00:36 +01:00
Dylan K. Taylor
10391be615 Remove useless class 2021-05-17 20:06:28 +01:00
Dylan K. Taylor
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
Dylan K. Taylor
b2e806e2fa World: Harden chunk loading against bad data in entity/tile NBT 2021-05-12 12:26:41 +01:00
Dylan K. Taylor
094c949e86 Entity: fixed extremely stupid bug with player respawning after ragequit 2021-05-11 19:08:56 +01:00
Dylan K. Taylor
742f86e022 Rename DestroyBlockParticle -> BlockBreakParticle
closes #3461

literally every other particle/sound has the subject first, followed by the (optional) verb, and finally Particle (or Sound).
In addition, we refer to breaking blocks as 'break' everywhere except here, where we refer to it as 'destroy'.
2021-05-06 18:33:18 +01:00