Commit Graph

341 Commits

Author SHA1 Message Date
Dylan K. Taylor
289ede669d BlockTranslator: use less ambiguous function names 2023-05-05 14:47:23 +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
096daef0d0 World: added setDisplayName()
this is an obvious use case, and I'm not really sure why it wasn't supported sooner.
2023-05-01 16:29:07 +01:00
Dylan K. Taylor
0dca85af44 Merge branch 'minor-next' into major-next 2023-04-26 23:28:27 +01:00
Dylan K. Taylor
9bfcd39f2a World: improve type info for getTickingChunks() 2023-04-26 17:06:52 +01:00
Dylan K. Taylor
8102616ff4 Added ticking chunk count to /status
closes #5716
2023-04-26 17:05:31 +01:00
Dylan K. Taylor
6c0ad9589b Block: rename isSameType() to hasSameTypeId()
this should remove any ambiguity about its behaviour.
2023-04-21 20:25:21 +01:00
Dylan K. Taylor
1026811741 Merge branch 'minor-next' into major-next 2023-04-14 21:00:08 +01:00
Dylan K. Taylor
e48a4aaa55 World: fixed chunk ticking not being disabled by setting chunk ticking radius to 0
I can't believe I missed this ...
2023-04-14 16:02:28 +01:00
Dylan K. Taylor
ed88d68fd7 Remove stuff deprecated in 4.19.0 2023-04-11 23:20:58 +01:00
Dylan K. Taylor
9bddcc72f7 Merge branch 'minor-next' into major-next 2023-04-11 22:51:50 +01:00
Dylan T
946c2fbacc Ticking chunks rewrite (#5689)
This API is much more flexible than the old, allowing any arbitrary set of chunks to be ticked.

These changes also improve the performance of random chunk ticking by almost entirely eliminating the cost of chunk selection. Ticking chunks are now reevaluated when a player moves, instead of every tick.

The system also does not attempt to check the same chunks twice, leading to further improvements.

Overall, the overhead of random chunk selection is reduced anywhere from 80-96%. In practice, this can offer a 5-10% performance gain for servers with sparsely distributed players.
2023-04-11 20:01:19 +01:00
Dylan K. Taylor
abd4ef01eb Merge branch 'minor-next' into major-next 2023-03-15 23:02:41 +00:00
Dylan K. Taylor
337a254768 Use NetworkBroadcastUtils for broadcasting packets
this eradicates all but 4 usages of Server in Entity, which is extremely cool.
2023-03-15 22:28:51 +00:00
Dylan K. Taylor
737a63b0a3 Merge branch 'next-minor' into next-major 2023-02-21 18:33:03 +00:00
Dylan K. Taylor
efdd7a186d World: fixed population timer sometimes not being stopped 2023-02-21 18:31:33 +00:00
Dylan K. Taylor
0a3ecfdae9 Clean up terminology around block state IDs and their handling 2023-01-25 19:01:15 +00:00
Dylan K. Taylor
cbaff1caec BlockPlaceEvent: use BlockTransaction, closes #1760
BlockPlaceEvent no longer extends BlockEvent, since it's now a multi-block event
getBlockReplaced() is removed
getTransaction() is added

to be honest, BlockPlaceEvent should be something like PlayerBlockPlaceEvent...
2023-01-24 15:49:42 +00:00
Dylan K. Taylor
7abfc46567 First look at 3D biome support 2023-01-17 21:41:30 +00:00
Dylan K. Taylor
5c2ed210fc Merge branch 'next-minor' into next-major 2023-01-14 20:53:41 +00:00
Dylan K. Taylor
7d59bafd83 World: added requestSafeSpawn() (async)
this simplifies usages of safe spawns, since the caller doesn't need to know which chunks will be needed for the spawn to be selected.

We'll need this in the future, because safe spawns may also get diverted horizontally as well as vertically, which might require loading adjacent chunks as well as the chunk the position is actually in.
2023-01-14 17:42:17 +00:00
Dylan K. Taylor
ecd8f151f1 Merge branch 'next-minor' into next-major 2023-01-12 22:08:25 +00:00
Dylan K. Taylor
91ac47ecba Merge branch 'stable' into next-minor 2023-01-12 21:47:37 +00:00
Dylan K. Taylor
a79be994de World: fixed block placement when clicking on replaceable blocks
in vanilla, it appears to behave as if the player always clicked on the up face if a block was replaced.

In PM, we were still using the original face, which caused bugs when, for example, placing a button next to a wall by clicking on the side of tallgrass. The button would replace the tallgrass, but stick to the wall, instead of placing itself on the ground like vanilla expects.

This may appear unusual to anyone who also happens to implement canBePlacedAt(), since the facing behaviour will be different. However, this behaviour appears to match vanilla, and even slabs (which I feared might break because of this change) work perfectly.

In the future, it may be desirable to pass some other value here, such as null, to indicate that the clicked block is being replaced. However, that's a BC break and therefore outside of the scope of a stable bug fix.
2023-01-12 21:11:48 +00:00
Dylan K. Taylor
c2918709a3 Merge branch 'next-minor' into next-major 2023-01-06 01:59:04 +00:00
Dylan K. Taylor
ece49f011c Merge branch 'stable' into next-minor 2023-01-06 01:50:17 +00:00
IvanCraft623
e647e8c933 World: Use existing function to notify nearby blocks of an update (#5494) 2023-01-05 16:55:35 +00:00
IvanCraft623
433f5451d7 Improve World::notifyNeighbourBlockUpdate() doc (#5491) 2023-01-04 20:11:55 +00:00
Dylan K. Taylor
f8cc015c51 Merge branch 'next-minor' into next-major 2022-12-23 16:58:59 +00:00
Dylan K. Taylor
17125ce0e3 Merge branch 'stable' into next-minor 2022-12-23 16:56:54 +00:00
Dylan K. Taylor
ee7d4728d8 World: added cache for isChunkTickable()
this considerably reduces the amount of work done by the function, since it's usually checking the same chunks over and over again.
2022-12-19 21:20:21 +00:00
Dylan K. Taylor
923dcec4e7 Revert "World: do not refresh ticked chunks list every tick"
This reverts commit aebcfc516f.

this has edge cases in the handling of adjacent chunk locks which I
didn't consider at the time. Once accounting for those edge cases, it
became significantly more complex to the point that I realized this
needed more planning.
2022-12-19 20:57:51 +00:00
Dylan K. Taylor
1e5597f0d5 World: account for null chunk edge case in tickChunk()
the target chunk may no longer be loaded if it was unloaded during a previous chunk's tick (e.g. during BlockGrowEvent).
Since the parent function iterates over a pre-selected array of chunks, the chunk will still be present in the list even if it's no longer loaded by the time it's reached.
2022-12-19 20:20:52 +00:00
Dylan K. Taylor
aebcfc516f World: do not refresh ticked chunks list every tick
this is just wasting CPU time, since the effects aren't noticeable on such a small timescale anyway.
This reduces the CPU impact of chunk selection by 95%. However, this is the lesser part of chunk ticking, and the lion's share of the performance impact still comes from actually ticking the chunks.
2022-12-19 20:17:29 +00:00
Dylan K. Taylor
4d79aced07 Merge branch 'next-minor' into next-major 2022-12-15 19:50:27 +00:00
Dylan K. Taylor
95d0a3bf41 Merge branch 'stable' into next-minor 2022-12-15 19:38:22 +00:00
Armen Deroian
4357c110c8 Add the event: WorldParticleEvent (#5428) 2022-12-06 14:19:14 +00:00
Dylan K. Taylor
99996b62d6 Align PhpDoc @param tags according to PHP-CS-Fixer 2022-12-06 13:21:20 +00:00
Armen Deroian
fed2a6d917 Add the event: WorldSoundEvent (#5322) 2022-12-06 13:06:40 +00:00
Dylan K. Taylor
613ce251c5 Merge branch 'next-minor' into next-major 2022-11-13 14:32:54 +00:00
Dylan K. Taylor
2fcff13578 World: added getter and setter for simulation radius 2022-11-12 23:32:12 +00:00
Dylan K. Taylor
b4b8ef1c6b World: Improve performance of ticked chunk selection when lots of loaders use the same chunk
since we use the same simulation distance for every loader, multiple loaders on the same chunk will produce the same set of ticked chunks.
2022-11-12 22:21:30 +00:00
Dylan K. Taylor
a205d64732 Merge branch 'next-minor' into next-major 2022-11-12 17:02:56 +00:00
Dylan K. Taylor
83ddcce987 World: Considerably simplify ticked chunk selection
WARNING: This WILL have a performance impact on larger servers, but that's the price to pay for having crops actually grow.

The old overengineered method for doing this was causing glacially slow crop growth, vanilla parity issues and really just didn't make much sense. This method is probably incorrect too, but it will at least produce visible results.
2022-11-12 16:57:35 +00:00
Dylan K. Taylor
2d0602d19f World: fixed spawning in the void when the spawn terrain is higher than y=70 on default worlds
fixes #5390
2022-11-07 14:24:17 +00:00
Dylan K. Taylor
1a5cc8212c World: fixed spawning in the void when the spawn terrain is higher than y=70 on default worlds
fixes #5390
2022-11-07 14:23:29 +00:00
Dylan K. Taylor
01bad344a0 Merge branch 'next-minor' into next-major 2022-11-04 20:47:26 +00:00
Dylan K. Taylor
2fdc46c165 PHPStan 1.9 features 2022-11-04 20:23:34 +00:00