Commit Graph

102 Commits

Author SHA1 Message Date
d6c48fd3a2 Implement new 1.21 paintings (#6393) 2024-07-12 13:24:43 +01:00
4c737b2ee3 Merge branch 'legacy/pm4' into stable 2023-07-31 11:29:58 +01:00
eb53b795d5 ItemEntity: fixed O(n^2) performance issue when many of the same unstackable item are in the same place
this produced a 40% performance improvement in a simulation with 800 item entities.

If the items were all different, then this would still be a problem. However, many of the same unstackable items occupying the same space is a problem for SkyBlock farms, so this should improve performance for SkyBlock quite a bit.
2023-07-31 11:29:12 +01:00
ed11fd5a83 CS again... 2023-05-06 17:51:00 +01:00
e0a6ec0c24 Start deglobalizing TypeConverter
there's a bunch of places we can't reach with this right now:

- particles
- sounds
- tile NBT
- entity metadata
- crafting data cache
- chunk encoding
- world block update encoding

this is a work in progress, but ultimately we want to get rid of these singletons entirely.
2023-05-06 17:47:09 +01:00
289ede669d BlockTranslator: use less ambiguous function names 2023-05-05 14:47:23 +01:00
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
6beb80b8fe Fixed usages of BlockDataUpgrader which weren't accounting for thrown exceptions 2023-05-02 17:13:31 +01:00
ed88d68fd7 Remove stuff deprecated in 4.19.0 2023-04-11 23:20:58 +01:00
a0dadc6e37 Merge branch 'minor-next' into major-next 2023-04-10 14:38:23 +01:00
d6c923b525 ExperienceOrb: add get/setDespawnDelay
closes #5645

the code for this is borrowed from ItemEntity. I didn't feel like a base class was appropriate, and we can't (yet) declare constants in traits.
2023-04-07 22:33:30 +01:00
bea878e9e9 Implement anvil fall damage (#5312) 2023-03-27 20:17:08 +01:00
7cdab75b05 Merge branch 'minor-next' into major-next 2023-03-20 22:12:54 +00:00
054c06fab9 Add specialized entityBaseTick timer for item entities
since item merging is a potential hotspot, we want to know if this code section is a performance problem.
Current timers only tell us whether overall ticking of a particular entity is slow, but that includes movement and therefore isn't particularly helpful.
2023-03-19 15:59:06 +00:00
abd4ef01eb Merge branch 'minor-next' into major-next 2023-03-15 23:02:41 +00:00
cc8660629b First look at shared EntityEventBroadcaster,
this improves performance in PvP servers and other areas where lots of players or entities exist in one space.

fixes #5622
2023-03-15 18:22:56 +00:00
50b8d39aba Merge branch 'next-minor' into next-major 2023-02-21 15:41:57 +00:00
b56b35b10d ItemEntity: fixed a bunch of suspicious logic in entityBaseTick()
closes #5580
2023-02-17 20:14:38 +00:00
0a3ecfdae9 Clean up terminology around block state IDs and their handling 2023-01-25 19:01:15 +00:00
6e2685cbbb Merge branch 'next-minor' into next-major 2022-12-18 22:25:32 +00:00
bf44edd179 Constify a bunch of NBT keys, pass 1 2022-12-18 22:12:15 +00:00
1785cbb6b5 Implement FallingBlock missing sounds (#5348) 2022-12-18 19:33:50 +00:00
3d75094874 Standardize explosion radius terminology
closes #5061
2022-12-15 22:43:36 +00:00
84f9136b95 Implement anvil damage on fall (#5345) 2022-12-15 19:12:18 +00:00
8f20b9da91 Rename ExplosionPrimeEvent to EntityPreExplodeEvent (#5434) 2022-11-26 19:55:16 +00:00
9f6c6b2b71 Merge branch 'next-minor' into next-major 2022-10-16 16:58:50 +01:00
7864294336 Merge branch 'stable' into next-minor 2022-10-16 16:53:14 +01:00
14d17a9546 Remove Erroneous documentation (#5346) 2022-10-16 15:21:35 +01:00
1c6a2b66f7 Merge remote-tracking branch 'origin/next-minor' into next-major 2022-09-29 22:38:26 +01:00
41970feb57 Entity: Fire EntitySpawnEvent/ItemSpawnEvent on the first entity tick, instead of in the constructor (#5314)
This allows plugins to modify the entity via setters in EntitySpawnEvent without their changes getting overwritten by setter calls directly after the 'new YourEntity' statement.

As well as benefiting plugins, this also clears a path for a BC-breaking change in PM5 (to have the programmer use addEntity() to spawn entities, instead of the constructor doing it, which will improve on a number of data handling aspects).

fixes #4973

This targets next-minor because it has some side effects on plugins that depended on the old behaviour, such as VanillaHopper, so it's not suitable for a patch release.
2022-09-29 22:30:12 +01:00
b39eaaf91f Merge branch 'next-minor' into next-major 2022-09-21 15:07:11 +01:00
23e98a30f5 ItemEntity: don't ignore parent's savable state 2022-09-20 14:50:35 +01:00
5bc7ca6569 ItemEntity: disable saving if the contained item is air or has a zero count 2022-09-20 14:45:10 +01:00
ba2baba7cc Added netherite blocks and items 2022-07-14 20:39:09 +01:00
0a23e91329 Rename BlockFactory::fromFullBlock() -> BlockFactory::fromStateId() 2022-07-05 13:46:19 +01:00
f24f2d9ca9 Hit block legacy metadata with the biggest nuke you've ever seen
This commit completely revamps the way that blocks are represented in memory at runtime.

Instead of being represented by legacy Mojang block IDs and metadata, which are dated, limited and unchangeable, we now use custom PM block IDs, which are generated from VanillaBlocks.
This means we have full control of how they are assigned, which opens the doors to finally addressing inconsistencies like glazed terracotta, stripped logs handling, etc.

To represent state, BlockDataReader and BlockDataWriter have been introduced, and are used by blocks with state information to pack said information into a binary form that can be stored on a chunk at runtime.
Conceptually it's pretty similar to legacy metadata, but the actual format shares no resemblance whatsoever to legacy metadata, and is fully controlled by PM.
This means that the 'state data' may change in serialization format at any time, so it should **NOT** be stored on disk or in a config.

In the future, this will be improved using more auto-generated code and attributes, instead of hand-baked decodeState() and encodeState(). For now, this opens the gateway to a significant expansion of features.
It's not ideal, but it's a big step forwards.
2022-06-24 23:19:37 +01:00
1533fcf8f6 Separate block legacy data upgrading from block deserialization
this commit provides a central place where all block data can go to be upgraded to the latest version (currently 1.19), irrespective of how old it is.

Previously I had issues during debugging, because it wasn't possible to just upgrade a block without deserializing it into a Block object, which isn't currently supported for many blocks.
This commit solves that problem by separating the upgrading from the deserialization.
2022-06-23 16:45:02 +01:00
680615eed8 Namespace rename 2022-06-08 15:54:45 +01:00
1ff69136a3 Merge branch 'next-major' into modern-world-support 2022-06-07 20:01:40 +01:00
aa9f8781ff Merge branch 'next-minor' into next-major 2022-06-07 19:56:26 +01:00
1584768c80 PaintingMotive: fixed botched painting fix from 0ea3861d43
I knew I should have used a singleton for this ...
2022-06-07 15:48:20 +01:00
5c85aa6e58 Eliminate remaining usages of legacy block ID+meta on disk
flower pots loaded from vanilla worlds should now correctly display the plant inside
2022-06-05 21:49:51 +01:00
083a35f970 Modernize property type declarations 2022-06-04 18:16:32 +01:00
38d6284671 Use PHP-CS-Fixer to enforce file header presence 2022-06-04 17:34:49 +01:00
7b8eeb42f6 Use typed properties in src/entity package
[bc break]
2022-06-01 21:19:02 +01:00
6ee551c5e1 Remove premature optimisation from World::getCollidingEntities()
this is already covered in more fine-grained detail by canCollideWith().

[bc break]
2022-06-01 21:00:54 +01:00
b7e2b3e94a Entity: Require declaration of gravity and drag via abstract methods
this guarantees that subclasses will actually declare them.

[bc break]
2022-06-01 20:51:18 +01:00
0ea3861d43 Fixed paintings not working in newly generated worlds
Paintings would not work unless at least one entity was loaded from disk
(or saved).
2022-05-20 11:13:14 +01:00
8f525ab399 Replace disallowed operators in src/entity/ 2022-01-20 19:14:28 +00:00
de82424fb2 XpManager: add APIs to prevent owning Human from attracting XP orbs (#4623)
Fixes #4589

The following API methods are added:

- `XpManager->canAttractXpOrbs()`
- `XpManager->setCanAttractXpOrbs()`

Possible future scope: flip this on its head to allow spectator players to attract XP orbs, in case someone wants that for some reason ???

Co-authored-by: Dylan K. Taylor <dktapps@pmmp.io>
2021-12-15 04:40:46 +00:00