Commit Graph

91 Commits

Author SHA1 Message Date
db8bf672f0 fix item frames 2022-06-25 16:10:06 +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
6964012464 fix a bunch of bugs 2022-06-23 19:34:08 +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
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
f2dc9187f0 Use covariant types for InventoryHolder and Container implementors 2022-06-05 18:49:48 +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
937bb4c6ce Merge branch 'stable' into next-minor 2022-04-28 21:00:23 +01:00
72cff0ee11 Modernize property declarations in pocketmine\block namespace 2022-04-25 13:00:29 +01:00
9f5d4180c9 Spawnable: remove dead code, deprecate isDirty() and setDirty() 2022-04-25 12:46:01 +01:00
5a98b08ee8 Fixed several crashes on bad data due to inadequate TAG_List type checks 2022-04-19 16:48:18 +01:00
d47a7f48bd BrewingStand: avoid duplicate method call (#4874) 2022-03-02 17:32:56 +00:00
e0da99a973 feat: Implement Brewing (#4413)
The following API constants have been added:
- tile\BrewingStand::BREW_TIME_TICKS
The following public API methods have been added:
- utils\BrewingStandSlot->getSlotNumber() : int
- CraftingManager->getPotionTypeRecipes() : array<string, array<string, PotionTypeRecipe>>
- CraftingManager->getPotionContainerChangeRecipes() : array<int, array<string, PotionContainerChangeRecipe>>
- CraftingManager->registerPotionTypeRecipe(PotionTypeRecipe $recipe) : void
- CraftingManager->registerPotionContainerChangeRecipe(PotionContainerChangeRecipe $recipe) : void
The following classes have been added:
- BrewingRecipe
- PotionTypeRecipe
- PotionContainerChangeRecipe
- BrewItemEvent
- BrewingFuelUseEvent
- PotionFinishBrewingSound
2022-01-22 16:54:58 +00:00
79d1feff9c Replace disallowed operators in src/block/ 2022-01-20 16:57:09 +00:00
1366c49f1f Implemented Lectern (#4708)
Co-authored-by: Covered123 <58715544+JavierLeon9966@users.noreply.github.com>
Co-authored-by: Dylan K. Taylor <dktapps@pmmp.io>
2022-01-15 21:21:29 +00:00
e04dfe96af Merge branch 'stable' into next-minor 2022-01-01 17:55:17 +00:00
3c6146b5e0 ContainerTrait: avoid absurdly inefficient use of setItem()
this substantially improves the performance of loading containers such as chests.
2022-01-01 15:05:32 +00:00
ed4978c31b Added VanillaItems::AIR()
we don't usually add VanillaItems entries for blocks since they already exist in VanillaBlocks, but air has a special use case specifically as an itemstack, so we make an exception for this case.
2021-12-07 00:41:07 +00:00
5c7125f190 Improved error handling for loading broken entity / tile data 2021-11-23 17:41:26 +00:00
c773e43eda Updated BedrockProtocol to pmmp/BedrockProtocol@97fa88e9ef 2021-10-23 01:16:45 +01:00
84170ad3e1 Furnace: fixed deactivation after being reloaded from disk (regression from PM3)
closes #4430
2021-09-12 15:49:33 +01:00
4111d92b98 Stop hardcoding chunk dimensions everywhere (#4443) 2021-09-10 16:13:25 +01:00
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
27e0ecf7ee Implemented Blast Furnace and Smoker (#4362) 2021-08-12 23:27:05 +01:00
5874ce582a Implemented bells 2021-07-19 17:00:56 +01:00
fc090e238d Add Shulker Boxes (#3678)
this implementation is working, although incomplete:

- The shulker close sound should not be played until the end of the shulker closing animation, which takes approximately 1 second.
- An open shulker box has a different collision box than a closed one - it should be +0.5 in whichever direction the shulker is facing. (During the animation, the bounding box also dynamically changes size - you can see this in vanilla by shooting an arrow into the top of an open shulkerbox facing UP, and then closing it - the arrow will fall and collide with the lid multiple times.

However, resolving both of these issues requires significant internal changes which are beyond the scope of this PR.
2021-07-10 19:48:38 +01:00
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
0910054c41 NetworkSession: Fixed InventoryManager nullability disaster
fixes #4277
fixes #4275
fixes #3139
2021-06-26 17:44:42 +01:00
6fb364b16f Store ender chest viewer count on the tile, instead of relying on the inventory's viewer count (#4238)
Fixes #4021
2021-06-13 14:37:09 +01:00
b2e806e2fa World: Harden chunk loading against bad data in entity/tile NBT 2021-05-12 12:26:41 +01:00
7b2c6c5ceb Avoid more $this refs on long-life closures 2021-05-06 14:27:56 +01:00
4ca5558ec1 Merge remote-tracking branch 'origin/stable' 2021-05-05 11:14:01 +01:00
b33bf1f433 Unfuck banners ... 2021-04-28 18:44:21 +01:00
d5e5a81cff Don't explode when data contains invalid dye colour IDs 2021-04-28 13:39:03 +01:00
a44203a3d4 Separate BannerPatternLayer from BannerPatternType 2021-04-28 12:47:42 +01:00
d5e1b4bd39 Furnace: Separate light/extinguish code into onStartSmelting() and onStopSmelting() hooks
this is a preparation for other kinds of furnaces which might not be plain old Furnaces.
2021-04-17 01:36:16 +01:00
a9f8afa077 Banner: remove Deque usages
originally I introduced this to make it easier to implement the various APIs addPattern removePattern etc, but those were later removed in favour of simple getPatterns() and setPatterns(), allowing plugin developers to use ext-ds APIs to manipulate patterns.
However, ds poses a number of headaches because of mutability combined with by-ref semantics, which make it a pain to use these on the APIs because we can't guarantee that they won't be modified.
As much as arrays suck, they have two significant advantages over ext-ds: 1) they have copy-on-write semantics, and 2) they support PHP 8.0 without any extra work from me.
2021-01-15 00:17:56 +00:00
9228f006d4 Merge remote-tracking branch 'origin/stable'
# Conflicts:
#	composer.json
#	composer.lock
#	resources/vanilla
#	src/CrashDump.php
#	src/PocketMine.php
#	src/pocketmine/Server.php
#	src/pocketmine/item/Bucket.php
#	src/pocketmine/item/Item.php
#	src/pocketmine/level/format/Chunk.php
#	src/pocketmine/level/format/io/leveldb/LevelDB.php
#	src/pocketmine/level/format/io/region/McRegion.php
#	src/pocketmine/network/mcpe/protocol/BatchPacket.php
#	src/pocketmine/tile/Furnace.php
#	src/pocketmine/utils/UUID.php
#	src/utils/ServerKiller.php
2020-12-20 20:54:13 +00:00
6a1f551aab [ci skip] update TileFactory TODOs (#3912) 2020-11-17 11:04:26 +00:00
b2765f32e9 Implemented Barrels, closes #3672 2020-11-16 17:26:07 +00:00
8e0cba56b8 Merge remote-tracking branch 'origin/stable'
# Conflicts:
#	resources/vanilla
#	src/pocketmine/entity/Entity.php
#	src/pocketmine/tile/Tile.php
#	tests/phpstan/configs/check-explicit-mixed-baseline.neon
#	tests/phpstan/configs/l7-baseline.neon
2020-11-12 22:10:47 +00:00
df7bafe2bc TileFactory: fixed missing Beacon tile registration
I had this locally but forgot to commit it ...
2020-10-07 15:16:27 +01:00
e39d2c4621 Beacon: fixed crash in PC worlds 2020-10-06 13:40:49 +01:00
7f9c4355f0 Revert back to floor/wall banner variants
this code largely duplicates the same code in FloorSign/WallSign and needs to be de-duplicated.
2020-10-04 19:05:43 +01:00
d3a3a41d2b Revert back to separated floor/wall sign
the conditionally useless properties are problematic.
2020-10-04 17:52:23 +01:00
5807a385cc Added stub classes for Beacon
this doesn't do anything yet, it's intended solely to prevent further loss of data.
2020-10-02 00:59:53 +01:00