mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-20 16:00:20 +00:00
Skeleton for copper blocks, stairs and slabs
This commit is contained in:
parent
a44c089f98
commit
260e54e4b1
@ -24,6 +24,7 @@ declare(strict_types=1);
|
||||
namespace pocketmine\build\generate_runtime_enum_serializers;
|
||||
|
||||
use pocketmine\block\utils\BellAttachmentType;
|
||||
use pocketmine\block\utils\CopperOxidation;
|
||||
use pocketmine\block\utils\CoralType;
|
||||
use pocketmine\block\utils\DyeColor;
|
||||
use pocketmine\block\utils\LeverFacing;
|
||||
@ -154,6 +155,7 @@ function buildEnumReaderFunc(array $enumMembers, string &$functionName) : array{
|
||||
|
||||
$enumsUsed = [
|
||||
BellAttachmentType::getAll(),
|
||||
CopperOxidation::getAll(),
|
||||
CoralType::getAll(),
|
||||
DyeColor::getAll(),
|
||||
LeverFacing::getAll(),
|
||||
|
@ -680,6 +680,10 @@ final class BlockTypeIds{
|
||||
public const CRYING_OBSIDIAN = 10653;
|
||||
public const GILDED_BLACKSTONE = 10654;
|
||||
public const LIGHTNING_ROD = 10655;
|
||||
public const COPPER = 10656;
|
||||
public const CUT_COPPER = 10657;
|
||||
public const CUT_COPPER_SLAB = 10658;
|
||||
public const CUT_COPPER_STAIRS = 10659;
|
||||
|
||||
public const FIRST_UNUSED_BLOCK_ID = 10656;
|
||||
public const FIRST_UNUSED_BLOCK_ID = 10660;
|
||||
}
|
||||
|
30
src/block/Copper.php
Normal file
30
src/block/Copper.php
Normal file
@ -0,0 +1,30 @@
|
||||
<?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\block;
|
||||
|
||||
use pocketmine\block\utils\CopperTrait;
|
||||
|
||||
class Copper extends Opaque{
|
||||
use CopperTrait;
|
||||
}
|
30
src/block/CopperSlab.php
Normal file
30
src/block/CopperSlab.php
Normal file
@ -0,0 +1,30 @@
|
||||
<?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\block;
|
||||
|
||||
use pocketmine\block\utils\CopperTrait;
|
||||
|
||||
class CopperSlab extends Slab{
|
||||
use CopperTrait;
|
||||
}
|
30
src/block/CopperStairs.php
Normal file
30
src/block/CopperStairs.php
Normal file
@ -0,0 +1,30 @@
|
||||
<?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\block;
|
||||
|
||||
use pocketmine\block\utils\CopperTrait;
|
||||
|
||||
class CopperStairs extends Stair{
|
||||
use CopperTrait;
|
||||
}
|
@ -164,6 +164,7 @@ use function mb_strtolower;
|
||||
* @method static ChemistryTable COMPOUND_CREATOR()
|
||||
* @method static Concrete CONCRETE()
|
||||
* @method static ConcretePowder CONCRETE_POWDER()
|
||||
* @method static Copper COPPER()
|
||||
* @method static CopperOre COPPER_ORE()
|
||||
* @method static Coral CORAL()
|
||||
* @method static CoralBlock CORAL_BLOCK()
|
||||
@ -189,6 +190,9 @@ use function mb_strtolower;
|
||||
* @method static WoodenTrapdoor CRIMSON_TRAPDOOR()
|
||||
* @method static WallSign CRIMSON_WALL_SIGN()
|
||||
* @method static Opaque CRYING_OBSIDIAN()
|
||||
* @method static Copper CUT_COPPER()
|
||||
* @method static CopperSlab CUT_COPPER_SLAB()
|
||||
* @method static CopperStairs CUT_COPPER_STAIRS()
|
||||
* @method static Opaque CUT_RED_SANDSTONE()
|
||||
* @method static Slab CUT_RED_SANDSTONE_SLAB()
|
||||
* @method static Opaque CUT_SANDSTONE()
|
||||
@ -1454,6 +1458,11 @@ final class VanillaBlocks{
|
||||
//blast resistance should be 30 if we were matched with java :(
|
||||
$copperBreakInfo = new BreakInfo(3.0, ToolType::PICKAXE, ToolTier::STONE()->getHarvestLevel(), 18.0);
|
||||
self::register("lightning_rod", new LightningRod(new BID(Ids::LIGHTNING_ROD), "Lightning Rod", $copperBreakInfo));
|
||||
|
||||
self::register("copper", new Copper(new BID(Ids::COPPER), "Copper Block", $copperBreakInfo));
|
||||
self::register("cut_copper", new Copper(new BID(Ids::CUT_COPPER), "Cut Copper Block", $copperBreakInfo));
|
||||
self::register("cut_copper_slab", new CopperSlab(new BID(Ids::CUT_COPPER_SLAB), "Cut Copper Slab", $copperBreakInfo));
|
||||
self::register("cut_copper_stairs", new CopperStairs(new BID(Ids::CUT_COPPER_STAIRS), "Cut Copper Stairs", $copperBreakInfo));
|
||||
}
|
||||
|
||||
private static function registerMudBlocks() : void{
|
||||
|
79
src/block/utils/CopperOxidation.php
Normal file
79
src/block/utils/CopperOxidation.php
Normal file
@ -0,0 +1,79 @@
|
||||
<?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\block\utils;
|
||||
|
||||
use pocketmine\utils\EnumTrait;
|
||||
|
||||
/**
|
||||
* This doc-block is generated automatically, do not modify it manually.
|
||||
* This must be regenerated whenever registry members are added, removed or changed.
|
||||
* @see build/generate-registry-annotations.php
|
||||
* @generate-registry-docblock
|
||||
*
|
||||
* @method static CopperOxidation EXPOSED()
|
||||
* @method static CopperOxidation NONE()
|
||||
* @method static CopperOxidation OXIDIZED()
|
||||
* @method static CopperOxidation WEATHERED()
|
||||
*/
|
||||
final class CopperOxidation{
|
||||
use EnumTrait {
|
||||
__construct as Enum___construct;
|
||||
register as Enum_register;
|
||||
}
|
||||
|
||||
protected static function setup() : void{
|
||||
self::registerAll(
|
||||
new self("none", 0),
|
||||
new self("exposed", 1),
|
||||
new self("weathered", 2),
|
||||
new self("oxidized", 3)
|
||||
);
|
||||
}
|
||||
|
||||
protected static function register(self $member) : void{
|
||||
self::Enum_register($member);
|
||||
self::$levelMap[$member->value] = $member;
|
||||
}
|
||||
|
||||
/**
|
||||
* @var self[]
|
||||
* @phpstan-var array<int, self>
|
||||
*/
|
||||
private static array $levelMap = [];
|
||||
|
||||
private function __construct(
|
||||
string $name,
|
||||
private int $value
|
||||
){
|
||||
$this->Enum___construct($name);
|
||||
}
|
||||
|
||||
public function getPrevious() : ?self{
|
||||
return self::$levelMap[$this->value - 1] ?? null;
|
||||
}
|
||||
|
||||
public function getNext() : ?self{
|
||||
return self::$levelMap[$this->value + 1] ?? null;
|
||||
}
|
||||
}
|
@ -47,6 +47,9 @@ use pocketmine\block\Chest;
|
||||
use pocketmine\block\CocoaBlock;
|
||||
use pocketmine\block\Concrete;
|
||||
use pocketmine\block\ConcretePowder;
|
||||
use pocketmine\block\Copper;
|
||||
use pocketmine\block\CopperSlab;
|
||||
use pocketmine\block\CopperStairs;
|
||||
use pocketmine\block\Coral;
|
||||
use pocketmine\block\CoralBlock;
|
||||
use pocketmine\block\DaylightSensor;
|
||||
@ -419,6 +422,80 @@ final class BlockObjectToBlockStateSerializer implements BlockStateSerializer{
|
||||
$this->mapStairs(Blocks::COBBLESTONE_STAIRS(), Ids::STONE_STAIRS);
|
||||
$this->map(Blocks::COBBLESTONE_WALL(), fn(Wall $block) => Helper::encodeLegacyWall($block, StringValues::WALL_BLOCK_TYPE_COBBLESTONE));
|
||||
$this->mapSimple(Blocks::COBWEB(), Ids::WEB);
|
||||
$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::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::COCOA_POD(), function(CocoaBlock $block) : Writer{
|
||||
return Writer::create(Ids::COCOA)
|
||||
->writeInt(StateNames::AGE, $block->getAge())
|
||||
|
@ -25,6 +25,9 @@ namespace pocketmine\data\bedrock\block\convert;
|
||||
|
||||
use pocketmine\block\Block;
|
||||
use pocketmine\block\Button;
|
||||
use pocketmine\block\Copper;
|
||||
use pocketmine\block\CopperSlab;
|
||||
use pocketmine\block\CopperStairs;
|
||||
use pocketmine\block\Crops;
|
||||
use pocketmine\block\DaylightSensor;
|
||||
use pocketmine\block\Door;
|
||||
@ -41,6 +44,7 @@ use pocketmine\block\Slab;
|
||||
use pocketmine\block\Stair;
|
||||
use pocketmine\block\Stem;
|
||||
use pocketmine\block\Trapdoor;
|
||||
use pocketmine\block\utils\CopperOxidation;
|
||||
use pocketmine\block\utils\DyeColor;
|
||||
use pocketmine\block\VanillaBlocks;
|
||||
use pocketmine\block\Wall;
|
||||
@ -85,6 +89,30 @@ final class BlockStateDeserializerHelper{
|
||||
->setSubtractMode($in->readBool(BlockStateNames::OUTPUT_SUBTRACT_BIT));
|
||||
}
|
||||
|
||||
/**
|
||||
* @phpstan-template TBlock of Copper|CopperSlab|CopperStairs
|
||||
*
|
||||
* @phpstan-param TBlock $block
|
||||
* @phpstan-return TBlock
|
||||
*/
|
||||
public static function decodeCopper(Copper|CopperSlab|CopperStairs $block, CopperOxidation $oxidation) : Copper|CopperSlab|CopperStairs{
|
||||
$block->setOxidation($oxidation);
|
||||
$block->setWaxed(false);
|
||||
return $block;
|
||||
}
|
||||
|
||||
/**
|
||||
* @phpstan-template TBlock of Copper|CopperSlab|CopperStairs
|
||||
*
|
||||
* @phpstan-param TBlock $block
|
||||
* @phpstan-return TBlock
|
||||
*/
|
||||
public static function decodeWaxedCopper(Copper|CopperSlab|CopperStairs $block, CopperOxidation $oxidation) : Copper|CopperSlab|CopperStairs{
|
||||
$block->setOxidation($oxidation);
|
||||
$block->setWaxed(true);
|
||||
return $block;
|
||||
}
|
||||
|
||||
/** @throws BlockStateDeserializeException */
|
||||
public static function decodeDaylightSensor(DaylightSensor $block, BlockStateReader $in) : DaylightSensor{
|
||||
return $block
|
||||
|
@ -41,6 +41,7 @@ use pocketmine\block\Stair;
|
||||
use pocketmine\block\Stem;
|
||||
use pocketmine\block\Torch;
|
||||
use pocketmine\block\Trapdoor;
|
||||
use pocketmine\block\utils\CopperOxidation;
|
||||
use pocketmine\block\utils\SlabType;
|
||||
use pocketmine\block\Wall;
|
||||
use pocketmine\block\WallSign;
|
||||
@ -49,6 +50,7 @@ use pocketmine\data\bedrock\block\BlockStateNames;
|
||||
use pocketmine\data\bedrock\block\BlockTypeNames as Ids;
|
||||
use pocketmine\data\bedrock\MushroomBlockTypeIdMap;
|
||||
use pocketmine\math\Facing;
|
||||
use pocketmine\utils\AssumptionFailedError;
|
||||
|
||||
final class BlockStateSerializerHelper{
|
||||
|
||||
@ -81,6 +83,16 @@ final class BlockStateSerializerHelper{
|
||||
->writeTorchFacing($block->getFacing());
|
||||
}
|
||||
|
||||
public static function selectCopperId(CopperOxidation $oxidation, string $noneId, string $exposedId, string $weatheredId, string $oxidizedId) : string{
|
||||
return match($oxidation){
|
||||
CopperOxidation::NONE() => $noneId,
|
||||
CopperOxidation::EXPOSED() => $exposedId,
|
||||
CopperOxidation::WEATHERED() => $weatheredId,
|
||||
CopperOxidation::OXIDIZED() => $oxidizedId,
|
||||
default => throw new AssumptionFailedError("Unhandled copper oxidation " . $oxidation->name())
|
||||
};
|
||||
}
|
||||
|
||||
public static function encodeDoor(Door $block, BlockStateWriter $out) : BlockStateWriter{
|
||||
return $out
|
||||
->writeBool(BlockStateNames::UPPER_BLOCK_BIT, $block->isTop())
|
||||
|
@ -30,6 +30,7 @@ use pocketmine\block\Slab;
|
||||
use pocketmine\block\Stair;
|
||||
use pocketmine\block\SweetBerryBush;
|
||||
use pocketmine\block\utils\BrewingStandSlot;
|
||||
use pocketmine\block\utils\CopperOxidation;
|
||||
use pocketmine\block\utils\CoralType;
|
||||
use pocketmine\block\utils\DyeColor;
|
||||
use pocketmine\block\utils\LeverFacing;
|
||||
@ -270,6 +271,10 @@ final class BlockStateToBlockObjectDeserializer implements BlockStateDeserialize
|
||||
return Blocks::CONCRETE_POWDER()
|
||||
->setColor($in->readColor());
|
||||
});
|
||||
$this->map(Ids::COPPER_BLOCK, fn() => Helper::decodeCopper(Blocks::COPPER(), CopperOxidation::NONE()));
|
||||
$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->map(Ids::COPPER_ORE, fn() => Blocks::COPPER_ORE());
|
||||
$this->map(Ids::CORAL, function(Reader $in) : Block{
|
||||
return Blocks::CORAL()
|
||||
@ -537,6 +542,10 @@ final class BlockStateToBlockObjectDeserializer implements BlockStateDeserialize
|
||||
return Blocks::ENDER_CHEST()
|
||||
->setFacing($in->readHorizontalFacing());
|
||||
});
|
||||
$this->map(Ids::EXPOSED_COPPER, fn() => Helper::decodeCopper(Blocks::COPPER(), 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::FARMLAND, function(Reader $in) : Block{
|
||||
return Blocks::FARMLAND()
|
||||
->setWetness($in->readBoundedInt(StateNames::MOISTURIZED_AMOUNT, 0, 7));
|
||||
@ -799,6 +808,10 @@ final class BlockStateToBlockObjectDeserializer implements BlockStateDeserialize
|
||||
$this->mapStairs(Ids::OAK_STAIRS, fn() => Blocks::OAK_STAIRS());
|
||||
$this->map(Ids::OBSIDIAN, fn() => Blocks::OBSIDIAN());
|
||||
$this->map(Ids::ORANGE_GLAZED_TERRACOTTA, fn(Reader $in) => Helper::decodeGlazedTerracotta(DyeColor::ORANGE(), $in));
|
||||
$this->map(Ids::OXIDIZED_COPPER, fn() => Helper::decodeCopper(Blocks::COPPER(), 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::PACKED_ICE, fn() => Blocks::PACKED_ICE());
|
||||
$this->map(Ids::PINK_GLAZED_TERRACOTTA, fn(Reader $in) => Helper::decodeGlazedTerracotta(DyeColor::PINK(), $in));
|
||||
$this->map(Ids::PLANKS, function(Reader $in) : Block{
|
||||
@ -1196,6 +1209,26 @@ final class BlockStateToBlockObjectDeserializer implements BlockStateDeserialize
|
||||
$this->map(Ids::WARPED_WART_BLOCK, fn() => Blocks::WARPED_WART_BLOCK());
|
||||
$this->map(Ids::WATER, fn(Reader $in) => Helper::decodeStillLiquid(Blocks::WATER(), $in));
|
||||
$this->map(Ids::WATERLILY, fn() => Blocks::LILY_PAD());
|
||||
$this->map(Ids::WAXED_COPPER, fn() => Helper::decodeWaxedCopper(Blocks::COPPER(), 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_EXPOSED_COPPER, fn() => Helper::decodeWaxedCopper(Blocks::COPPER(), 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_OXIDIZED_COPPER, fn() => Helper::decodeWaxedCopper(Blocks::COPPER(), 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_WEATHERED_COPPER, fn() => Helper::decodeWaxedCopper(Blocks::COPPER(), 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::WEATHERED_COPPER, fn() => Helper::decodeCopper(Blocks::COPPER(), 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::WEB, fn() => Blocks::COBWEB());
|
||||
$this->map(Ids::WHEAT, fn(Reader $in) => Helper::decodeCrops(Blocks::WHEAT(), $in));
|
||||
$this->map(Ids::WHITE_GLAZED_TERRACOTTA, fn(Reader $in) => Helper::decodeGlazedTerracotta(DyeColor::WHITE(), $in));
|
||||
|
@ -39,6 +39,16 @@ final class RuntimeEnumDeserializer{
|
||||
};
|
||||
}
|
||||
|
||||
public static function readCopperOxidation(RuntimeDataReader $r) : \pocketmine\block\utils\CopperOxidation{
|
||||
return match($r->readInt(2)){
|
||||
0 => \pocketmine\block\utils\CopperOxidation::EXPOSED(),
|
||||
1 => \pocketmine\block\utils\CopperOxidation::NONE(),
|
||||
2 => \pocketmine\block\utils\CopperOxidation::OXIDIZED(),
|
||||
3 => \pocketmine\block\utils\CopperOxidation::WEATHERED(),
|
||||
default => throw new InvalidSerializedRuntimeDataException("Invalid serialized value for CopperOxidation")
|
||||
};
|
||||
}
|
||||
|
||||
public static function readCoralType(RuntimeDataReader $r) : \pocketmine\block\utils\CoralType{
|
||||
return match($r->readInt(3)){
|
||||
0 => \pocketmine\block\utils\CoralType::BRAIN(),
|
||||
|
@ -39,6 +39,16 @@ final class RuntimeEnumSerializer{
|
||||
});
|
||||
}
|
||||
|
||||
public static function writeCopperOxidation(RuntimeDataWriter $w, \pocketmine\block\utils\CopperOxidation $value) : void{
|
||||
$w->writeInt(2, match($value){
|
||||
\pocketmine\block\utils\CopperOxidation::EXPOSED() => 0,
|
||||
\pocketmine\block\utils\CopperOxidation::NONE() => 1,
|
||||
\pocketmine\block\utils\CopperOxidation::OXIDIZED() => 2,
|
||||
\pocketmine\block\utils\CopperOxidation::WEATHERED() => 3,
|
||||
default => throw new \pocketmine\utils\AssumptionFailedError("All CopperOxidation cases should be covered")
|
||||
});
|
||||
}
|
||||
|
||||
public static function writeCoralType(RuntimeDataWriter $w, \pocketmine\block\utils\CoralType $value) : void{
|
||||
$w->writeInt(3, match($value){
|
||||
\pocketmine\block\utils\CoralType::BRAIN() => 0,
|
||||
|
@ -25,6 +25,7 @@ namespace pocketmine\item;
|
||||
|
||||
use pocketmine\block\Block;
|
||||
use pocketmine\block\Light;
|
||||
use pocketmine\block\utils\CopperOxidation;
|
||||
use pocketmine\block\utils\CoralType;
|
||||
use pocketmine\block\utils\DyeColor;
|
||||
use pocketmine\block\utils\SkullType;
|
||||
@ -77,6 +78,18 @@ final class StringToItemParser extends StringToTParser{
|
||||
$result->registerBlock("light_block_$i", fn() => Blocks::LIGHT()->setLightLevel($i));
|
||||
}
|
||||
|
||||
foreach(CopperOxidation::getAll() as $oxidation){
|
||||
$oxPrefix = $oxidation->equals(CopperOxidation::NONE()) ? "" : $oxidation->name() . "_";
|
||||
|
||||
foreach(["" => false, "waxed_" => true] as $waxedPrefix => $waxed){
|
||||
$prefix = $waxedPrefix . $oxPrefix;
|
||||
$result->registerBlock($prefix . "copper_block", fn() => Blocks::COPPER()->setOxidation($oxidation)->setWaxed($waxed));
|
||||
$result->registerBlock($prefix . "cut_copper_block", fn() => Blocks::CUT_COPPER()->setOxidation($oxidation)->setWaxed($waxed));
|
||||
$result->registerBlock($prefix . "cut_copper_stairs", fn() => Blocks::CUT_COPPER_STAIRS()->setOxidation($oxidation)->setWaxed($waxed));
|
||||
$result->registerBlock($prefix . "cut_copper_slab", fn() => Blocks::CUT_COPPER_SLAB()->setOxidation($oxidation)->setWaxed($waxed));
|
||||
}
|
||||
}
|
||||
|
||||
$result->registerBlock("acacia_button", fn() => Blocks::ACACIA_BUTTON());
|
||||
$result->registerBlock("acacia_door", fn() => Blocks::ACACIA_DOOR());
|
||||
$result->registerBlock("acacia_door_block", fn() => Blocks::ACACIA_DOOR());
|
||||
|
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user