diff --git a/.github/workflows/discord-release-notify.yml b/.github/workflows/discord-release-notify.yml index 94b7bb99d..f73113098 100644 --- a/.github/workflows/discord-release-notify.yml +++ b/.github/workflows/discord-release-notify.yml @@ -13,7 +13,7 @@ jobs: - uses: actions/checkout@v4 - name: Setup PHP and tools - uses: shivammathur/setup-php@2.26.0 + uses: shivammathur/setup-php@2.27.1 with: php-version: 8.1 diff --git a/.github/workflows/draft-release.yml b/.github/workflows/draft-release.yml index f7026c646..03bfedc89 100644 --- a/.github/workflows/draft-release.yml +++ b/.github/workflows/draft-release.yml @@ -20,7 +20,7 @@ jobs: submodules: true - name: Setup PHP - uses: shivammathur/setup-php@2.26.0 + uses: shivammathur/setup-php@2.27.1 with: php-version: ${{ matrix.php-version }} diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 1fd1731a2..c57cecb84 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -173,7 +173,7 @@ jobs: - uses: actions/checkout@v4 - name: Setup PHP and tools - uses: shivammathur/setup-php@2.26.0 + uses: shivammathur/setup-php@2.27.1 with: php-version: 8.1 tools: php-cs-fixer:3.17 diff --git a/composer.json b/composer.json index 6373fd232..9e6ebe125 100644 --- a/composer.json +++ b/composer.json @@ -52,7 +52,7 @@ "symfony/filesystem": "~6.3.0" }, "require-dev": { - "phpstan/phpstan": "1.10.40", + "phpstan/phpstan": "1.10.41", "phpstan/phpstan-phpunit": "^1.1.0", "phpstan/phpstan-strict-rules": "^1.2.0", "phpunit/phpunit": "~10.3.0 || ~10.2.0 || ~10.1.0" diff --git a/composer.lock b/composer.lock index 4c9588263..2888a3291 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "ca499c3c5acafac837f7384ecdae136e", + "content-hash": "5c19f4766fd04be0cbd38d9f4681864e", "packages": [ { "name": "adhocore/json-comment", @@ -1378,16 +1378,16 @@ }, { "name": "phpstan/phpstan", - "version": "1.10.40", + "version": "1.10.41", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "93c84b5bf7669920d823631e39904d69b9c7dc5d" + "reference": "c6174523c2a69231df55bdc65b61655e72876d76" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/93c84b5bf7669920d823631e39904d69b9c7dc5d", - "reference": "93c84b5bf7669920d823631e39904d69b9c7dc5d", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/c6174523c2a69231df55bdc65b61655e72876d76", + "reference": "c6174523c2a69231df55bdc65b61655e72876d76", "shasum": "" }, "require": { @@ -1436,7 +1436,7 @@ "type": "tidelift" } ], - "time": "2023-10-30T14:48:31+00:00" + "time": "2023-11-05T12:57:57+00:00" }, { "name": "phpstan/phpstan-phpunit", @@ -2964,5 +2964,5 @@ "platform-overrides": { "php": "8.1.0" }, - "plugin-api-version": "2.3.0" + "plugin-api-version": "2.6.0" } diff --git a/src/BootstrapOptions.php b/src/BootstrapOptions.php new file mode 100644 index 000000000..879c502a6 --- /dev/null +++ b/src/BootstrapOptions.php @@ -0,0 +1,48 @@ += 0){ + $messages[] = "php-libdeflate ^0.2.0 is required, while you have $libdeflate_version."; + } + } + if(extension_loaded("pocketmine")){ $messages[] = "The native PocketMine extension is no longer supported."; } @@ -267,8 +274,8 @@ JIT_WARNING ErrorToExceptionHandler::set(); $cwd = Utils::assumeNotFalse(realpath(Utils::assumeNotFalse(getcwd()))); - $dataPath = getopt_string("data") ?? $cwd; - $pluginPath = getopt_string("plugins") ?? $cwd . DIRECTORY_SEPARATOR . "plugins"; + $dataPath = getopt_string(BootstrapOptions::DATA) ?? $cwd; + $pluginPath = getopt_string(BootstrapOptions::PLUGINS) ?? $cwd . DIRECTORY_SEPARATOR . "plugins"; Filesystem::addCleanedPath($pluginPath, Filesystem::CLEAN_PATH_PLUGINS_PREFIX); if(!@mkdir($dataPath, 0777, true) && !is_dir($dataPath)){ @@ -301,10 +308,10 @@ JIT_WARNING //Logger has a dependency on timezone Timezone::init(); - $opts = getopt("", ["no-wizard", "enable-ansi", "disable-ansi"]); - if(isset($opts["enable-ansi"])){ + $opts = getopt("", [BootstrapOptions::NO_WIZARD, BootstrapOptions::ENABLE_ANSI, BootstrapOptions::DISABLE_ANSI]); + if(isset($opts[BootstrapOptions::ENABLE_ANSI])){ Terminal::init(true); - }elseif(isset($opts["disable-ansi"])){ + }elseif(isset($opts[BootstrapOptions::DISABLE_ANSI])){ Terminal::init(false); }else{ Terminal::init(); @@ -317,7 +324,7 @@ JIT_WARNING $exitCode = 0; do{ - if(!file_exists(Path::join($dataPath, "server.properties")) && !isset($opts["no-wizard"])){ + if(!file_exists(Path::join($dataPath, "server.properties")) && !isset($opts[BootstrapOptions::NO_WIZARD])){ $installer = new SetupWizard($dataPath); if(!$installer->run()){ $exitCode = -1; diff --git a/src/block/Block.php b/src/block/Block.php index a1d553b9d..b2847bb35 100644 --- a/src/block/Block.php +++ b/src/block/Block.php @@ -270,11 +270,22 @@ class Block{ } private function encodeFullState() : int{ - $writer = new RuntimeDataWriter($this->requiredBlockItemStateDataBits + $this->requiredBlockOnlyStateDataBits); - $writer->writeInt($this->requiredBlockItemStateDataBits, $this->encodeBlockItemState()); - $writer->writeInt($this->requiredBlockOnlyStateDataBits, $this->encodeBlockOnlyState()); + $blockItemBits = $this->requiredBlockItemStateDataBits; + $blockOnlyBits = $this->requiredBlockOnlyStateDataBits; - return $writer->getValue(); + if($blockOnlyBits === 0 && $blockItemBits === 0){ + return 0; + } + + $result = 0; + if($blockItemBits > 0){ + $result |= $this->encodeBlockItemState(); + } + if($blockOnlyBits > 0){ + $result |= $this->encodeBlockOnlyState() << $blockItemBits; + } + + return $result; } /** diff --git a/src/block/Crops.php b/src/block/Crops.php index 350268863..e90ac6236 100644 --- a/src/block/Crops.php +++ b/src/block/Crops.php @@ -25,6 +25,7 @@ namespace pocketmine\block; use pocketmine\block\utils\AgeableTrait; use pocketmine\block\utils\BlockEventHelper; +use pocketmine\block\utils\CropGrowthHelper; use pocketmine\block\utils\StaticSupportTrait; use pocketmine\item\Fertilizer; use pocketmine\item\Item; @@ -66,7 +67,7 @@ abstract class Crops extends Flowable{ } public function onRandomTick() : void{ - if($this->age < self::MAX_AGE && mt_rand(0, 2) === 1){ + if($this->age < self::MAX_AGE && CropGrowthHelper::canGrow($this)){ $block = clone $this; ++$block->age; BlockEventHelper::grow($this, $block, null); diff --git a/src/block/DoublePitcherCrop.php b/src/block/DoublePitcherCrop.php index db700a625..e34dd1baf 100644 --- a/src/block/DoublePitcherCrop.php +++ b/src/block/DoublePitcherCrop.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace pocketmine\block; use pocketmine\block\utils\AgeableTrait; +use pocketmine\block\utils\CropGrowthHelper; use pocketmine\data\runtime\RuntimeDataDescriber; use pocketmine\event\block\StructureGrowEvent; use pocketmine\item\Fertilizer; @@ -34,7 +35,6 @@ use pocketmine\math\Facing; use pocketmine\math\Vector3; use pocketmine\player\Player; use pocketmine\world\BlockTransaction; -use function mt_rand; final class DoublePitcherCrop extends DoublePlant{ use AgeableTrait { @@ -101,9 +101,8 @@ final class DoublePitcherCrop extends DoublePlant{ } public function onRandomTick() : void{ - //TODO: the growth speed is influenced by farmland and nearby crops //only the bottom half of the plant can grow randomly - if(mt_rand(0, 2) === 0 && !$this->top){ + if(CropGrowthHelper::canGrow($this) && !$this->top){ $this->grow(null); } } diff --git a/src/block/GoldOre.php b/src/block/GoldOre.php index ae26d8b4e..75374c1b0 100644 --- a/src/block/GoldOre.php +++ b/src/block/GoldOre.php @@ -23,13 +23,14 @@ declare(strict_types=1); namespace pocketmine\block; +use pocketmine\block\utils\FortuneDropHelper; use pocketmine\item\Item; use pocketmine\item\VanillaItems; final class GoldOre extends Opaque{ public function getDropsForCompatibleTool(Item $item) : array{ - return [VanillaItems::RAW_GOLD()]; + return [VanillaItems::RAW_GOLD()->setCount(FortuneDropHelper::weighted($item, min: 1, maxBase: 1))]; } public function isAffectedBySilkTouch() : bool{ return true; } diff --git a/src/block/IronOre.php b/src/block/IronOre.php index 8d7e9bd3f..11c8cc299 100644 --- a/src/block/IronOre.php +++ b/src/block/IronOre.php @@ -23,13 +23,14 @@ declare(strict_types=1); namespace pocketmine\block; +use pocketmine\block\utils\FortuneDropHelper; use pocketmine\item\Item; use pocketmine\item\VanillaItems; final class IronOre extends Opaque{ public function getDropsForCompatibleTool(Item $item) : array{ - return [VanillaItems::RAW_IRON()]; + return [VanillaItems::RAW_IRON()->setCount(FortuneDropHelper::weighted($item, min: 1, maxBase: 1))]; } public function isAffectedBySilkTouch() : bool{ return true; } diff --git a/src/block/PitcherCrop.php b/src/block/PitcherCrop.php index 2d9a02162..e0b9af3d2 100644 --- a/src/block/PitcherCrop.php +++ b/src/block/PitcherCrop.php @@ -25,6 +25,7 @@ namespace pocketmine\block; use pocketmine\block\utils\AgeableTrait; use pocketmine\block\utils\BlockEventHelper; +use pocketmine\block\utils\CropGrowthHelper; use pocketmine\block\utils\StaticSupportTrait; use pocketmine\event\block\StructureGrowEvent; use pocketmine\item\Fertilizer; @@ -35,7 +36,6 @@ use pocketmine\math\Facing; use pocketmine\math\Vector3; use pocketmine\player\Player; use pocketmine\world\BlockTransaction; -use function mt_rand; final class PitcherCrop extends Flowable{ use AgeableTrait; @@ -97,8 +97,7 @@ final class PitcherCrop extends Flowable{ } public function onRandomTick() : void{ - //TODO: the growth speed is influenced by farmland and nearby crops - if(mt_rand(0, 2) === 0){ + if(CropGrowthHelper::canGrow($this)){ $this->grow(null); } } diff --git a/src/block/Stem.php b/src/block/Stem.php index 7223572dd..2ac95aa3f 100644 --- a/src/block/Stem.php +++ b/src/block/Stem.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace pocketmine\block; use pocketmine\block\utils\BlockEventHelper; +use pocketmine\block\utils\CropGrowthHelper; use pocketmine\data\runtime\RuntimeDataDescriber; use pocketmine\item\Item; use pocketmine\math\Facing; @@ -58,8 +59,12 @@ abstract class Stem extends Crops{ parent::onNearbyBlockChange(); } + public function ticksRandomly() : bool{ + return $this->age < self::MAX_AGE || $this->facing === Facing::UP; + } + public function onRandomTick() : void{ - if($this->facing === Facing::UP && mt_rand(0, 2) === 1){ + if($this->facing === Facing::UP && CropGrowthHelper::canGrow($this)){ $world = $this->position->getWorld(); if($this->age < self::MAX_AGE){ $block = clone $this; @@ -76,7 +81,9 @@ abstract class Stem extends Crops{ $facing = Facing::HORIZONTAL[array_rand(Facing::HORIZONTAL)]; $side = $this->getSide($facing); if($side->getTypeId() === BlockTypeIds::AIR && $side->getSide(Facing::DOWN)->hasTypeTag(BlockTypeTags::DIRT)){ - BlockEventHelper::grow($side, $grow, null); + if(BlockEventHelper::grow($side, $grow, null)){ + $this->position->getWorld()->setBlock($this->position, $this->setFacing($facing)); + } } } } diff --git a/src/block/TorchflowerCrop.php b/src/block/TorchflowerCrop.php index 75efe142b..033b08552 100644 --- a/src/block/TorchflowerCrop.php +++ b/src/block/TorchflowerCrop.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace pocketmine\block; use pocketmine\block\utils\BlockEventHelper; +use pocketmine\block\utils\CropGrowthHelper; use pocketmine\block\utils\StaticSupportTrait; use pocketmine\data\runtime\RuntimeDataDescriber; use pocketmine\item\Fertilizer; @@ -32,7 +33,6 @@ use pocketmine\item\VanillaItems; use pocketmine\math\Facing; use pocketmine\math\Vector3; use pocketmine\player\Player; -use function mt_rand; final class TorchflowerCrop extends Flowable{ use StaticSupportTrait; @@ -79,7 +79,7 @@ final class TorchflowerCrop extends Flowable{ } public function onRandomTick() : void{ - if(mt_rand(0, 2) === 1){ + if(CropGrowthHelper::canGrow($this)){ BlockEventHelper::grow($this, $this->getNextState(), null); } } diff --git a/src/block/VanillaBlocks.php b/src/block/VanillaBlocks.php index bb0041c23..1f58a7b7c 100644 --- a/src/block/VanillaBlocks.php +++ b/src/block/VanillaBlocks.php @@ -1495,7 +1495,9 @@ final class VanillaBlocks{ //for some reason, slabs have weird hardness like the legacy ones $slabBreakInfo = new Info(BreakInfo::pickaxe(2.0, ToolTier::WOOD, 30.0)); - self::register("ancient_debris", new Opaque(new BID(Ids::ANCIENT_DEBRIS), "Ancient Debris", new Info(BreakInfo::pickaxe(30, ToolTier::DIAMOND, 3600.0)))); + self::register("ancient_debris", new class(new BID(Ids::ANCIENT_DEBRIS), "Ancient Debris", new Info(BreakInfo::pickaxe(30, ToolTier::DIAMOND, 3600.0))) extends Opaque{ + public function isFireProofAsItem() : bool{ return true; } + }); $netheriteBreakInfo = new Info(BreakInfo::pickaxe(50, ToolTier::DIAMOND, 3600.0)); self::register("netherite", new class(new BID(Ids::NETHERITE), "Netherite Block", $netheriteBreakInfo) extends Opaque{ public function isFireProofAsItem() : bool{ return true; } diff --git a/src/block/tile/Sign.php b/src/block/tile/Sign.php index d5d314ee3..2ced414ff 100644 --- a/src/block/tile/Sign.php +++ b/src/block/tile/Sign.php @@ -77,22 +77,30 @@ class Sign extends Spawnable{ parent::__construct($world, $pos); } + private function readTextTag(CompoundTag $nbt, bool $lightingBugResolved) : void{ + $baseColor = new Color(0, 0, 0); + $glowingText = false; + if(($baseColorTag = $nbt->getTag(self::TAG_TEXT_COLOR)) instanceof IntTag){ + $baseColor = Color::fromARGB(Binary::unsignInt($baseColorTag->getValue())); + } + if($lightingBugResolved && ($glowingTextTag = $nbt->getTag(self::TAG_GLOWING_TEXT)) instanceof ByteTag){ + //both of these must be 1 - if only one is set, it's a leftover from 1.16.210 experimental features + //see https://bugs.mojang.com/browse/MCPE-117835 + $glowingText = $glowingTextTag->getValue() !== 0; + } + $this->text = SignText::fromBlob(mb_scrub($nbt->getString(self::TAG_TEXT_BLOB), 'UTF-8'), $baseColor, $glowingText); + } + public function readSaveData(CompoundTag $nbt) : void{ - if(($textBlobTag = $nbt->getTag(self::TAG_TEXT_BLOB)) instanceof StringTag){ //MCPE 1.2 save format - $baseColor = new Color(0, 0, 0); - $glowingText = false; - if(($baseColorTag = $nbt->getTag(self::TAG_TEXT_COLOR)) instanceof IntTag){ - $baseColor = Color::fromARGB(Binary::unsignInt($baseColorTag->getValue())); + $frontTextTag = $nbt->getTag(self::TAG_FRONT_TEXT); + if($frontTextTag instanceof CompoundTag){ + $this->readTextTag($frontTextTag, true); + }elseif($nbt->getTag(self::TAG_TEXT_BLOB) instanceof StringTag){ //MCPE 1.2 save format + $lightingBugResolved = false; + if(($lightingBugResolvedTag = $nbt->getTag(self::TAG_LEGACY_BUG_RESOLVE)) instanceof ByteTag){ + $lightingBugResolved = $lightingBugResolvedTag->getValue() !== 0; } - if( - ($glowingTextTag = $nbt->getTag(self::TAG_GLOWING_TEXT)) instanceof ByteTag && - ($lightingBugResolvedTag = $nbt->getTag(self::TAG_LEGACY_BUG_RESOLVE)) instanceof ByteTag - ){ - //both of these must be 1 - if only one is set, it's a leftover from 1.16.210 experimental features - //see https://bugs.mojang.com/browse/MCPE-117835 - $glowingText = $glowingTextTag->getValue() !== 0 && $lightingBugResolvedTag->getValue() !== 0; - } - $this->text = SignText::fromBlob(mb_scrub($textBlobTag->getValue(), 'UTF-8'), $baseColor, $glowingText); + $this->readTextTag($nbt, $lightingBugResolved); }else{ $text = []; for($i = 0; $i < SignText::LINE_COUNT; ++$i){ @@ -107,15 +115,19 @@ class Sign extends Spawnable{ } protected function writeSaveData(CompoundTag $nbt) : void{ - $nbt->setString(self::TAG_TEXT_BLOB, implode("\n", $this->text->getLines())); + $nbt->setTag(self::TAG_FRONT_TEXT, CompoundTag::create() + ->setString(self::TAG_TEXT_BLOB, implode("\n", $this->text->getLines())) + ->setInt(self::TAG_TEXT_COLOR, Binary::signInt($this->text->getBaseColor()->toARGB())) + ->setByte(self::TAG_GLOWING_TEXT, $this->text->isGlowing() ? 1 : 0) + ->setByte(self::TAG_PERSIST_FORMATTING, 1) + ); + $nbt->setTag(self::TAG_BACK_TEXT, CompoundTag::create() + ->setString(self::TAG_TEXT_BLOB, "") + ->setInt(self::TAG_TEXT_COLOR, Binary::signInt(0xff_00_00_00)) + ->setByte(self::TAG_GLOWING_TEXT, 0) + ->setByte(self::TAG_PERSIST_FORMATTING, 1) + ); - for($i = 0; $i < SignText::LINE_COUNT; ++$i){ //Backwards-compatibility - $textKey = sprintf(self::TAG_TEXT_LINE, $i + 1); - $nbt->setString($textKey, $this->text->getLine($i)); - } - $nbt->setInt(self::TAG_TEXT_COLOR, Binary::signInt($this->text->getBaseColor()->toARGB())); - $nbt->setByte(self::TAG_GLOWING_TEXT, $this->text->isGlowing() ? 1 : 0); - $nbt->setByte(self::TAG_LEGACY_BUG_RESOLVE, 1); $nbt->setByte(self::TAG_WAXED, $this->waxed ? 1 : 0); } diff --git a/src/block/utils/CropGrowthHelper.php b/src/block/utils/CropGrowthHelper.php new file mode 100644 index 000000000..e85b0b82d --- /dev/null +++ b/src/block/utils/CropGrowthHelper.php @@ -0,0 +1,120 @@ +getPosition(); + + $world = $position->getWorld(); + $baseX = $position->getFloorX(); + $baseY = $position->getFloorY(); + $baseZ = $position->getFloorZ(); + + $farmland = $world->getBlockAt($baseX, $baseY - 1, $baseZ); + + if($farmland instanceof Farmland){ + $result += $farmland->getWetness() > 0 ? self::ON_HYDRATED_FARMLAND_BONUS : self::ON_DRY_FARMLAND_BONUS; + } + + $xRow = false; + $zRow = false; + $improperArrangement = false; + + for($x = -1; $x <= 1; $x++){ + for($z = -1; $z <= 1; $z++){ + if($x === 0 && $z === 0){ + continue; + } + $nextFarmland = $world->getBlockAt($baseX + $x, $baseY - 1, $baseZ + $z); + + if(!$nextFarmland instanceof Farmland){ + continue; + } + + $result += $nextFarmland->getWetness() > 0 ? self::ADJACENT_HYDRATED_FARMLAND_BONUS : self::ADJACENT_DRY_FARMLAND_BONUS; + + if(!$improperArrangement){ + $nextCrop = $world->getBlockAt($baseX + $x, $baseY, $baseZ + $z); + if($nextCrop->hasSameTypeId($block)){ + match(0){ + $x => $zRow ? $improperArrangement = true : $xRow = true, + $z => $xRow ? $improperArrangement = true : $zRow = true, + default => $improperArrangement = true, + }; + } + } + } + } + + //crops can be arranged in rows, but the rows must not cross and must be spaced apart by at least one block + if($improperArrangement){ + $result /= self::IMPROPER_ARRANGEMENT_DIVISOR; + } + + return $result; + } + + public static function hasEnoughLight(Block $block, int $minLevel = self::MIN_LIGHT_LEVEL) : bool{ + $position = $block->getPosition(); + $world = $position->getWorld(); + + //crop growth is not affected by time of day since 1.11 or so + return $world->getPotentialLightAt($position->x, $position->y, $position->z) >= $minLevel; + } + + public static function canGrow(Block $block) : bool{ + //while it may be tempting to use mt_rand(0, 25) < multiplier, this would make crops grow a bit faster than + //vanilla in most cases due to the remainder of 25 / multiplier not being discarded + return mt_rand(0, (int) (25 / self::calculateMultiplier($block))) === 0 && self::hasEnoughLight($block); + } +} diff --git a/src/data/bedrock/block/upgrade/BlockStateUpgrader.php b/src/data/bedrock/block/upgrade/BlockStateUpgrader.php index 5c84cd383..582039305 100644 --- a/src/data/bedrock/block/upgrade/BlockStateUpgrader.php +++ b/src/data/bedrock/block/upgrade/BlockStateUpgrader.php @@ -86,7 +86,7 @@ final class BlockStateUpgrader{ if(is_string($remap->newName)){ $newName = $remap->newName; }else{ - $flattenedValue = $oldState[$remap->newName->flattenedProperty]; + $flattenedValue = $oldState[$remap->newName->flattenedProperty] ?? null; if($flattenedValue instanceof StringTag){ $newName = sprintf("%s%s%s", $remap->newName->prefix, $flattenedValue->getValue(), $remap->newName->suffix); unset($oldState[$remap->newName->flattenedProperty]); diff --git a/src/data/bedrock/item/ItemSerializerDeserializerRegistrar.php b/src/data/bedrock/item/ItemSerializerDeserializerRegistrar.php index 6bb3a56b3..a2bed6ee1 100644 --- a/src/data/bedrock/item/ItemSerializerDeserializerRegistrar.php +++ b/src/data/bedrock/item/ItemSerializerDeserializerRegistrar.php @@ -193,6 +193,7 @@ final class ItemSerializerDeserializerRegistrar{ $this->map1to1Item(Ids::CLAY_BALL, Items::CLAY()); $this->map1to1Item(Ids::CLOCK, Items::CLOCK()); $this->map1to1Item(Ids::COAL, Items::COAL()); + $this->map1to1Item(Ids::COAST_ARMOR_TRIM_SMITHING_TEMPLATE, Items::COAST_ARMOR_TRIM_SMITHING_TEMPLATE()); $this->map1to1Item(Ids::COCOA_BEANS, Items::COCOA_BEANS()); $this->map1to1Item(Ids::COD, Items::RAW_FISH()); $this->map1to1Item(Ids::COMPASS, Items::COMPASS()); @@ -221,6 +222,7 @@ final class ItemSerializerDeserializerRegistrar{ $this->map1to1Item(Ids::DISC_FRAGMENT_5, Items::DISC_FRAGMENT_5()); $this->map1to1Item(Ids::DRAGON_BREATH, Items::DRAGON_BREATH()); $this->map1to1Item(Ids::DRIED_KELP, Items::DRIED_KELP()); + $this->map1to1Item(Ids::DUNE_ARMOR_TRIM_SMITHING_TEMPLATE, Items::DUNE_ARMOR_TRIM_SMITHING_TEMPLATE()); $this->map1to1Item(Ids::ECHO_SHARD, Items::ECHO_SHARD()); $this->map1to1Item(Ids::EGG, Items::EGG()); $this->map1to1Item(Ids::EMERALD, Items::EMERALD()); @@ -228,6 +230,7 @@ final class ItemSerializerDeserializerRegistrar{ $this->map1to1Item(Ids::ENCHANTED_GOLDEN_APPLE, Items::ENCHANTED_GOLDEN_APPLE()); $this->map1to1Item(Ids::ENDER_PEARL, Items::ENDER_PEARL()); $this->map1to1Item(Ids::EXPERIENCE_BOTTLE, Items::EXPERIENCE_BOTTLE()); + $this->map1to1Item(Ids::EYE_ARMOR_TRIM_SMITHING_TEMPLATE, Items::EYE_ARMOR_TRIM_SMITHING_TEMPLATE()); $this->map1to1Item(Ids::FEATHER, Items::FEATHER()); $this->map1to1Item(Ids::FERMENTED_SPIDER_EYE, Items::FERMENTED_SPIDER_EYE()); $this->map1to1Item(Ids::FIRE_CHARGE, Items::FIRE_CHARGE()); @@ -257,6 +260,7 @@ final class ItemSerializerDeserializerRegistrar{ $this->map1to1Item(Ids::HEART_OF_THE_SEA, Items::HEART_OF_THE_SEA()); $this->map1to1Item(Ids::HONEY_BOTTLE, Items::HONEY_BOTTLE()); $this->map1to1Item(Ids::HONEYCOMB, Items::HONEYCOMB()); + $this->map1to1Item(Ids::HOST_ARMOR_TRIM_SMITHING_TEMPLATE, Items::HOST_ARMOR_TRIM_SMITHING_TEMPLATE()); $this->map1to1Item(Ids::INK_SAC, Items::INK_SAC()); $this->map1to1Item(Ids::IRON_AXE, Items::IRON_AXE()); $this->map1to1Item(Ids::IRON_BOOTS, Items::IRON_BOOTS()); @@ -316,6 +320,7 @@ final class ItemSerializerDeserializerRegistrar{ $this->map1to1Item(Ids::NETHERITE_SCRAP, Items::NETHERITE_SCRAP()); $this->map1to1Item(Ids::NETHERITE_SHOVEL, Items::NETHERITE_SHOVEL()); $this->map1to1Item(Ids::NETHERITE_SWORD, Items::NETHERITE_SWORD()); + $this->map1to1Item(Ids::NETHERITE_UPGRADE_SMITHING_TEMPLATE, Items::NETHERITE_UPGRADE_SMITHING_TEMPLATE()); $this->map1to1Item(Ids::OAK_BOAT, Items::OAK_BOAT()); $this->map1to1Item(Ids::OAK_SIGN, Items::OAK_SIGN()); $this->map1to1Item(Ids::PAINTING, Items::PAINTING()); @@ -335,18 +340,25 @@ final class ItemSerializerDeserializerRegistrar{ $this->map1to1Item(Ids::RABBIT_FOOT, Items::RABBIT_FOOT()); $this->map1to1Item(Ids::RABBIT_HIDE, Items::RABBIT_HIDE()); $this->map1to1Item(Ids::RABBIT_STEW, Items::RABBIT_STEW()); + $this->map1to1Item(Ids::RAISER_ARMOR_TRIM_SMITHING_TEMPLATE, Items::RAISER_ARMOR_TRIM_SMITHING_TEMPLATE()); $this->map1to1Item(Ids::RAW_COPPER, Items::RAW_COPPER()); $this->map1to1Item(Ids::RAW_GOLD, Items::RAW_GOLD()); $this->map1to1Item(Ids::RAW_IRON, Items::RAW_IRON()); $this->map1to1Item(Ids::REDSTONE, Items::REDSTONE_DUST()); + $this->map1to1Item(Ids::RIB_ARMOR_TRIM_SMITHING_TEMPLATE, Items::RIB_ARMOR_TRIM_SMITHING_TEMPLATE()); $this->map1to1Item(Ids::ROTTEN_FLESH, Items::ROTTEN_FLESH()); $this->map1to1Item(Ids::SALMON, Items::RAW_SALMON()); $this->map1to1Item(Ids::SCUTE, Items::SCUTE()); + $this->map1to1Item(Ids::SENTRY_ARMOR_TRIM_SMITHING_TEMPLATE, Items::SENTRY_ARMOR_TRIM_SMITHING_TEMPLATE()); + $this->map1to1Item(Ids::SHAPER_ARMOR_TRIM_SMITHING_TEMPLATE, Items::SHAPER_ARMOR_TRIM_SMITHING_TEMPLATE()); $this->map1to1Item(Ids::SHEARS, Items::SHEARS()); $this->map1to1Item(Ids::SHULKER_SHELL, Items::SHULKER_SHELL()); + $this->map1to1Item(Ids::SILENCE_ARMOR_TRIM_SMITHING_TEMPLATE, Items::SILENCE_ARMOR_TRIM_SMITHING_TEMPLATE()); $this->map1to1Item(Ids::SLIME_BALL, Items::SLIMEBALL()); + $this->map1to1Item(Ids::SNOUT_ARMOR_TRIM_SMITHING_TEMPLATE, Items::SNOUT_ARMOR_TRIM_SMITHING_TEMPLATE()); $this->map1to1Item(Ids::SNOWBALL, Items::SNOWBALL()); $this->map1to1Item(Ids::SPIDER_EYE, Items::SPIDER_EYE()); + $this->map1to1Item(Ids::SPIRE_ARMOR_TRIM_SMITHING_TEMPLATE, Items::SPIRE_ARMOR_TRIM_SMITHING_TEMPLATE()); $this->map1to1Item(Ids::SPRUCE_BOAT, Items::SPRUCE_BOAT()); $this->map1to1Item(Ids::SPRUCE_SIGN, Items::SPRUCE_SIGN()); $this->map1to1Item(Ids::SPYGLASS, Items::SPYGLASS()); @@ -361,14 +373,19 @@ final class ItemSerializerDeserializerRegistrar{ $this->map1to1Item(Ids::SUGAR, Items::SUGAR()); $this->map1to1Item(Ids::SWEET_BERRIES, Items::SWEET_BERRIES()); $this->map1to1Item(Ids::TORCHFLOWER_SEEDS, Items::TORCHFLOWER_SEEDS()); + $this->map1to1Item(Ids::TIDE_ARMOR_TRIM_SMITHING_TEMPLATE, Items::TIDE_ARMOR_TRIM_SMITHING_TEMPLATE()); $this->map1to1Item(Ids::TOTEM_OF_UNDYING, Items::TOTEM()); $this->map1to1Item(Ids::TROPICAL_FISH, Items::CLOWNFISH()); $this->map1to1Item(Ids::TURTLE_HELMET, Items::TURTLE_HELMET()); + $this->map1to1Item(Ids::VEX_ARMOR_TRIM_SMITHING_TEMPLATE, Items::VEX_ARMOR_TRIM_SMITHING_TEMPLATE()); $this->map1to1Item(Ids::VILLAGER_SPAWN_EGG, Items::VILLAGER_SPAWN_EGG()); + $this->map1to1Item(Ids::WARD_ARMOR_TRIM_SMITHING_TEMPLATE, Items::WARD_ARMOR_TRIM_SMITHING_TEMPLATE()); $this->map1to1Item(Ids::WARPED_SIGN, Items::WARPED_SIGN()); $this->map1to1Item(Ids::WATER_BUCKET, Items::WATER_BUCKET()); + $this->map1to1Item(Ids::WAYFINDER_ARMOR_TRIM_SMITHING_TEMPLATE, Items::WAYFINDER_ARMOR_TRIM_SMITHING_TEMPLATE()); $this->map1to1Item(Ids::WHEAT, Items::WHEAT()); $this->map1to1Item(Ids::WHEAT_SEEDS, Items::WHEAT_SEEDS()); + $this->map1to1Item(Ids::WILD_ARMOR_TRIM_SMITHING_TEMPLATE, Items::WILD_ARMOR_TRIM_SMITHING_TEMPLATE()); $this->map1to1Item(Ids::WOODEN_AXE, Items::WOODEN_AXE()); $this->map1to1Item(Ids::WOODEN_HOE, Items::WOODEN_HOE()); $this->map1to1Item(Ids::WOODEN_PICKAXE, Items::WOODEN_PICKAXE()); diff --git a/src/item/ItemTypeIds.php b/src/item/ItemTypeIds.php index 4c2f0a1ec..451d25a59 100644 --- a/src/item/ItemTypeIds.php +++ b/src/item/ItemTypeIds.php @@ -305,8 +305,25 @@ final class ItemTypeIds{ public const CHERRY_SIGN = 20266; public const ENCHANTED_BOOK = 20267; public const TORCHFLOWER_SEEDS = 20268; + public const NETHERITE_UPGRADE_SMITHING_TEMPLATE = 20269; + public const SENTRY_ARMOR_TRIM_SMITHING_TEMPLATE = 20270; + public const VEX_ARMOR_TRIM_SMITHING_TEMPLATE = 20271; + public const WILD_ARMOR_TRIM_SMITHING_TEMPLATE = 20272; + public const COAST_ARMOR_TRIM_SMITHING_TEMPLATE = 20273; + public const DUNE_ARMOR_TRIM_SMITHING_TEMPLATE = 20274; + public const WAYFINDER_ARMOR_TRIM_SMITHING_TEMPLATE = 20275; + public const RAISER_ARMOR_TRIM_SMITHING_TEMPLATE = 20276; + public const SHAPER_ARMOR_TRIM_SMITHING_TEMPLATE = 20277; + public const HOST_ARMOR_TRIM_SMITHING_TEMPLATE = 20278; + public const WARD_ARMOR_TRIM_SMITHING_TEMPLATE = 20279; + public const SILENCE_ARMOR_TRIM_SMITHING_TEMPLATE = 20280; + public const TIDE_ARMOR_TRIM_SMITHING_TEMPLATE = 20281; + public const SNOUT_ARMOR_TRIM_SMITHING_TEMPLATE = 20282; + public const RIB_ARMOR_TRIM_SMITHING_TEMPLATE = 20283; + public const EYE_ARMOR_TRIM_SMITHING_TEMPLATE = 20284; + public const SPIRE_ARMOR_TRIM_SMITHING_TEMPLATE = 20285; - public const FIRST_UNUSED_ITEM_ID = 20269; + public const FIRST_UNUSED_ITEM_ID = 20286; private static int $nextDynamicId = self::FIRST_UNUSED_ITEM_ID; diff --git a/src/item/StringToItemParser.php b/src/item/StringToItemParser.php index d4f242621..8d78fcf95 100644 --- a/src/item/StringToItemParser.php +++ b/src/item/StringToItemParser.php @@ -1264,6 +1264,7 @@ final class StringToItemParser extends StringToTParser{ $result->register("clown_fish", fn() => Items::CLOWNFISH()); $result->register("clownfish", fn() => Items::CLOWNFISH()); $result->register("coal", fn() => Items::COAL()); + $result->register("coast_armor_trim_smithing_template", fn() => Items::COAST_ARMOR_TRIM_SMITHING_TEMPLATE()); $result->register("cocoa_beans", fn() => Items::COCOA_BEANS()); $result->register("cod", fn() => Items::RAW_FISH()); $result->register("compass", fn() => Items::COMPASS()); @@ -1292,6 +1293,7 @@ final class StringToItemParser extends StringToTParser{ $result->register("disc_fragment_5", fn() => Items::DISC_FRAGMENT_5()); $result->register("dragon_breath", fn() => Items::DRAGON_BREATH()); $result->register("dried_kelp", fn() => Items::DRIED_KELP()); + $result->register("dune_armor_trim_smithing_template", fn() => Items::DUNE_ARMOR_TRIM_SMITHING_TEMPLATE()); $result->register("dye", fn() => Items::INK_SAC()); $result->register("echo_shard", fn() => Items::ECHO_SHARD()); $result->register("egg", fn() => Items::EGG()); @@ -1302,6 +1304,7 @@ final class StringToItemParser extends StringToTParser{ $result->register("enchanting_bottle", fn() => Items::EXPERIENCE_BOTTLE()); $result->register("ender_pearl", fn() => Items::ENDER_PEARL()); $result->register("experience_bottle", fn() => Items::EXPERIENCE_BOTTLE()); + $result->register("eye_armor_trim_smithing_template", fn() => Items::EYE_ARMOR_TRIM_SMITHING_TEMPLATE()); $result->register("eye_drops", fn() => Items::MEDICINE()->setType(MedicineType::EYE_DROPS)); $result->register("feather", fn() => Items::FEATHER()); $result->register("fermented_spider_eye", fn() => Items::FERMENTED_SPIDER_EYE()); @@ -1343,6 +1346,7 @@ final class StringToItemParser extends StringToTParser{ $result->register("gunpowder", fn() => Items::GUNPOWDER()); $result->register("heart_of_the_sea", fn() => Items::HEART_OF_THE_SEA()); $result->register("honey_bottle", fn() => Items::HONEY_BOTTLE()); + $result->register("host_armor_trim_smithing_template", fn() => Items::HOST_ARMOR_TRIM_SMITHING_TEMPLATE()); $result->register("honeycomb", fn() => Items::HONEYCOMB()); $result->register("ink_sac", fn() => Items::INK_SAC()); $result->register("iron_axe", fn() => Items::IRON_AXE()); @@ -1396,6 +1400,7 @@ final class StringToItemParser extends StringToTParser{ $result->register("netherite_shovel", fn() => Items::NETHERITE_SHOVEL()); $result->register("netherite_sword", fn() => Items::NETHERITE_SWORD()); $result->register("netherstar", fn() => Items::NETHER_STAR()); + $result->register("netherite_upgrade_smithing_template", fn() => Items::NETHERITE_UPGRADE_SMITHING_TEMPLATE()); $result->register("oak_boat", fn() => Items::OAK_BOAT()); $result->register("painting", fn() => Items::PAINTING()); $result->register("paper", fn() => Items::PAPER()); @@ -1416,6 +1421,7 @@ final class StringToItemParser extends StringToTParser{ $result->register("rabbit_foot", fn() => Items::RABBIT_FOOT()); $result->register("rabbit_hide", fn() => Items::RABBIT_HIDE()); $result->register("rabbit_stew", fn() => Items::RABBIT_STEW()); + $result->register("raiser_armor_trim_smithing_template", fn() => Items::RAISER_ARMOR_TRIM_SMITHING_TEMPLATE()); $result->register("raw_beef", fn() => Items::RAW_BEEF()); $result->register("raw_cod", fn() => Items::RAW_FISH()); $result->register("raw_copper", fn() => Items::RAW_COPPER()); @@ -1444,17 +1450,23 @@ final class StringToItemParser extends StringToTParser{ $result->register("record_ward", fn() => Items::RECORD_WARD()); $result->register("redstone", fn() => Items::REDSTONE_DUST()); $result->register("redstone_dust", fn() => Items::REDSTONE_DUST()); + $result->register("rib_armor_trim_smithing_template", fn() => Items::RIB_ARMOR_TRIM_SMITHING_TEMPLATE()); $result->register("rotten_flesh", fn() => Items::ROTTEN_FLESH()); $result->register("salmon", fn() => Items::RAW_SALMON()); $result->register("scute", fn() => Items::SCUTE()); + $result->register("sentry_armor_trim_smithing_template", fn() => Items::SENTRY_ARMOR_TRIM_SMITHING_TEMPLATE()); + $result->register("shaper_armor_trim_smithing_template", fn() => Items::SHAPER_ARMOR_TRIM_SMITHING_TEMPLATE()); $result->register("seeds", fn() => Items::WHEAT_SEEDS()); $result->register("shears", fn() => Items::SHEARS()); $result->register("shulker_shell", fn() => Items::SHULKER_SHELL()); + $result->register("silence_armor_trim_smithing_template", fn() => Items::SILENCE_ARMOR_TRIM_SMITHING_TEMPLATE()); $result->register("slime_ball", fn() => Items::SLIMEBALL()); + $result->register("snout_armor_trim_smithing_template", fn() => Items::SNOUT_ARMOR_TRIM_SMITHING_TEMPLATE()); $result->register("slimeball", fn() => Items::SLIMEBALL()); $result->register("snowball", fn() => Items::SNOWBALL()); $result->register("speckled_melon", fn() => Items::GLISTERING_MELON()); $result->register("spider_eye", fn() => Items::SPIDER_EYE()); + $result->register("spire_armor_trim_smithing_template", fn() => Items::SPIRE_ARMOR_TRIM_SMITHING_TEMPLATE()); $result->register("splash_potion", fn() => Items::SPLASH_POTION()); $result->register("spruce_boat", fn() => Items::SPRUCE_BOAT()); $result->register("spyglass", fn() => Items::SPYGLASS()); @@ -1473,13 +1485,18 @@ final class StringToItemParser extends StringToTParser{ $result->register("sweet_berries", fn() => Items::SWEET_BERRIES()); $result->register("tonic", fn() => Items::MEDICINE()->setType(MedicineType::TONIC)); $result->register("torchflower_seeds", fn() => Items::TORCHFLOWER_SEEDS()); + $result->register("tide_armor_trim_smithing_template", fn() => Items::TIDE_ARMOR_TRIM_SMITHING_TEMPLATE()); $result->register("totem", fn() => Items::TOTEM()); $result->register("turtle_helmet", fn() => Items::TURTLE_HELMET()); + $result->register("vex_armor_trim_smithing_template", fn() => Items::VEX_ARMOR_TRIM_SMITHING_TEMPLATE()); $result->register("turtle_shell_piece", fn() => Items::SCUTE()); $result->register("villager_spawn_egg", fn() => Items::VILLAGER_SPAWN_EGG()); + $result->register("ward_armor_trim_smithing_template", fn() => Items::WARD_ARMOR_TRIM_SMITHING_TEMPLATE()); $result->register("water_bucket", fn() => Items::WATER_BUCKET()); + $result->register("wayfinder_armor_trim_smithing_template", fn() => Items::WAYFINDER_ARMOR_TRIM_SMITHING_TEMPLATE()); $result->register("wheat", fn() => Items::WHEAT()); $result->register("wheat_seeds", fn() => Items::WHEAT_SEEDS()); + $result->register("wild_armor_trim_smithing_template", fn() => Items::WILD_ARMOR_TRIM_SMITHING_TEMPLATE()); $result->register("wooden_axe", fn() => Items::WOODEN_AXE()); $result->register("wooden_hoe", fn() => Items::WOODEN_HOE()); $result->register("wooden_pickaxe", fn() => Items::WOODEN_PICKAXE()); diff --git a/src/item/VanillaItems.php b/src/item/VanillaItems.php index e07d4161b..5f4f60f8e 100644 --- a/src/item/VanillaItems.php +++ b/src/item/VanillaItems.php @@ -121,6 +121,7 @@ use function strtolower; * @method static Clock CLOCK() * @method static Clownfish CLOWNFISH() * @method static Coal COAL() + * @method static Item COAST_ARMOR_TRIM_SMITHING_TEMPLATE() * @method static CocoaBeans COCOA_BEANS() * @method static Compass COMPASS() * @method static CookedChicken COOKED_CHICKEN() @@ -148,6 +149,7 @@ use function strtolower; * @method static Item DISC_FRAGMENT_5() * @method static Item DRAGON_BREATH() * @method static DriedKelp DRIED_KELP() + * @method static Item DUNE_ARMOR_TRIM_SMITHING_TEMPLATE() * @method static Dye DYE() * @method static Item ECHO_SHARD() * @method static Egg EGG() @@ -156,6 +158,7 @@ use function strtolower; * @method static GoldenAppleEnchanted ENCHANTED_GOLDEN_APPLE() * @method static EnderPearl ENDER_PEARL() * @method static ExperienceBottle EXPERIENCE_BOTTLE() + * @method static Item EYE_ARMOR_TRIM_SMITHING_TEMPLATE() * @method static Item FEATHER() * @method static Item FERMENTED_SPIDER_EYE() * @method static FireCharge FIRE_CHARGE() @@ -185,6 +188,7 @@ use function strtolower; * @method static Item HEART_OF_THE_SEA() * @method static Item HONEYCOMB() * @method static HoneyBottle HONEY_BOTTLE() + * @method static Item HOST_ARMOR_TRIM_SMITHING_TEMPLATE() * @method static Item INK_SAC() * @method static Axe IRON_AXE() * @method static Armor IRON_BOOTS() @@ -227,6 +231,7 @@ use function strtolower; * @method static Item NETHERITE_SCRAP() * @method static Shovel NETHERITE_SHOVEL() * @method static Sword NETHERITE_SWORD() + * @method static Item NETHERITE_UPGRADE_SMITHING_TEMPLATE() * @method static Item NETHER_BRICK() * @method static Item NETHER_QUARTZ() * @method static Item NETHER_STAR() @@ -247,6 +252,7 @@ use function strtolower; * @method static Item RABBIT_FOOT() * @method static Item RABBIT_HIDE() * @method static RabbitStew RABBIT_STEW() + * @method static Item RAISER_ARMOR_TRIM_SMITHING_TEMPLATE() * @method static RawBeef RAW_BEEF() * @method static RawChicken RAW_CHICKEN() * @method static Item RAW_COPPER() @@ -273,13 +279,19 @@ use function strtolower; * @method static Record RECORD_WAIT() * @method static Record RECORD_WARD() * @method static Redstone REDSTONE_DUST() + * @method static Item RIB_ARMOR_TRIM_SMITHING_TEMPLATE() * @method static RottenFlesh ROTTEN_FLESH() * @method static Item SCUTE() + * @method static Item SENTRY_ARMOR_TRIM_SMITHING_TEMPLATE() + * @method static Item SHAPER_ARMOR_TRIM_SMITHING_TEMPLATE() * @method static Shears SHEARS() * @method static Item SHULKER_SHELL() + * @method static Item SILENCE_ARMOR_TRIM_SMITHING_TEMPLATE() * @method static Item SLIMEBALL() + * @method static Item SNOUT_ARMOR_TRIM_SMITHING_TEMPLATE() * @method static Snowball SNOWBALL() * @method static SpiderEye SPIDER_EYE() + * @method static Item SPIRE_ARMOR_TRIM_SMITHING_TEMPLATE() * @method static SplashPotion SPLASH_POTION() * @method static Boat SPRUCE_BOAT() * @method static ItemBlockWallOrFloor SPRUCE_SIGN() @@ -296,14 +308,19 @@ use function strtolower; * @method static Item SUGAR() * @method static SuspiciousStew SUSPICIOUS_STEW() * @method static SweetBerries SWEET_BERRIES() + * @method static Item TIDE_ARMOR_TRIM_SMITHING_TEMPLATE() * @method static TorchflowerSeeds TORCHFLOWER_SEEDS() * @method static Totem TOTEM() * @method static TurtleHelmet TURTLE_HELMET() + * @method static Item VEX_ARMOR_TRIM_SMITHING_TEMPLATE() * @method static SpawnEgg VILLAGER_SPAWN_EGG() + * @method static Item WARD_ARMOR_TRIM_SMITHING_TEMPLATE() * @method static ItemBlockWallOrFloor WARPED_SIGN() * @method static LiquidBucket WATER_BUCKET() + * @method static Item WAYFINDER_ARMOR_TRIM_SMITHING_TEMPLATE() * @method static Item WHEAT() * @method static WheatSeeds WHEAT_SEEDS() + * @method static Item WILD_ARMOR_TRIM_SMITHING_TEMPLATE() * @method static Axe WOODEN_AXE() * @method static Hoe WOODEN_HOE() * @method static Pickaxe WOODEN_PICKAXE() @@ -339,6 +356,7 @@ final class VanillaItems{ self::registerArmorItems(); self::registerSpawnEggs(); self::registerTierToolItems(); + self::registerSmithingTemplates(); self::register("air", Blocks::AIR()->asItem()->setCount(0)); @@ -644,4 +662,24 @@ final class VanillaItems{ self::register("netherite_leggings", new Armor(new IID(Ids::NETHERITE_LEGGINGS), "Netherite Leggings", new ArmorTypeInfo(6, 556, ArmorInventory::SLOT_LEGS, 3, true, material: ArmorMaterials::NETHERITE()), [EnchantmentTags::LEGGINGS])); } + private static function registerSmithingTemplates() : void{ + self::register("netherite_upgrade_smithing_template", new Item(new IID(Ids::NETHERITE_UPGRADE_SMITHING_TEMPLATE), "Netherite Upgrade Smithing Template")); + self::register("coast_armor_trim_smithing_template", new Item(new IID(Ids::COAST_ARMOR_TRIM_SMITHING_TEMPLATE), "Coast Armor Trim Smithing Template")); + self::register("dune_armor_trim_smithing_template", new Item(new IID(Ids::DUNE_ARMOR_TRIM_SMITHING_TEMPLATE), "Dune Armor Trim Smithing Template")); + self::register("eye_armor_trim_smithing_template", new Item(new IID(Ids::EYE_ARMOR_TRIM_SMITHING_TEMPLATE), "Eye Armor Trim Smithing Template")); + self::register("host_armor_trim_smithing_template", new Item(new IID(Ids::HOST_ARMOR_TRIM_SMITHING_TEMPLATE), "Host Armor Trim Smithing Template")); + self::register("raiser_armor_trim_smithing_template", new Item(new IID(Ids::RAISER_ARMOR_TRIM_SMITHING_TEMPLATE), "Raiser Armor Trim Smithing Template")); + self::register("rib_armor_trim_smithing_template", new Item(new IID(Ids::RIB_ARMOR_TRIM_SMITHING_TEMPLATE), "Rib Armor Trim Smithing Template")); + self::register("sentry_armor_trim_smithing_template", new Item(new IID(Ids::SENTRY_ARMOR_TRIM_SMITHING_TEMPLATE), "Sentry Armor Trim Smithing Template")); + self::register("shaper_armor_trim_smithing_template", new Item(new IID(Ids::SHAPER_ARMOR_TRIM_SMITHING_TEMPLATE), "Shaper Armor Trim Smithing Template")); + self::register("silence_armor_trim_smithing_template", new Item(new IID(Ids::SILENCE_ARMOR_TRIM_SMITHING_TEMPLATE), "Silence Armor Trim Smithing Template")); + self::register("snout_armor_trim_smithing_template", new Item(new IID(Ids::SNOUT_ARMOR_TRIM_SMITHING_TEMPLATE), "Snout Armor Trim Smithing Template")); + self::register("spire_armor_trim_smithing_template", new Item(new IID(Ids::SPIRE_ARMOR_TRIM_SMITHING_TEMPLATE), "Spire Armor Trim Smithing Template")); + self::register("tide_armor_trim_smithing_template", new Item(new IID(Ids::TIDE_ARMOR_TRIM_SMITHING_TEMPLATE), "Tide Armor Trim Smithing Template")); + self::register("vex_armor_trim_smithing_template", new Item(new IID(Ids::VEX_ARMOR_TRIM_SMITHING_TEMPLATE), "Vex Armor Trim Smithing Template")); + self::register("ward_armor_trim_smithing_template", new Item(new IID(Ids::WARD_ARMOR_TRIM_SMITHING_TEMPLATE), "Ward Armor Trim Smithing Template")); + self::register("wayfinder_armor_trim_smithing_template", new Item(new IID(Ids::WAYFINDER_ARMOR_TRIM_SMITHING_TEMPLATE), "Wayfinder Armor Trim Smithing Template")); + self::register("wild_armor_trim_smithing_template", new Item(new IID(Ids::WILD_ARMOR_TRIM_SMITHING_TEMPLATE), "Wild Armor Trim Smithing Template")); + } + } diff --git a/src/network/mcpe/compression/ZlibCompressor.php b/src/network/mcpe/compression/ZlibCompressor.php index 317a64451..066ba876a 100644 --- a/src/network/mcpe/compression/ZlibCompressor.php +++ b/src/network/mcpe/compression/ZlibCompressor.php @@ -67,17 +67,12 @@ final class ZlibCompressor implements Compressor{ return $result; } - private static function zlib_encode(string $data, int $level) : string{ - return Utils::assumeNotFalse(zlib_encode($data, ZLIB_ENCODING_RAW, $level), "ZLIB compression failed"); - } - public function compress(string $payload) : string{ $compressible = $this->minCompressionSize !== null && strlen($payload) >= $this->minCompressionSize; - if(function_exists('libdeflate_deflate_compress')){ - return $compressible ? - libdeflate_deflate_compress($payload, $this->level) : - self::zlib_encode($payload, 0); - } - return self::zlib_encode($payload, $compressible ? $this->level : 0); + $level = $compressible ? $this->level : 0; + + return function_exists('libdeflate_deflate_compress') ? + libdeflate_deflate_compress($payload, $level) : + Utils::assumeNotFalse(zlib_encode($payload, ZLIB_ENCODING_RAW, $level), "ZLIB compression failed"); } } diff --git a/src/world/World.php b/src/world/World.php index 3e1131272..f554479c9 100644 --- a/src/world/World.php +++ b/src/world/World.php @@ -1666,16 +1666,19 @@ class World implements ChunkManager{ } /** - * Returns the highest available level of any type of light at the given coordinates, adjusted for the current - * weather and time of day. + * Returns the highest level of any type of light at the given coordinates, adjusted for the current weather and + * time of day. */ public function getFullLight(Vector3 $pos) : int{ - return $this->getFullLightAt($pos->x, $pos->y, $pos->z); + $floorX = $pos->getFloorX(); + $floorY = $pos->getFloorY(); + $floorZ = $pos->getFloorZ(); + return $this->getFullLightAt($floorX, $floorY, $floorZ); } /** - * Returns the highest available level of any type of light at the given coordinates, adjusted for the current - * weather and time of day. + * Returns the highest level of any type of light at the given coordinates, adjusted for the current weather and + * time of day. */ public function getFullLightAt(int $x, int $y, int $z) : int{ $skyLight = $this->getRealBlockSkyLightAt($x, $y, $z); @@ -1687,18 +1690,43 @@ class World implements ChunkManager{ } /** - * Returns the highest available level of any type of light at, or adjacent to, the given coordinates, adjusted for - * the current weather and time of day. + * Returns the highest level of any type of light at, or adjacent to, the given coordinates, adjusted for the + * current weather and time of day. */ public function getHighestAdjacentFullLightAt(int $x, int $y, int $z) : int{ return $this->getHighestAdjacentLight($x, $y, $z, $this->getFullLightAt(...)); } + /** + * Returns the highest potential level of any type of light at the target coordinates. + * This is not affected by weather or time of day. + */ + public function getPotentialLight(Vector3 $pos) : int{ + $floorX = $pos->getFloorX(); + $floorY = $pos->getFloorY(); + $floorZ = $pos->getFloorZ(); + return $this->getPotentialLightAt($floorX, $floorY, $floorZ); + } + + /** + * Returns the highest potential level of any type of light at the target coordinates. + * This is not affected by weather or time of day. + */ + public function getPotentialLightAt(int $x, int $y, int $z) : int{ + return max($this->getPotentialBlockSkyLightAt($x, $y, $z), $this->getBlockLightAt($x, $y, $z)); + } + + /** + * Returns the highest potential level of any type of light at, or adjacent to, the given coordinates. + * This is not affected by weather or time of day. + */ + public function getHighestAdjacentPotentialLightAt(int $x, int $y, int $z) : int{ + return $this->getHighestAdjacentLight($x, $y, $z, $this->getPotentialLightAt(...)); + } + /** * Returns the highest potential level of sky light at the target coordinates, regardless of the time of day or * weather conditions. - * You usually don't want to use this for vanilla gameplay logic; prefer the real sky light instead. - * @see World::getRealBlockSkyLightAt() * * @return int 0-15 */ diff --git a/tests/phpstan/configs/actual-problems.neon b/tests/phpstan/configs/actual-problems.neon index cf7e9b02f..1e5d83dda 100644 --- a/tests/phpstan/configs/actual-problems.neon +++ b/tests/phpstan/configs/actual-problems.neon @@ -425,6 +425,21 @@ parameters: count: 3 path: ../../../src/block/tile/Spawnable.php + - + message: "#^Parameter \\#1 \\$x of method pocketmine\\\\world\\\\World\\:\\:getPotentialLightAt\\(\\) expects int, float\\|int given\\.$#" + count: 1 + path: ../../../src/block/utils/CropGrowthHelper.php + + - + message: "#^Parameter \\#2 \\$y of method pocketmine\\\\world\\\\World\\:\\:getPotentialLightAt\\(\\) expects int, float\\|int given\\.$#" + count: 1 + path: ../../../src/block/utils/CropGrowthHelper.php + + - + message: "#^Parameter \\#3 \\$z of method pocketmine\\\\world\\\\World\\:\\:getPotentialLightAt\\(\\) expects int, float\\|int given\\.$#" + count: 1 + path: ../../../src/block/utils/CropGrowthHelper.php + - message: "#^Cannot call method addParticle\\(\\) on pocketmine\\\\world\\\\World\\|null\\.$#" count: 1 @@ -910,11 +925,6 @@ parameters: count: 1 path: ../../../src/world/World.php - - - message: "#^Parameter \\#1 \\$x of method pocketmine\\\\world\\\\World\\:\\:getFullLightAt\\(\\) expects int, float\\|int given\\.$#" - count: 1 - path: ../../../src/world/World.php - - message: "#^Parameter \\#1 \\$x of method pocketmine\\\\world\\\\World\\:\\:getTileAt\\(\\) expects int, float\\|int given\\.$#" count: 1 @@ -940,11 +950,6 @@ parameters: count: 1 path: ../../../src/world/World.php - - - message: "#^Parameter \\#2 \\$y of method pocketmine\\\\world\\\\World\\:\\:getFullLightAt\\(\\) expects int, float\\|int given\\.$#" - count: 1 - path: ../../../src/world/World.php - - message: "#^Parameter \\#2 \\$y of method pocketmine\\\\world\\\\World\\:\\:getTileAt\\(\\) expects int, float\\|int given\\.$#" count: 1 @@ -975,11 +980,6 @@ parameters: count: 1 path: ../../../src/world/World.php - - - message: "#^Parameter \\#3 \\$z of method pocketmine\\\\world\\\\World\\:\\:getFullLightAt\\(\\) expects int, float\\|int given\\.$#" - count: 1 - path: ../../../src/world/World.php - - message: "#^Parameter \\#3 \\$z of method pocketmine\\\\world\\\\World\\:\\:getTileAt\\(\\) expects int, float\\|int given\\.$#" count: 1 diff --git a/tools/generate-blockstate-upgrade-schema.php b/tools/generate-blockstate-upgrade-schema.php index f247d6112..dfb8f6066 100644 --- a/tools/generate-blockstate-upgrade-schema.php +++ b/tools/generate-blockstate-upgrade-schema.php @@ -37,7 +37,6 @@ use pocketmine\network\mcpe\protocol\serializer\NetworkNbtSerializer; use pocketmine\utils\AssumptionFailedError; use pocketmine\utils\Filesystem; use pocketmine\utils\Utils; -use function array_filter; use function array_key_first; use function array_keys; use function array_map; @@ -481,16 +480,9 @@ function generateBlockStateUpgradeSchema(array $upgradeTable) : BlockStateUpgrad throw new \RuntimeException("States with the same ID should be fully consistent"); } }else{ - if(isset($newNameFound[$oldName])){ - //some of the states stayed under the same ID - we can process these as normal states - $stateGroup = array_filter($blockStateMappings, fn(BlockStateMapping $m) => $m->new->getName() === $oldName); - if(processStateGroup($oldName, $stateGroup, $result)){ - foreach(Utils::stringifyKeys($stateGroup) as $k => $mapping){ - unset($blockStateMappings[$k]); - } - } - } //block mapped to multiple different new IDs; we can't guess these, so we just do a plain old remap + //even if some of the states stay under the same ID, the compression techniques used by this function + //implicitly rely on knowing the full set of old states and their new transformations $result->remappedStates[$oldName] = processRemappedStates($blockStateMappings); } }