mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-22 11:24:02 +00:00
Merge pull request #6658 from pmmp/minor-next-release
This commit is contained in:
commit
f416cb8902
71
changelogs/5.26.md
Normal file
71
changelogs/5.26.md
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
# 5.26.0
|
||||||
|
Released 22nd March 2025.
|
||||||
|
|
||||||
|
This is a minor feature release focused on performance improvements.
|
||||||
|
|
||||||
|
**Plugin compatibility:** Plugins for previous 5.x versions will run unchanged on this release, unless they use internal APIs, reflection, or packages like the `pocketmine\network\mcpe` or `pocketmine\data` namespace.
|
||||||
|
Do not update plugin minimum API versions unless you need new features added in this release.
|
||||||
|
|
||||||
|
**WARNING: If your plugin uses the `pocketmine\network\mcpe` namespace, you're not shielded by API change constraints.**
|
||||||
|
Consider using the `mcpe-protocol` directive in `plugin.yml` as a constraint if you're using packets directly.
|
||||||
|
|
||||||
|
## Performance
|
||||||
|
- Significantly improved performance of entity movement. Load testing with item entities showed a 3x increase in the number of entities supported without lag.
|
||||||
|
- Significantly improved performance of on-ground checks for player movement. This still needs further work, but optimisations implemented in this version should improve performance substantially.
|
||||||
|
- Updated `pocketmine/nbt` dependency with performance improvements to `TAG_Compound` and `TAG_List` comparison. This should improve performance of inventory-related actions.
|
||||||
|
- `InventoryTransaction` now avoids useless item clones when processing transactions, which should improve performance of inventory-related actions.
|
||||||
|
|
||||||
|
## Dependencies
|
||||||
|
- `pocketmine/bedrock-protocol` has been updated to `36.2.0`, which adds new functions to access some packet fields.
|
||||||
|
- `pocketmine/nbt` has been updated to `1.1.0`, which improves performance when comparing NBT object trees.
|
||||||
|
|
||||||
|
## Gameplay
|
||||||
|
- Block breaking animation speed now takes into account the following: jumping, being in water, haste, mining fatigue
|
||||||
|
|
||||||
|
## Tools
|
||||||
|
- `blockstate-upgrade-schema-utils.php` now has a new `dump-table` command, which turns a `.bin` palette table file into human-readable text for debugging.
|
||||||
|
|
||||||
|
## API
|
||||||
|
### `pocketmine\block`
|
||||||
|
- The following methods have been added:
|
||||||
|
- `public RuntimeBlockStateRegistry->hasStateId(int $stateId) : bool` - checks whether the given state ID is registered
|
||||||
|
|
||||||
|
### `pocketmine\crafting`
|
||||||
|
- The following methods have been deprecated:
|
||||||
|
- `CraftingManager::sort()` - this was implicitly internal anyway
|
||||||
|
|
||||||
|
### `pocketmine\utils`
|
||||||
|
- The following constants have been added:
|
||||||
|
- `TextFormat::MATERIAL_RESIN`
|
||||||
|
- The following static properties have been added:
|
||||||
|
- `Terminal::$COLOR_MATERIAL_RESIN`
|
||||||
|
|
||||||
|
### `pocketmine\data\bedrock\block`
|
||||||
|
- `BlockStateToObjectDeserializer` now permits overriding **deserializers** for Bedrock IDs. This may be useful to implement custom state handling, or to implement missing block variants (such as snow cauldron).
|
||||||
|
- This was originally prohibited since 5.0.0. However, there is no technical reason to disallow overriding **deserializers**.
|
||||||
|
- Overriding **serializers** is still **not permitted**. Reusing type IDs doesn't make any sense and would break internal design contracts.
|
||||||
|
- If you want to make a custom version of a vanilla block, create a custom type ID for it, exactly as you would for a regular custom block.
|
||||||
|
- The following methods have been added:
|
||||||
|
- `public BlockStateToObjectDeserializer->getDeserializerForId(string $id) : ?(\Closure(BlockStateReader) : Block)`
|
||||||
|
|
||||||
|
### `pocketmine\data\bedrock\item`
|
||||||
|
- `ItemDeserializer` now permits overriding **deserializers** for Bedrock IDs. As above, this may be useful to implement custom data handling, or to implement missing variants of existing items.
|
||||||
|
- This was originally prohibited since 5.0.0. However, there is no technical reason to disallow overriding **deserializers**.
|
||||||
|
- Overriding **serializers** is still **not permitted**. Reusing type IDs doesn't make any sense and would break internal design contracts.
|
||||||
|
- As above, if you want to make a custom version of a vanilla item, create a custom type ID for it, exactly as you would for a regular custom item.
|
||||||
|
- The following methods have been added:
|
||||||
|
- `public ItemDeserializer->getDeserializerForId(string $id) : ?(\Closure(SavedItemData) : Item)`
|
||||||
|
|
||||||
|
## Internals
|
||||||
|
- `new $class` is now banned on new internals code by a PHPStan rule. Closures or factory objects should be used instead for greater flexibility and better static analysis.
|
||||||
|
- `CraftingManager` now uses a more stable hash function for recipe output filtering.
|
||||||
|
- `ChunkCache` now accepts `int $dimensionId` in the constructor. This may be useful for plugins which implement the nether.
|
||||||
|
- `RuntimeBlockStateRegistry` now precomputes basic collision info about known states for fast paths.
|
||||||
|
- This permits specialization for common shapes like cubes and collisionless blocks, which allows skipping complex logic in entity movement calculation. This vastly improves performance.
|
||||||
|
- Any block whose class overrides `readStateFromWorld()` or `getModelPositionOffset()` will *not* be optimised.
|
||||||
|
- `Block->recalculateCollisionBoxes()` now has a hard requirement not to depend on anything other than available properties. It must not use `World` or its position.
|
||||||
|
- This change was problematic for `ChorusPlant`, which used nearby blocks to calculate its collision boxes.
|
||||||
|
- Blocks which need nearby blocks should override `readStateFromWorld()` and set dynamic state properties, similar to fences.
|
||||||
|
- This design flaw will be corrected with a major change to `Block` internals currently in planning for a future major version.
|
||||||
|
- `Block->getCollisionBoxes()` may not be called at all during gameplay for blocks with shapes determined to be simple, like cubes and collisionless blocks.
|
||||||
|
- `BlockStateToObjectDeserializer` now checks if the returned blockstate is registered in `RuntimeBlockStateRegistry` to promote earlier error detection (instead of crashing in random code paths).
|
@ -36,7 +36,7 @@
|
|||||||
"pocketmine/bedrock-block-upgrade-schema": "~5.1.0+bedrock-1.21.60",
|
"pocketmine/bedrock-block-upgrade-schema": "~5.1.0+bedrock-1.21.60",
|
||||||
"pocketmine/bedrock-data": "~4.0.0+bedrock-1.21.60",
|
"pocketmine/bedrock-data": "~4.0.0+bedrock-1.21.60",
|
||||||
"pocketmine/bedrock-item-upgrade-schema": "~1.14.0+bedrock-1.21.50",
|
"pocketmine/bedrock-item-upgrade-schema": "~1.14.0+bedrock-1.21.50",
|
||||||
"pocketmine/bedrock-protocol": "~36.0.0+bedrock-1.21.60",
|
"pocketmine/bedrock-protocol": "~36.2.0+bedrock-1.21.60",
|
||||||
"pocketmine/binaryutils": "^0.2.1",
|
"pocketmine/binaryutils": "^0.2.1",
|
||||||
"pocketmine/callback-validator": "^1.0.2",
|
"pocketmine/callback-validator": "^1.0.2",
|
||||||
"pocketmine/color": "^0.3.0",
|
"pocketmine/color": "^0.3.0",
|
||||||
@ -44,7 +44,7 @@
|
|||||||
"pocketmine/locale-data": "~2.24.0",
|
"pocketmine/locale-data": "~2.24.0",
|
||||||
"pocketmine/log": "^0.4.0",
|
"pocketmine/log": "^0.4.0",
|
||||||
"pocketmine/math": "~1.0.0",
|
"pocketmine/math": "~1.0.0",
|
||||||
"pocketmine/nbt": "~1.0.0",
|
"pocketmine/nbt": "~1.1.0",
|
||||||
"pocketmine/raklib": "~1.1.0",
|
"pocketmine/raklib": "~1.1.0",
|
||||||
"pocketmine/raklib-ipc": "~1.0.0",
|
"pocketmine/raklib-ipc": "~1.0.0",
|
||||||
"pocketmine/snooze": "^0.5.0",
|
"pocketmine/snooze": "^0.5.0",
|
||||||
|
26
composer.lock
generated
26
composer.lock
generated
@ -4,7 +4,7 @@
|
|||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"content-hash": "d3a1dc398ea7b59dcb674143ac10f289",
|
"content-hash": "6314ae9a7919042f10bd17f0a3ef6e9d",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "adhocore/json-comment",
|
"name": "adhocore/json-comment",
|
||||||
@ -256,16 +256,16 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "pocketmine/bedrock-protocol",
|
"name": "pocketmine/bedrock-protocol",
|
||||||
"version": "36.0.0+bedrock-1.21.60",
|
"version": "36.2.0+bedrock-1.21.60",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/pmmp/BedrockProtocol.git",
|
"url": "https://github.com/pmmp/BedrockProtocol.git",
|
||||||
"reference": "2057de319c5c551001c2a544e08d1bc7727d9963"
|
"reference": "6830e8a9ee9ecb6984b7b02f412473136ae92d50"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/pmmp/BedrockProtocol/zipball/2057de319c5c551001c2a544e08d1bc7727d9963",
|
"url": "https://api.github.com/repos/pmmp/BedrockProtocol/zipball/6830e8a9ee9ecb6984b7b02f412473136ae92d50",
|
||||||
"reference": "2057de319c5c551001c2a544e08d1bc7727d9963",
|
"reference": "6830e8a9ee9ecb6984b7b02f412473136ae92d50",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
@ -296,9 +296,9 @@
|
|||||||
"description": "An implementation of the Minecraft: Bedrock Edition protocol in PHP",
|
"description": "An implementation of the Minecraft: Bedrock Edition protocol in PHP",
|
||||||
"support": {
|
"support": {
|
||||||
"issues": "https://github.com/pmmp/BedrockProtocol/issues",
|
"issues": "https://github.com/pmmp/BedrockProtocol/issues",
|
||||||
"source": "https://github.com/pmmp/BedrockProtocol/tree/36.0.0+bedrock-1.21.60"
|
"source": "https://github.com/pmmp/BedrockProtocol/tree/36.2.0+bedrock-1.21.60"
|
||||||
},
|
},
|
||||||
"time": "2025-02-16T15:59:08+00:00"
|
"time": "2025-03-14T17:17:21+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "pocketmine/binaryutils",
|
"name": "pocketmine/binaryutils",
|
||||||
@ -576,16 +576,16 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "pocketmine/nbt",
|
"name": "pocketmine/nbt",
|
||||||
"version": "1.0.1",
|
"version": "1.1.1",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/pmmp/NBT.git",
|
"url": "https://github.com/pmmp/NBT.git",
|
||||||
"reference": "53db37487bc5ddbfbd84247966e1a073bdcfdb7d"
|
"reference": "c3c7b0a7295daeaf7873d90fed5c5d10381d12e1"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/pmmp/NBT/zipball/53db37487bc5ddbfbd84247966e1a073bdcfdb7d",
|
"url": "https://api.github.com/repos/pmmp/NBT/zipball/c3c7b0a7295daeaf7873d90fed5c5d10381d12e1",
|
||||||
"reference": "53db37487bc5ddbfbd84247966e1a073bdcfdb7d",
|
"reference": "c3c7b0a7295daeaf7873d90fed5c5d10381d12e1",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
@ -612,9 +612,9 @@
|
|||||||
"description": "PHP library for working with Named Binary Tags",
|
"description": "PHP library for working with Named Binary Tags",
|
||||||
"support": {
|
"support": {
|
||||||
"issues": "https://github.com/pmmp/NBT/issues",
|
"issues": "https://github.com/pmmp/NBT/issues",
|
||||||
"source": "https://github.com/pmmp/NBT/tree/1.0.1"
|
"source": "https://github.com/pmmp/NBT/tree/1.1.1"
|
||||||
},
|
},
|
||||||
"time": "2025-01-07T22:47:46+00:00"
|
"time": "2025-03-09T01:46:03+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "pocketmine/raklib",
|
"name": "pocketmine/raklib",
|
||||||
|
@ -11,6 +11,7 @@ includes:
|
|||||||
|
|
||||||
rules:
|
rules:
|
||||||
- pocketmine\phpstan\rules\DeprecatedLegacyEnumAccessRule
|
- pocketmine\phpstan\rules\DeprecatedLegacyEnumAccessRule
|
||||||
|
- pocketmine\phpstan\rules\DisallowDynamicNewRule
|
||||||
- pocketmine\phpstan\rules\DisallowEnumComparisonRule
|
- pocketmine\phpstan\rules\DisallowEnumComparisonRule
|
||||||
- pocketmine\phpstan\rules\DisallowForeachByReferenceRule
|
- pocketmine\phpstan\rules\DisallowForeachByReferenceRule
|
||||||
- pocketmine\phpstan\rules\ExplodeLimitRule
|
- pocketmine\phpstan\rules\ExplodeLimitRule
|
||||||
|
@ -31,8 +31,8 @@ use function str_repeat;
|
|||||||
|
|
||||||
final class VersionInfo{
|
final class VersionInfo{
|
||||||
public const NAME = "PocketMine-MP";
|
public const NAME = "PocketMine-MP";
|
||||||
public const BASE_VERSION = "5.25.3";
|
public const BASE_VERSION = "5.26.0";
|
||||||
public const IS_DEVELOPMENT_BUILD = true;
|
public const IS_DEVELOPMENT_BUILD = false;
|
||||||
public const BUILD_CHANNEL = "stable";
|
public const BUILD_CHANNEL = "stable";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -34,11 +34,16 @@ use function mt_rand;
|
|||||||
final class ChorusPlant extends Flowable{
|
final class ChorusPlant extends Flowable{
|
||||||
use StaticSupportTrait;
|
use StaticSupportTrait;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var true[]
|
||||||
|
* @phpstan-var array<int, true>
|
||||||
|
*/
|
||||||
|
protected array $connections = [];
|
||||||
|
|
||||||
protected function recalculateCollisionBoxes() : array{
|
protected function recalculateCollisionBoxes() : array{
|
||||||
$bb = AxisAlignedBB::one();
|
$bb = AxisAlignedBB::one();
|
||||||
foreach($this->getAllSides() as $facing => $block){
|
foreach(Facing::ALL as $facing){
|
||||||
$id = $block->getTypeId();
|
if(!isset($this->connections[$facing])){
|
||||||
if($id !== BlockTypeIds::END_STONE && $id !== BlockTypeIds::CHORUS_FLOWER && !$block->hasSameTypeId($this)){
|
|
||||||
$bb->trim($facing, 2 / 16);
|
$bb->trim($facing, 2 / 16);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -46,6 +51,26 @@ final class ChorusPlant extends Flowable{
|
|||||||
return [$bb];
|
return [$bb];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function readStateFromWorld() : Block{
|
||||||
|
parent::readStateFromWorld();
|
||||||
|
|
||||||
|
$this->collisionBoxes = null;
|
||||||
|
|
||||||
|
foreach(Facing::ALL as $facing){
|
||||||
|
$block = $this->getSide($facing);
|
||||||
|
if(match($block->getTypeId()){
|
||||||
|
BlockTypeIds::END_STONE, BlockTypeIds::CHORUS_FLOWER, $this->getTypeId() => true,
|
||||||
|
default => false
|
||||||
|
}){
|
||||||
|
$this->connections[$facing] = true;
|
||||||
|
}else{
|
||||||
|
unset($this->connections[$facing]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
private function canBeSupportedBy(Block $block) : bool{
|
private function canBeSupportedBy(Block $block) : bool{
|
||||||
return $block->hasSameTypeId($this) || $block->getTypeId() === BlockTypeIds::END_STONE;
|
return $block->hasSameTypeId($this) || $block->getTypeId() === BlockTypeIds::END_STONE;
|
||||||
}
|
}
|
||||||
|
@ -28,6 +28,7 @@ use pocketmine\block\BlockIdentifier as BID;
|
|||||||
use pocketmine\utils\AssumptionFailedError;
|
use pocketmine\utils\AssumptionFailedError;
|
||||||
use pocketmine\utils\SingletonTrait;
|
use pocketmine\utils\SingletonTrait;
|
||||||
use pocketmine\world\light\LightUpdate;
|
use pocketmine\world\light\LightUpdate;
|
||||||
|
use function count;
|
||||||
use function min;
|
use function min;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -40,6 +41,11 @@ use function min;
|
|||||||
class RuntimeBlockStateRegistry{
|
class RuntimeBlockStateRegistry{
|
||||||
use SingletonTrait;
|
use SingletonTrait;
|
||||||
|
|
||||||
|
public const COLLISION_CUSTOM = 0;
|
||||||
|
public const COLLISION_CUBE = 1;
|
||||||
|
public const COLLISION_NONE = 2;
|
||||||
|
public const COLLISION_MAY_OVERFLOW = 3;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Block[]
|
* @var Block[]
|
||||||
* @phpstan-var array<int, Block>
|
* @phpstan-var array<int, Block>
|
||||||
@ -74,6 +80,13 @@ class RuntimeBlockStateRegistry{
|
|||||||
*/
|
*/
|
||||||
public array $blastResistance = [];
|
public array $blastResistance = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Map of state ID -> useful AABB info to avoid unnecessary block allocations
|
||||||
|
* @var int[]
|
||||||
|
* @phpstan-var array<int, int>
|
||||||
|
*/
|
||||||
|
public array $collisionInfo = [];
|
||||||
|
|
||||||
public function __construct(){
|
public function __construct(){
|
||||||
foreach(VanillaBlocks::getAll() as $block){
|
foreach(VanillaBlocks::getAll() as $block){
|
||||||
$this->register($block);
|
$this->register($block);
|
||||||
@ -100,6 +113,70 @@ class RuntimeBlockStateRegistry{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if the given class method overrides a method in Block.
|
||||||
|
* Used to determine if a block might need to disable fast path optimizations.
|
||||||
|
*
|
||||||
|
* @phpstan-param anyClosure $closure
|
||||||
|
*/
|
||||||
|
private static function overridesBlockMethod(\Closure $closure) : bool{
|
||||||
|
$declarer = (new \ReflectionFunction($closure))->getClosureScopeClass();
|
||||||
|
return $declarer !== null && $declarer->getName() !== Block::class;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A big ugly hack to set up fast paths for handling collisions on blocks with common shapes.
|
||||||
|
* The information returned here is stored in RuntimeBlockStateRegistry->collisionInfo, and is used during entity
|
||||||
|
* collision box calculations to avoid complex logic and unnecessary block object allocations.
|
||||||
|
* This hack allows significant performance improvements.
|
||||||
|
*
|
||||||
|
* TODO: We'll want to redesign block collision box handling and block shapes in the future, but that's a job for a
|
||||||
|
* major version. For now, this hack nets major performance wins.
|
||||||
|
*/
|
||||||
|
private static function calculateCollisionInfo(Block $block) : int{
|
||||||
|
if(
|
||||||
|
self::overridesBlockMethod($block->getModelPositionOffset(...)) ||
|
||||||
|
self::overridesBlockMethod($block->readStateFromWorld(...))
|
||||||
|
){
|
||||||
|
//getModelPositionOffset() might cause AABBs to shift outside the cell
|
||||||
|
//readStateFromWorld() might cause overflow in ways we can't predict just by looking at known states
|
||||||
|
//TODO: excluding overriders of readStateFromWorld() also excludes blocks with tiles that don't do anything
|
||||||
|
//weird with their AABBs, but for now this is the best we can do.
|
||||||
|
return self::COLLISION_MAY_OVERFLOW;
|
||||||
|
}
|
||||||
|
|
||||||
|
//TODO: this could blow up if any recalculateCollisionBoxes() uses the world
|
||||||
|
//it shouldn't, but that doesn't mean that custom blocks won't...
|
||||||
|
$boxes = $block->getCollisionBoxes();
|
||||||
|
if(count($boxes) === 0){
|
||||||
|
return self::COLLISION_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(
|
||||||
|
count($boxes) === 1 &&
|
||||||
|
$boxes[0]->minX === 0.0 &&
|
||||||
|
$boxes[0]->minY === 0.0 &&
|
||||||
|
$boxes[0]->minZ === 0.0 &&
|
||||||
|
$boxes[0]->maxX === 1.0 &&
|
||||||
|
$boxes[0]->maxY === 1.0 &&
|
||||||
|
$boxes[0]->maxZ === 1.0
|
||||||
|
){
|
||||||
|
return self::COLLISION_CUBE;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach($boxes as $box){
|
||||||
|
if(
|
||||||
|
$box->minX < 0 || $box->maxX > 1 ||
|
||||||
|
$box->minY < 0 || $box->maxY > 1 ||
|
||||||
|
$box->minZ < 0 || $box->maxZ > 1
|
||||||
|
){
|
||||||
|
return self::COLLISION_MAY_OVERFLOW;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return self::COLLISION_CUSTOM;
|
||||||
|
}
|
||||||
|
|
||||||
private function fillStaticArrays(int $index, Block $block) : void{
|
private function fillStaticArrays(int $index, Block $block) : void{
|
||||||
$fullId = $block->getStateId();
|
$fullId = $block->getStateId();
|
||||||
if($index !== $fullId){
|
if($index !== $fullId){
|
||||||
@ -112,6 +189,8 @@ class RuntimeBlockStateRegistry{
|
|||||||
if($block->blocksDirectSkyLight()){
|
if($block->blocksDirectSkyLight()){
|
||||||
$this->blocksDirectSkyLight[$index] = true;
|
$this->blocksDirectSkyLight[$index] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->collisionInfo[$index] = self::calculateCollisionInfo($block);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -130,6 +209,10 @@ class RuntimeBlockStateRegistry{
|
|||||||
return $block;
|
return $block;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function hasStateId(int $stateId) : bool{
|
||||||
|
return isset($this->fullList[$stateId]);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Block[]
|
* @return Block[]
|
||||||
* @phpstan-return array<int, Block>
|
* @phpstan-return array<int, Block>
|
||||||
|
@ -29,8 +29,12 @@ use pocketmine\nbt\TreeRoot;
|
|||||||
use pocketmine\utils\BinaryStream;
|
use pocketmine\utils\BinaryStream;
|
||||||
use pocketmine\utils\DestructorCallbackTrait;
|
use pocketmine\utils\DestructorCallbackTrait;
|
||||||
use pocketmine\utils\ObjectSet;
|
use pocketmine\utils\ObjectSet;
|
||||||
|
use function array_shift;
|
||||||
|
use function count;
|
||||||
|
use function implode;
|
||||||
|
use function ksort;
|
||||||
use function spl_object_id;
|
use function spl_object_id;
|
||||||
use function usort;
|
use const SORT_STRING;
|
||||||
|
|
||||||
class CraftingManager{
|
class CraftingManager{
|
||||||
use DestructorCallbackTrait;
|
use DestructorCallbackTrait;
|
||||||
@ -100,6 +104,7 @@ class CraftingManager{
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Function used to arrange Shapeless Recipe ingredient lists into a consistent order.
|
* Function used to arrange Shapeless Recipe ingredient lists into a consistent order.
|
||||||
|
* @deprecated
|
||||||
*/
|
*/
|
||||||
public static function sort(Item $i1, Item $i2) : int{
|
public static function sort(Item $i1, Item $i2) : int{
|
||||||
//Use spaceship operator to compare each property, then try the next one if they are equivalent.
|
//Use spaceship operator to compare each property, then try the next one if they are equivalent.
|
||||||
@ -108,45 +113,30 @@ class CraftingManager{
|
|||||||
return $retval;
|
return $retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
private static function hashOutput(Item $output) : string{
|
||||||
* @param Item[] $items
|
$write = new BinaryStream();
|
||||||
*
|
$write->putVarInt($output->getStateId());
|
||||||
* @return Item[]
|
$write->put((new LittleEndianNbtSerializer())->write(new TreeRoot($output->getNamedTag())));
|
||||||
* @phpstan-return list<Item>
|
|
||||||
*/
|
|
||||||
private static function pack(array $items) : array{
|
|
||||||
$result = [];
|
|
||||||
|
|
||||||
foreach($items as $item){
|
return $write->getBuffer();
|
||||||
foreach($result as $otherItem){
|
|
||||||
if($item->canStackWith($otherItem)){
|
|
||||||
$otherItem->setCount($otherItem->getCount() + $item->getCount());
|
|
||||||
continue 2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//No matching item found
|
|
||||||
$result[] = clone $item;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Item[] $outputs
|
* @param Item[] $outputs
|
||||||
*/
|
*/
|
||||||
private static function hashOutputs(array $outputs) : string{
|
private static function hashOutputs(array $outputs) : string{
|
||||||
$outputs = self::pack($outputs);
|
if(count($outputs) === 1){
|
||||||
usort($outputs, [self::class, "sort"]);
|
return self::hashOutput(array_shift($outputs));
|
||||||
$result = new BinaryStream();
|
}
|
||||||
|
$unique = [];
|
||||||
foreach($outputs as $o){
|
foreach($outputs as $o){
|
||||||
//count is not written because the outputs might be from multiple repetitions of a single recipe
|
//count is not written because the outputs might be from multiple repetitions of a single recipe
|
||||||
//this reduces the accuracy of the hash, but it won't matter in most cases.
|
//this reduces the accuracy of the hash, but it won't matter in most cases.
|
||||||
$result->putVarInt($o->getStateId());
|
$hash = self::hashOutput($o);
|
||||||
$result->put((new LittleEndianNbtSerializer())->write(new TreeRoot($o->getNamedTag())));
|
$unique[$hash] = $hash;
|
||||||
}
|
}
|
||||||
|
ksort($unique, SORT_STRING);
|
||||||
return $result->getBuffer();
|
return implode("", $unique);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -214,6 +214,7 @@ final class BlockObjectToStateSerializer implements BlockStateSerializer{
|
|||||||
$this->registerLeavesSerializers();
|
$this->registerLeavesSerializers();
|
||||||
$this->registerSaplingSerializers();
|
$this->registerSaplingSerializers();
|
||||||
$this->registerMobHeadSerializers();
|
$this->registerMobHeadSerializers();
|
||||||
|
$this->registerCopperSerializers();
|
||||||
$this->registerSimpleSerializers();
|
$this->registerSimpleSerializers();
|
||||||
$this->registerSerializers();
|
$this->registerSerializers();
|
||||||
}
|
}
|
||||||
@ -791,6 +792,178 @@ final class BlockObjectToStateSerializer implements BlockStateSerializer{
|
|||||||
})->writeFacingWithoutDown($block->getFacing()));
|
})->writeFacingWithoutDown($block->getFacing()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function registerCopperSerializers() : void{
|
||||||
|
$this->map(Blocks::COPPER(), function(Copper $block) : Writer{
|
||||||
|
$oxidation = $block->getOxidation();
|
||||||
|
return new Writer($block->isWaxed() ?
|
||||||
|
Helper::selectCopperId($oxidation, Ids::WAXED_COPPER, Ids::WAXED_EXPOSED_COPPER, Ids::WAXED_WEATHERED_COPPER, Ids::WAXED_OXIDIZED_COPPER) :
|
||||||
|
Helper::selectCopperId($oxidation, Ids::COPPER_BLOCK, Ids::EXPOSED_COPPER, Ids::WEATHERED_COPPER, Ids::OXIDIZED_COPPER)
|
||||||
|
);
|
||||||
|
});
|
||||||
|
$this->map(Blocks::CHISELED_COPPER(), function(Copper $block) : Writer{
|
||||||
|
$oxidation = $block->getOxidation();
|
||||||
|
return new Writer($block->isWaxed() ?
|
||||||
|
Helper::selectCopperId($oxidation,
|
||||||
|
Ids::WAXED_CHISELED_COPPER,
|
||||||
|
Ids::WAXED_EXPOSED_CHISELED_COPPER,
|
||||||
|
Ids::WAXED_WEATHERED_CHISELED_COPPER,
|
||||||
|
Ids::WAXED_OXIDIZED_CHISELED_COPPER
|
||||||
|
) :
|
||||||
|
Helper::selectCopperId($oxidation,
|
||||||
|
Ids::CHISELED_COPPER,
|
||||||
|
Ids::EXPOSED_CHISELED_COPPER,
|
||||||
|
Ids::WEATHERED_CHISELED_COPPER,
|
||||||
|
Ids::OXIDIZED_CHISELED_COPPER
|
||||||
|
)
|
||||||
|
);
|
||||||
|
});
|
||||||
|
$this->map(Blocks::COPPER_GRATE(), function(CopperGrate $block) : Writer{
|
||||||
|
$oxidation = $block->getOxidation();
|
||||||
|
return new Writer($block->isWaxed() ?
|
||||||
|
Helper::selectCopperId($oxidation,
|
||||||
|
Ids::WAXED_COPPER_GRATE,
|
||||||
|
Ids::WAXED_EXPOSED_COPPER_GRATE,
|
||||||
|
Ids::WAXED_WEATHERED_COPPER_GRATE,
|
||||||
|
Ids::WAXED_OXIDIZED_COPPER_GRATE
|
||||||
|
) :
|
||||||
|
Helper::selectCopperId($oxidation,
|
||||||
|
Ids::COPPER_GRATE,
|
||||||
|
Ids::EXPOSED_COPPER_GRATE,
|
||||||
|
Ids::WEATHERED_COPPER_GRATE,
|
||||||
|
Ids::OXIDIZED_COPPER_GRATE
|
||||||
|
)
|
||||||
|
);
|
||||||
|
});
|
||||||
|
$this->map(Blocks::CUT_COPPER(), function(Copper $block) : Writer{
|
||||||
|
$oxidation = $block->getOxidation();
|
||||||
|
return new Writer($block->isWaxed() ?
|
||||||
|
Helper::selectCopperId($oxidation, Ids::WAXED_CUT_COPPER, Ids::WAXED_EXPOSED_CUT_COPPER, Ids::WAXED_WEATHERED_CUT_COPPER, Ids::WAXED_OXIDIZED_CUT_COPPER) :
|
||||||
|
Helper::selectCopperId($oxidation, Ids::CUT_COPPER, Ids::EXPOSED_CUT_COPPER, Ids::WEATHERED_CUT_COPPER, Ids::OXIDIZED_CUT_COPPER)
|
||||||
|
);
|
||||||
|
});
|
||||||
|
$this->map(Blocks::CUT_COPPER_SLAB(), function(CopperSlab $block) : Writer{
|
||||||
|
$oxidation = $block->getOxidation();
|
||||||
|
return Helper::encodeSlab(
|
||||||
|
$block,
|
||||||
|
($block->isWaxed() ?
|
||||||
|
Helper::selectCopperId(
|
||||||
|
$oxidation,
|
||||||
|
Ids::WAXED_CUT_COPPER_SLAB,
|
||||||
|
Ids::WAXED_EXPOSED_CUT_COPPER_SLAB,
|
||||||
|
Ids::WAXED_WEATHERED_CUT_COPPER_SLAB,
|
||||||
|
Ids::WAXED_OXIDIZED_CUT_COPPER_SLAB
|
||||||
|
) :
|
||||||
|
Helper::selectCopperId(
|
||||||
|
$oxidation,
|
||||||
|
Ids::CUT_COPPER_SLAB,
|
||||||
|
Ids::EXPOSED_CUT_COPPER_SLAB,
|
||||||
|
Ids::WEATHERED_CUT_COPPER_SLAB,
|
||||||
|
Ids::OXIDIZED_CUT_COPPER_SLAB
|
||||||
|
)
|
||||||
|
),
|
||||||
|
($block->isWaxed() ?
|
||||||
|
Helper::selectCopperId(
|
||||||
|
$oxidation,
|
||||||
|
Ids::WAXED_DOUBLE_CUT_COPPER_SLAB,
|
||||||
|
Ids::WAXED_EXPOSED_DOUBLE_CUT_COPPER_SLAB,
|
||||||
|
Ids::WAXED_WEATHERED_DOUBLE_CUT_COPPER_SLAB,
|
||||||
|
Ids::WAXED_OXIDIZED_DOUBLE_CUT_COPPER_SLAB
|
||||||
|
) :
|
||||||
|
Helper::selectCopperId(
|
||||||
|
$oxidation,
|
||||||
|
Ids::DOUBLE_CUT_COPPER_SLAB,
|
||||||
|
Ids::EXPOSED_DOUBLE_CUT_COPPER_SLAB,
|
||||||
|
Ids::WEATHERED_DOUBLE_CUT_COPPER_SLAB,
|
||||||
|
Ids::OXIDIZED_DOUBLE_CUT_COPPER_SLAB
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
});
|
||||||
|
$this->map(Blocks::CUT_COPPER_STAIRS(), function(CopperStairs $block) : Writer{
|
||||||
|
$oxidation = $block->getOxidation();
|
||||||
|
return Helper::encodeStairs(
|
||||||
|
$block,
|
||||||
|
new Writer($block->isWaxed() ?
|
||||||
|
Helper::selectCopperId(
|
||||||
|
$oxidation,
|
||||||
|
Ids::WAXED_CUT_COPPER_STAIRS,
|
||||||
|
Ids::WAXED_EXPOSED_CUT_COPPER_STAIRS,
|
||||||
|
Ids::WAXED_WEATHERED_CUT_COPPER_STAIRS,
|
||||||
|
Ids::WAXED_OXIDIZED_CUT_COPPER_STAIRS
|
||||||
|
) :
|
||||||
|
Helper::selectCopperId(
|
||||||
|
$oxidation,
|
||||||
|
Ids::CUT_COPPER_STAIRS,
|
||||||
|
Ids::EXPOSED_CUT_COPPER_STAIRS,
|
||||||
|
Ids::WEATHERED_CUT_COPPER_STAIRS,
|
||||||
|
Ids::OXIDIZED_CUT_COPPER_STAIRS
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
});
|
||||||
|
$this->map(Blocks::COPPER_BULB(), function(CopperBulb $block) : Writer{
|
||||||
|
$oxidation = $block->getOxidation();
|
||||||
|
return Writer::create($block->isWaxed() ?
|
||||||
|
Helper::selectCopperId($oxidation,
|
||||||
|
Ids::WAXED_COPPER_BULB,
|
||||||
|
Ids::WAXED_EXPOSED_COPPER_BULB,
|
||||||
|
Ids::WAXED_WEATHERED_COPPER_BULB,
|
||||||
|
Ids::WAXED_OXIDIZED_COPPER_BULB) :
|
||||||
|
Helper::selectCopperId($oxidation,
|
||||||
|
Ids::COPPER_BULB,
|
||||||
|
Ids::EXPOSED_COPPER_BULB,
|
||||||
|
Ids::WEATHERED_COPPER_BULB,
|
||||||
|
Ids::OXIDIZED_COPPER_BULB
|
||||||
|
))
|
||||||
|
->writeBool(StateNames::LIT, $block->isLit())
|
||||||
|
->writeBool(StateNames::POWERED_BIT, $block->isPowered());
|
||||||
|
});
|
||||||
|
$this->map(Blocks::COPPER_DOOR(), function(CopperDoor $block) : Writer{
|
||||||
|
$oxidation = $block->getOxidation();
|
||||||
|
return Helper::encodeDoor(
|
||||||
|
$block,
|
||||||
|
new Writer($block->isWaxed() ?
|
||||||
|
Helper::selectCopperId(
|
||||||
|
$oxidation,
|
||||||
|
Ids::WAXED_COPPER_DOOR,
|
||||||
|
Ids::WAXED_EXPOSED_COPPER_DOOR,
|
||||||
|
Ids::WAXED_WEATHERED_COPPER_DOOR,
|
||||||
|
Ids::WAXED_OXIDIZED_COPPER_DOOR
|
||||||
|
) :
|
||||||
|
Helper::selectCopperId(
|
||||||
|
$oxidation,
|
||||||
|
Ids::COPPER_DOOR,
|
||||||
|
Ids::EXPOSED_COPPER_DOOR,
|
||||||
|
Ids::WEATHERED_COPPER_DOOR,
|
||||||
|
Ids::OXIDIZED_COPPER_DOOR
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
});
|
||||||
|
$this->map(Blocks::COPPER_TRAPDOOR(), function(CopperTrapdoor $block) : Writer{
|
||||||
|
$oxidation = $block->getOxidation();
|
||||||
|
return Helper::encodeTrapdoor(
|
||||||
|
$block,
|
||||||
|
new Writer($block->isWaxed() ?
|
||||||
|
Helper::selectCopperId(
|
||||||
|
$oxidation,
|
||||||
|
Ids::WAXED_COPPER_TRAPDOOR,
|
||||||
|
Ids::WAXED_EXPOSED_COPPER_TRAPDOOR,
|
||||||
|
Ids::WAXED_WEATHERED_COPPER_TRAPDOOR,
|
||||||
|
Ids::WAXED_OXIDIZED_COPPER_TRAPDOOR
|
||||||
|
) :
|
||||||
|
Helper::selectCopperId(
|
||||||
|
$oxidation,
|
||||||
|
Ids::COPPER_TRAPDOOR,
|
||||||
|
Ids::EXPOSED_COPPER_TRAPDOOR,
|
||||||
|
Ids::WEATHERED_COPPER_TRAPDOOR,
|
||||||
|
Ids::OXIDIZED_COPPER_TRAPDOOR
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
private function registerSimpleSerializers() : void{
|
private function registerSimpleSerializers() : void{
|
||||||
$this->mapSimple(Blocks::AIR(), Ids::AIR);
|
$this->mapSimple(Blocks::AIR(), Ids::AIR);
|
||||||
$this->mapSimple(Blocks::AMETHYST(), Ids::AMETHYST_BLOCK);
|
$this->mapSimple(Blocks::AMETHYST(), Ids::AMETHYST_BLOCK);
|
||||||
@ -1265,175 +1438,6 @@ final class BlockObjectToStateSerializer implements BlockStateSerializer{
|
|||||||
$this->mapSlab(Blocks::COBBLESTONE_SLAB(), Ids::COBBLESTONE_SLAB, Ids::COBBLESTONE_DOUBLE_SLAB);
|
$this->mapSlab(Blocks::COBBLESTONE_SLAB(), Ids::COBBLESTONE_SLAB, Ids::COBBLESTONE_DOUBLE_SLAB);
|
||||||
$this->mapStairs(Blocks::COBBLESTONE_STAIRS(), Ids::STONE_STAIRS);
|
$this->mapStairs(Blocks::COBBLESTONE_STAIRS(), Ids::STONE_STAIRS);
|
||||||
$this->map(Blocks::COBBLESTONE_WALL(), fn(Wall $block) => Helper::encodeWall($block, Writer::create(Ids::COBBLESTONE_WALL)));
|
$this->map(Blocks::COBBLESTONE_WALL(), fn(Wall $block) => Helper::encodeWall($block, Writer::create(Ids::COBBLESTONE_WALL)));
|
||||||
$this->map(Blocks::COPPER(), function(Copper $block) : Writer{
|
|
||||||
$oxidation = $block->getOxidation();
|
|
||||||
return new Writer($block->isWaxed() ?
|
|
||||||
Helper::selectCopperId($oxidation, Ids::WAXED_COPPER, Ids::WAXED_EXPOSED_COPPER, Ids::WAXED_WEATHERED_COPPER, Ids::WAXED_OXIDIZED_COPPER) :
|
|
||||||
Helper::selectCopperId($oxidation, Ids::COPPER_BLOCK, Ids::EXPOSED_COPPER, Ids::WEATHERED_COPPER, Ids::OXIDIZED_COPPER)
|
|
||||||
);
|
|
||||||
});
|
|
||||||
$this->map(Blocks::CHISELED_COPPER(), function(Copper $block) : Writer{
|
|
||||||
$oxidation = $block->getOxidation();
|
|
||||||
return new Writer($block->isWaxed() ?
|
|
||||||
Helper::selectCopperId($oxidation,
|
|
||||||
Ids::WAXED_CHISELED_COPPER,
|
|
||||||
Ids::WAXED_EXPOSED_CHISELED_COPPER,
|
|
||||||
Ids::WAXED_WEATHERED_CHISELED_COPPER,
|
|
||||||
Ids::WAXED_OXIDIZED_CHISELED_COPPER
|
|
||||||
) :
|
|
||||||
Helper::selectCopperId($oxidation,
|
|
||||||
Ids::CHISELED_COPPER,
|
|
||||||
Ids::EXPOSED_CHISELED_COPPER,
|
|
||||||
Ids::WEATHERED_CHISELED_COPPER,
|
|
||||||
Ids::OXIDIZED_CHISELED_COPPER
|
|
||||||
)
|
|
||||||
);
|
|
||||||
});
|
|
||||||
$this->map(Blocks::COPPER_GRATE(), function(CopperGrate $block) : Writer{
|
|
||||||
$oxidation = $block->getOxidation();
|
|
||||||
return new Writer($block->isWaxed() ?
|
|
||||||
Helper::selectCopperId($oxidation,
|
|
||||||
Ids::WAXED_COPPER_GRATE,
|
|
||||||
Ids::WAXED_EXPOSED_COPPER_GRATE,
|
|
||||||
Ids::WAXED_WEATHERED_COPPER_GRATE,
|
|
||||||
Ids::WAXED_OXIDIZED_COPPER_GRATE
|
|
||||||
) :
|
|
||||||
Helper::selectCopperId($oxidation,
|
|
||||||
Ids::COPPER_GRATE,
|
|
||||||
Ids::EXPOSED_COPPER_GRATE,
|
|
||||||
Ids::WEATHERED_COPPER_GRATE,
|
|
||||||
Ids::OXIDIZED_COPPER_GRATE
|
|
||||||
)
|
|
||||||
);
|
|
||||||
});
|
|
||||||
$this->map(Blocks::CUT_COPPER(), function(Copper $block) : Writer{
|
|
||||||
$oxidation = $block->getOxidation();
|
|
||||||
return new Writer($block->isWaxed() ?
|
|
||||||
Helper::selectCopperId($oxidation, Ids::WAXED_CUT_COPPER, Ids::WAXED_EXPOSED_CUT_COPPER, Ids::WAXED_WEATHERED_CUT_COPPER, Ids::WAXED_OXIDIZED_CUT_COPPER) :
|
|
||||||
Helper::selectCopperId($oxidation, Ids::CUT_COPPER, Ids::EXPOSED_CUT_COPPER, Ids::WEATHERED_CUT_COPPER, Ids::OXIDIZED_CUT_COPPER)
|
|
||||||
);
|
|
||||||
});
|
|
||||||
$this->map(Blocks::CUT_COPPER_SLAB(), function(CopperSlab $block) : Writer{
|
|
||||||
$oxidation = $block->getOxidation();
|
|
||||||
return Helper::encodeSlab(
|
|
||||||
$block,
|
|
||||||
($block->isWaxed() ?
|
|
||||||
Helper::selectCopperId(
|
|
||||||
$oxidation,
|
|
||||||
Ids::WAXED_CUT_COPPER_SLAB,
|
|
||||||
Ids::WAXED_EXPOSED_CUT_COPPER_SLAB,
|
|
||||||
Ids::WAXED_WEATHERED_CUT_COPPER_SLAB,
|
|
||||||
Ids::WAXED_OXIDIZED_CUT_COPPER_SLAB
|
|
||||||
) :
|
|
||||||
Helper::selectCopperId(
|
|
||||||
$oxidation,
|
|
||||||
Ids::CUT_COPPER_SLAB,
|
|
||||||
Ids::EXPOSED_CUT_COPPER_SLAB,
|
|
||||||
Ids::WEATHERED_CUT_COPPER_SLAB,
|
|
||||||
Ids::OXIDIZED_CUT_COPPER_SLAB
|
|
||||||
)
|
|
||||||
),
|
|
||||||
($block->isWaxed() ?
|
|
||||||
Helper::selectCopperId(
|
|
||||||
$oxidation,
|
|
||||||
Ids::WAXED_DOUBLE_CUT_COPPER_SLAB,
|
|
||||||
Ids::WAXED_EXPOSED_DOUBLE_CUT_COPPER_SLAB,
|
|
||||||
Ids::WAXED_WEATHERED_DOUBLE_CUT_COPPER_SLAB,
|
|
||||||
Ids::WAXED_OXIDIZED_DOUBLE_CUT_COPPER_SLAB
|
|
||||||
) :
|
|
||||||
Helper::selectCopperId(
|
|
||||||
$oxidation,
|
|
||||||
Ids::DOUBLE_CUT_COPPER_SLAB,
|
|
||||||
Ids::EXPOSED_DOUBLE_CUT_COPPER_SLAB,
|
|
||||||
Ids::WEATHERED_DOUBLE_CUT_COPPER_SLAB,
|
|
||||||
Ids::OXIDIZED_DOUBLE_CUT_COPPER_SLAB
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
});
|
|
||||||
$this->map(Blocks::CUT_COPPER_STAIRS(), function(CopperStairs $block) : Writer{
|
|
||||||
$oxidation = $block->getOxidation();
|
|
||||||
return Helper::encodeStairs(
|
|
||||||
$block,
|
|
||||||
new Writer($block->isWaxed() ?
|
|
||||||
Helper::selectCopperId(
|
|
||||||
$oxidation,
|
|
||||||
Ids::WAXED_CUT_COPPER_STAIRS,
|
|
||||||
Ids::WAXED_EXPOSED_CUT_COPPER_STAIRS,
|
|
||||||
Ids::WAXED_WEATHERED_CUT_COPPER_STAIRS,
|
|
||||||
Ids::WAXED_OXIDIZED_CUT_COPPER_STAIRS
|
|
||||||
) :
|
|
||||||
Helper::selectCopperId(
|
|
||||||
$oxidation,
|
|
||||||
Ids::CUT_COPPER_STAIRS,
|
|
||||||
Ids::EXPOSED_CUT_COPPER_STAIRS,
|
|
||||||
Ids::WEATHERED_CUT_COPPER_STAIRS,
|
|
||||||
Ids::OXIDIZED_CUT_COPPER_STAIRS
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
});
|
|
||||||
$this->map(Blocks::COPPER_BULB(), function(CopperBulb $block) : Writer{
|
|
||||||
$oxidation = $block->getOxidation();
|
|
||||||
return Writer::create($block->isWaxed() ?
|
|
||||||
Helper::selectCopperId($oxidation,
|
|
||||||
Ids::WAXED_COPPER_BULB,
|
|
||||||
Ids::WAXED_EXPOSED_COPPER_BULB,
|
|
||||||
Ids::WAXED_WEATHERED_COPPER_BULB,
|
|
||||||
Ids::WAXED_OXIDIZED_COPPER_BULB) :
|
|
||||||
Helper::selectCopperId($oxidation,
|
|
||||||
Ids::COPPER_BULB,
|
|
||||||
Ids::EXPOSED_COPPER_BULB,
|
|
||||||
Ids::WEATHERED_COPPER_BULB,
|
|
||||||
Ids::OXIDIZED_COPPER_BULB
|
|
||||||
))
|
|
||||||
->writeBool(StateNames::LIT, $block->isLit())
|
|
||||||
->writeBool(StateNames::POWERED_BIT, $block->isPowered());
|
|
||||||
});
|
|
||||||
$this->map(Blocks::COPPER_DOOR(), function(CopperDoor $block) : Writer{
|
|
||||||
$oxidation = $block->getOxidation();
|
|
||||||
return Helper::encodeDoor(
|
|
||||||
$block,
|
|
||||||
new Writer($block->isWaxed() ?
|
|
||||||
Helper::selectCopperId(
|
|
||||||
$oxidation,
|
|
||||||
Ids::WAXED_COPPER_DOOR,
|
|
||||||
Ids::WAXED_EXPOSED_COPPER_DOOR,
|
|
||||||
Ids::WAXED_WEATHERED_COPPER_DOOR,
|
|
||||||
Ids::WAXED_OXIDIZED_COPPER_DOOR
|
|
||||||
) :
|
|
||||||
Helper::selectCopperId(
|
|
||||||
$oxidation,
|
|
||||||
Ids::COPPER_DOOR,
|
|
||||||
Ids::EXPOSED_COPPER_DOOR,
|
|
||||||
Ids::WEATHERED_COPPER_DOOR,
|
|
||||||
Ids::OXIDIZED_COPPER_DOOR
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
});
|
|
||||||
$this->map(Blocks::COPPER_TRAPDOOR(), function(CopperTrapdoor $block) : Writer{
|
|
||||||
$oxidation = $block->getOxidation();
|
|
||||||
return Helper::encodeTrapdoor(
|
|
||||||
$block,
|
|
||||||
new Writer($block->isWaxed() ?
|
|
||||||
Helper::selectCopperId(
|
|
||||||
$oxidation,
|
|
||||||
Ids::WAXED_COPPER_TRAPDOOR,
|
|
||||||
Ids::WAXED_EXPOSED_COPPER_TRAPDOOR,
|
|
||||||
Ids::WAXED_WEATHERED_COPPER_TRAPDOOR,
|
|
||||||
Ids::WAXED_OXIDIZED_COPPER_TRAPDOOR
|
|
||||||
) :
|
|
||||||
Helper::selectCopperId(
|
|
||||||
$oxidation,
|
|
||||||
Ids::COPPER_TRAPDOOR,
|
|
||||||
Ids::EXPOSED_COPPER_TRAPDOOR,
|
|
||||||
Ids::WEATHERED_COPPER_TRAPDOOR,
|
|
||||||
Ids::OXIDIZED_COPPER_TRAPDOOR
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
});
|
|
||||||
$this->map(Blocks::COCOA_POD(), function(CocoaBlock $block) : Writer{
|
$this->map(Blocks::COCOA_POD(), function(CocoaBlock $block) : Writer{
|
||||||
return Writer::create(Ids::COCOA)
|
return Writer::create(Ids::COCOA)
|
||||||
->writeInt(StateNames::AGE, $block->getAge())
|
->writeInt(StateNames::AGE, $block->getAge())
|
||||||
|
@ -126,7 +126,13 @@ final class BlockStateDeserializerHelper{
|
|||||||
->setOutputSignalStrength($in->readBoundedInt(BlockStateNames::REDSTONE_SIGNAL, 0, 15));
|
->setOutputSignalStrength($in->readBoundedInt(BlockStateNames::REDSTONE_SIGNAL, 0, 15));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @throws BlockStateDeserializeException */
|
/**
|
||||||
|
* @phpstan-template TDoor of Door
|
||||||
|
* @phpstan-param TDoor $block
|
||||||
|
* @phpstan-return TDoor
|
||||||
|
*
|
||||||
|
* @throws BlockStateDeserializeException
|
||||||
|
*/
|
||||||
public static function decodeDoor(Door $block, BlockStateReader $in) : Door{
|
public static function decodeDoor(Door $block, BlockStateReader $in) : Door{
|
||||||
//TODO: check if these need any special treatment to get the appropriate data to both halves of the door
|
//TODO: check if these need any special treatment to get the appropriate data to both halves of the door
|
||||||
return $block
|
return $block
|
||||||
@ -237,18 +243,36 @@ final class BlockStateDeserializerHelper{
|
|||||||
return $block->setPressed($in->readBoundedInt(BlockStateNames::REDSTONE_SIGNAL, 0, 15) !== 0);
|
return $block->setPressed($in->readBoundedInt(BlockStateNames::REDSTONE_SIGNAL, 0, 15) !== 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @throws BlockStateDeserializeException */
|
/**
|
||||||
|
* @phpstan-template TSlab of Slab
|
||||||
|
* @phpstan-param TSlab $block
|
||||||
|
* @phpstan-return TSlab
|
||||||
|
*
|
||||||
|
* @throws BlockStateDeserializeException
|
||||||
|
*/
|
||||||
public static function decodeSingleSlab(Slab $block, BlockStateReader $in) : Slab{
|
public static function decodeSingleSlab(Slab $block, BlockStateReader $in) : Slab{
|
||||||
return $block->setSlabType($in->readSlabPosition());
|
return $block->setSlabType($in->readSlabPosition());
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @throws BlockStateDeserializeException */
|
/**
|
||||||
|
* @phpstan-template TSlab of Slab
|
||||||
|
* @phpstan-param TSlab $block
|
||||||
|
* @phpstan-return TSlab
|
||||||
|
*
|
||||||
|
* @throws BlockStateDeserializeException
|
||||||
|
*/
|
||||||
public static function decodeDoubleSlab(Slab $block, BlockStateReader $in) : Slab{
|
public static function decodeDoubleSlab(Slab $block, BlockStateReader $in) : Slab{
|
||||||
$in->ignored(StateNames::MC_VERTICAL_HALF);
|
$in->ignored(StateNames::MC_VERTICAL_HALF);
|
||||||
return $block->setSlabType(SlabType::DOUBLE);
|
return $block->setSlabType(SlabType::DOUBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @throws BlockStateDeserializeException */
|
/**
|
||||||
|
* @phpstan-template TStair of Stair
|
||||||
|
* @phpstan-param TStair $block
|
||||||
|
* @phpstan-return TStair
|
||||||
|
*
|
||||||
|
* @throws BlockStateDeserializeException
|
||||||
|
*/
|
||||||
public static function decodeStairs(Stair $block, BlockStateReader $in) : Stair{
|
public static function decodeStairs(Stair $block, BlockStateReader $in) : Stair{
|
||||||
return $block
|
return $block
|
||||||
->setUpsideDown($in->readBool(BlockStateNames::UPSIDE_DOWN_BIT))
|
->setUpsideDown($in->readBool(BlockStateNames::UPSIDE_DOWN_BIT))
|
||||||
@ -265,7 +289,13 @@ final class BlockStateDeserializerHelper{
|
|||||||
->setFacing($facing === Facing::DOWN ? Facing::UP : $facing);
|
->setFacing($facing === Facing::DOWN ? Facing::UP : $facing);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @throws BlockStateDeserializeException */
|
/**
|
||||||
|
* @phpstan-template TTrapdoor of Trapdoor
|
||||||
|
* @phpstan-param TTrapdoor $block
|
||||||
|
* @phpstan-return TTrapdoor
|
||||||
|
*
|
||||||
|
* @throws BlockStateDeserializeException
|
||||||
|
*/
|
||||||
public static function decodeTrapdoor(Trapdoor $block, BlockStateReader $in) : Trapdoor{
|
public static function decodeTrapdoor(Trapdoor $block, BlockStateReader $in) : Trapdoor{
|
||||||
return $block
|
return $block
|
||||||
->setFacing($in->read5MinusHorizontalFacing())
|
->setFacing($in->read5MinusHorizontalFacing())
|
||||||
|
@ -33,11 +33,13 @@ use pocketmine\block\DoublePitcherCrop;
|
|||||||
use pocketmine\block\Opaque;
|
use pocketmine\block\Opaque;
|
||||||
use pocketmine\block\PinkPetals;
|
use pocketmine\block\PinkPetals;
|
||||||
use pocketmine\block\PitcherCrop;
|
use pocketmine\block\PitcherCrop;
|
||||||
|
use pocketmine\block\RuntimeBlockStateRegistry;
|
||||||
use pocketmine\block\Slab;
|
use pocketmine\block\Slab;
|
||||||
use pocketmine\block\Stair;
|
use pocketmine\block\Stair;
|
||||||
use pocketmine\block\SweetBerryBush;
|
use pocketmine\block\SweetBerryBush;
|
||||||
use pocketmine\block\utils\BrewingStandSlot;
|
use pocketmine\block\utils\BrewingStandSlot;
|
||||||
use pocketmine\block\utils\ChiseledBookshelfSlot;
|
use pocketmine\block\utils\ChiseledBookshelfSlot;
|
||||||
|
use pocketmine\block\utils\CopperMaterial;
|
||||||
use pocketmine\block\utils\CopperOxidation;
|
use pocketmine\block\utils\CopperOxidation;
|
||||||
use pocketmine\block\utils\CoralType;
|
use pocketmine\block\utils\CoralType;
|
||||||
use pocketmine\block\utils\DirtType;
|
use pocketmine\block\utils\DirtType;
|
||||||
@ -59,6 +61,7 @@ use pocketmine\data\bedrock\block\convert\BlockStateDeserializerHelper as Helper
|
|||||||
use pocketmine\data\bedrock\block\convert\BlockStateReader as Reader;
|
use pocketmine\data\bedrock\block\convert\BlockStateReader as Reader;
|
||||||
use pocketmine\math\Axis;
|
use pocketmine\math\Axis;
|
||||||
use pocketmine\math\Facing;
|
use pocketmine\math\Facing;
|
||||||
|
use pocketmine\utils\Utils;
|
||||||
use function array_key_exists;
|
use function array_key_exists;
|
||||||
use function count;
|
use function count;
|
||||||
use function min;
|
use function min;
|
||||||
@ -87,6 +90,7 @@ final class BlockStateToObjectDeserializer implements BlockStateDeserializer{
|
|||||||
$this->registerSaplingDeserializers();
|
$this->registerSaplingDeserializers();
|
||||||
$this->registerLightDeserializers();
|
$this->registerLightDeserializers();
|
||||||
$this->registerMobHeadDeserializers();
|
$this->registerMobHeadDeserializers();
|
||||||
|
$this->registerCopperDeserializers();
|
||||||
$this->registerSimpleDeserializers();
|
$this->registerSimpleDeserializers();
|
||||||
$this->registerDeserializers();
|
$this->registerDeserializers();
|
||||||
}
|
}
|
||||||
@ -94,19 +98,37 @@ final class BlockStateToObjectDeserializer implements BlockStateDeserializer{
|
|||||||
public function deserialize(BlockStateData $stateData) : int{
|
public function deserialize(BlockStateData $stateData) : int{
|
||||||
if(count($stateData->getStates()) === 0){
|
if(count($stateData->getStates()) === 0){
|
||||||
//if a block has zero properties, we can keep a map of string ID -> internal blockstate ID
|
//if a block has zero properties, we can keep a map of string ID -> internal blockstate ID
|
||||||
return $this->simpleCache[$stateData->getName()] ??= $this->deserializeBlock($stateData)->getStateId();
|
return $this->simpleCache[$stateData->getName()] ??= $this->deserializeToStateId($stateData);
|
||||||
}
|
}
|
||||||
|
|
||||||
//we can't cache blocks that have properties - go ahead and deserialize the slow way
|
//we can't cache blocks that have properties - go ahead and deserialize the slow way
|
||||||
return $this->deserializeBlock($stateData)->getStateId();
|
return $this->deserializeToStateId($stateData);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function deserializeToStateId(BlockStateData $stateData) : int{
|
||||||
|
$stateId = $this->deserializeBlock($stateData)->getStateId();
|
||||||
|
//plugin devs seem to keep missing this and causing core crashes, so we need to verify this at the earliest
|
||||||
|
//available opportunity
|
||||||
|
if(!RuntimeBlockStateRegistry::getInstance()->hasStateId($stateId)){
|
||||||
|
throw new \LogicException("State ID $stateId returned by deserializer for " . $stateData->getName() . " is not registered in RuntimeBlockStateRegistry");
|
||||||
|
}
|
||||||
|
return $stateId;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @phpstan-param \Closure(Reader) : Block $c */
|
/** @phpstan-param \Closure(Reader) : Block $c */
|
||||||
public function map(string $id, \Closure $c) : void{
|
public function map(string $id, \Closure $c) : void{
|
||||||
if(array_key_exists($id, $this->deserializeFuncs)){
|
|
||||||
throw new \InvalidArgumentException("Deserializer is already assigned for \"$id\"");
|
|
||||||
}
|
|
||||||
$this->deserializeFuncs[$id] = $c;
|
$this->deserializeFuncs[$id] = $c;
|
||||||
|
$this->simpleCache = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the existing data deserializer for the given ID, or null if none exists.
|
||||||
|
* This may be useful if you need to override a deserializer, but still want to be able to fall back to the original.
|
||||||
|
*
|
||||||
|
* @phpstan-return ?\Closure(Reader) : Block
|
||||||
|
*/
|
||||||
|
public function getDeserializerForId(string $id) : ?\Closure{
|
||||||
|
return $this->deserializeFuncs[$id] ?? null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @phpstan-param \Closure() : Block $getBlock */
|
/** @phpstan-param \Closure() : Block $getBlock */
|
||||||
@ -715,6 +737,150 @@ final class BlockStateToObjectDeserializer implements BlockStateDeserializer{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @phpstan-param \Closure(Reader) : (CopperMaterial&Block) $deserializer
|
||||||
|
*/
|
||||||
|
private function mapCopper(
|
||||||
|
string $normalId,
|
||||||
|
string $waxedNormalId,
|
||||||
|
string $exposedId,
|
||||||
|
string $waxedExposedId,
|
||||||
|
string $weatheredId,
|
||||||
|
string $waxedWeatheredId,
|
||||||
|
string $oxidizedId,
|
||||||
|
string $waxedOxidizedId,
|
||||||
|
\Closure $deserializer
|
||||||
|
) : void{
|
||||||
|
foreach(Utils::stringifyKeys([
|
||||||
|
$normalId => [CopperOxidation::NONE, false],
|
||||||
|
$waxedNormalId => [CopperOxidation::NONE, true],
|
||||||
|
$exposedId => [CopperOxidation::EXPOSED, false],
|
||||||
|
$waxedExposedId => [CopperOxidation::EXPOSED, true],
|
||||||
|
$weatheredId => [CopperOxidation::WEATHERED, false],
|
||||||
|
$waxedWeatheredId => [CopperOxidation::WEATHERED, true],
|
||||||
|
$oxidizedId => [CopperOxidation::OXIDIZED, false],
|
||||||
|
$waxedOxidizedId => [CopperOxidation::OXIDIZED, true],
|
||||||
|
]) as $id => [$oxidation, $waxed]){
|
||||||
|
$this->map($id, fn(Reader $in) => $deserializer($in)->setOxidation($oxidation)->setWaxed($waxed));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function registerCopperDeserializers() : void{
|
||||||
|
$this->mapCopper(
|
||||||
|
Ids::CUT_COPPER_SLAB,
|
||||||
|
Ids::WAXED_CUT_COPPER_SLAB,
|
||||||
|
Ids::EXPOSED_CUT_COPPER_SLAB,
|
||||||
|
Ids::WAXED_EXPOSED_CUT_COPPER_SLAB,
|
||||||
|
Ids::WEATHERED_CUT_COPPER_SLAB,
|
||||||
|
Ids::WAXED_WEATHERED_CUT_COPPER_SLAB,
|
||||||
|
Ids::OXIDIZED_CUT_COPPER_SLAB,
|
||||||
|
Ids::WAXED_OXIDIZED_CUT_COPPER_SLAB,
|
||||||
|
fn(Reader $in) => Helper::decodeSingleSlab(Blocks::CUT_COPPER_SLAB(), $in)
|
||||||
|
);
|
||||||
|
$this->mapCopper(
|
||||||
|
Ids::DOUBLE_CUT_COPPER_SLAB,
|
||||||
|
Ids::WAXED_DOUBLE_CUT_COPPER_SLAB,
|
||||||
|
Ids::EXPOSED_DOUBLE_CUT_COPPER_SLAB,
|
||||||
|
Ids::WAXED_EXPOSED_DOUBLE_CUT_COPPER_SLAB,
|
||||||
|
Ids::WEATHERED_DOUBLE_CUT_COPPER_SLAB,
|
||||||
|
Ids::WAXED_WEATHERED_DOUBLE_CUT_COPPER_SLAB,
|
||||||
|
Ids::OXIDIZED_DOUBLE_CUT_COPPER_SLAB,
|
||||||
|
Ids::WAXED_OXIDIZED_DOUBLE_CUT_COPPER_SLAB,
|
||||||
|
fn(Reader $in) => Helper::decodeDoubleSlab(Blocks::CUT_COPPER_SLAB(), $in)
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->mapCopper(
|
||||||
|
Ids::COPPER_BULB,
|
||||||
|
Ids::WAXED_COPPER_BULB,
|
||||||
|
Ids::EXPOSED_COPPER_BULB,
|
||||||
|
Ids::WAXED_EXPOSED_COPPER_BULB,
|
||||||
|
Ids::WEATHERED_COPPER_BULB,
|
||||||
|
Ids::WAXED_WEATHERED_COPPER_BULB,
|
||||||
|
Ids::OXIDIZED_COPPER_BULB,
|
||||||
|
Ids::WAXED_OXIDIZED_COPPER_BULB,
|
||||||
|
fn(Reader $in) => Blocks::COPPER_BULB()
|
||||||
|
->setLit($in->readBool(StateNames::LIT))
|
||||||
|
->setPowered($in->readBool(StateNames::POWERED_BIT))
|
||||||
|
);
|
||||||
|
$this->mapCopper(
|
||||||
|
Ids::COPPER_DOOR,
|
||||||
|
Ids::WAXED_COPPER_DOOR,
|
||||||
|
Ids::EXPOSED_COPPER_DOOR,
|
||||||
|
Ids::WAXED_EXPOSED_COPPER_DOOR,
|
||||||
|
Ids::WEATHERED_COPPER_DOOR,
|
||||||
|
Ids::WAXED_WEATHERED_COPPER_DOOR,
|
||||||
|
Ids::OXIDIZED_COPPER_DOOR,
|
||||||
|
Ids::WAXED_OXIDIZED_COPPER_DOOR,
|
||||||
|
fn(Reader $in) => Helper::decodeDoor(Blocks::COPPER_DOOR(), $in)
|
||||||
|
);
|
||||||
|
$this->mapCopper(
|
||||||
|
Ids::COPPER_TRAPDOOR,
|
||||||
|
Ids::WAXED_COPPER_TRAPDOOR,
|
||||||
|
Ids::EXPOSED_COPPER_TRAPDOOR,
|
||||||
|
Ids::WAXED_EXPOSED_COPPER_TRAPDOOR,
|
||||||
|
Ids::WEATHERED_COPPER_TRAPDOOR,
|
||||||
|
Ids::WAXED_WEATHERED_COPPER_TRAPDOOR,
|
||||||
|
Ids::OXIDIZED_COPPER_TRAPDOOR,
|
||||||
|
Ids::WAXED_OXIDIZED_COPPER_TRAPDOOR,
|
||||||
|
fn(Reader $in) => Helper::decodeTrapdoor(Blocks::COPPER_TRAPDOOR(), $in)
|
||||||
|
);
|
||||||
|
$this->mapCopper(
|
||||||
|
Ids::COPPER_BLOCK,
|
||||||
|
Ids::WAXED_COPPER,
|
||||||
|
Ids::EXPOSED_COPPER,
|
||||||
|
Ids::WAXED_EXPOSED_COPPER,
|
||||||
|
Ids::WEATHERED_COPPER,
|
||||||
|
Ids::WAXED_WEATHERED_COPPER,
|
||||||
|
Ids::OXIDIZED_COPPER,
|
||||||
|
Ids::WAXED_OXIDIZED_COPPER,
|
||||||
|
fn(Reader $in) => Blocks::COPPER()
|
||||||
|
);
|
||||||
|
$this->mapCopper(
|
||||||
|
Ids::CHISELED_COPPER,
|
||||||
|
Ids::WAXED_CHISELED_COPPER,
|
||||||
|
Ids::EXPOSED_CHISELED_COPPER,
|
||||||
|
Ids::WAXED_EXPOSED_CHISELED_COPPER,
|
||||||
|
Ids::WEATHERED_CHISELED_COPPER,
|
||||||
|
Ids::WAXED_WEATHERED_CHISELED_COPPER,
|
||||||
|
Ids::OXIDIZED_CHISELED_COPPER,
|
||||||
|
Ids::WAXED_OXIDIZED_CHISELED_COPPER,
|
||||||
|
fn(Reader $in) => Blocks::CHISELED_COPPER()
|
||||||
|
);
|
||||||
|
$this->mapCopper(
|
||||||
|
Ids::COPPER_GRATE,
|
||||||
|
Ids::WAXED_COPPER_GRATE,
|
||||||
|
Ids::EXPOSED_COPPER_GRATE,
|
||||||
|
Ids::WAXED_EXPOSED_COPPER_GRATE,
|
||||||
|
Ids::WEATHERED_COPPER_GRATE,
|
||||||
|
Ids::WAXED_WEATHERED_COPPER_GRATE,
|
||||||
|
Ids::OXIDIZED_COPPER_GRATE,
|
||||||
|
Ids::WAXED_OXIDIZED_COPPER_GRATE,
|
||||||
|
fn(Reader $in) => Blocks::COPPER_GRATE()
|
||||||
|
);
|
||||||
|
$this->mapCopper(
|
||||||
|
Ids::CUT_COPPER,
|
||||||
|
Ids::WAXED_CUT_COPPER,
|
||||||
|
Ids::EXPOSED_CUT_COPPER,
|
||||||
|
Ids::WAXED_EXPOSED_CUT_COPPER,
|
||||||
|
Ids::WEATHERED_CUT_COPPER,
|
||||||
|
Ids::WAXED_WEATHERED_CUT_COPPER,
|
||||||
|
Ids::OXIDIZED_CUT_COPPER,
|
||||||
|
Ids::WAXED_OXIDIZED_CUT_COPPER,
|
||||||
|
fn(Reader $in) => Blocks::CUT_COPPER()
|
||||||
|
);
|
||||||
|
$this->mapCopper(
|
||||||
|
Ids::CUT_COPPER_STAIRS,
|
||||||
|
Ids::WAXED_CUT_COPPER_STAIRS,
|
||||||
|
Ids::EXPOSED_CUT_COPPER_STAIRS,
|
||||||
|
Ids::WAXED_EXPOSED_CUT_COPPER_STAIRS,
|
||||||
|
Ids::WEATHERED_CUT_COPPER_STAIRS,
|
||||||
|
Ids::WAXED_WEATHERED_CUT_COPPER_STAIRS,
|
||||||
|
Ids::OXIDIZED_CUT_COPPER_STAIRS,
|
||||||
|
Ids::WAXED_OXIDIZED_CUT_COPPER_STAIRS,
|
||||||
|
fn(Reader $in) => Helper::decodeStairs(Blocks::CUT_COPPER_STAIRS(), $in)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
private function registerSimpleDeserializers() : void{
|
private function registerSimpleDeserializers() : void{
|
||||||
$this->mapSimple(Ids::AIR, fn() => Blocks::AIR());
|
$this->mapSimple(Ids::AIR, fn() => Blocks::AIR());
|
||||||
$this->mapSimple(Ids::AMETHYST_BLOCK, fn() => Blocks::AMETHYST());
|
$this->mapSimple(Ids::AMETHYST_BLOCK, fn() => Blocks::AMETHYST());
|
||||||
@ -1220,18 +1386,6 @@ final class BlockStateToObjectDeserializer implements BlockStateDeserializer{
|
|||||||
$this->map(Ids::COMPOUND_CREATOR, fn(Reader $in) => Blocks::COMPOUND_CREATOR()
|
$this->map(Ids::COMPOUND_CREATOR, fn(Reader $in) => Blocks::COMPOUND_CREATOR()
|
||||||
->setFacing(Facing::opposite($in->readLegacyHorizontalFacing()))
|
->setFacing(Facing::opposite($in->readLegacyHorizontalFacing()))
|
||||||
);
|
);
|
||||||
$this->map(Ids::COPPER_BLOCK, fn() => Helper::decodeCopper(Blocks::COPPER(), CopperOxidation::NONE));
|
|
||||||
$this->map(Ids::COPPER_BULB, function(Reader $in) : Block{
|
|
||||||
return Helper::decodeCopper(Blocks::COPPER_BULB(), CopperOxidation::NONE)
|
|
||||||
->setLit($in->readBool(StateNames::LIT))
|
|
||||||
->setPowered($in->readBool(StateNames::POWERED_BIT));
|
|
||||||
});
|
|
||||||
$this->map(Ids::COPPER_DOOR, fn(Reader $in) => Helper::decodeDoor(Helper::decodeCopper(Blocks::COPPER_DOOR(), CopperOxidation::NONE), $in));
|
|
||||||
$this->map(Ids::COPPER_GRATE, fn() => Helper::decodeCopper(Blocks::COPPER_GRATE(), CopperOxidation::NONE));
|
|
||||||
$this->map(Ids::COPPER_TRAPDOOR, fn(Reader $in) => Helper::decodeTrapdoor(Helper::decodeCopper(Blocks::COPPER_TRAPDOOR(), CopperOxidation::NONE), $in));
|
|
||||||
$this->map(Ids::CUT_COPPER, fn() => Helper::decodeCopper(Blocks::CUT_COPPER(), CopperOxidation::NONE));
|
|
||||||
$this->mapSlab(Ids::CUT_COPPER_SLAB, Ids::DOUBLE_CUT_COPPER_SLAB, fn() => Helper::decodeCopper(Blocks::CUT_COPPER_SLAB(), CopperOxidation::NONE));
|
|
||||||
$this->mapStairs(Ids::CUT_COPPER_STAIRS, fn() => Helper::decodeCopper(Blocks::CUT_COPPER_STAIRS(), CopperOxidation::NONE));
|
|
||||||
$this->mapSlab(Ids::CUT_RED_SANDSTONE_SLAB, Ids::CUT_RED_SANDSTONE_DOUBLE_SLAB, fn() => Blocks::CUT_RED_SANDSTONE_SLAB());
|
$this->mapSlab(Ids::CUT_RED_SANDSTONE_SLAB, Ids::CUT_RED_SANDSTONE_DOUBLE_SLAB, fn() => Blocks::CUT_RED_SANDSTONE_SLAB());
|
||||||
$this->mapSlab(Ids::CUT_SANDSTONE_SLAB, Ids::CUT_SANDSTONE_DOUBLE_SLAB, fn() => Blocks::CUT_SANDSTONE_SLAB());
|
$this->mapSlab(Ids::CUT_SANDSTONE_SLAB, Ids::CUT_SANDSTONE_DOUBLE_SLAB, fn() => Blocks::CUT_SANDSTONE_SLAB());
|
||||||
$this->mapSlab(Ids::DARK_PRISMARINE_SLAB, Ids::DARK_PRISMARINE_DOUBLE_SLAB, fn() => Blocks::DARK_PRISMARINE_SLAB());
|
$this->mapSlab(Ids::DARK_PRISMARINE_SLAB, Ids::DARK_PRISMARINE_DOUBLE_SLAB, fn() => Blocks::DARK_PRISMARINE_SLAB());
|
||||||
@ -1286,19 +1440,6 @@ final class BlockStateToObjectDeserializer implements BlockStateDeserializer{
|
|||||||
return Blocks::ENDER_CHEST()
|
return Blocks::ENDER_CHEST()
|
||||||
->setFacing($in->readCardinalHorizontalFacing());
|
->setFacing($in->readCardinalHorizontalFacing());
|
||||||
});
|
});
|
||||||
$this->map(Ids::EXPOSED_COPPER, fn() => Helper::decodeCopper(Blocks::COPPER(), CopperOxidation::EXPOSED));
|
|
||||||
$this->map(Ids::EXPOSED_CHISELED_COPPER, fn() => Helper::decodeCopper(Blocks::CHISELED_COPPER(), CopperOxidation::EXPOSED));
|
|
||||||
$this->map(Ids::EXPOSED_COPPER_GRATE, fn() => Helper::decodeCopper(Blocks::COPPER_GRATE(), CopperOxidation::EXPOSED));
|
|
||||||
$this->map(Ids::EXPOSED_CUT_COPPER, fn() => Helper::decodeCopper(Blocks::CUT_COPPER(), CopperOxidation::EXPOSED));
|
|
||||||
$this->mapSlab(Ids::EXPOSED_CUT_COPPER_SLAB, Ids::EXPOSED_DOUBLE_CUT_COPPER_SLAB, fn() => Helper::decodeCopper(Blocks::CUT_COPPER_SLAB(), CopperOxidation::EXPOSED));
|
|
||||||
$this->mapStairs(Ids::EXPOSED_CUT_COPPER_STAIRS, fn() => Helper::decodeCopper(Blocks::CUT_COPPER_STAIRS(), CopperOxidation::EXPOSED));
|
|
||||||
$this->map(Ids::EXPOSED_COPPER_BULB, function(Reader $in) : Block{
|
|
||||||
return Helper::decodeCopper(Blocks::COPPER_BULB(), CopperOxidation::EXPOSED)
|
|
||||||
->setLit($in->readBool(StateNames::LIT))
|
|
||||||
->setPowered($in->readBool(StateNames::POWERED_BIT));
|
|
||||||
});
|
|
||||||
$this->map(Ids::EXPOSED_COPPER_DOOR, fn(Reader $in) => Helper::decodeDoor(Helper::decodeCopper(Blocks::COPPER_DOOR(), CopperOxidation::EXPOSED), $in));
|
|
||||||
$this->map(Ids::EXPOSED_COPPER_TRAPDOOR, fn(Reader $in) => Helper::decodeTrapdoor(Helper::decodeCopper(Blocks::COPPER_TRAPDOOR(), CopperOxidation::EXPOSED), $in));
|
|
||||||
$this->map(Ids::FARMLAND, function(Reader $in) : Block{
|
$this->map(Ids::FARMLAND, function(Reader $in) : Block{
|
||||||
return Blocks::FARMLAND()
|
return Blocks::FARMLAND()
|
||||||
->setWetness($in->readBoundedInt(StateNames::MOISTURIZED_AMOUNT, 0, 7));
|
->setWetness($in->readBoundedInt(StateNames::MOISTURIZED_AMOUNT, 0, 7));
|
||||||
@ -1451,19 +1592,6 @@ final class BlockStateToObjectDeserializer implements BlockStateDeserializer{
|
|||||||
$this->mapSlab(Ids::NORMAL_STONE_SLAB, Ids::NORMAL_STONE_DOUBLE_SLAB, fn() => Blocks::STONE_SLAB());
|
$this->mapSlab(Ids::NORMAL_STONE_SLAB, Ids::NORMAL_STONE_DOUBLE_SLAB, fn() => Blocks::STONE_SLAB());
|
||||||
$this->mapStairs(Ids::NORMAL_STONE_STAIRS, fn() => Blocks::STONE_STAIRS());
|
$this->mapStairs(Ids::NORMAL_STONE_STAIRS, fn() => Blocks::STONE_STAIRS());
|
||||||
$this->map(Ids::OCHRE_FROGLIGHT, fn(Reader $in) => Blocks::FROGLIGHT()->setFroglightType(FroglightType::OCHRE)->setAxis($in->readPillarAxis()));
|
$this->map(Ids::OCHRE_FROGLIGHT, fn(Reader $in) => Blocks::FROGLIGHT()->setFroglightType(FroglightType::OCHRE)->setAxis($in->readPillarAxis()));
|
||||||
$this->map(Ids::OXIDIZED_COPPER, fn() => Helper::decodeCopper(Blocks::COPPER(), CopperOxidation::OXIDIZED));
|
|
||||||
$this->map(Ids::OXIDIZED_CHISELED_COPPER, fn() => Helper::decodeCopper(Blocks::CHISELED_COPPER(), CopperOxidation::OXIDIZED));
|
|
||||||
$this->map(Ids::OXIDIZED_COPPER_GRATE, fn() => Helper::decodeCopper(Blocks::COPPER_GRATE(), CopperOxidation::OXIDIZED));
|
|
||||||
$this->map(Ids::OXIDIZED_CUT_COPPER, fn() => Helper::decodeCopper(Blocks::CUT_COPPER(), CopperOxidation::OXIDIZED));
|
|
||||||
$this->mapSlab(Ids::OXIDIZED_CUT_COPPER_SLAB, Ids::OXIDIZED_DOUBLE_CUT_COPPER_SLAB, fn() => Helper::decodeCopper(Blocks::CUT_COPPER_SLAB(), CopperOxidation::OXIDIZED));
|
|
||||||
$this->mapStairs(Ids::OXIDIZED_CUT_COPPER_STAIRS, fn() => Helper::decodeCopper(Blocks::CUT_COPPER_STAIRS(), CopperOxidation::OXIDIZED));
|
|
||||||
$this->map(Ids::OXIDIZED_COPPER_BULB, function(Reader $in) : Block{
|
|
||||||
return Helper::decodeCopper(Blocks::COPPER_BULB(), CopperOxidation::OXIDIZED)
|
|
||||||
->setLit($in->readBool(StateNames::LIT))
|
|
||||||
->setPowered($in->readBool(StateNames::POWERED_BIT));
|
|
||||||
});
|
|
||||||
$this->map(Ids::OXIDIZED_COPPER_DOOR, fn(Reader $in) => Helper::decodeDoor(Helper::decodeCopper(Blocks::COPPER_DOOR(), CopperOxidation::OXIDIZED), $in));
|
|
||||||
$this->map(Ids::OXIDIZED_COPPER_TRAPDOOR, fn(Reader $in) => Helper::decodeTrapdoor(Helper::decodeCopper(Blocks::COPPER_TRAPDOOR(), CopperOxidation::OXIDIZED), $in));
|
|
||||||
$this->map(Ids::PEARLESCENT_FROGLIGHT, fn(Reader $in) => Blocks::FROGLIGHT()->setFroglightType(FroglightType::PEARLESCENT)->setAxis($in->readPillarAxis()));
|
$this->map(Ids::PEARLESCENT_FROGLIGHT, fn(Reader $in) => Blocks::FROGLIGHT()->setFroglightType(FroglightType::PEARLESCENT)->setAxis($in->readPillarAxis()));
|
||||||
$this->mapSlab(Ids::PETRIFIED_OAK_SLAB, Ids::PETRIFIED_OAK_DOUBLE_SLAB, fn() => Blocks::FAKE_WOODEN_SLAB());
|
$this->mapSlab(Ids::PETRIFIED_OAK_SLAB, Ids::PETRIFIED_OAK_DOUBLE_SLAB, fn() => Blocks::FAKE_WOODEN_SLAB());
|
||||||
$this->map(Ids::PINK_PETALS, function(Reader $in) : Block{
|
$this->map(Ids::PINK_PETALS, function(Reader $in) : Block{
|
||||||
@ -1736,71 +1864,7 @@ final class BlockStateToObjectDeserializer implements BlockStateDeserializer{
|
|||||||
->setFacing($in->readHorizontalFacing());
|
->setFacing($in->readHorizontalFacing());
|
||||||
});
|
});
|
||||||
$this->map(Ids::WATER, fn(Reader $in) => Helper::decodeStillLiquid(Blocks::WATER(), $in));
|
$this->map(Ids::WATER, fn(Reader $in) => Helper::decodeStillLiquid(Blocks::WATER(), $in));
|
||||||
$this->map(Ids::WAXED_COPPER, fn() => Helper::decodeWaxedCopper(Blocks::COPPER(), CopperOxidation::NONE));
|
|
||||||
$this->map(Ids::WAXED_CHISELED_COPPER, fn() => Helper::decodeWaxedCopper(Blocks::CHISELED_COPPER(), CopperOxidation::NONE));
|
|
||||||
$this->map(Ids::WAXED_COPPER_GRATE, fn() => Helper::decodeWaxedCopper(Blocks::COPPER_GRATE(), CopperOxidation::NONE));
|
|
||||||
$this->map(Ids::WAXED_CUT_COPPER, fn() => Helper::decodeWaxedCopper(Blocks::CUT_COPPER(), CopperOxidation::NONE));
|
|
||||||
$this->mapSlab(Ids::WAXED_CUT_COPPER_SLAB, Ids::WAXED_DOUBLE_CUT_COPPER_SLAB, fn() => Helper::decodeWaxedCopper(Blocks::CUT_COPPER_SLAB(), CopperOxidation::NONE));
|
|
||||||
$this->mapStairs(Ids::WAXED_CUT_COPPER_STAIRS, fn() => Helper::decodeWaxedCopper(Blocks::CUT_COPPER_STAIRS(), CopperOxidation::NONE));
|
|
||||||
$this->map(Ids::WAXED_COPPER_BULB, function(Reader $in) : Block{
|
|
||||||
return Helper::decodeWaxedCopper(Blocks::COPPER_BULB(), CopperOxidation::NONE)
|
|
||||||
->setLit($in->readBool(StateNames::LIT))
|
|
||||||
->setPowered($in->readBool(StateNames::POWERED_BIT));
|
|
||||||
});
|
|
||||||
$this->map(Ids::WAXED_COPPER_DOOR, fn(Reader $in) => Helper::decodeDoor(Helper::decodeWaxedCopper(Blocks::COPPER_DOOR(), CopperOxidation::NONE), $in));
|
|
||||||
$this->map(Ids::WAXED_COPPER_TRAPDOOR, fn(Reader $in) => Helper::decodeTrapdoor(Helper::decodeWaxedCopper(Blocks::COPPER_TRAPDOOR(), CopperOxidation::NONE), $in));
|
|
||||||
$this->map(Ids::WAXED_EXPOSED_COPPER, fn() => Helper::decodeWaxedCopper(Blocks::COPPER(), CopperOxidation::EXPOSED));
|
|
||||||
$this->map(Ids::WAXED_EXPOSED_CHISELED_COPPER, fn() => Helper::decodeWaxedCopper(Blocks::CHISELED_COPPER(), CopperOxidation::EXPOSED));
|
|
||||||
$this->map(Ids::WAXED_EXPOSED_COPPER_GRATE, fn() => Helper::decodeWaxedCopper(Blocks::COPPER_GRATE(), CopperOxidation::EXPOSED));
|
|
||||||
$this->map(Ids::WAXED_EXPOSED_CUT_COPPER, fn() => Helper::decodeWaxedCopper(Blocks::CUT_COPPER(), CopperOxidation::EXPOSED));
|
|
||||||
$this->mapSlab(Ids::WAXED_EXPOSED_CUT_COPPER_SLAB, Ids::WAXED_EXPOSED_DOUBLE_CUT_COPPER_SLAB, fn() => Helper::decodeWaxedCopper(Blocks::CUT_COPPER_SLAB(), CopperOxidation::EXPOSED));
|
|
||||||
$this->mapStairs(Ids::WAXED_EXPOSED_CUT_COPPER_STAIRS, fn() => Helper::decodeWaxedCopper(Blocks::CUT_COPPER_STAIRS(), CopperOxidation::EXPOSED));
|
|
||||||
$this->map(Ids::WAXED_EXPOSED_COPPER_BULB, function(Reader $in) : Block{
|
|
||||||
return Helper::decodeWaxedCopper(Blocks::COPPER_BULB(), CopperOxidation::EXPOSED)
|
|
||||||
->setLit($in->readBool(StateNames::LIT))
|
|
||||||
->setPowered($in->readBool(StateNames::POWERED_BIT));
|
|
||||||
});
|
|
||||||
$this->map(Ids::WAXED_EXPOSED_COPPER_DOOR, fn(Reader $in) => Helper::decodeDoor(Helper::decodeWaxedCopper(Blocks::COPPER_DOOR(), CopperOxidation::EXPOSED), $in));
|
|
||||||
$this->map(Ids::WAXED_EXPOSED_COPPER_TRAPDOOR, fn(Reader $in) => Helper::decodeTrapdoor(Helper::decodeWaxedCopper(Blocks::COPPER_TRAPDOOR(), CopperOxidation::EXPOSED), $in));
|
|
||||||
$this->map(Ids::WAXED_OXIDIZED_COPPER, fn() => Helper::decodeWaxedCopper(Blocks::COPPER(), CopperOxidation::OXIDIZED));
|
|
||||||
$this->map(Ids::WAXED_OXIDIZED_CHISELED_COPPER, fn() => Helper::decodeWaxedCopper(Blocks::CHISELED_COPPER(), CopperOxidation::OXIDIZED));
|
|
||||||
$this->map(Ids::WAXED_OXIDIZED_COPPER_GRATE, fn() => Helper::decodeWaxedCopper(Blocks::COPPER_GRATE(), CopperOxidation::OXIDIZED));
|
|
||||||
$this->map(Ids::WAXED_OXIDIZED_CUT_COPPER, fn() => Helper::decodeWaxedCopper(Blocks::CUT_COPPER(), CopperOxidation::OXIDIZED));
|
|
||||||
$this->mapSlab(Ids::WAXED_OXIDIZED_CUT_COPPER_SLAB, Ids::WAXED_OXIDIZED_DOUBLE_CUT_COPPER_SLAB, fn() => Helper::decodeWaxedCopper(Blocks::CUT_COPPER_SLAB(), CopperOxidation::OXIDIZED));
|
|
||||||
$this->mapStairs(Ids::WAXED_OXIDIZED_CUT_COPPER_STAIRS, fn() => Helper::decodeWaxedCopper(Blocks::CUT_COPPER_STAIRS(), CopperOxidation::OXIDIZED));
|
|
||||||
$this->map(Ids::WAXED_OXIDIZED_COPPER_BULB, function(Reader $in) : Block{
|
|
||||||
return Helper::decodeWaxedCopper(Blocks::COPPER_BULB(), CopperOxidation::OXIDIZED)
|
|
||||||
->setLit($in->readBool(StateNames::LIT))
|
|
||||||
->setPowered($in->readBool(StateNames::POWERED_BIT));
|
|
||||||
});
|
|
||||||
$this->map(Ids::WAXED_OXIDIZED_COPPER_DOOR, fn(Reader $in) => Helper::decodeDoor(Helper::decodeWaxedCopper(Blocks::COPPER_DOOR(), CopperOxidation::OXIDIZED), $in));
|
|
||||||
$this->map(Ids::WAXED_OXIDIZED_COPPER_TRAPDOOR, fn(Reader $in) => Helper::decodeTrapdoor(Helper::decodeWaxedCopper(Blocks::COPPER_TRAPDOOR(), CopperOxidation::OXIDIZED), $in));
|
|
||||||
$this->map(Ids::WAXED_WEATHERED_COPPER, fn() => Helper::decodeWaxedCopper(Blocks::COPPER(), CopperOxidation::WEATHERED));
|
|
||||||
$this->map(Ids::WAXED_WEATHERED_CHISELED_COPPER, fn() => Helper::decodeWaxedCopper(Blocks::CHISELED_COPPER(), CopperOxidation::WEATHERED));
|
|
||||||
$this->map(Ids::WAXED_WEATHERED_COPPER_GRATE, fn() => Helper::decodeWaxedCopper(Blocks::COPPER_GRATE(), CopperOxidation::WEATHERED));
|
|
||||||
$this->map(Ids::WAXED_WEATHERED_CUT_COPPER, fn() => Helper::decodeWaxedCopper(Blocks::CUT_COPPER(), CopperOxidation::WEATHERED));
|
|
||||||
$this->mapSlab(Ids::WAXED_WEATHERED_CUT_COPPER_SLAB, Ids::WAXED_WEATHERED_DOUBLE_CUT_COPPER_SLAB, fn() => Helper::decodeWaxedCopper(Blocks::CUT_COPPER_SLAB(), CopperOxidation::WEATHERED));
|
|
||||||
$this->mapStairs(Ids::WAXED_WEATHERED_CUT_COPPER_STAIRS, fn() => Helper::decodeWaxedCopper(Blocks::CUT_COPPER_STAIRS(), CopperOxidation::WEATHERED));
|
|
||||||
$this->map(Ids::WAXED_WEATHERED_COPPER_BULB, function(Reader $in) : Block{
|
|
||||||
return Helper::decodeWaxedCopper(Blocks::COPPER_BULB(), CopperOxidation::WEATHERED)
|
|
||||||
->setLit($in->readBool(StateNames::LIT))
|
|
||||||
->setPowered($in->readBool(StateNames::POWERED_BIT));
|
|
||||||
});
|
|
||||||
$this->map(Ids::WAXED_WEATHERED_COPPER_DOOR, fn(Reader $in) => Helper::decodeDoor(Helper::decodeWaxedCopper(Blocks::COPPER_DOOR(), CopperOxidation::WEATHERED), $in));
|
|
||||||
$this->map(Ids::WAXED_WEATHERED_COPPER_TRAPDOOR, fn(Reader $in) => Helper::decodeTrapdoor(Helper::decodeWaxedCopper(Blocks::COPPER_TRAPDOOR(), CopperOxidation::WEATHERED), $in));
|
|
||||||
$this->map(Ids::WEATHERED_COPPER, fn() => Helper::decodeCopper(Blocks::COPPER(), CopperOxidation::WEATHERED));
|
|
||||||
$this->map(Ids::WEATHERED_CHISELED_COPPER, fn() => Helper::decodeCopper(Blocks::CHISELED_COPPER(), CopperOxidation::WEATHERED));
|
|
||||||
$this->map(Ids::WEATHERED_COPPER_GRATE, fn() => Helper::decodeCopper(Blocks::COPPER_GRATE(), CopperOxidation::WEATHERED));
|
|
||||||
$this->map(Ids::WEATHERED_CUT_COPPER, fn() => Helper::decodeCopper(Blocks::CUT_COPPER(), CopperOxidation::WEATHERED));
|
|
||||||
$this->mapSlab(Ids::WEATHERED_CUT_COPPER_SLAB, Ids::WEATHERED_DOUBLE_CUT_COPPER_SLAB, fn() => Helper::decodeCopper(Blocks::CUT_COPPER_SLAB(), CopperOxidation::WEATHERED));
|
|
||||||
$this->mapStairs(Ids::WEATHERED_CUT_COPPER_STAIRS, fn() => Helper::decodeCopper(Blocks::CUT_COPPER_STAIRS(), CopperOxidation::WEATHERED));
|
|
||||||
$this->map(Ids::WEATHERED_COPPER_BULB, function(Reader $in) : Block{
|
|
||||||
return Helper::decodeCopper(Blocks::COPPER_BULB(), CopperOxidation::WEATHERED)
|
|
||||||
->setLit($in->readBool(StateNames::LIT))
|
|
||||||
->setPowered($in->readBool(StateNames::POWERED_BIT));
|
|
||||||
});
|
|
||||||
$this->map(Ids::WEATHERED_COPPER_DOOR, fn(Reader $in) => Helper::decodeDoor(Helper::decodeCopper(Blocks::COPPER_DOOR(), CopperOxidation::WEATHERED), $in));
|
|
||||||
$this->map(Ids::WEATHERED_COPPER_TRAPDOOR, fn(Reader $in) => Helper::decodeTrapdoor(Helper::decodeCopper(Blocks::COPPER_TRAPDOOR(), CopperOxidation::WEATHERED), $in));
|
|
||||||
$this->map(Ids::WEEPING_VINES, function(Reader $in) : Block{
|
$this->map(Ids::WEEPING_VINES, function(Reader $in) : Block{
|
||||||
return Blocks::WEEPING_VINES()
|
return Blocks::WEEPING_VINES()
|
||||||
->setAge($in->readBoundedInt(StateNames::WEEPING_VINES_AGE, 0, 25));
|
->setAge($in->readBoundedInt(StateNames::WEEPING_VINES_AGE, 0, 25));
|
||||||
|
@ -51,12 +51,19 @@ final class ItemDeserializer{
|
|||||||
* @phpstan-param \Closure(Data) : Item $deserializer
|
* @phpstan-param \Closure(Data) : Item $deserializer
|
||||||
*/
|
*/
|
||||||
public function map(string $id, \Closure $deserializer) : void{
|
public function map(string $id, \Closure $deserializer) : void{
|
||||||
if(isset($this->deserializers[$id])){
|
|
||||||
throw new \InvalidArgumentException("Deserializer is already assigned for \"$id\"");
|
|
||||||
}
|
|
||||||
$this->deserializers[$id] = $deserializer;
|
$this->deserializers[$id] = $deserializer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the existing data deserializer for the given ID, or null if none exists.
|
||||||
|
* This may be useful if you need to override a deserializer, but still want to be able to fall back to the original.
|
||||||
|
*
|
||||||
|
* @phpstan-return ?\Closure(Data) : Item
|
||||||
|
*/
|
||||||
|
public function getDeserializerForId(string $id) : ?\Closure{
|
||||||
|
return $this->deserializers[$id] ?? null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @phpstan-param \Closure(Data) : Block $deserializer
|
* @phpstan-param \Closure(Data) : Block $deserializer
|
||||||
*/
|
*/
|
||||||
|
@ -144,8 +144,9 @@ class InventoryTransaction{
|
|||||||
$needItems = [];
|
$needItems = [];
|
||||||
$haveItems = [];
|
$haveItems = [];
|
||||||
foreach($this->actions as $key => $action){
|
foreach($this->actions as $key => $action){
|
||||||
if(!$action->getTargetItem()->isNull()){
|
$targetItem = $action->getTargetItem();
|
||||||
$needItems[] = $action->getTargetItem();
|
if(!$targetItem->isNull()){
|
||||||
|
$needItems[] = $targetItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
try{
|
try{
|
||||||
@ -154,8 +155,9 @@ class InventoryTransaction{
|
|||||||
throw new TransactionValidationException(get_class($action) . "#" . spl_object_id($action) . ": " . $e->getMessage(), 0, $e);
|
throw new TransactionValidationException(get_class($action) . "#" . spl_object_id($action) . ": " . $e->getMessage(), 0, $e);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!$action->getSourceItem()->isNull()){
|
$sourceItem = $action->getSourceItem();
|
||||||
$haveItems[] = $action->getSourceItem();
|
if(!$sourceItem->isNull()){
|
||||||
|
$haveItems[] = $sourceItem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
8
src/network/mcpe/cache/ChunkCache.php
vendored
8
src/network/mcpe/cache/ChunkCache.php
vendored
@ -88,9 +88,13 @@ class ChunkCache implements ChunkListener{
|
|||||||
private int $hits = 0;
|
private int $hits = 0;
|
||||||
private int $misses = 0;
|
private int $misses = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @phpstan-param DimensionIds::* $dimensionId
|
||||||
|
*/
|
||||||
private function __construct(
|
private function __construct(
|
||||||
private World $world,
|
private World $world,
|
||||||
private Compressor $compressor
|
private Compressor $compressor,
|
||||||
|
private int $dimensionId = DimensionIds::OVERWORLD
|
||||||
){}
|
){}
|
||||||
|
|
||||||
private function prepareChunkAsync(int $chunkX, int $chunkZ, int $chunkHash) : CompressBatchPromise{
|
private function prepareChunkAsync(int $chunkX, int $chunkZ, int $chunkHash) : CompressBatchPromise{
|
||||||
@ -109,7 +113,7 @@ class ChunkCache implements ChunkListener{
|
|||||||
new ChunkRequestTask(
|
new ChunkRequestTask(
|
||||||
$chunkX,
|
$chunkX,
|
||||||
$chunkZ,
|
$chunkZ,
|
||||||
DimensionIds::OVERWORLD, //TODO: not hardcode this
|
$this->dimensionId,
|
||||||
$chunk,
|
$chunk,
|
||||||
$promise,
|
$promise,
|
||||||
$this->compressor
|
$this->compressor
|
||||||
|
@ -25,6 +25,8 @@ namespace pocketmine\player;
|
|||||||
|
|
||||||
use pocketmine\block\Block;
|
use pocketmine\block\Block;
|
||||||
use pocketmine\entity\animation\ArmSwingAnimation;
|
use pocketmine\entity\animation\ArmSwingAnimation;
|
||||||
|
use pocketmine\entity\effect\VanillaEffects;
|
||||||
|
use pocketmine\item\enchantment\VanillaEnchantments;
|
||||||
use pocketmine\math\Facing;
|
use pocketmine\math\Facing;
|
||||||
use pocketmine\math\Vector3;
|
use pocketmine\math\Vector3;
|
||||||
use pocketmine\network\mcpe\protocol\LevelEventPacket;
|
use pocketmine\network\mcpe\protocol\LevelEventPacket;
|
||||||
@ -65,11 +67,29 @@ final class SurvivalBlockBreakHandler{
|
|||||||
if(!$this->block->getBreakInfo()->isBreakable()){
|
if(!$this->block->getBreakInfo()->isBreakable()){
|
||||||
return 0.0;
|
return 0.0;
|
||||||
}
|
}
|
||||||
//TODO: improve this to take stuff like swimming, ladders, enchanted tools into account, fix wrong tool break time calculations for bad tools (pmmp/PocketMine-MP#211)
|
|
||||||
$breakTimePerTick = $this->block->getBreakInfo()->getBreakTime($this->player->getInventory()->getItemInHand()) * 20;
|
$breakTimePerTick = $this->block->getBreakInfo()->getBreakTime($this->player->getInventory()->getItemInHand()) * 20;
|
||||||
|
if(!$this->player->isOnGround() && !$this->player->isFlying()){
|
||||||
|
$breakTimePerTick *= 5;
|
||||||
|
}
|
||||||
|
if($this->player->isUnderwater() && !$this->player->getArmorInventory()->getHelmet()->hasEnchantment(VanillaEnchantments::AQUA_AFFINITY())){
|
||||||
|
$breakTimePerTick *= 5;
|
||||||
|
}
|
||||||
if($breakTimePerTick > 0){
|
if($breakTimePerTick > 0){
|
||||||
return 1 / $breakTimePerTick;
|
$progressPerTick = 1 / $breakTimePerTick;
|
||||||
|
|
||||||
|
$haste = $this->player->getEffects()->get(VanillaEffects::HASTE());
|
||||||
|
if($haste !== null){
|
||||||
|
$hasteLevel = $haste->getEffectLevel();
|
||||||
|
$progressPerTick *= (1 + 0.2 * $hasteLevel) * (1.2 ** $hasteLevel);
|
||||||
|
}
|
||||||
|
|
||||||
|
$miningFatigue = $this->player->getEffects()->get(VanillaEffects::MINING_FATIGUE());
|
||||||
|
if($miningFatigue !== null){
|
||||||
|
$miningFatigueLevel = $miningFatigue->getEffectLevel();
|
||||||
|
$progressPerTick *= 0.21 ** $miningFatigueLevel;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $progressPerTick;
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -82,7 +102,10 @@ final class SurvivalBlockBreakHandler{
|
|||||||
$newBreakSpeed = $this->calculateBreakProgressPerTick();
|
$newBreakSpeed = $this->calculateBreakProgressPerTick();
|
||||||
if(abs($newBreakSpeed - $this->breakSpeed) > 0.0001){
|
if(abs($newBreakSpeed - $this->breakSpeed) > 0.0001){
|
||||||
$this->breakSpeed = $newBreakSpeed;
|
$this->breakSpeed = $newBreakSpeed;
|
||||||
//TODO: sync with client
|
$this->player->getWorld()->broadcastPacketToViewers(
|
||||||
|
$this->blockPos,
|
||||||
|
LevelEventPacket::create(LevelEvent::BLOCK_BREAK_SPEED, (int) (65535 * $this->breakSpeed), $this->blockPos)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->breakProgress += $this->breakSpeed;
|
$this->breakProgress += $this->breakSpeed;
|
||||||
|
@ -69,6 +69,7 @@ abstract class Terminal{
|
|||||||
public static string $COLOR_MATERIAL_DIAMOND = "";
|
public static string $COLOR_MATERIAL_DIAMOND = "";
|
||||||
public static string $COLOR_MATERIAL_LAPIS = "";
|
public static string $COLOR_MATERIAL_LAPIS = "";
|
||||||
public static string $COLOR_MATERIAL_AMETHYST = "";
|
public static string $COLOR_MATERIAL_AMETHYST = "";
|
||||||
|
public static string $COLOR_MATERIAL_RESIN = "";
|
||||||
|
|
||||||
private static ?bool $formattingCodes = null;
|
private static ?bool $formattingCodes = null;
|
||||||
|
|
||||||
@ -131,6 +132,7 @@ abstract class Terminal{
|
|||||||
self::$COLOR_MATERIAL_DIAMOND = $color(37);
|
self::$COLOR_MATERIAL_DIAMOND = $color(37);
|
||||||
self::$COLOR_MATERIAL_LAPIS = $color(24);
|
self::$COLOR_MATERIAL_LAPIS = $color(24);
|
||||||
self::$COLOR_MATERIAL_AMETHYST = $color(98);
|
self::$COLOR_MATERIAL_AMETHYST = $color(98);
|
||||||
|
self::$COLOR_MATERIAL_RESIN = $color(208);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static function getEscapeCodes() : void{
|
protected static function getEscapeCodes() : void{
|
||||||
@ -174,11 +176,12 @@ abstract class Terminal{
|
|||||||
self::$COLOR_MATERIAL_DIAMOND = $colors >= 256 ? $setaf(37) : $setaf(14);
|
self::$COLOR_MATERIAL_DIAMOND = $colors >= 256 ? $setaf(37) : $setaf(14);
|
||||||
self::$COLOR_MATERIAL_LAPIS = $colors >= 256 ? $setaf(24) : $setaf(12);
|
self::$COLOR_MATERIAL_LAPIS = $colors >= 256 ? $setaf(24) : $setaf(12);
|
||||||
self::$COLOR_MATERIAL_AMETHYST = $colors >= 256 ? $setaf(98) : $setaf(13);
|
self::$COLOR_MATERIAL_AMETHYST = $colors >= 256 ? $setaf(98) : $setaf(13);
|
||||||
|
self::$COLOR_MATERIAL_RESIN = $colors >= 256 ? $setaf(208) : $setaf(11);
|
||||||
}else{
|
}else{
|
||||||
self::$COLOR_BLACK = self::$COLOR_DARK_GRAY = self::$COLOR_MATERIAL_NETHERITE = $setaf(0);
|
self::$COLOR_BLACK = self::$COLOR_DARK_GRAY = self::$COLOR_MATERIAL_NETHERITE = $setaf(0);
|
||||||
self::$COLOR_RED = self::$COLOR_DARK_RED = self::$COLOR_MATERIAL_REDSTONE = self::$COLOR_MATERIAL_COPPER = $setaf(1);
|
self::$COLOR_RED = self::$COLOR_DARK_RED = self::$COLOR_MATERIAL_REDSTONE = self::$COLOR_MATERIAL_COPPER = $setaf(1);
|
||||||
self::$COLOR_GREEN = self::$COLOR_DARK_GREEN = self::$COLOR_MATERIAL_EMERALD = $setaf(2);
|
self::$COLOR_GREEN = self::$COLOR_DARK_GREEN = self::$COLOR_MATERIAL_EMERALD = $setaf(2);
|
||||||
self::$COLOR_YELLOW = self::$COLOR_GOLD = self::$COLOR_MINECOIN_GOLD = self::$COLOR_MATERIAL_GOLD = $setaf(3);
|
self::$COLOR_YELLOW = self::$COLOR_GOLD = self::$COLOR_MINECOIN_GOLD = self::$COLOR_MATERIAL_GOLD = self::$COLOR_MATERIAL_RESIN = $setaf(3);
|
||||||
self::$COLOR_BLUE = self::$COLOR_DARK_BLUE = self::$COLOR_MATERIAL_LAPIS = $setaf(4);
|
self::$COLOR_BLUE = self::$COLOR_DARK_BLUE = self::$COLOR_MATERIAL_LAPIS = $setaf(4);
|
||||||
self::$COLOR_LIGHT_PURPLE = self::$COLOR_PURPLE = self::$COLOR_MATERIAL_AMETHYST = $setaf(5);
|
self::$COLOR_LIGHT_PURPLE = self::$COLOR_PURPLE = self::$COLOR_MATERIAL_AMETHYST = $setaf(5);
|
||||||
self::$COLOR_AQUA = self::$COLOR_DARK_AQUA = self::$COLOR_MATERIAL_DIAMOND = $setaf(6);
|
self::$COLOR_AQUA = self::$COLOR_DARK_AQUA = self::$COLOR_MATERIAL_DIAMOND = $setaf(6);
|
||||||
@ -253,6 +256,7 @@ abstract class Terminal{
|
|||||||
TextFormat::MATERIAL_DIAMOND => Terminal::$COLOR_MATERIAL_DIAMOND,
|
TextFormat::MATERIAL_DIAMOND => Terminal::$COLOR_MATERIAL_DIAMOND,
|
||||||
TextFormat::MATERIAL_LAPIS => Terminal::$COLOR_MATERIAL_LAPIS,
|
TextFormat::MATERIAL_LAPIS => Terminal::$COLOR_MATERIAL_LAPIS,
|
||||||
TextFormat::MATERIAL_AMETHYST => Terminal::$COLOR_MATERIAL_AMETHYST,
|
TextFormat::MATERIAL_AMETHYST => Terminal::$COLOR_MATERIAL_AMETHYST,
|
||||||
|
TextFormat::MATERIAL_RESIN => Terminal::$COLOR_MATERIAL_RESIN,
|
||||||
default => $token,
|
default => $token,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -73,6 +73,7 @@ abstract class TextFormat{
|
|||||||
public const MATERIAL_DIAMOND = TextFormat::ESCAPE . "s";
|
public const MATERIAL_DIAMOND = TextFormat::ESCAPE . "s";
|
||||||
public const MATERIAL_LAPIS = TextFormat::ESCAPE . "t";
|
public const MATERIAL_LAPIS = TextFormat::ESCAPE . "t";
|
||||||
public const MATERIAL_AMETHYST = TextFormat::ESCAPE . "u";
|
public const MATERIAL_AMETHYST = TextFormat::ESCAPE . "u";
|
||||||
|
public const MATERIAL_RESIN = TextFormat::ESCAPE . "v";
|
||||||
|
|
||||||
public const COLORS = [
|
public const COLORS = [
|
||||||
self::BLACK => self::BLACK,
|
self::BLACK => self::BLACK,
|
||||||
@ -102,6 +103,7 @@ abstract class TextFormat{
|
|||||||
self::MATERIAL_DIAMOND => self::MATERIAL_DIAMOND,
|
self::MATERIAL_DIAMOND => self::MATERIAL_DIAMOND,
|
||||||
self::MATERIAL_LAPIS => self::MATERIAL_LAPIS,
|
self::MATERIAL_LAPIS => self::MATERIAL_LAPIS,
|
||||||
self::MATERIAL_AMETHYST => self::MATERIAL_AMETHYST,
|
self::MATERIAL_AMETHYST => self::MATERIAL_AMETHYST,
|
||||||
|
self::MATERIAL_RESIN => self::MATERIAL_RESIN,
|
||||||
];
|
];
|
||||||
|
|
||||||
public const OBFUSCATED = TextFormat::ESCAPE . "k";
|
public const OBFUSCATED = TextFormat::ESCAPE . "k";
|
||||||
@ -150,7 +152,7 @@ abstract class TextFormat{
|
|||||||
* @return string[]
|
* @return string[]
|
||||||
*/
|
*/
|
||||||
public static function tokenize(string $string) : array{
|
public static function tokenize(string $string) : array{
|
||||||
$result = preg_split("/(" . TextFormat::ESCAPE . "[0-9a-u])/u", $string, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE);
|
$result = preg_split("/(" . TextFormat::ESCAPE . "[0-9a-v])/u", $string, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE);
|
||||||
if($result === false) throw self::makePcreError();
|
if($result === false) throw self::makePcreError();
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
@ -164,7 +166,7 @@ abstract class TextFormat{
|
|||||||
$string = mb_scrub($string, 'UTF-8');
|
$string = mb_scrub($string, 'UTF-8');
|
||||||
$string = self::preg_replace("/[\x{E000}-\x{F8FF}]/u", "", $string); //remove unicode private-use-area characters (they might break the console)
|
$string = self::preg_replace("/[\x{E000}-\x{F8FF}]/u", "", $string); //remove unicode private-use-area characters (they might break the console)
|
||||||
if($removeFormat){
|
if($removeFormat){
|
||||||
$string = str_replace(TextFormat::ESCAPE, "", self::preg_replace("/" . TextFormat::ESCAPE . "[0-9a-u]/u", "", $string));
|
$string = str_replace(TextFormat::ESCAPE, "", self::preg_replace("/" . TextFormat::ESCAPE . "[0-9a-v]/u", "", $string));
|
||||||
}
|
}
|
||||||
return str_replace("\x1b", "", self::preg_replace("/\x1b[\\(\\][[0-9;\\[\\(]+[Bm]/u", "", $string));
|
return str_replace("\x1b", "", self::preg_replace("/\x1b[\\(\\][[0-9;\\[\\(]+[Bm]/u", "", $string));
|
||||||
}
|
}
|
||||||
@ -175,7 +177,7 @@ abstract class TextFormat{
|
|||||||
* @param string $placeholder default "&"
|
* @param string $placeholder default "&"
|
||||||
*/
|
*/
|
||||||
public static function colorize(string $string, string $placeholder = "&") : string{
|
public static function colorize(string $string, string $placeholder = "&") : string{
|
||||||
return self::preg_replace('/' . preg_quote($placeholder, "/") . '([0-9a-u])/u', TextFormat::ESCAPE . '$1', $string);
|
return self::preg_replace('/' . preg_quote($placeholder, "/") . '([0-9a-v])/u', TextFormat::ESCAPE . '$1', $string);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -252,6 +254,7 @@ abstract class TextFormat{
|
|||||||
TextFormat::MATERIAL_DIAMOND => "color:#2cb9a8",
|
TextFormat::MATERIAL_DIAMOND => "color:#2cb9a8",
|
||||||
TextFormat::MATERIAL_LAPIS => "color:#20487a",
|
TextFormat::MATERIAL_LAPIS => "color:#20487a",
|
||||||
TextFormat::MATERIAL_AMETHYST => "color:#9a5cc5",
|
TextFormat::MATERIAL_AMETHYST => "color:#9a5cc5",
|
||||||
|
TextFormat::MATERIAL_RESIN => "color:#fc7812",
|
||||||
TextFormat::BOLD => "font-weight:bold",
|
TextFormat::BOLD => "font-weight:bold",
|
||||||
TextFormat::ITALIC => "font-style:italic",
|
TextFormat::ITALIC => "font-style:italic",
|
||||||
default => null
|
default => null
|
||||||
|
@ -375,6 +375,8 @@ class World implements ChunkManager{
|
|||||||
|
|
||||||
private \Logger $logger;
|
private \Logger $logger;
|
||||||
|
|
||||||
|
private RuntimeBlockStateRegistry $blockStateRegistry;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @phpstan-return ChunkPosHash
|
* @phpstan-return ChunkPosHash
|
||||||
*/
|
*/
|
||||||
@ -488,6 +490,7 @@ class World implements ChunkManager{
|
|||||||
$this->displayName = $this->provider->getWorldData()->getName();
|
$this->displayName = $this->provider->getWorldData()->getName();
|
||||||
$this->logger = new \PrefixedLogger($server->getLogger(), "World: $this->displayName");
|
$this->logger = new \PrefixedLogger($server->getLogger(), "World: $this->displayName");
|
||||||
|
|
||||||
|
$this->blockStateRegistry = RuntimeBlockStateRegistry::getInstance();
|
||||||
$this->minY = $this->provider->getWorldMinY();
|
$this->minY = $this->provider->getWorldMinY();
|
||||||
$this->maxY = $this->provider->getWorldMaxY();
|
$this->maxY = $this->provider->getWorldMaxY();
|
||||||
|
|
||||||
@ -559,7 +562,7 @@ class World implements ChunkManager{
|
|||||||
}catch(BlockStateDeserializeException){
|
}catch(BlockStateDeserializeException){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$block = RuntimeBlockStateRegistry::getInstance()->fromStateId(GlobalBlockStateHandlers::getDeserializer()->deserialize($blockStateData));
|
$block = $this->blockStateRegistry->fromStateId(GlobalBlockStateHandlers::getDeserializer()->deserialize($blockStateData));
|
||||||
}else{
|
}else{
|
||||||
//TODO: we probably ought to log an error here
|
//TODO: we probably ought to log an error here
|
||||||
continue;
|
continue;
|
||||||
@ -570,7 +573,7 @@ class World implements ChunkManager{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach(RuntimeBlockStateRegistry::getInstance()->getAllKnownStates() as $state){
|
foreach($this->blockStateRegistry->getAllKnownStates() as $state){
|
||||||
$dontTickName = $dontTickBlocks[$state->getTypeId()] ?? null;
|
$dontTickName = $dontTickBlocks[$state->getTypeId()] ?? null;
|
||||||
if($dontTickName === null && $state->ticksRandomly()){
|
if($dontTickName === null && $state->ticksRandomly()){
|
||||||
$this->randomTickBlocks[$state->getStateId()] = true;
|
$this->randomTickBlocks[$state->getStateId()] = true;
|
||||||
@ -1394,7 +1397,7 @@ class World implements ChunkManager{
|
|||||||
$entity->onRandomUpdate();
|
$entity->onRandomUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
$blockFactory = RuntimeBlockStateRegistry::getInstance();
|
$blockFactory = $this->blockStateRegistry;
|
||||||
foreach($chunk->getSubChunks() as $Y => $subChunk){
|
foreach($chunk->getSubChunks() as $Y => $subChunk){
|
||||||
if(!$subChunk->isEmptyFast()){
|
if(!$subChunk->isEmptyFast()){
|
||||||
$k = 0;
|
$k = 0;
|
||||||
@ -1528,24 +1531,48 @@ class World implements ChunkManager{
|
|||||||
|
|
||||||
$collides = [];
|
$collides = [];
|
||||||
|
|
||||||
|
$collisionInfo = $this->blockStateRegistry->collisionInfo;
|
||||||
if($targetFirst){
|
if($targetFirst){
|
||||||
for($z = $minZ; $z <= $maxZ; ++$z){
|
for($z = $minZ; $z <= $maxZ; ++$z){
|
||||||
|
$zOverflow = $z === $minZ || $z === $maxZ;
|
||||||
for($x = $minX; $x <= $maxX; ++$x){
|
for($x = $minX; $x <= $maxX; ++$x){
|
||||||
|
$zxOverflow = $zOverflow || $x === $minX || $x === $maxX;
|
||||||
for($y = $minY; $y <= $maxY; ++$y){
|
for($y = $minY; $y <= $maxY; ++$y){
|
||||||
$block = $this->getBlockAt($x, $y, $z);
|
$overflow = $zxOverflow || $y === $minY || $y === $maxY;
|
||||||
if($block->collidesWithBB($bb)){
|
|
||||||
return [$block];
|
$stateCollisionInfo = $this->getBlockCollisionInfo($x, $y, $z, $collisionInfo);
|
||||||
|
if($overflow ?
|
||||||
|
$stateCollisionInfo === RuntimeBlockStateRegistry::COLLISION_MAY_OVERFLOW && $this->getBlockAt($x, $y, $z)->collidesWithBB($bb) :
|
||||||
|
match ($stateCollisionInfo) {
|
||||||
|
RuntimeBlockStateRegistry::COLLISION_CUBE => true,
|
||||||
|
RuntimeBlockStateRegistry::COLLISION_NONE => false,
|
||||||
|
default => $this->getBlockAt($x, $y, $z)->collidesWithBB($bb)
|
||||||
|
}
|
||||||
|
){
|
||||||
|
return [$this->getBlockAt($x, $y, $z)];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
|
//TODO: duplicated code :( this way is better for performance though
|
||||||
for($z = $minZ; $z <= $maxZ; ++$z){
|
for($z = $minZ; $z <= $maxZ; ++$z){
|
||||||
|
$zOverflow = $z === $minZ || $z === $maxZ;
|
||||||
for($x = $minX; $x <= $maxX; ++$x){
|
for($x = $minX; $x <= $maxX; ++$x){
|
||||||
|
$zxOverflow = $zOverflow || $x === $minX || $x === $maxX;
|
||||||
for($y = $minY; $y <= $maxY; ++$y){
|
for($y = $minY; $y <= $maxY; ++$y){
|
||||||
$block = $this->getBlockAt($x, $y, $z);
|
$overflow = $zxOverflow || $y === $minY || $y === $maxY;
|
||||||
if($block->collidesWithBB($bb)){
|
|
||||||
$collides[] = $block;
|
$stateCollisionInfo = $this->getBlockCollisionInfo($x, $y, $z, $collisionInfo);
|
||||||
|
if($overflow ?
|
||||||
|
$stateCollisionInfo === RuntimeBlockStateRegistry::COLLISION_MAY_OVERFLOW && $this->getBlockAt($x, $y, $z)->collidesWithBB($bb) :
|
||||||
|
match ($stateCollisionInfo) {
|
||||||
|
RuntimeBlockStateRegistry::COLLISION_CUBE => true,
|
||||||
|
RuntimeBlockStateRegistry::COLLISION_NONE => false,
|
||||||
|
default => $this->getBlockAt($x, $y, $z)->collidesWithBB($bb)
|
||||||
|
}
|
||||||
|
){
|
||||||
|
$collides[] = $this->getBlockAt($x, $y, $z);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1555,24 +1582,64 @@ class World implements ChunkManager{
|
|||||||
return $collides;
|
return $collides;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param int[] $collisionInfo
|
||||||
|
* @phpstan-param array<int, int> $collisionInfo
|
||||||
|
*/
|
||||||
|
private function getBlockCollisionInfo(int $x, int $y, int $z, array $collisionInfo) : int{
|
||||||
|
if(!$this->isInWorld($x, $y, $z)){
|
||||||
|
return RuntimeBlockStateRegistry::COLLISION_NONE;
|
||||||
|
}
|
||||||
|
$chunk = $this->getChunk($x >> Chunk::COORD_BIT_SIZE, $z >> Chunk::COORD_BIT_SIZE);
|
||||||
|
if($chunk === null){
|
||||||
|
return RuntimeBlockStateRegistry::COLLISION_NONE;
|
||||||
|
}
|
||||||
|
$stateId = $chunk
|
||||||
|
->getSubChunk($y >> SubChunk::COORD_BIT_SIZE)
|
||||||
|
->getBlockStateId(
|
||||||
|
$x & SubChunk::COORD_MASK,
|
||||||
|
$y & SubChunk::COORD_MASK,
|
||||||
|
$z & SubChunk::COORD_MASK
|
||||||
|
);
|
||||||
|
return $collisionInfo[$stateId];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a list of all block AABBs which overlap the full block area at the given coordinates.
|
* Returns a list of all block AABBs which overlap the full block area at the given coordinates.
|
||||||
* This checks a padding of 1 block around the coordinates to account for oversized AABBs of blocks like fences.
|
* This checks a padding of 1 block around the coordinates to account for oversized AABBs of blocks like fences.
|
||||||
* Larger AABBs (>= 2 blocks on any axis) are not accounted for.
|
* Larger AABBs (>= 2 blocks on any axis) are not accounted for.
|
||||||
*
|
*
|
||||||
|
* @param int[] $collisionInfo
|
||||||
|
* @phpstan-param array<int, int> $collisionInfo
|
||||||
|
*
|
||||||
* @return AxisAlignedBB[]
|
* @return AxisAlignedBB[]
|
||||||
* @phpstan-return list<AxisAlignedBB>
|
* @phpstan-return list<AxisAlignedBB>
|
||||||
*/
|
*/
|
||||||
private function getBlockCollisionBoxesForCell(int $x, int $y, int $z) : array{
|
private function getBlockCollisionBoxesForCell(int $x, int $y, int $z, array $collisionInfo) : array{
|
||||||
$block = $this->getBlockAt($x, $y, $z);
|
$stateCollisionInfo = $this->getBlockCollisionInfo($x, $y, $z, $collisionInfo);
|
||||||
$boxes = $block->getCollisionBoxes();
|
$boxes = match($stateCollisionInfo){
|
||||||
|
RuntimeBlockStateRegistry::COLLISION_NONE => [],
|
||||||
|
RuntimeBlockStateRegistry::COLLISION_CUBE => [AxisAlignedBB::one()->offset($x, $y, $z)],
|
||||||
|
default => $this->getBlockAt($x, $y, $z)->getCollisionBoxes()
|
||||||
|
};
|
||||||
|
|
||||||
$cellBB = AxisAlignedBB::one()->offset($x, $y, $z);
|
//overlapping AABBs can't make any difference if this is a cube, so we can save some CPU cycles in this common case
|
||||||
foreach(Facing::OFFSET as [$dx, $dy, $dz]){
|
if($stateCollisionInfo !== RuntimeBlockStateRegistry::COLLISION_CUBE){
|
||||||
$extraBoxes = $this->getBlockAt($x + $dx, $y + $dy, $z + $dz)->getCollisionBoxes();
|
$cellBB = null;
|
||||||
foreach($extraBoxes as $extraBox){
|
foreach(Facing::OFFSET as [$dx, $dy, $dz]){
|
||||||
if($extraBox->intersectsWith($cellBB)){
|
$offsetX = $x + $dx;
|
||||||
$boxes[] = $extraBox;
|
$offsetY = $y + $dy;
|
||||||
|
$offsetZ = $z + $dz;
|
||||||
|
$stateCollisionInfo = $this->getBlockCollisionInfo($offsetX, $offsetY, $offsetZ, $collisionInfo);
|
||||||
|
if($stateCollisionInfo === RuntimeBlockStateRegistry::COLLISION_MAY_OVERFLOW){
|
||||||
|
//avoid allocating this unless it's needed
|
||||||
|
$cellBB ??= AxisAlignedBB::one()->offset($x, $y, $z);
|
||||||
|
$extraBoxes = $this->getBlockAt($offsetX, $offsetY, $offsetZ)->getCollisionBoxes();
|
||||||
|
foreach($extraBoxes as $extraBox){
|
||||||
|
if($extraBox->intersectsWith($cellBB)){
|
||||||
|
$boxes[] = $extraBox;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1594,13 +1661,15 @@ class World implements ChunkManager{
|
|||||||
|
|
||||||
$collides = [];
|
$collides = [];
|
||||||
|
|
||||||
|
$collisionInfo = $this->blockStateRegistry->collisionInfo;
|
||||||
|
|
||||||
for($z = $minZ; $z <= $maxZ; ++$z){
|
for($z = $minZ; $z <= $maxZ; ++$z){
|
||||||
for($x = $minX; $x <= $maxX; ++$x){
|
for($x = $minX; $x <= $maxX; ++$x){
|
||||||
$chunkPosHash = World::chunkHash($x >> Chunk::COORD_BIT_SIZE, $z >> Chunk::COORD_BIT_SIZE);
|
$chunkPosHash = World::chunkHash($x >> Chunk::COORD_BIT_SIZE, $z >> Chunk::COORD_BIT_SIZE);
|
||||||
for($y = $minY; $y <= $maxY; ++$y){
|
for($y = $minY; $y <= $maxY; ++$y){
|
||||||
$relativeBlockHash = World::chunkBlockHash($x, $y, $z);
|
$relativeBlockHash = World::chunkBlockHash($x, $y, $z);
|
||||||
|
|
||||||
$boxes = $this->blockCollisionBoxCache[$chunkPosHash][$relativeBlockHash] ??= $this->getBlockCollisionBoxesForCell($x, $y, $z);
|
$boxes = $this->blockCollisionBoxCache[$chunkPosHash][$relativeBlockHash] ??= $this->getBlockCollisionBoxesForCell($x, $y, $z, $collisionInfo);
|
||||||
|
|
||||||
foreach($boxes as $blockBB){
|
foreach($boxes as $blockBB){
|
||||||
if($blockBB->intersectsWith($bb)){
|
if($blockBB->intersectsWith($bb)){
|
||||||
@ -1795,7 +1864,7 @@ class World implements ChunkManager{
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$blockFactory = RuntimeBlockStateRegistry::getInstance();
|
$blockFactory = $this->blockStateRegistry;
|
||||||
$this->timings->doBlockSkyLightUpdates->startTiming();
|
$this->timings->doBlockSkyLightUpdates->startTiming();
|
||||||
if($this->skyLightUpdate === null){
|
if($this->skyLightUpdate === null){
|
||||||
$this->skyLightUpdate = new SkyLightUpdate(new SubChunkExplorer($this), $blockFactory->lightFilter, $blockFactory->blocksDirectSkyLight);
|
$this->skyLightUpdate = new SkyLightUpdate(new SubChunkExplorer($this), $blockFactory->lightFilter, $blockFactory->blocksDirectSkyLight);
|
||||||
@ -1914,7 +1983,7 @@ class World implements ChunkManager{
|
|||||||
|
|
||||||
$chunk = $this->chunks[$chunkHash] ?? null;
|
$chunk = $this->chunks[$chunkHash] ?? null;
|
||||||
if($chunk !== null){
|
if($chunk !== null){
|
||||||
$block = RuntimeBlockStateRegistry::getInstance()->fromStateId($chunk->getBlockStateId($x & Chunk::COORD_MASK, $y, $z & Chunk::COORD_MASK));
|
$block = $this->blockStateRegistry->fromStateId($chunk->getBlockStateId($x & Chunk::COORD_MASK, $y, $z & Chunk::COORD_MASK));
|
||||||
}else{
|
}else{
|
||||||
$addToCache = false;
|
$addToCache = false;
|
||||||
$block = VanillaBlocks::AIR();
|
$block = VanillaBlocks::AIR();
|
||||||
@ -2573,7 +2642,7 @@ class World implements ChunkManager{
|
|||||||
$localY = $tilePosition->getFloorY();
|
$localY = $tilePosition->getFloorY();
|
||||||
$localZ = $tilePosition->getFloorZ() & Chunk::COORD_MASK;
|
$localZ = $tilePosition->getFloorZ() & Chunk::COORD_MASK;
|
||||||
|
|
||||||
$newBlock = RuntimeBlockStateRegistry::getInstance()->fromStateId($chunk->getBlockStateId($localX, $localY, $localZ));
|
$newBlock = $this->blockStateRegistry->fromStateId($chunk->getBlockStateId($localX, $localY, $localZ));
|
||||||
$expectedTileClass = $newBlock->getIdInfo()->getTileClass();
|
$expectedTileClass = $newBlock->getIdInfo()->getTileClass();
|
||||||
if(
|
if(
|
||||||
$expectedTileClass === null || //new block doesn't expect a tile
|
$expectedTileClass === null || //new block doesn't expect a tile
|
||||||
|
@ -18,6 +18,12 @@ parameters:
|
|||||||
count: 1
|
count: 1
|
||||||
path: ../../../src/Server.php
|
path: ../../../src/Server.php
|
||||||
|
|
||||||
|
-
|
||||||
|
message: '#^Dynamic new is not allowed\.$#'
|
||||||
|
identifier: pocketmine.new.dynamic
|
||||||
|
count: 1
|
||||||
|
path: ../../../src/Server.php
|
||||||
|
|
||||||
-
|
-
|
||||||
message: '#^Method pocketmine\\Server\:\:getCommandAliases\(\) should return array\<string, list\<string\>\> but returns array\<string, array\<mixed\>\>\.$#'
|
message: '#^Method pocketmine\\Server\:\:getCommandAliases\(\) should return array\<string, list\<string\>\> but returns array\<string, array\<mixed\>\>\.$#'
|
||||||
identifier: return.type
|
identifier: return.type
|
||||||
@ -54,6 +60,12 @@ parameters:
|
|||||||
count: 1
|
count: 1
|
||||||
path: ../../../src/VersionInfo.php
|
path: ../../../src/VersionInfo.php
|
||||||
|
|
||||||
|
-
|
||||||
|
message: '#^Dynamic new is not allowed\.$#'
|
||||||
|
identifier: pocketmine.new.dynamic
|
||||||
|
count: 1
|
||||||
|
path: ../../../src/block/Block.php
|
||||||
|
|
||||||
-
|
-
|
||||||
message: '#^Parameter \#1 \$x of method pocketmine\\world\\World\:\:getBlockAt\(\) expects int, float\|int given\.$#'
|
message: '#^Parameter \#1 \$x of method pocketmine\\world\\World\:\:getBlockAt\(\) expects int, float\|int given\.$#'
|
||||||
identifier: argument.type
|
identifier: argument.type
|
||||||
@ -510,6 +522,12 @@ parameters:
|
|||||||
count: 3
|
count: 3
|
||||||
path: ../../../src/block/tile/Spawnable.php
|
path: ../../../src/block/tile/Spawnable.php
|
||||||
|
|
||||||
|
-
|
||||||
|
message: '#^Dynamic new is not allowed\.$#'
|
||||||
|
identifier: pocketmine.new.dynamic
|
||||||
|
count: 1
|
||||||
|
path: ../../../src/block/tile/TileFactory.php
|
||||||
|
|
||||||
-
|
-
|
||||||
message: '#^Parameter \#1 \$x of method pocketmine\\world\\World\:\:getPotentialLightAt\(\) expects int, float\|int given\.$#'
|
message: '#^Parameter \#1 \$x of method pocketmine\\world\\World\:\:getPotentialLightAt\(\) expects int, float\|int given\.$#'
|
||||||
identifier: argument.type
|
identifier: argument.type
|
||||||
@ -936,6 +954,12 @@ parameters:
|
|||||||
count: 4
|
count: 4
|
||||||
path: ../../../src/plugin/PluginManager.php
|
path: ../../../src/plugin/PluginManager.php
|
||||||
|
|
||||||
|
-
|
||||||
|
message: '#^Dynamic new is not allowed\.$#'
|
||||||
|
identifier: pocketmine.new.dynamic
|
||||||
|
count: 1
|
||||||
|
path: ../../../src/plugin/PluginManager.php
|
||||||
|
|
||||||
-
|
-
|
||||||
message: '#^Method pocketmine\\resourcepacks\\ZippedResourcePack\:\:getPackSize\(\) should return int but returns int\<0, max\>\|false\.$#'
|
message: '#^Method pocketmine\\resourcepacks\\ZippedResourcePack\:\:getPackSize\(\) should return int but returns int\<0, max\>\|false\.$#'
|
||||||
identifier: return.type
|
identifier: return.type
|
||||||
@ -1248,6 +1272,12 @@ parameters:
|
|||||||
count: 1
|
count: 1
|
||||||
path: ../../../src/world/format/io/region/RegionLoader.php
|
path: ../../../src/world/format/io/region/RegionLoader.php
|
||||||
|
|
||||||
|
-
|
||||||
|
message: '#^Dynamic new is not allowed\.$#'
|
||||||
|
identifier: pocketmine.new.dynamic
|
||||||
|
count: 1
|
||||||
|
path: ../../../src/world/generator/GeneratorRegisterTask.php
|
||||||
|
|
||||||
-
|
-
|
||||||
message: '#^Method pocketmine\\world\\generator\\biome\\BiomeSelector\:\:pickBiome\(\) should return pocketmine\\world\\biome\\Biome but returns pocketmine\\world\\biome\\Biome\|null\.$#'
|
message: '#^Method pocketmine\\world\\generator\\biome\\BiomeSelector\:\:pickBiome\(\) should return pocketmine\\world\\biome\\Biome but returns pocketmine\\world\\biome\\Biome\|null\.$#'
|
||||||
identifier: return.type
|
identifier: return.type
|
||||||
|
55
tests/phpstan/rules/DisallowDynamicNewRule.php
Normal file
55
tests/phpstan/rules/DisallowDynamicNewRule.php
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
* ____ _ _ __ __ _ __ __ ____
|
||||||
|
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||||
|
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||||
|
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||||
|
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* @author PocketMine Team
|
||||||
|
* @link http://www.pocketmine.net/
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace pocketmine\phpstan\rules;
|
||||||
|
|
||||||
|
use PhpParser\Node;
|
||||||
|
use PhpParser\Node\Expr;
|
||||||
|
use PhpParser\Node\Expr\New_;
|
||||||
|
use PHPStan\Analyser\Scope;
|
||||||
|
use PHPStan\Rules\Rule;
|
||||||
|
use PHPStan\Rules\RuleErrorBuilder;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @phpstan-implements Rule<New_>
|
||||||
|
*/
|
||||||
|
final class DisallowDynamicNewRule implements Rule{
|
||||||
|
|
||||||
|
public function getNodeType() : string{
|
||||||
|
return New_::class;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function processNode(Node $node, Scope $scope) : array{
|
||||||
|
/** @var New_ $node */
|
||||||
|
if($node->class instanceof Expr){
|
||||||
|
return [
|
||||||
|
RuleErrorBuilder::message("Dynamic new is not allowed.")
|
||||||
|
->tip("For factories, use closures instead. Closures can implement custom logic, are statically analyzable, and don't restrict the constructor signature.")
|
||||||
|
->identifier("pocketmine.new.dynamic")
|
||||||
|
->build()
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
}
|
@ -51,8 +51,10 @@ use function array_unique;
|
|||||||
use function array_values;
|
use function array_values;
|
||||||
use function count;
|
use function count;
|
||||||
use function dirname;
|
use function dirname;
|
||||||
|
use function fclose;
|
||||||
use function file_exists;
|
use function file_exists;
|
||||||
use function file_put_contents;
|
use function file_put_contents;
|
||||||
|
use function fopen;
|
||||||
use function fwrite;
|
use function fwrite;
|
||||||
use function get_class;
|
use function get_class;
|
||||||
use function get_debug_type;
|
use function get_debug_type;
|
||||||
@ -885,6 +887,44 @@ function cmdUpdateAll(array $argv) : int{
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string[] $argv
|
||||||
|
*/
|
||||||
|
function cmdDumpTable(array $argv) : int{
|
||||||
|
$tableFile = $argv[2];
|
||||||
|
$outputFile = $argv[3];
|
||||||
|
|
||||||
|
$output = fopen($outputFile, 'wb');
|
||||||
|
if($output === false){
|
||||||
|
fwrite(STDERR, "Failed to open output file: $outputFile\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
$table = loadUpgradeTableFromFile($tableFile, reverse: false);
|
||||||
|
ksort($table, SORT_STRING);
|
||||||
|
|
||||||
|
foreach(Utils::stringifyKeys($table) as $oldName => $mappings){
|
||||||
|
fwrite($output, "---------- MAPPING LIST: $oldName ----------\n");
|
||||||
|
foreach($mappings as $mapping){
|
||||||
|
$oldNbt = $mapping->old->toVanillaNbt();
|
||||||
|
$oldNbt->setInt("version", $mapping->new->getVersion());
|
||||||
|
|
||||||
|
//intentionally not reused result of toVanillaNbt otherwise output wouldn't include version
|
||||||
|
fwrite($output, "OLD: " . $mapping->old->toVanillaNbt() . "\n");
|
||||||
|
if(!$oldNbt->equals($mapping->new->toVanillaNbt())){
|
||||||
|
fwrite($output, "NEW: " . $mapping->new->toVanillaNbt() . "\n");
|
||||||
|
}else{
|
||||||
|
fwrite($output, "NEW: version bump only (" . $mapping->new->getVersion() . ")\n");
|
||||||
|
}
|
||||||
|
fwrite($output, "-----\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fclose($output);
|
||||||
|
\GlobalLogger::get()->info("Table dump file $outputFile generated successfully.");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string[] $argv
|
* @param string[] $argv
|
||||||
*/
|
*/
|
||||||
@ -893,7 +933,8 @@ function main(array $argv) : int{
|
|||||||
"generate" => [["palette upgrade table file", "schema output file"], cmdGenerate(...)],
|
"generate" => [["palette upgrade table file", "schema output file"], cmdGenerate(...)],
|
||||||
"test" => [["palette upgrade table file", "schema output file"], cmdTest(...)],
|
"test" => [["palette upgrade table file", "schema output file"], cmdTest(...)],
|
||||||
"update" => [["schema input file", "old palette file", "updated schema output file"], cmdUpdate(...)],
|
"update" => [["schema input file", "old palette file", "updated schema output file"], cmdUpdate(...)],
|
||||||
"update-all" => [["schema folder", "path to BlockPaletteArchive"], cmdUpdateAll(...)]
|
"update-all" => [["schema folder", "path to BlockPaletteArchive"], cmdUpdateAll(...)],
|
||||||
|
"dump-table" => [["palette upgrade table file", "txt output file"], cmdDumpTable(...)]
|
||||||
];
|
];
|
||||||
|
|
||||||
$selected = $argv[1] ?? null;
|
$selected = $argv[1] ?? null;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user