mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-08 04:38:35 +00:00
Implemented chain (#5454)
This commit is contained in:
parent
044d35956e
commit
b3473960b4
@ -706,8 +706,9 @@ final class BlockTypeIds{
|
|||||||
public const FROGLIGHT = 10679;
|
public const FROGLIGHT = 10679;
|
||||||
public const TWISTING_VINES = 10680;
|
public const TWISTING_VINES = 10680;
|
||||||
public const WEEPING_VINES = 10681;
|
public const WEEPING_VINES = 10681;
|
||||||
|
public const CHAIN = 10682;
|
||||||
|
|
||||||
public const FIRST_UNUSED_BLOCK_ID = 10682;
|
public const FIRST_UNUSED_BLOCK_ID = 10683;
|
||||||
|
|
||||||
private static int $nextDynamicId = self::FIRST_UNUSED_BLOCK_ID;
|
private static int $nextDynamicId = self::FIRST_UNUSED_BLOCK_ID;
|
||||||
|
|
||||||
|
48
src/block/Chain.php
Normal file
48
src/block/Chain.php
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
<?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\PillarRotationTrait;
|
||||||
|
use pocketmine\block\utils\SupportType;
|
||||||
|
use pocketmine\math\Axis;
|
||||||
|
use pocketmine\math\AxisAlignedBB;
|
||||||
|
use pocketmine\math\Facing;
|
||||||
|
|
||||||
|
final class Chain extends Transparent{
|
||||||
|
use PillarRotationTrait;
|
||||||
|
|
||||||
|
public function getSupportType(int $facing) : SupportType{
|
||||||
|
return $this->axis === Axis::Y && Facing::axis($facing) === Axis::Y ? SupportType::CENTER() : SupportType::NONE();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function recalculateCollisionBoxes() : array{
|
||||||
|
$bb = AxisAlignedBB::one();
|
||||||
|
foreach([Axis::Y, Axis::Z, Axis::X] as $axis){
|
||||||
|
if($axis !== $this->axis){
|
||||||
|
$bb->squash($axis, 13 / 32);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return [$bb];
|
||||||
|
}
|
||||||
|
}
|
@ -153,6 +153,7 @@ use function mb_strtolower;
|
|||||||
* @method static CartographyTable CARTOGRAPHY_TABLE()
|
* @method static CartographyTable CARTOGRAPHY_TABLE()
|
||||||
* @method static CarvedPumpkin CARVED_PUMPKIN()
|
* @method static CarvedPumpkin CARVED_PUMPKIN()
|
||||||
* @method static Cauldron CAULDRON()
|
* @method static Cauldron CAULDRON()
|
||||||
|
* @method static Chain CHAIN()
|
||||||
* @method static ChemicalHeat CHEMICAL_HEAT()
|
* @method static ChemicalHeat CHEMICAL_HEAT()
|
||||||
* @method static Chest CHEST()
|
* @method static Chest CHEST()
|
||||||
* @method static Opaque CHISELED_DEEPSLATE()
|
* @method static Opaque CHISELED_DEEPSLATE()
|
||||||
@ -1473,6 +1474,8 @@ final class VanillaBlocks{
|
|||||||
|
|
||||||
self::register("twisting_vines", new NetherVines(new BID(Ids::TWISTING_VINES), "Twisting Vines", new Info(BreakInfo::instant()), Facing::UP));
|
self::register("twisting_vines", new NetherVines(new BID(Ids::TWISTING_VINES), "Twisting Vines", new Info(BreakInfo::instant()), Facing::UP));
|
||||||
self::register("weeping_vines", new NetherVines(new BID(Ids::WEEPING_VINES), "Weeping Vines", new Info(BreakInfo::instant()), Facing::DOWN));
|
self::register("weeping_vines", new NetherVines(new BID(Ids::WEEPING_VINES), "Weeping Vines", new Info(BreakInfo::instant()), Facing::DOWN));
|
||||||
|
|
||||||
|
self::register("chain", new Chain(new BID(Ids::CHAIN), "Chain", new Info(BreakInfo::pickaxe(5.0, ToolTier::WOOD()))));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function registerBlocksR17() : void{
|
private static function registerBlocksR17() : void{
|
||||||
|
@ -45,6 +45,7 @@ use pocketmine\block\Candle;
|
|||||||
use pocketmine\block\Carpet;
|
use pocketmine\block\Carpet;
|
||||||
use pocketmine\block\Carrot;
|
use pocketmine\block\Carrot;
|
||||||
use pocketmine\block\CarvedPumpkin;
|
use pocketmine\block\CarvedPumpkin;
|
||||||
|
use pocketmine\block\Chain;
|
||||||
use pocketmine\block\ChemistryTable;
|
use pocketmine\block\ChemistryTable;
|
||||||
use pocketmine\block\Chest;
|
use pocketmine\block\Chest;
|
||||||
use pocketmine\block\ChorusFlower;
|
use pocketmine\block\ChorusFlower;
|
||||||
@ -712,6 +713,10 @@ final class BlockObjectToStateSerializer implements BlockStateSerializer{
|
|||||||
return Writer::create(Ids::CARVED_PUMPKIN)
|
return Writer::create(Ids::CARVED_PUMPKIN)
|
||||||
->writeLegacyHorizontalFacing($block->getFacing());
|
->writeLegacyHorizontalFacing($block->getFacing());
|
||||||
});
|
});
|
||||||
|
$this->map(Blocks::CHAIN(), function(Chain $block) : Writer{
|
||||||
|
return Writer::create(Ids::CHAIN)
|
||||||
|
->writePillarAxis($block->getAxis());
|
||||||
|
});
|
||||||
$this->map(Blocks::CHEST(), function(Chest $block) : Writer{
|
$this->map(Blocks::CHEST(), function(Chest $block) : Writer{
|
||||||
return Writer::create(Ids::CHEST)
|
return Writer::create(Ids::CHEST)
|
||||||
->writeHorizontalFacing($block->getFacing());
|
->writeHorizontalFacing($block->getFacing());
|
||||||
|
@ -549,6 +549,10 @@ final class BlockStateToObjectDeserializer implements BlockStateDeserializer{
|
|||||||
return Blocks::CARVED_PUMPKIN()
|
return Blocks::CARVED_PUMPKIN()
|
||||||
->setFacing($in->readLegacyHorizontalFacing());
|
->setFacing($in->readLegacyHorizontalFacing());
|
||||||
});
|
});
|
||||||
|
$this->map(Ids::CHAIN, function(Reader $in) : Block{
|
||||||
|
return Blocks::CHAIN()
|
||||||
|
->setAxis($in->readPillarAxis());
|
||||||
|
});
|
||||||
$this->map(Ids::CHEMISTRY_TABLE, function(Reader $in) : Block{
|
$this->map(Ids::CHEMISTRY_TABLE, function(Reader $in) : Block{
|
||||||
return (match($type = $in->readString(StateNames::CHEMISTRY_TABLE_TYPE)){
|
return (match($type = $in->readString(StateNames::CHEMISTRY_TABLE_TYPE)){
|
||||||
StringValues::CHEMISTRY_TABLE_TYPE_COMPOUND_CREATOR => Blocks::COMPOUND_CREATOR(),
|
StringValues::CHEMISTRY_TABLE_TYPE_COMPOUND_CREATOR => Blocks::COMPOUND_CREATOR(),
|
||||||
|
@ -134,6 +134,7 @@ final class ItemSerializerDeserializerRegistrar{
|
|||||||
$this->map1to1Block(Ids::BREWING_STAND, Blocks::BREWING_STAND());
|
$this->map1to1Block(Ids::BREWING_STAND, Blocks::BREWING_STAND());
|
||||||
$this->map1to1Block(Ids::CAKE, Blocks::CAKE());
|
$this->map1to1Block(Ids::CAKE, Blocks::CAKE());
|
||||||
$this->map1to1Block(Ids::CAULDRON, Blocks::CAULDRON());
|
$this->map1to1Block(Ids::CAULDRON, Blocks::CAULDRON());
|
||||||
|
$this->map1to1Block(Ids::CHAIN, Blocks::CHAIN());
|
||||||
$this->map1to1Block(Ids::COMPARATOR, Blocks::REDSTONE_COMPARATOR());
|
$this->map1to1Block(Ids::COMPARATOR, Blocks::REDSTONE_COMPARATOR());
|
||||||
$this->map1to1Block(Ids::CRIMSON_DOOR, Blocks::CRIMSON_DOOR());
|
$this->map1to1Block(Ids::CRIMSON_DOOR, Blocks::CRIMSON_DOOR());
|
||||||
$this->map1to1Block(Ids::DARK_OAK_DOOR, Blocks::DARK_OAK_DOOR());
|
$this->map1to1Block(Ids::DARK_OAK_DOOR, Blocks::DARK_OAK_DOOR());
|
||||||
|
@ -205,6 +205,7 @@ final class StringToItemParser extends StringToTParser{
|
|||||||
$result->registerBlock("carrots", fn() => Blocks::CARROTS());
|
$result->registerBlock("carrots", fn() => Blocks::CARROTS());
|
||||||
$result->registerBlock("carved_pumpkin", fn() => Blocks::CARVED_PUMPKIN());
|
$result->registerBlock("carved_pumpkin", fn() => Blocks::CARVED_PUMPKIN());
|
||||||
$result->registerBlock("cauldron", fn() => Blocks::CAULDRON());
|
$result->registerBlock("cauldron", fn() => Blocks::CAULDRON());
|
||||||
|
$result->registerBlock("chain", fn() => Blocks::CHAIN());
|
||||||
$result->registerBlock("chemical_heat", fn() => Blocks::CHEMICAL_HEAT());
|
$result->registerBlock("chemical_heat", fn() => Blocks::CHEMICAL_HEAT());
|
||||||
$result->registerBlock("chemistry_table", fn() => Blocks::COMPOUND_CREATOR());
|
$result->registerBlock("chemistry_table", fn() => Blocks::COMPOUND_CREATOR());
|
||||||
$result->registerBlock("chest", fn() => Blocks::CHEST());
|
$result->registerBlock("chest", fn() => Blocks::CHEST());
|
||||||
|
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user