1146 Commits

Author SHA1 Message Date
Dylan K. Taylor
ae564e445d
Start migrating EnumTrait enums to PHP 8.1 native enums 2023-09-07 17:20:52 +01:00
Dylan K. Taylor
31d8cc1cb5
Generate and use constants for pocketmine.yml constant names
a couple of usages of properties that no longer exist couldn't be migrated.
in addition, this revealed a couple of dead properties in the default file.

this is not an ideal solution (I'd much rather model the configs using classes and map them) but in the absence of a good and reliable library to do that, this is the next best thing.
2023-08-25 13:23:38 +01:00
Dylan K. Taylor
f4d5605de1
Use hasHandlers() on more warm-hot events 2023-08-23 14:35:53 +01:00
Dylan T
e323c5dd76
Implement pressure plate activation logic and events (#5991)
closes #5936

This implements all of the basic activation logic for pressure plates.
It also introduces a PressurePlateUpdateEvent, which is called in pulses when entities are standing on top of the plate and when it deactivates. Deactivation can be detected by checking if the list of activating entities is empty.

---------

Co-authored-by: Javier León <58715544+JavierLeon9966@users.noreply.github.com>
2023-08-16 13:00:23 +01:00
Dylan K. Taylor
e48b5b2ec0
GeneratorManager: allow aliasing existing generators 2023-08-10 13:07:03 +01:00
Dylan K. Taylor
447f061566
Use Event::hasHandlers() for a few more hot events 2023-08-09 15:46:20 +01:00
Dylan K. Taylor
59c88fe7f7
Added WorldDifficultyChangeEvent 2023-08-09 12:22:03 +01:00
Dylan K. Taylor
9f14901820
Merge branch 'stable' into minor-next 2023-08-08 17:48:12 +01:00
Dylan K. Taylor
1cf508abdb
World: use Facing::OFFSET in getHighestAdjacentLight() 2023-08-03 16:51:09 +01:00
Dylan K. Taylor
6ac45526f9
Use new features in pocketmine/math 1.0.0 2023-08-03 16:46:16 +01:00
Dylan T
c91c8c2f9e
Improving performance of small moving entities (e.g. dropped items) (#5954)
* World: cache block AABBs directly in the world
this removes some indirection when fetching the AABBs, and also allows the AABB cache to live longer than the block cache.

In local testing this showed a 10-20% performance improvement, but it was difficult to properly measure.

* World: eliminate padding block checks in getCollisionBoxes()
this substantially improves the function's performance for small entities.

The padding of 1 block in each direction was previously necessary to account for blocks like fences, which might have an AABB larger than the cell containing them. However, by tracking this information in the collisionBoxCache directly, we can avoid the need to check this at the expense of slightly more complex code. This reduces the number of blocks checked for a moving item entity from 27-64 all the way down to 1-8, which is a major improvement.

Locally, this change allowed me to simulate 2100 item entities without lag, compared with 1500 on the previous commit.
2023-08-03 14:51:51 +01:00
jasonw_4331
1a2c10e844
World: Fixed getSafeSpawn() not accepting seed positions below y=1 (#5955)
this should have been changed during the introduction of y=-64 minimum world height, but it got missed.
2023-08-02 18:05:16 +01:00
Dylan K. Taylor
3afe3b7f44
Merge branch 'stable' into minor-next 2023-07-24 12:02:24 +01:00
Dylan K. Taylor
86810c5e1c
LevelDB: clearer error message 2023-07-19 16:31:10 +01:00
Dylan K. Taylor
b33a9690e9
LevelDB: simplify condition 2023-07-19 16:30:13 +01:00
Dylan K. Taylor
1b9c282194
LevelDB: tolerate incorrect number of biome palettes, as long as there are enough for each real subchunk
modern versions save 24 exactly, but previous versions saved more. We don't use the excess, so it's not a problem if they are missing, but this is nonetheless non-compliant with vanilla.
2023-07-19 16:29:14 +01:00
Dylan K. Taylor
82b75e0ccb
LevelDB: Remove happy debug message 2023-07-19 15:21:47 +01:00
Dylan K. Taylor
6c59912ed5
LevelDB: workaround 0 bpb palettes with a length prefix
this was caused by a plugin overriding the world provider.

related:
-  https://github.com/pmmp/PocketMine-MP/issues/5911
-  https://github.com/Refaltor77/CustomItemAPI/issues/68

fixes #5911
2023-07-19 15:19:33 +01:00
Dylan K. Taylor
537721fe7d
Replace Closure::fromCallable() usages with first-class callables
PHP 8.1 <3
2023-07-19 13:34:42 +01:00
Dylan K. Taylor
2e9a4f2be2
Merge branch 'trees' into minor-next 2023-07-18 12:39:41 +01:00
ipad54
83d11c7429
Implemented Big & Small dripleaf (#5835) 2023-07-17 16:30:52 +01:00
Dylan K. Taylor
b7210755a7
1.20.10 2023-07-12 13:39:39 +01:00
Dylan K. Taylor
3abd592b1f
Update to pmmp/BedrockBlockUpgradeSchema@3.0.0 2023-07-03 18:07:51 +01:00
Dylan K. Taylor
5d51ffdfe3
Merge branch 'minor-next' into trees 2023-07-01 12:25:44 +01:00
Dylan K. Taylor
8dedbb7471
World: clamp clickVector components from 0-1
this ensures that #5827 won't randomly start crashing if clients give bad values.
2023-06-21 16:59:14 +01:00
Dylan K. Taylor
eb9f804781
ÂBedrockWorldData: throw less confusing errors on missing version tags 2023-06-19 12:22:50 +01:00
Dylan K. Taylor
ab75838c89
First shot at implementing acacia trees
this is mostly working, but due to some issue with leaf decay, the edges of the larger canopy will decay within minutes.

I don't know why this is yet, but it's likely some incorrect implementation of Leaves causing the problem.

In addition, the secondary branch of acacia may generate next to the base block of the trunk, which I've never observed to happen in vanilla. This has a 2% chance of occurring, so I haven't been able to rule it out yet, but it probably shouldn't happen.
2023-06-10 18:35:42 +01:00
Dylan K. Taylor
9a67e3d660
PM5-specific changes for 1.20.0.23 beta 2023-06-07 21:08:41 +01:00
Dylan K. Taylor
8744032ab6
Fixed empty block handling after blockstate ID XOR change 2023-05-29 18:26:23 +01:00
Dylan K. Taylor
5a9cdef40c
Chunk: added DIRTY_FLAGS_ALL and DIRTY_FLAGS_NONE 2023-05-29 17:45:19 +01:00
Dylan K. Taylor
a49842278a
WorldProvider subsystem no longer depends on Chunk
Instead, it provides the data needed to construct the chunk, which doesn't require the provider to be aware of anywhere near as much logic.
2023-05-29 17:44:00 +01:00
Dylan K. Taylor
d57954dff0
PopulationTask: ensure that unmodified chunks don't get sent back to the main thread for no reason 2023-05-29 17:30:04 +01:00
Dylan K. Taylor
ce5e663a73
Assume chunks are dirty by default
having them be clean by default makes no sense. It only makes sense for them to be clean if they were loaded directly from disk without any alterations.

Default clean is a footgun.
2023-05-29 17:22:39 +01:00
Dylan K. Taylor
c10be0f346
WorldProvider: allow loadChunk() to return additional information about the loaded chunk data
this will be needed for dealing with #5733. I don't plan to fix that before 5.0, but we need to make the appropriate BC breaks now, before release.
2023-05-29 17:03:39 +01:00
Dylan K. Taylor
f5a1a0c9cb
ÂInsert PM data version into blockstates, chunks, entities, tiles and level.dat
this information will allow us to correct for any bugs introduced by past versions.

however, we still need to propagate this information to permit actually using it when loading data.
2023-05-29 16:32:24 +01:00
Dylan K. Taylor
b8ba2d03ba
Added new note instruments up to 1.19
1.20 adds extra ones for each type of mob head, but we're not supporting 1.20 yet.
2023-05-26 16:58:06 +01:00
Dylan K. Taylor
fddab29e87
Move mob head and note instrument save IDs into pocketmine\data\bedrock
to be consistent, these shouldn't be exposed in the API like this...
I'm not very happy with the whole 'type ID map' paradigm (particularly its lack of static analysis guarantees), but the most important thing right now is to get this stuff out of the API so that plugin devs don't try and abuse it. We're not going to change the whole system days before PM5 release.
2023-05-26 15:47:12 +01:00
Dylan K. Taylor
edafe9d21f
Entity: Rename and document isImmobile() and friends
while I could implement server-side ability to disable entity movement, I don't think that's particularly useful. However, the intended function of this (disabling client sided AI) is useful, so it makes more sense to rename it to match its functionality, rather than changing its functionality to match the name.

closes #3130
2023-05-26 14:01:21 +01:00
Dylan K. Taylor
ee9ce8a4f4
Merge branch 'minor-next' into major-next 2023-05-17 15:45:03 +01:00
ipad54
fa719f37d5
Implement Cave Vines & Glow Berries (#5424) 2023-05-08 19:24:23 +01:00
Dylan K. Taylor
d317347a9b
WorldTimings: remove TODO
I tried this, and it didn't really provide any information that the tree table didn't already show.
2023-05-08 16:35:30 +01:00
Dylan K. Taylor
077fac84bf
Added aggregate timers for all world timings
this allows timings list view to display totals for these sections. It does make the tree view a bit more annoying in some cases though.
2023-05-08 16:27:46 +01:00
Dylan K. Taylor
5c7f4570b4
Merge branch 'minor-next' into major-next 2023-05-06 17:20:37 +01:00
Dylan K. Taylor
289ede669d
BlockTranslator: use less ambiguous function names 2023-05-05 14:47:23 +01:00
Dylan K. Taylor
2c81446e5b
Move TreeType to generator package, added dedicated SaplingType enum
TreeType includes a bunch of stuff that don't have regular saplings associated with them, such as mangrove and azalea trees.
Mangrove has a dedicated propagule block with different behaviour than the others, and azalea trees are grown from azalea blocks, which are solid and have different behaviour to saplings.

We may also want to account for crimson and warped 'trees' in TreeType too, although I'm not sure if those belong there or not.
2023-05-04 16:54:10 +01:00
Dylan K. Taylor
32e6fdd95a
Rename RuntimeBlockMapping -> BlockTranslator 2023-05-03 22:18:27 +01:00
Dylan K. Taylor
01f340985a
Centralize all conversion-related stuff under TypeConverter
instead of having singletons for everything, which are a nightmare to manage for multi version
2023-05-03 16:33:17 +01:00
Dylan K. Taylor
6beb80b8fe
Fixed usages of BlockDataUpgrader which weren't accounting for thrown exceptions 2023-05-02 17:13:31 +01:00
Dylan K. Taylor
4d0cecbac2
RegionWorldProvider: use provider logger instead of global logger 2023-05-02 16:47:25 +01:00
Dylan K. Taylor
5fcf5e0c40
LevelDB: log more stuff, stop bailing on recoverable errors 2023-05-02 16:46:45 +01:00