mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-21 00:07:30 +00:00
Added froglights
This commit is contained in:
parent
4419161a49
commit
102406ee79
@ -28,6 +28,7 @@ use pocketmine\block\utils\CopperOxidation;
|
||||
use pocketmine\block\utils\CoralType;
|
||||
use pocketmine\block\utils\DirtType;
|
||||
use pocketmine\block\utils\DyeColor;
|
||||
use pocketmine\block\utils\FroglightType;
|
||||
use pocketmine\block\utils\LeverFacing;
|
||||
use pocketmine\block\utils\MushroomBlockType;
|
||||
use pocketmine\block\utils\SkullType;
|
||||
@ -161,6 +162,7 @@ $enumsUsed = [
|
||||
CoralType::getAll(),
|
||||
DirtType::getAll(),
|
||||
DyeColor::getAll(),
|
||||
FroglightType::getAll(),
|
||||
LeverFacing::getAll(),
|
||||
MushroomBlockType::getAll(),
|
||||
SkullType::getAll(),
|
||||
|
@ -703,6 +703,7 @@ final class BlockTypeIds{
|
||||
public const CHORUS_PLANT = 10676;
|
||||
public const MANGROVE_ROOTS = 10677;
|
||||
public const MUDDY_MANGROVE_ROOTS = 10678;
|
||||
public const FROGLIGHT = 10679;
|
||||
|
||||
public const FIRST_UNUSED_BLOCK_ID = 10679;
|
||||
public const FIRST_UNUSED_BLOCK_ID = 10680;
|
||||
}
|
||||
|
56
src/block/Froglight.php
Normal file
56
src/block/Froglight.php
Normal file
@ -0,0 +1,56 @@
|
||||
<?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\FroglightType;
|
||||
use pocketmine\data\runtime\RuntimeDataReader;
|
||||
use pocketmine\data\runtime\RuntimeDataWriter;
|
||||
|
||||
final class Froglight extends SimplePillar{
|
||||
|
||||
private FroglightType $froglightType;
|
||||
|
||||
public function __construct(BlockIdentifier $idInfo, string $name, BlockBreakInfo $breakInfo){
|
||||
$this->froglightType = FroglightType::OCHRE();
|
||||
parent::__construct($idInfo, $name, $breakInfo);
|
||||
}
|
||||
|
||||
public function getRequiredTypeDataBits() : int{ return 2; }
|
||||
|
||||
protected function describeType(RuntimeDataReader|RuntimeDataWriter $w) : void{
|
||||
$w->froglightType($this->froglightType);
|
||||
}
|
||||
|
||||
public function getFroglightType() : FroglightType{ return $this->froglightType; }
|
||||
|
||||
/** @return $this */
|
||||
public function setFroglightType(FroglightType $froglightType) : self{
|
||||
$this->froglightType = $froglightType;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getLightLevel() : int{
|
||||
return 15;
|
||||
}
|
||||
}
|
@ -393,6 +393,7 @@ use function mb_strtolower;
|
||||
* @method static Fire FIRE()
|
||||
* @method static FletchingTable FLETCHING_TABLE()
|
||||
* @method static FlowerPot FLOWER_POT()
|
||||
* @method static Froglight FROGLIGHT()
|
||||
* @method static FrostedIce FROSTED_ICE()
|
||||
* @method static Furnace FURNACE()
|
||||
* @method static GildedBlackstone GILDED_BLACKSTONE()
|
||||
@ -1170,6 +1171,7 @@ final class VanillaBlocks{
|
||||
self::register("mangrove_roots", new MangroveRoots(new BID(Ids::MANGROVE_ROOTS), "Mangrove Roots", new BreakInfo(0.7, ToolType::AXE)));
|
||||
//TODO: muddy mangrove roots are supposed to be axis-rotatable (Bedrock parity issue https://bugs.mojang.com/browse/MCPE-153721)
|
||||
self::register("muddy_mangrove_roots", new Transparent(new BID(Ids::MUDDY_MANGROVE_ROOTS), "Muddy Mangrove Roots", new BreakInfo(0.7, ToolType::SHOVEL)));
|
||||
self::register("froglight", new Froglight(new BID(Ids::FROGLIGHT), "Froglight", new BreakInfo(0.3)));
|
||||
|
||||
self::registerBlocksR13();
|
||||
self::registerBlocksR14();
|
||||
|
48
src/block/utils/FroglightType.php
Normal file
48
src/block/utils/FroglightType.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\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 FroglightType OCHRE()
|
||||
* @method static FroglightType PEARLESCENT()
|
||||
* @method static FroglightType VERDANT()
|
||||
*/
|
||||
final class FroglightType{
|
||||
use EnumTrait;
|
||||
|
||||
protected static function setup() : void{
|
||||
self::registerAll(
|
||||
new self("ochre"),
|
||||
new self("pearlescent"),
|
||||
new self("verdant")
|
||||
);
|
||||
}
|
||||
}
|
@ -74,6 +74,7 @@ use pocketmine\block\Fire;
|
||||
use pocketmine\block\FloorBanner;
|
||||
use pocketmine\block\FloorCoralFan;
|
||||
use pocketmine\block\FloorSign;
|
||||
use pocketmine\block\Froglight;
|
||||
use pocketmine\block\FrostedIce;
|
||||
use pocketmine\block\Furnace;
|
||||
use pocketmine\block\GlazedTerracotta;
|
||||
@ -134,6 +135,7 @@ use pocketmine\block\utils\BrewingStandSlot;
|
||||
use pocketmine\block\utils\CoralType;
|
||||
use pocketmine\block\utils\DirtType;
|
||||
use pocketmine\block\utils\DyeColor;
|
||||
use pocketmine\block\utils\FroglightType;
|
||||
use pocketmine\block\utils\LeverFacing;
|
||||
use pocketmine\block\VanillaBlocks as Blocks;
|
||||
use pocketmine\block\Vine;
|
||||
@ -939,6 +941,15 @@ final class BlockObjectToBlockStateSerializer implements BlockStateSerializer{
|
||||
return Writer::create(Ids::FLOWER_POT)
|
||||
->writeBool(StateNames::UPDATE_BIT, false); //to keep MCPE happy
|
||||
});
|
||||
$this->map(Blocks::FROGLIGHT(), function(Froglight $block){
|
||||
return Writer::create(match($block->getFroglightType()){
|
||||
FroglightType::OCHRE() => Ids::OCHRE_FROGLIGHT,
|
||||
FroglightType::PEARLESCENT() => Ids::PEARLESCENT_FROGLIGHT,
|
||||
FroglightType::VERDANT() => Ids::VERDANT_FROGLIGHT,
|
||||
default => throw new AssumptionFailedError("Unhandled froglight type " . $block->getFroglightType()->name())
|
||||
})
|
||||
->writePillarAxis($block->getAxis());
|
||||
});
|
||||
$this->map(Blocks::FROSTED_ICE(), function(FrostedIce $block) : Writer{
|
||||
return Writer::create(Ids::FROSTED_ICE)
|
||||
->writeInt(StateNames::AGE, $block->getAge());
|
||||
|
@ -35,6 +35,7 @@ use pocketmine\block\utils\CopperOxidation;
|
||||
use pocketmine\block\utils\CoralType;
|
||||
use pocketmine\block\utils\DirtType;
|
||||
use pocketmine\block\utils\DyeColor;
|
||||
use pocketmine\block\utils\FroglightType;
|
||||
use pocketmine\block\utils\LeverFacing;
|
||||
use pocketmine\block\utils\SlabType;
|
||||
use pocketmine\block\VanillaBlocks as Blocks;
|
||||
@ -918,11 +919,13 @@ final class BlockStateToBlockObjectDeserializer implements BlockStateDeserialize
|
||||
});
|
||||
$this->mapStairs(Ids::NORMAL_STONE_STAIRS, fn() => Blocks::STONE_STAIRS());
|
||||
$this->mapStairs(Ids::OAK_STAIRS, fn() => Blocks::OAK_STAIRS());
|
||||
$this->map(Ids::OCHRE_FROGLIGHT, fn(Reader $in) => Blocks::FROGLIGHT()->setFroglightType(FroglightType::OCHRE())->setAxis($in->readPillarAxis()));
|
||||
$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::PEARLESCENT_FROGLIGHT, fn(Reader $in) => Blocks::FROGLIGHT()->setFroglightType(FroglightType::PEARLESCENT())->setAxis($in->readPillarAxis()));
|
||||
$this->map(Ids::PINK_GLAZED_TERRACOTTA, fn(Reader $in) => Helper::decodeGlazedTerracotta(DyeColor::PINK(), $in));
|
||||
$this->map(Ids::PLANKS, function(Reader $in) : Block{
|
||||
return match($woodName = $in->readString(StateNames::WOOD_TYPE)){
|
||||
@ -1265,6 +1268,7 @@ final class BlockStateToBlockObjectDeserializer implements BlockStateDeserialize
|
||||
$this->map(Ids::UNPOWERED_COMPARATOR, fn(Reader $in) => Helper::decodeComparator(Blocks::REDSTONE_COMPARATOR(), $in));
|
||||
$this->map(Ids::UNPOWERED_REPEATER, fn(Reader $in) => Helper::decodeRepeater(Blocks::REDSTONE_REPEATER(), $in)
|
||||
->setPowered(false));
|
||||
$this->map(Ids::VERDANT_FROGLIGHT, fn(Reader $in) => Blocks::FROGLIGHT()->setFroglightType(FroglightType::VERDANT())->setAxis($in->readPillarAxis()));
|
||||
$this->map(Ids::VINE, function(Reader $in) : Block{
|
||||
$vineDirectionFlags = $in->readBoundedInt(StateNames::VINE_DIRECTION_BITS, 0, 15);
|
||||
return Blocks::VINES()
|
||||
|
@ -93,6 +93,15 @@ trait RuntimeEnumDeserializerTrait{
|
||||
};
|
||||
}
|
||||
|
||||
public function froglightType(\pocketmine\block\utils\FroglightType &$value) : void{
|
||||
$value = match($this->readInt(2)){
|
||||
0 => \pocketmine\block\utils\FroglightType::OCHRE(),
|
||||
1 => \pocketmine\block\utils\FroglightType::PEARLESCENT(),
|
||||
2 => \pocketmine\block\utils\FroglightType::VERDANT(),
|
||||
default => throw new InvalidSerializedRuntimeDataException("Invalid serialized value for FroglightType")
|
||||
};
|
||||
}
|
||||
|
||||
public function leverFacing(\pocketmine\block\utils\LeverFacing &$value) : void{
|
||||
$value = match($this->readInt(3)){
|
||||
0 => \pocketmine\block\utils\LeverFacing::DOWN_AXIS_X(),
|
||||
|
@ -93,6 +93,15 @@ trait RuntimeEnumSerializerTrait{
|
||||
});
|
||||
}
|
||||
|
||||
public function froglightType(\pocketmine\block\utils\FroglightType $value) : void{
|
||||
$this->int(2, match($value){
|
||||
\pocketmine\block\utils\FroglightType::OCHRE() => 0,
|
||||
\pocketmine\block\utils\FroglightType::PEARLESCENT() => 1,
|
||||
\pocketmine\block\utils\FroglightType::VERDANT() => 2,
|
||||
default => throw new \pocketmine\utils\AssumptionFailedError("All FroglightType cases should be covered")
|
||||
});
|
||||
}
|
||||
|
||||
public function leverFacing(\pocketmine\block\utils\LeverFacing $value) : void{
|
||||
$this->int(3, match($value){
|
||||
\pocketmine\block\utils\LeverFacing::DOWN_AXIS_X() => 0,
|
||||
|
@ -29,6 +29,7 @@ use pocketmine\block\utils\CopperOxidation;
|
||||
use pocketmine\block\utils\CoralType;
|
||||
use pocketmine\block\utils\DirtType;
|
||||
use pocketmine\block\utils\DyeColor;
|
||||
use pocketmine\block\utils\FroglightType;
|
||||
use pocketmine\block\utils\SkullType;
|
||||
use pocketmine\block\utils\SlabType;
|
||||
use pocketmine\block\VanillaBlocks as Blocks;
|
||||
@ -99,6 +100,10 @@ final class StringToItemParser extends StringToTParser{
|
||||
$result->registerBlock($prefix . "cut_copper_slab", fn() => Blocks::CUT_COPPER_SLAB()->setOxidation($oxidation)->setWaxed($waxed));
|
||||
}
|
||||
}
|
||||
|
||||
foreach(FroglightType::getAll() as $froglightType){
|
||||
$result->registerBlock($froglightType->name() . "_froglight", fn() => Blocks::FROGLIGHT()->setFroglightType($froglightType));
|
||||
}
|
||||
}
|
||||
|
||||
private static function registerBlocks(self $result) : void{
|
||||
|
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user